@artblocks/contracts 0.0.1 → 1.0.0

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 (113) hide show
  1. package/README.md +27 -2
  2. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Address.json +10 -0
  3. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Counters.json +10 -0
  4. package/artifacts/contracts/archive/GenArt721CoreV0.sol/CustomERC721Metadata.json +425 -0
  5. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC165.json +38 -0
  6. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721.json +322 -0
  7. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721Enumerable.json +384 -0
  8. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721ReceiverMock.json +101 -0
  9. package/artifacts/contracts/archive/GenArt721CoreV0.sol/GenArt721.json +1528 -0
  10. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC165.json +32 -0
  11. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721.json +316 -0
  12. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Enumerable.json +378 -0
  13. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Receiver.json +47 -0
  14. package/artifacts/contracts/archive/GenArt721CoreV0.sol/SafeMath.json +10 -0
  15. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Strings.json +10 -0
  16. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Address.json +10 -0
  17. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Counters.json +10 -0
  18. package/artifacts/contracts/archive/GenArt721CoreV1.sol/CustomERC721Metadata.json +425 -0
  19. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC165.json +38 -0
  20. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721.json +322 -0
  21. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721Enumerable.json +384 -0
  22. package/artifacts/contracts/archive/GenArt721CoreV1.sol/GenArt721Core.json +1773 -0
  23. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC165.json +32 -0
  24. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721.json +316 -0
  25. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Enumerable.json +378 -0
  26. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Receiver.json +47 -0
  27. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Randomizer.json +26 -0
  28. package/artifacts/contracts/archive/GenArt721CoreV1.sol/SafeMath.json +10 -0
  29. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Strings.json +10 -0
  30. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol/MinterDAExpV0.json +575 -0
  31. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol/MinterDAExpV1.json +463 -0
  32. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +3 -3
  33. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +3 -3
  34. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +15 -15
  35. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol/MinterDALinV0.json +551 -0
  36. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol/MinterDALinV1.json +439 -0
  37. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +3 -3
  38. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +3 -3
  39. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol/MinterHolderV0.json +622 -0
  40. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +719 -0
  41. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +794 -0
  42. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +3 -3
  43. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol/MinterMerkleV0.json +873 -0
  44. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +932 -0
  45. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +984 -0
  46. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +3 -3
  47. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +3 -3
  48. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol/MinterSetPriceV0.json +400 -0
  49. package/artifacts/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol/MinterSetPriceV1.json +3 -3
  50. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +3 -3
  51. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +3 -3
  52. package/artifacts/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +3 -3
  53. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +349 -0
  54. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +3 -3
  55. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +3 -3
  56. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +12 -12
  57. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol/IFilteredMinterDAExpSettlement_Mixin.json +161 -0
  58. package/artifacts/contracts/interfaces/0.8.x/IMinterBaseV0.sol/IMinterBaseV0.json +24 -0
  59. package/artifacts/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol/IMintingAPICoreV0.json +185 -0
  60. package/artifacts/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol/IMintingAPIMinterV0.json +88 -0
  61. package/artifacts/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol/MinterBase.json +24 -0
  62. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +1066 -0
  63. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV4.sol/MinterDAExpV4.json +869 -0
  64. package/artifacts/contracts/minter-suite/Minters/MinterDALinV4.sol/MinterDALinV4.json +845 -0
  65. package/artifacts/contracts/minter-suite/Minters/MinterHolderV4.sol/MinterHolderV4.json +1113 -0
  66. package/artifacts/contracts/minter-suite/Minters/MinterMerkleV5.sol/MinterMerkleV5.json +1052 -0
  67. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +755 -0
  68. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV4.sol/MinterSetPriceV4.json +684 -0
  69. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +1817 -0
  70. package/contracts/archive/GenArt721CoreV0.sol +1621 -0
  71. package/contracts/archive/GenArt721CoreV1.sol +1577 -0
  72. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol +503 -0
  73. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol +442 -0
  74. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol +3 -3
  75. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol +3 -3
  76. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +3 -3
  77. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol +450 -0
  78. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol +406 -0
  79. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol +3 -3
  80. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol +3 -3
  81. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol +540 -0
  82. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol +648 -0
  83. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV2.sol +6 -6
  84. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol +4 -4
  85. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol +523 -0
  86. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol +602 -0
  87. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol +679 -0
  88. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol +4 -4
  89. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol +4 -4
  90. package/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol +333 -0
  91. package/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol +0 -0
  92. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol +3 -3
  93. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol +3 -3
  94. package/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol +0 -0
  95. package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol +411 -0
  96. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol +3 -3
  97. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol +3 -3
  98. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol +4 -53
  99. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol +62 -0
  100. package/contracts/interfaces/0.8.x/IMinterBaseV0.sol +20 -0
  101. package/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol +62 -0
  102. package/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol +31 -0
  103. package/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol +293 -0
  104. package/contracts/minter-suite/Minters/MinterDAExpSettlementV1.sol +1026 -0
  105. package/contracts/minter-suite/Minters/MinterDAExpV4.sol +572 -0
  106. package/contracts/minter-suite/Minters/MinterDALinV4.sol +525 -0
  107. package/contracts/minter-suite/Minters/MinterHolderV4.sol +752 -0
  108. package/contracts/minter-suite/Minters/MinterMerkleV5.sol +688 -0
  109. package/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol +451 -0
  110. package/contracts/minter-suite/Minters/MinterSetPriceV4.sol +352 -0
  111. package/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol +1979 -0
  112. package/package.json +1 -1
  113. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +0 -794
@@ -0,0 +1,525 @@
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/IFilteredMinterDALinV1.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
+ * - setMinimumAuctionLengthSeconds (note: this is only enforced when creating
31
+ * 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 MinterDALinV4 is ReentrancyGuard, MinterBase, IFilteredMinterDALinV1 {
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 = "MinterDALinV4";
69
+
70
+ uint256 constant ONE_MILLION = 1_000_000;
71
+
72
+ struct ProjectConfig {
73
+ bool maxHasBeenInvoked;
74
+ uint24 maxInvocations;
75
+ // max uint64 ~= 1.8e19 sec ~= 570 billion years
76
+ uint64 timestampStart;
77
+ uint64 timestampEnd;
78
+ uint256 startPrice;
79
+ uint256 basePrice;
80
+ }
81
+
82
+ mapping(uint256 => ProjectConfig) public projectConfig;
83
+
84
+ /// Minimum auction length in seconds
85
+ uint256 public minimumAuctionLengthSeconds = 3600;
86
+
87
+ // modifier to restrict access to only AdminACL allowed calls
88
+ // @dev defers which ACL contract is used to the core contract
89
+ modifier onlyCoreAdminACL(bytes4 _selector) {
90
+ require(
91
+ genArtCoreContract_Base.adminACLAllowed(
92
+ msg.sender,
93
+ address(this),
94
+ _selector
95
+ ),
96
+ "Only Core AdminACL allowed"
97
+ );
98
+ _;
99
+ }
100
+
101
+ modifier onlyArtist(uint256 _projectId) {
102
+ require(
103
+ (msg.sender ==
104
+ genArtCoreContract_Base.projectIdToArtistAddress(_projectId)),
105
+ "Only Artist"
106
+ );
107
+ _;
108
+ }
109
+
110
+ /**
111
+ * @notice Initializes contract to be a Filtered Minter for
112
+ * `_minterFilter`, integrated with Art Blocks core contract
113
+ * at address `_genArt721Address`.
114
+ * @param _genArt721Address Art Blocks core contract address for
115
+ * which this contract will be a minter.
116
+ * @param _minterFilter Minter filter for which
117
+ * this will a filtered minter.
118
+ */
119
+ constructor(
120
+ address _genArt721Address,
121
+ address _minterFilter
122
+ ) ReentrancyGuard() MinterBase(_genArt721Address) {
123
+ genArt721CoreAddress = _genArt721Address;
124
+ // always populate immutable engine contracts, but only use appropriate
125
+ // interface based on isEngine in the rest of the contract
126
+ genArtCoreContract_Base = IGenArt721CoreContractV3_Base(
127
+ _genArt721Address
128
+ );
129
+ minterFilterAddress = _minterFilter;
130
+ minterFilter = IMinterFilterV0(_minterFilter);
131
+ require(
132
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
133
+ "Illegal contract pairing"
134
+ );
135
+ }
136
+
137
+ /**
138
+ * @notice Syncs local maximum invocations of project `_projectId` based on
139
+ * the value currently defined in the core contract.
140
+ * @param _projectId Project ID to set the maximum invocations for.
141
+ * @dev this enables gas reduction after maxInvocations have been reached -
142
+ * core contracts shall still enforce a maxInvocation check during mint.
143
+ */
144
+ function setProjectMaxInvocations(
145
+ uint256 _projectId
146
+ ) external onlyArtist(_projectId) {
147
+ uint256 maxInvocations;
148
+ uint256 invocations;
149
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
150
+ .projectStateData(_projectId);
151
+ // update storage with results
152
+ projectConfig[_projectId].maxInvocations = uint24(maxInvocations);
153
+
154
+ // We need to ensure maxHasBeenInvoked is correctly set after manually syncing the
155
+ // local maxInvocations value with the core contract's maxInvocations value.
156
+ // This synced value of maxInvocations from the core contract will always be greater
157
+ // than or equal to the previous value of maxInvocations stored locally.
158
+ projectConfig[_projectId].maxHasBeenInvoked =
159
+ invocations == maxInvocations;
160
+
161
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, maxInvocations);
162
+ }
163
+
164
+ /**
165
+ * @notice Manually sets the local maximum invocations of project `_projectId`
166
+ * with the provided `_maxInvocations`, checking that `_maxInvocations` is less
167
+ * than or equal to the value of project `_project_id`'s maximum invocations that is
168
+ * set on the core contract.
169
+ * @dev Note that a `_maxInvocations` of 0 can only be set if the current `invocations`
170
+ * value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
171
+ * this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
172
+ * @param _projectId Project ID to set the maximum invocations for.
173
+ * @param _maxInvocations Maximum invocations to set for the project.
174
+ */
175
+ function manuallyLimitProjectMaxInvocations(
176
+ uint256 _projectId,
177
+ uint256 _maxInvocations
178
+ ) external onlyArtist(_projectId) {
179
+ // CHECKS
180
+ // ensure that the manually set maxInvocations is not greater than what is set on the core contract
181
+ uint256 maxInvocations;
182
+ uint256 invocations;
183
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
184
+ .projectStateData(_projectId);
185
+ require(
186
+ _maxInvocations <= maxInvocations,
187
+ "Cannot increase project max invocations above core contract set project max invocations"
188
+ );
189
+ require(
190
+ _maxInvocations >= invocations,
191
+ "Cannot set project max invocations to less than current invocations"
192
+ );
193
+
194
+ // EFFECTS
195
+ // update storage with results
196
+ projectConfig[_projectId].maxInvocations = uint24(_maxInvocations);
197
+ projectConfig[_projectId].maxHasBeenInvoked =
198
+ invocations == _maxInvocations;
199
+
200
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, _maxInvocations);
201
+ }
202
+
203
+ /**
204
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
205
+ * This method exists purely for interface-conformance purposes.
206
+ */
207
+ function togglePurchaseToDisabled(
208
+ uint256 _projectId
209
+ ) external view onlyArtist(_projectId) {
210
+ revert("Action not supported");
211
+ }
212
+
213
+ /**
214
+ * @notice projectId => has project reached its maximum number of
215
+ * invocations? Note that this returns a local cache of the core contract's
216
+ * state, and may be out of sync with the core contract. This is
217
+ * intentional, as it only enables gas optimization of mints after a
218
+ * project's maximum invocations has been reached. A false negative will
219
+ * only result in a gas cost increase, since the core contract will still
220
+ * enforce a maxInvocation check during minting. A false positive is not
221
+ * possible because the V3 core contract only allows maximum invocations
222
+ * to be reduced, not increased. Based on this rationale, we intentionally
223
+ * do not do input validation in this method as to whether or not the input
224
+ * `_projectId` is an existing project ID.
225
+ */
226
+ function projectMaxHasBeenInvoked(
227
+ uint256 _projectId
228
+ ) external view returns (bool) {
229
+ return projectConfig[_projectId].maxHasBeenInvoked;
230
+ }
231
+
232
+ /**
233
+ * @notice projectId => project's maximum number of invocations.
234
+ * Optionally synced with core contract value, for gas optimization.
235
+ * Note that this returns a local cache of the core contract's
236
+ * state, and may be out of sync with the core contract. This is
237
+ * intentional, as it only enables gas optimization of mints after a
238
+ * project's maximum invocations has been reached.
239
+ * @dev A number greater than the core contract's project max invocations
240
+ * will only result in a gas cost increase, since the core contract will
241
+ * still enforce a maxInvocation check during minting. A number less than
242
+ * the core contract's project max invocations is only possible when the
243
+ * project's max invocations have not been synced on this minter, since the
244
+ * V3 core contract only allows maximum invocations to be reduced, not
245
+ * increased. When this happens, the minter will enable minting, allowing
246
+ * the core contract to enforce the max invocations check. Based on this
247
+ * rationale, we intentionally do not do input validation in this method as
248
+ * to whether or not the input `_projectId` is an existing project ID.
249
+ */
250
+ function projectMaxInvocations(
251
+ uint256 _projectId
252
+ ) external view returns (uint256) {
253
+ return uint256(projectConfig[_projectId].maxInvocations);
254
+ }
255
+
256
+ /**
257
+ * @notice projectId => auction parameters
258
+ */
259
+ function projectAuctionParameters(
260
+ uint256 _projectId
261
+ )
262
+ external
263
+ view
264
+ returns (
265
+ uint256 timestampStart,
266
+ uint256 timestampEnd,
267
+ uint256 startPrice,
268
+ uint256 basePrice
269
+ )
270
+ {
271
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
272
+ return (
273
+ _projectConfig.timestampStart,
274
+ _projectConfig.timestampEnd,
275
+ _projectConfig.startPrice,
276
+ _projectConfig.basePrice
277
+ );
278
+ }
279
+
280
+ /**
281
+ * @notice Sets minimum auction length to `_minimumAuctionLengthSeconds`
282
+ * for all projects.
283
+ * @param _minimumAuctionLengthSeconds Minimum auction length in seconds.
284
+ */
285
+ function setMinimumAuctionLengthSeconds(
286
+ uint256 _minimumAuctionLengthSeconds
287
+ ) external onlyCoreAdminACL(this.setMinimumAuctionLengthSeconds.selector) {
288
+ minimumAuctionLengthSeconds = _minimumAuctionLengthSeconds;
289
+ emit MinimumAuctionLengthSecondsUpdated(_minimumAuctionLengthSeconds);
290
+ }
291
+
292
+ ////// Auction Functions
293
+ /**
294
+ * @notice Sets auction details for project `_projectId`.
295
+ * @param _projectId Project ID to set auction details for.
296
+ * @param _auctionTimestampStart Timestamp at which to start the auction.
297
+ * @param _auctionTimestampEnd Timestamp at which to end the auction.
298
+ * @param _startPrice Price at which to start the auction, in Wei.
299
+ * @param _basePrice Resting price of the auction, in Wei.
300
+ * @dev Note that it is intentionally supported here that the configured
301
+ * price may be explicitly set to `0`.
302
+ */
303
+ function setAuctionDetails(
304
+ uint256 _projectId,
305
+ uint256 _auctionTimestampStart,
306
+ uint256 _auctionTimestampEnd,
307
+ uint256 _startPrice,
308
+ uint256 _basePrice
309
+ ) external onlyArtist(_projectId) {
310
+ // CHECKS
311
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
312
+ require(
313
+ _projectConfig.timestampStart == 0 ||
314
+ block.timestamp < _projectConfig.timestampStart,
315
+ "No modifications mid-auction"
316
+ );
317
+ require(
318
+ block.timestamp < _auctionTimestampStart,
319
+ "Only future auctions"
320
+ );
321
+ require(
322
+ _auctionTimestampEnd > _auctionTimestampStart,
323
+ "Auction end must be greater than auction start"
324
+ );
325
+ require(
326
+ _auctionTimestampEnd >=
327
+ _auctionTimestampStart + minimumAuctionLengthSeconds,
328
+ "Auction length must be at least minimumAuctionLengthSeconds"
329
+ );
330
+ require(
331
+ _startPrice > _basePrice,
332
+ "Auction start price must be greater than auction end price"
333
+ );
334
+ // EFFECTS
335
+ _projectConfig.timestampStart = _auctionTimestampStart.toUint64();
336
+ _projectConfig.timestampEnd = _auctionTimestampEnd.toUint64();
337
+ _projectConfig.startPrice = _startPrice;
338
+ _projectConfig.basePrice = _basePrice;
339
+ emit SetAuctionDetails(
340
+ _projectId,
341
+ _auctionTimestampStart,
342
+ _auctionTimestampEnd,
343
+ _startPrice,
344
+ _basePrice
345
+ );
346
+ }
347
+
348
+ /**
349
+ * @notice Resets auction details for project `_projectId`, zero-ing out all
350
+ * relevant auction fields. Not intended to be used in normal auction
351
+ * operation, but rather only in case of the need to halt an auction.
352
+ * @param _projectId Project ID to set auction details for.
353
+ */
354
+ function resetAuctionDetails(
355
+ uint256 _projectId
356
+ ) external onlyCoreAdminACL(this.resetAuctionDetails.selector) {
357
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
358
+ // reset to initial values
359
+ _projectConfig.timestampStart = 0;
360
+ _projectConfig.timestampEnd = 0;
361
+ _projectConfig.startPrice = 0;
362
+ _projectConfig.basePrice = 0;
363
+
364
+ emit ResetAuctionDetails(_projectId);
365
+ }
366
+
367
+ /**
368
+ * @notice Purchases a token from project `_projectId`.
369
+ * @param _projectId Project ID to mint a token on.
370
+ * @return tokenId Token ID of minted token
371
+ */
372
+ function purchase(
373
+ uint256 _projectId
374
+ ) external payable returns (uint256 tokenId) {
375
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
376
+ return tokenId;
377
+ }
378
+
379
+ /**
380
+ * @notice gas-optimized version of purchase(uint256).
381
+ */
382
+ function purchase_H4M(
383
+ uint256 _projectId
384
+ ) external payable returns (uint256 tokenId) {
385
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
386
+ return tokenId;
387
+ }
388
+
389
+ /**
390
+ * @notice Purchases a token from project `_projectId` and sets
391
+ * the token's owner to `_to`.
392
+ * @param _to Address to be the new token's owner.
393
+ * @param _projectId Project ID to mint a token on.
394
+ * @return tokenId Token ID of minted token
395
+ */
396
+ function purchaseTo(
397
+ address _to,
398
+ uint256 _projectId
399
+ ) external payable returns (uint256 tokenId) {
400
+ return purchaseTo_do6(_to, _projectId);
401
+ }
402
+
403
+ /**
404
+ * @notice gas-optimized version of purchaseTo(address, uint256).
405
+ */
406
+ function purchaseTo_do6(
407
+ address _to,
408
+ uint256 _projectId
409
+ ) public payable nonReentrant returns (uint256 tokenId) {
410
+ // CHECKS
411
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
412
+
413
+ // Note that `maxHasBeenInvoked` is only checked here to reduce gas
414
+ // consumption after a project has been fully minted.
415
+ // `_projectConfig.maxHasBeenInvoked` is locally cached to reduce
416
+ // gas consumption, but if not in sync with the core contract's value,
417
+ // the core contract also enforces its own max invocation check during
418
+ // minting.
419
+ require(
420
+ !_projectConfig.maxHasBeenInvoked,
421
+ "Maximum number of invocations reached"
422
+ );
423
+
424
+ // _getPrice reverts if auction is unconfigured or has not started
425
+ uint256 pricePerTokenInWei = _getPrice(_projectId);
426
+ require(
427
+ msg.value >= pricePerTokenInWei,
428
+ "Must send minimum value to mint!"
429
+ );
430
+
431
+ // EFFECTS
432
+ tokenId = minterFilter.mint(_to, _projectId, msg.sender);
433
+
434
+ // okay if this underflows because if statement will always eval false.
435
+ // this is only for gas optimization (core enforces maxInvocations).
436
+ unchecked {
437
+ if (tokenId % ONE_MILLION == _projectConfig.maxInvocations - 1) {
438
+ _projectConfig.maxHasBeenInvoked = true;
439
+ }
440
+ }
441
+
442
+ // INTERACTIONS
443
+ splitFundsETH(_projectId, pricePerTokenInWei, genArt721CoreAddress);
444
+
445
+ return tokenId;
446
+ }
447
+
448
+ /**
449
+ * @notice Gets price of minting a token on project `_projectId` given
450
+ * the project's AuctionParameters and current block timestamp.
451
+ * Reverts if auction has not yet started or auction is unconfigured.
452
+ * @param _projectId Project ID to get price of token for.
453
+ * @return current price of token in Wei
454
+ */
455
+ function _getPrice(uint256 _projectId) private view returns (uint256) {
456
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
457
+ // move parameters to memory if used more than once
458
+ uint256 _timestampStart = uint256(_projectConfig.timestampStart);
459
+ uint256 _timestampEnd = uint256(_projectConfig.timestampEnd);
460
+ uint256 _startPrice = _projectConfig.startPrice;
461
+ uint256 _basePrice = _projectConfig.basePrice;
462
+
463
+ require(block.timestamp > _timestampStart, "Auction not yet started");
464
+ if (block.timestamp >= _timestampEnd) {
465
+ require(_timestampEnd > 0, "Only configured auctions");
466
+ return _basePrice;
467
+ }
468
+ uint256 elapsedTime;
469
+ uint256 duration;
470
+ uint256 startToEndDiff;
471
+ unchecked {
472
+ // already checked that block.timestamp > _timestampStart
473
+ elapsedTime = block.timestamp - _timestampStart;
474
+ // _timestampEnd > _timestampStart enforced during assignment
475
+ duration = _timestampEnd - _timestampStart;
476
+ // _startPrice > _basePrice enforced during assignment
477
+ startToEndDiff = _startPrice - _basePrice;
478
+ }
479
+ return _startPrice - ((elapsedTime * startToEndDiff) / duration);
480
+ }
481
+
482
+ /**
483
+ * @notice Gets if price of token is configured, price of minting a
484
+ * token on project `_projectId`, and currency symbol and address to be
485
+ * used as payment. Supersedes any core contract price information.
486
+ * @param _projectId Project ID to get price information for.
487
+ * @return isConfigured true only if project's auction parameters have been
488
+ * configured on this minter
489
+ * @return tokenPriceInWei current price of token on this minter - invalid
490
+ * if auction has not yet been configured
491
+ * @return currencySymbol currency symbol for purchases of project on this
492
+ * minter. This minter always returns "ETH"
493
+ * @return currencyAddress currency address for purchases of project on
494
+ * this minter. This minter always returns null address, reserved for ether
495
+ */
496
+ function getPriceInfo(
497
+ uint256 _projectId
498
+ )
499
+ external
500
+ view
501
+ returns (
502
+ bool isConfigured,
503
+ uint256 tokenPriceInWei,
504
+ string memory currencySymbol,
505
+ address currencyAddress
506
+ )
507
+ {
508
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
509
+
510
+ isConfigured = (_projectConfig.startPrice > 0);
511
+ if (block.timestamp <= _projectConfig.timestampStart) {
512
+ // Provide a reasonable value for `tokenPriceInWei` when it would
513
+ // otherwise revert, using the starting price before auction starts.
514
+ tokenPriceInWei = _projectConfig.startPrice;
515
+ } else if (_projectConfig.timestampEnd == 0) {
516
+ // In the case of unconfigured auction, return price of zero when
517
+ // it would otherwise revert
518
+ tokenPriceInWei = 0;
519
+ } else {
520
+ tokenPriceInWei = _getPrice(_projectId);
521
+ }
522
+ currencySymbol = "ETH";
523
+ currencyAddress = address(0);
524
+ }
525
+ }