@artblocks/contracts 0.0.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +30 -11
  2. package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
  3. package/artifacts/contracts/BasicPolyptychRandomizerV0.sol/BasicPolyptychRandomizerV0.json +229 -0
  4. package/artifacts/contracts/BasicRandomizerV2.sol/BasicRandomizerV2.json +3 -3
  5. package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +2 -2
  6. package/artifacts/contracts/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +2 -2
  7. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Address.json +10 -0
  8. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Counters.json +10 -0
  9. package/artifacts/contracts/archive/GenArt721CoreV0.sol/CustomERC721Metadata.json +425 -0
  10. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC165.json +38 -0
  11. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721.json +322 -0
  12. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721Enumerable.json +384 -0
  13. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721ReceiverMock.json +101 -0
  14. package/artifacts/contracts/archive/GenArt721CoreV0.sol/GenArt721.json +1528 -0
  15. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC165.json +32 -0
  16. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721.json +316 -0
  17. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Enumerable.json +378 -0
  18. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Receiver.json +47 -0
  19. package/artifacts/contracts/archive/GenArt721CoreV0.sol/SafeMath.json +10 -0
  20. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Strings.json +10 -0
  21. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Address.json +10 -0
  22. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Counters.json +10 -0
  23. package/artifacts/contracts/archive/GenArt721CoreV1.sol/CustomERC721Metadata.json +425 -0
  24. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC165.json +38 -0
  25. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721.json +322 -0
  26. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721Enumerable.json +384 -0
  27. package/artifacts/contracts/archive/GenArt721CoreV1.sol/GenArt721Core.json +1773 -0
  28. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC165.json +32 -0
  29. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721.json +316 -0
  30. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Enumerable.json +378 -0
  31. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Receiver.json +47 -0
  32. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Randomizer.json +26 -0
  33. package/artifacts/contracts/archive/GenArt721CoreV1.sol/SafeMath.json +10 -0
  34. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Strings.json +10 -0
  35. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol/MinterDAExpV0.json +575 -0
  36. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol/MinterDAExpV1.json +463 -0
  37. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +3 -3
  38. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +3 -3
  39. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +15 -15
  40. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +1066 -0
  41. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol/MinterDALinV0.json +551 -0
  42. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol/MinterDALinV1.json +439 -0
  43. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +3 -3
  44. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +3 -3
  45. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol/MinterHolderV0.json +622 -0
  46. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +719 -0
  47. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +794 -0
  48. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +3 -3
  49. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol/MinterMerkleV0.json +873 -0
  50. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +932 -0
  51. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +984 -0
  52. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +3 -3
  53. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +3 -3
  54. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol/MinterSetPriceV0.json +400 -0
  55. package/artifacts/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol/MinterSetPriceV1.json +3 -3
  56. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +3 -3
  57. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +3 -3
  58. package/artifacts/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +3 -3
  59. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +349 -0
  60. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +3 -3
  61. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +3 -3
  62. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +2 -2
  63. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +12 -12
  64. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol/IFilteredMinterDAExpSettlementV1.json +767 -0
  65. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol/IFilteredMinterDAExpSettlement_Mixin.json +161 -0
  66. package/artifacts/contracts/interfaces/0.8.x/IMinterBaseV0.sol/IMinterBaseV0.json +24 -0
  67. package/artifacts/contracts/interfaces/0.8.x/IMinterFilterV0.sol/IMinterFilterV0.json +6 -0
  68. package/artifacts/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol/IMintingAPICoreV0.json +185 -0
  69. package/artifacts/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol/IMintingAPIMinterV0.json +88 -0
  70. package/artifacts/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol/IRandomizerPolyptychV0.json +87 -0
  71. package/artifacts/contracts/interfaces/0.8.x/IRandomizerV2.sol/IRandomizerV2.json +1 -1
  72. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV0.sol/MinterFilterV0.json +8 -2
  73. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +34 -2
  74. package/artifacts/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol/MinterBase.json +24 -0
  75. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +1127 -0
  76. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV4.sol/MinterDAExpV4.json +882 -0
  77. package/artifacts/contracts/minter-suite/Minters/MinterDALinV4.sol/MinterDALinV4.json +858 -0
  78. package/artifacts/contracts/minter-suite/Minters/MinterHolderV4.sol/MinterHolderV4.json +1126 -0
  79. package/artifacts/contracts/minter-suite/Minters/MinterMerkleV5.sol/MinterMerkleV5.json +1065 -0
  80. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/IGenArt721CoreContractV3WithRandomizer.json +662 -0
  81. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/MinterPolyptychV0.json +1268 -0
  82. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +768 -0
  83. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV4.sol/MinterSetPriceV4.json +697 -0
  84. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +1817 -0
  85. package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +3 -3
  86. package/contracts/BasicPolyptychRandomizerV0.sol +126 -0
  87. package/contracts/BasicRandomizerV2.sol +3 -3
  88. package/contracts/archive/GenArt721CoreV0.sol +1621 -0
  89. package/contracts/archive/GenArt721CoreV1.sol +1577 -0
  90. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol +503 -0
  91. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol +442 -0
  92. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol +3 -3
  93. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol +3 -3
  94. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +3 -3
  95. package/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol +1026 -0
  96. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol +450 -0
  97. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol +406 -0
  98. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol +3 -3
  99. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol +3 -3
  100. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol +540 -0
  101. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol +648 -0
  102. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV2.sol +6 -6
  103. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol +4 -4
  104. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol +523 -0
  105. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol +602 -0
  106. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol +679 -0
  107. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol +4 -4
  108. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol +4 -4
  109. package/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol +333 -0
  110. package/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol +0 -0
  111. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol +3 -3
  112. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol +3 -3
  113. package/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol +0 -0
  114. package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol +411 -0
  115. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol +3 -3
  116. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol +3 -3
  117. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol +4 -53
  118. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol +21 -0
  119. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol +62 -0
  120. package/contracts/interfaces/0.8.x/IMinterBaseV0.sol +20 -0
  121. package/contracts/interfaces/0.8.x/IMinterFilterV0.sol +6 -0
  122. package/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol +62 -0
  123. package/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol +31 -0
  124. package/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol +31 -0
  125. package/contracts/interfaces/0.8.x/IRandomizerV2.sol +5 -2
  126. package/contracts/minter-suite/MinterFilter/MinterFilterV1.sol +18 -0
  127. package/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol +293 -0
  128. package/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol +1312 -0
  129. package/contracts/minter-suite/Minters/MinterDAExpV4.sol +600 -0
  130. package/contracts/minter-suite/Minters/MinterDALinV4.sol +552 -0
  131. package/contracts/minter-suite/Minters/MinterHolderV4.sol +781 -0
  132. package/contracts/minter-suite/Minters/MinterMerkleV5.sol +717 -0
  133. package/contracts/minter-suite/Minters/MinterPolyptychV0.sol +998 -0
  134. package/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol +480 -0
  135. package/contracts/minter-suite/Minters/MinterSetPriceV4.sol +380 -0
  136. package/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol +1979 -0
  137. package/package.json +8 -2
  138. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +0 -794
@@ -0,0 +1,600 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ import "../../interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol";
5
+ import "../../interfaces/0.8.x/IMinterFilterV0.sol";
6
+ import "../../interfaces/0.8.x/IFilteredMinterDAExpV1.sol";
7
+ import "./MinterBase_v0_1_1.sol";
8
+
9
+ import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
10
+ import "@openzeppelin-4.5/contracts/utils/math/SafeCast.sol";
11
+
12
+ pragma solidity 0.8.17;
13
+
14
+ /**
15
+ * @title Filtered Minter contract that allows tokens to be minted with ETH.
16
+ * Pricing is achieved using an automated Dutch-auction mechanism.
17
+ * This is designed to be used with GenArt721CoreContractV3 flagship or
18
+ * engine contracts.
19
+ * @author Art Blocks Inc.
20
+ * @notice Privileged Roles and Ownership:
21
+ * This contract is designed to be managed, with limited powers.
22
+ * Privileged roles and abilities are controlled by the core contract's Admin
23
+ * ACL contract and a project's artist. Both of these roles hold extensive
24
+ * power and can modify minter details.
25
+ * Care must be taken to ensure that the admin ACL contract and artist
26
+ * addresses are secure behind a multi-sig or other access control mechanism.
27
+ * ----------------------------------------------------------------------------
28
+ * The following functions are restricted to the core contract's Admin ACL
29
+ * contract:
30
+ * - setAllowablePriceDecayHalfLifeRangeSeconds (note: this range is only
31
+ * enforced when creating new auctions)
32
+ * - resetAuctionDetails (note: this will prevent minting until a new auction
33
+ * is created)
34
+ * ----------------------------------------------------------------------------
35
+ * The following functions are restricted to a project's artist:
36
+ * - setAuctionDetails (note: this may only be called when there is no active
37
+ * auction)
38
+ * - setProjectMaxInvocations
39
+ * - manuallyLimitProjectMaxInvocations
40
+ * ----------------------------------------------------------------------------
41
+ * Additional admin and artist privileged roles may be described on other
42
+ * contracts that this minter integrates with.
43
+ *
44
+ * @dev Note that while this minter makes use of `block.timestamp` and it is
45
+ * technically possible that this value is manipulated by block producers, such
46
+ * manipulation will not have material impact on the price values of this minter
47
+ * given the business practices for how pricing is congfigured for this minter
48
+ * and that variations on the order of less than a minute should not
49
+ * meaningfully impact price given the minimum allowable price decay rate that
50
+ * this minter intends to support.
51
+ */
52
+ contract MinterDAExpV4 is ReentrancyGuard, MinterBase, IFilteredMinterDAExpV1 {
53
+ using SafeCast for uint256;
54
+
55
+ /// Core contract address this minter interacts with
56
+ address public immutable genArt721CoreAddress;
57
+
58
+ /// The core contract integrates with V3 contracts
59
+ IGenArt721CoreContractV3_Base private immutable genArtCoreContract_Base;
60
+
61
+ /// Minter filter address this minter interacts with
62
+ address public immutable minterFilterAddress;
63
+
64
+ /// Minter filter this minter may interact with.
65
+ IMinterFilterV0 private immutable minterFilter;
66
+
67
+ /// minterType for this minter
68
+ string public constant minterType = "MinterDAExpV4";
69
+
70
+ /// minter version for this minter
71
+ string public constant minterVersion = "v4.1.0";
72
+
73
+ uint256 constant ONE_MILLION = 1_000_000;
74
+
75
+ struct ProjectConfig {
76
+ bool maxHasBeenInvoked;
77
+ uint24 maxInvocations;
78
+ // max uint64 ~= 1.8e19 sec ~= 570 billion years
79
+ uint64 timestampStart;
80
+ uint64 priceDecayHalfLifeSeconds;
81
+ uint256 startPrice;
82
+ uint256 basePrice;
83
+ }
84
+
85
+ mapping(uint256 => ProjectConfig) public projectConfig;
86
+
87
+ /// Minimum price decay half life: price must decay with a half life of at
88
+ /// least this amount (must cut in half at least every N seconds).
89
+ uint256 public minimumPriceDecayHalfLifeSeconds = 300; // 5 minutes
90
+ /// Maximum price decay half life: price may decay with a half life of no
91
+ /// more than this amount (may cut in half at no more than every N seconds).
92
+ uint256 public maximumPriceDecayHalfLifeSeconds = 3600; // 60 minutes
93
+
94
+ // modifier to restrict access to only AdminACL allowed calls
95
+ // @dev defers which ACL contract is used to the core contract
96
+ modifier onlyCoreAdminACL(bytes4 _selector) {
97
+ require(
98
+ genArtCoreContract_Base.adminACLAllowed(
99
+ msg.sender,
100
+ address(this),
101
+ _selector
102
+ ),
103
+ "Only Core AdminACL allowed"
104
+ );
105
+ _;
106
+ }
107
+
108
+ modifier onlyArtist(uint256 _projectId) {
109
+ require(
110
+ (msg.sender ==
111
+ genArtCoreContract_Base.projectIdToArtistAddress(_projectId)),
112
+ "Only Artist"
113
+ );
114
+ _;
115
+ }
116
+
117
+ /**
118
+ * @notice Initializes contract to be a Filtered Minter for
119
+ * `_minterFilter`, integrated with Art Blocks core contract
120
+ * at address `_genArt721Address`.
121
+ * @param _genArt721Address Art Blocks core contract address for
122
+ * which this contract will be a minter.
123
+ * @param _minterFilter Minter filter for which
124
+ * this will a filtered minter.
125
+ */
126
+ constructor(
127
+ address _genArt721Address,
128
+ address _minterFilter
129
+ ) ReentrancyGuard() MinterBase(_genArt721Address) {
130
+ genArt721CoreAddress = _genArt721Address;
131
+ // always populate immutable engine contracts, but only use appropriate
132
+ // interface based on isEngine in the rest of the contract
133
+ genArtCoreContract_Base = IGenArt721CoreContractV3_Base(
134
+ _genArt721Address
135
+ );
136
+ minterFilterAddress = _minterFilter;
137
+ minterFilter = IMinterFilterV0(_minterFilter);
138
+ require(
139
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
140
+ "Illegal contract pairing"
141
+ );
142
+ }
143
+
144
+ /**
145
+ * @notice Syncs local maximum invocations of project `_projectId` based on
146
+ * the value currently defined in the core contract.
147
+ * @param _projectId Project ID to set the maximum invocations for.
148
+ * @dev this enables gas reduction after maxInvocations have been reached -
149
+ * core contracts shall still enforce a maxInvocation check during mint.
150
+ */
151
+ function setProjectMaxInvocations(
152
+ uint256 _projectId
153
+ ) public onlyArtist(_projectId) {
154
+ uint256 maxInvocations;
155
+ uint256 invocations;
156
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
157
+ .projectStateData(_projectId);
158
+
159
+ // update storage with results
160
+ projectConfig[_projectId].maxInvocations = uint24(maxInvocations);
161
+
162
+ // We need to ensure maxHasBeenInvoked is correctly set after manually syncing the
163
+ // local maxInvocations value with the core contract's maxInvocations value.
164
+ // This synced value of maxInvocations from the core contract will always be greater
165
+ // than or equal to the previous value of maxInvocations stored locally.
166
+ projectConfig[_projectId].maxHasBeenInvoked =
167
+ invocations == maxInvocations;
168
+
169
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, maxInvocations);
170
+ }
171
+
172
+ /**
173
+ * @notice Manually sets the local maximum invocations of project `_projectId`
174
+ * with the provided `_maxInvocations`, checking that `_maxInvocations` is less
175
+ * than or equal to the value of project `_project_id`'s maximum invocations that is
176
+ * set on the core contract.
177
+ * @dev Note that a `_maxInvocations` of 0 can only be set if the current `invocations`
178
+ * value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
179
+ * this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
180
+ * @param _projectId Project ID to set the maximum invocations for.
181
+ * @param _maxInvocations Maximum invocations to set for the project.
182
+ */
183
+ function manuallyLimitProjectMaxInvocations(
184
+ uint256 _projectId,
185
+ uint256 _maxInvocations
186
+ ) external onlyArtist(_projectId) {
187
+ // CHECKS
188
+ // ensure that the manually set maxInvocations is not greater than what is set on the core contract
189
+ uint256 maxInvocations;
190
+ uint256 invocations;
191
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
192
+ .projectStateData(_projectId);
193
+ require(
194
+ _maxInvocations <= maxInvocations,
195
+ "Cannot increase project max invocations above core contract set project max invocations"
196
+ );
197
+ require(
198
+ _maxInvocations >= invocations,
199
+ "Cannot set project max invocations to less than current invocations"
200
+ );
201
+ // EFFECTS
202
+ // update storage with results
203
+ projectConfig[_projectId].maxInvocations = uint24(_maxInvocations);
204
+ // We need to ensure maxHasBeenInvoked is correctly set after manually setting the
205
+ // local maxInvocations value.
206
+ projectConfig[_projectId].maxHasBeenInvoked =
207
+ invocations == _maxInvocations;
208
+
209
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, _maxInvocations);
210
+ }
211
+
212
+ /**
213
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
214
+ * This method exists purely for interface-conformance purposes.
215
+ */
216
+ function togglePurchaseToDisabled(
217
+ uint256 _projectId
218
+ ) external view onlyArtist(_projectId) {
219
+ revert("Action not supported");
220
+ }
221
+
222
+ /**
223
+ * @notice projectId => has project reached its maximum number of
224
+ * invocations? Note that this returns a local cache of the core contract's
225
+ * state, and may be out of sync with the core contract. This is
226
+ * intentional, as it only enables gas optimization of mints after a
227
+ * project's maximum invocations has been reached. A false negative will
228
+ * only result in a gas cost increase, since the core contract will still
229
+ * enforce a maxInvocation check during minting. A false positive is not
230
+ * possible because the V3 core contract only allows maximum invocations
231
+ * to be reduced, not increased. Based on this rationale, we intentionally
232
+ * do not do input validation in this method as to whether or not the input
233
+ * `_projectId` is an existing project ID.
234
+ *
235
+ */
236
+ function projectMaxHasBeenInvoked(
237
+ uint256 _projectId
238
+ ) external view returns (bool) {
239
+ return projectConfig[_projectId].maxHasBeenInvoked;
240
+ }
241
+
242
+ /**
243
+ * @notice projectId => project's maximum number of invocations.
244
+ * Optionally synced with core contract value, for gas optimization.
245
+ * Note that this returns a local cache of the core contract's
246
+ * state, and may be out of sync with the core contract. This is
247
+ * intentional, as it only enables gas optimization of mints after a
248
+ * project's maximum invocations has been reached.
249
+ * @dev A number greater than the core contract's project max invocations
250
+ * will only result in a gas cost increase, since the core contract will
251
+ * still enforce a maxInvocation check during minting. A number less than
252
+ * the core contract's project max invocations is only possible when the
253
+ * project's max invocations have not been synced on this minter, since the
254
+ * V3 core contract only allows maximum invocations to be reduced, not
255
+ * increased. When this happens, the minter will enable minting, allowing
256
+ * the core contract to enforce the max invocations check. Based on this
257
+ * rationale, we intentionally do not do input validation in this method as
258
+ * to whether or not the input `_projectId` is an existing project ID.
259
+ */
260
+ function projectMaxInvocations(
261
+ uint256 _projectId
262
+ ) external view returns (uint256) {
263
+ return uint256(projectConfig[_projectId].maxInvocations);
264
+ }
265
+
266
+ /**
267
+ * @notice projectId => auction parameters
268
+ */
269
+ function projectAuctionParameters(
270
+ uint256 _projectId
271
+ )
272
+ external
273
+ view
274
+ returns (
275
+ uint256 timestampStart,
276
+ uint256 priceDecayHalfLifeSeconds,
277
+ uint256 startPrice,
278
+ uint256 basePrice
279
+ )
280
+ {
281
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
282
+ return (
283
+ _projectConfig.timestampStart,
284
+ _projectConfig.priceDecayHalfLifeSeconds,
285
+ _projectConfig.startPrice,
286
+ _projectConfig.basePrice
287
+ );
288
+ }
289
+
290
+ /**
291
+ * @notice Sets the minimum and maximum values that are settable for
292
+ * `_priceDecayHalfLifeSeconds` across all projects.
293
+ * @param _minimumPriceDecayHalfLifeSeconds Minimum price decay half life
294
+ * (in seconds).
295
+ * @param _maximumPriceDecayHalfLifeSeconds Maximum price decay half life
296
+ * (in seconds).
297
+ */
298
+ function setAllowablePriceDecayHalfLifeRangeSeconds(
299
+ uint256 _minimumPriceDecayHalfLifeSeconds,
300
+ uint256 _maximumPriceDecayHalfLifeSeconds
301
+ )
302
+ external
303
+ onlyCoreAdminACL(
304
+ this.setAllowablePriceDecayHalfLifeRangeSeconds.selector
305
+ )
306
+ {
307
+ require(
308
+ _maximumPriceDecayHalfLifeSeconds >
309
+ _minimumPriceDecayHalfLifeSeconds,
310
+ "Maximum half life must be greater than minimum"
311
+ );
312
+ require(
313
+ _minimumPriceDecayHalfLifeSeconds > 0,
314
+ "Half life of zero not allowed"
315
+ );
316
+ minimumPriceDecayHalfLifeSeconds = _minimumPriceDecayHalfLifeSeconds;
317
+ maximumPriceDecayHalfLifeSeconds = _maximumPriceDecayHalfLifeSeconds;
318
+ emit AuctionHalfLifeRangeSecondsUpdated(
319
+ _minimumPriceDecayHalfLifeSeconds,
320
+ _maximumPriceDecayHalfLifeSeconds
321
+ );
322
+ }
323
+
324
+ ////// Auction Functions
325
+ /**
326
+ * @notice Sets auction details for project `_projectId`.
327
+ * @param _projectId Project ID to set auction details for.
328
+ * @param _auctionTimestampStart Timestamp at which to start the auction.
329
+ * @param _priceDecayHalfLifeSeconds The half life with which to decay the
330
+ * price (in seconds).
331
+ * @param _startPrice Price at which to start the auction, in Wei.
332
+ * @param _basePrice Resting price of the auction, in Wei.
333
+ * @dev Note that it is intentionally supported here that the configured
334
+ * price may be explicitly set to `0`.
335
+ */
336
+ function setAuctionDetails(
337
+ uint256 _projectId,
338
+ uint256 _auctionTimestampStart,
339
+ uint256 _priceDecayHalfLifeSeconds,
340
+ uint256 _startPrice,
341
+ uint256 _basePrice
342
+ ) external onlyArtist(_projectId) {
343
+ // CHECKS
344
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
345
+ require(
346
+ _projectConfig.timestampStart == 0 ||
347
+ block.timestamp < _projectConfig.timestampStart,
348
+ "No modifications mid-auction"
349
+ );
350
+ require(
351
+ block.timestamp < _auctionTimestampStart,
352
+ "Only future auctions"
353
+ );
354
+ require(
355
+ _startPrice > _basePrice,
356
+ "Auction start price must be greater than auction end price"
357
+ );
358
+ require(
359
+ (_priceDecayHalfLifeSeconds >= minimumPriceDecayHalfLifeSeconds) &&
360
+ (_priceDecayHalfLifeSeconds <=
361
+ maximumPriceDecayHalfLifeSeconds),
362
+ "Price decay half life must fall between min and max allowable values"
363
+ );
364
+ // EFFECTS
365
+ _projectConfig.timestampStart = _auctionTimestampStart.toUint64();
366
+ _projectConfig.priceDecayHalfLifeSeconds = _priceDecayHalfLifeSeconds
367
+ .toUint64();
368
+ _projectConfig.startPrice = _startPrice;
369
+ _projectConfig.basePrice = _basePrice;
370
+
371
+ emit SetAuctionDetails(
372
+ _projectId,
373
+ _auctionTimestampStart,
374
+ _priceDecayHalfLifeSeconds,
375
+ _startPrice,
376
+ _basePrice
377
+ );
378
+
379
+ // sync local max invocations if not initially populated
380
+ // @dev if local max invocations and maxHasBeenInvoked are both
381
+ // initial values, we know they have not been populated.
382
+ if (
383
+ _projectConfig.maxInvocations == 0 &&
384
+ _projectConfig.maxHasBeenInvoked == false
385
+ ) {
386
+ setProjectMaxInvocations(_projectId);
387
+ }
388
+ }
389
+
390
+ /**
391
+ * @notice Resets auction details for project `_projectId`, zero-ing out all
392
+ * relevant auction fields. Not intended to be used in normal auction
393
+ * operation, but rather only in case of the need to halt an auction.
394
+ * @param _projectId Project ID to set auction details for.
395
+ */
396
+ function resetAuctionDetails(
397
+ uint256 _projectId
398
+ ) external onlyCoreAdminACL(this.resetAuctionDetails.selector) {
399
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
400
+ // reset to initial values
401
+ _projectConfig.timestampStart = 0;
402
+ _projectConfig.priceDecayHalfLifeSeconds = 0;
403
+ _projectConfig.startPrice = 0;
404
+ _projectConfig.basePrice = 0;
405
+
406
+ emit ResetAuctionDetails(_projectId);
407
+ }
408
+
409
+ /**
410
+ * @notice Purchases a token from project `_projectId`.
411
+ * @param _projectId Project ID to mint a token on.
412
+ * @return tokenId Token ID of minted token
413
+ */
414
+ function purchase(
415
+ uint256 _projectId
416
+ ) external payable returns (uint256 tokenId) {
417
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
418
+ return tokenId;
419
+ }
420
+
421
+ /**
422
+ * @notice gas-optimized version of purchase(uint256).
423
+ */
424
+ function purchase_H4M(
425
+ uint256 _projectId
426
+ ) external payable returns (uint256 tokenId) {
427
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
428
+ return tokenId;
429
+ }
430
+
431
+ /**
432
+ * @notice Purchases a token from project `_projectId` and sets
433
+ * the token's owner to `_to`.
434
+ * @param _to Address to be the new token's owner.
435
+ * @param _projectId Project ID to mint a token on.
436
+ * @return tokenId Token ID of minted token
437
+ */
438
+ function purchaseTo(
439
+ address _to,
440
+ uint256 _projectId
441
+ ) external payable returns (uint256 tokenId) {
442
+ return purchaseTo_do6(_to, _projectId);
443
+ }
444
+
445
+ /**
446
+ * @notice gas-optimized version of purchaseTo(address, uint256).
447
+ */
448
+ function purchaseTo_do6(
449
+ address _to,
450
+ uint256 _projectId
451
+ ) public payable nonReentrant returns (uint256 tokenId) {
452
+ // CHECKS
453
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
454
+
455
+ // Note that `maxHasBeenInvoked` is only checked here to reduce gas
456
+ // consumption after a project has been fully minted.
457
+ // `_projectConfig.maxHasBeenInvoked` is locally cached to reduce
458
+ // gas consumption, but if not in sync with the core contract's value,
459
+ // the core contract also enforces its own max invocation check during
460
+ // minting.
461
+ require(
462
+ !_projectConfig.maxHasBeenInvoked,
463
+ "Maximum number of invocations reached"
464
+ );
465
+
466
+ // _getPrice reverts if auction is unconfigured or has not started
467
+ uint256 pricePerTokenInWei = _getPrice(_projectId);
468
+ require(
469
+ msg.value >= pricePerTokenInWei,
470
+ "Must send minimum value to mint!"
471
+ );
472
+
473
+ // EFFECTS
474
+ tokenId = minterFilter.mint(_to, _projectId, msg.sender);
475
+
476
+ // invocation is token number plus one, and will never overflow due to
477
+ // limit of 1e6 invocations per project. block scope for gas efficiency
478
+ // (i.e. avoid an unnecessary var initialization to 0).
479
+ unchecked {
480
+ uint256 tokenInvocation = (tokenId % ONE_MILLION) + 1;
481
+ uint256 localMaxInvocations = _projectConfig.maxInvocations;
482
+ // handle the case where the token invocation == minter local max
483
+ // invocations occurred on a different minter, and we have a stale
484
+ // local maxHasBeenInvoked value returning a false negative.
485
+ // @dev this is a CHECK after EFFECTS, so security was considered
486
+ // in detail here.
487
+ require(
488
+ tokenInvocation <= localMaxInvocations,
489
+ "Maximum invocations reached"
490
+ );
491
+ // in typical case, update the local maxHasBeenInvoked value
492
+ // to true if the token invocation == minter local max invocations
493
+ // (enables gas efficient reverts after sellout)
494
+ if (tokenInvocation == localMaxInvocations) {
495
+ _projectConfig.maxHasBeenInvoked = true;
496
+ }
497
+ }
498
+
499
+ // INTERACTIONS
500
+ splitFundsETH(_projectId, pricePerTokenInWei, genArt721CoreAddress);
501
+
502
+ return tokenId;
503
+ }
504
+
505
+ /**
506
+ * @notice Gets price of minting a token on project `_projectId` given
507
+ * the project's AuctionParameters and current block timestamp.
508
+ * Reverts if auction has not yet started or auction is unconfigured.
509
+ * @param _projectId Project ID to get price of token for.
510
+ * @return current price of token in Wei
511
+ * @dev This method calculates price decay using a linear interpolation
512
+ * of exponential decay based on the artist-provided half-life for price
513
+ * decay, `_priceDecayHalfLifeSeconds`.
514
+ */
515
+ function _getPrice(uint256 _projectId) private view returns (uint256) {
516
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
517
+ // move parameters to memory if used more than once
518
+ uint256 _timestampStart = uint256(_projectConfig.timestampStart);
519
+ uint256 _priceDecayHalfLifeSeconds = uint256(
520
+ _projectConfig.priceDecayHalfLifeSeconds
521
+ );
522
+ uint256 _basePrice = _projectConfig.basePrice;
523
+
524
+ require(block.timestamp > _timestampStart, "Auction not yet started");
525
+ require(_priceDecayHalfLifeSeconds > 0, "Only configured auctions");
526
+ uint256 decayedPrice = _projectConfig.startPrice;
527
+ uint256 elapsedTimeSeconds;
528
+ unchecked {
529
+ // already checked that block.timestamp > _timestampStart above
530
+ elapsedTimeSeconds = block.timestamp - _timestampStart;
531
+ }
532
+ // Divide by two (via bit-shifting) for the number of entirely completed
533
+ // half-lives that have elapsed since auction start time.
534
+ unchecked {
535
+ // already required _priceDecayHalfLifeSeconds > 0
536
+ decayedPrice >>= elapsedTimeSeconds / _priceDecayHalfLifeSeconds;
537
+ }
538
+ // Perform a linear interpolation between partial half-life points, to
539
+ // approximate the current place on a perfect exponential decay curve.
540
+ unchecked {
541
+ // value of expression is provably always less than decayedPrice,
542
+ // so no underflow is possible when the subtraction assignment
543
+ // operator is used on decayedPrice.
544
+ decayedPrice -=
545
+ (decayedPrice *
546
+ (elapsedTimeSeconds % _priceDecayHalfLifeSeconds)) /
547
+ _priceDecayHalfLifeSeconds /
548
+ 2;
549
+ }
550
+ if (decayedPrice < _basePrice) {
551
+ // Price may not decay below stay `basePrice`.
552
+ return _basePrice;
553
+ }
554
+ return decayedPrice;
555
+ }
556
+
557
+ /**
558
+ * @notice Gets if price of token is configured, price of minting a
559
+ * token on project `_projectId`, and currency symbol and address to be
560
+ * used as payment. Supersedes any core contract price information.
561
+ * @param _projectId Project ID to get price information for.
562
+ * @return isConfigured true only if project's auction parameters have been
563
+ * configured on this minter
564
+ * @return tokenPriceInWei current price of token on this minter - invalid
565
+ * if auction has not yet been configured
566
+ * @return currencySymbol currency symbol for purchases of project on this
567
+ * minter. This minter always returns "ETH"
568
+ * @return currencyAddress currency address for purchases of project on
569
+ * this minter. This minter always returns null address, reserved for ether
570
+ */
571
+ function getPriceInfo(
572
+ uint256 _projectId
573
+ )
574
+ external
575
+ view
576
+ returns (
577
+ bool isConfigured,
578
+ uint256 tokenPriceInWei,
579
+ string memory currencySymbol,
580
+ address currencyAddress
581
+ )
582
+ {
583
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
584
+
585
+ isConfigured = (_projectConfig.startPrice > 0);
586
+ if (block.timestamp <= _projectConfig.timestampStart) {
587
+ // Provide a reasonable value for `tokenPriceInWei` when it would
588
+ // otherwise revert, using the starting price before auction starts.
589
+ tokenPriceInWei = _projectConfig.startPrice;
590
+ } else if (_projectConfig.startPrice == 0) {
591
+ // In the case of unconfigured auction, return price of zero when
592
+ // it would otherwise revert
593
+ tokenPriceInWei = 0;
594
+ } else {
595
+ tokenPriceInWei = _getPrice(_projectId);
596
+ }
597
+ currencySymbol = "ETH";
598
+ currencyAddress = address(0);
599
+ }
600
+ }