@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,572 @@
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
+ 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 priceDecayHalfLifeSeconds;
78
+ uint256 startPrice;
79
+ uint256 basePrice;
80
+ }
81
+
82
+ mapping(uint256 => ProjectConfig) public projectConfig;
83
+
84
+ /// Minimum price decay half life: price must decay with a half life of at
85
+ /// least this amount (must cut in half at least every N seconds).
86
+ uint256 public minimumPriceDecayHalfLifeSeconds = 300; // 5 minutes
87
+ /// Maximum price decay half life: price may decay with a half life of no
88
+ /// more than this amount (may cut in half at no more than every N seconds).
89
+ uint256 public maximumPriceDecayHalfLifeSeconds = 3600; // 60 minutes
90
+
91
+ // modifier to restrict access to only AdminACL allowed calls
92
+ // @dev defers which ACL contract is used to the core contract
93
+ modifier onlyCoreAdminACL(bytes4 _selector) {
94
+ require(
95
+ genArtCoreContract_Base.adminACLAllowed(
96
+ msg.sender,
97
+ address(this),
98
+ _selector
99
+ ),
100
+ "Only Core AdminACL allowed"
101
+ );
102
+ _;
103
+ }
104
+
105
+ modifier onlyArtist(uint256 _projectId) {
106
+ require(
107
+ (msg.sender ==
108
+ genArtCoreContract_Base.projectIdToArtistAddress(_projectId)),
109
+ "Only Artist"
110
+ );
111
+ _;
112
+ }
113
+
114
+ /**
115
+ * @notice Initializes contract to be a Filtered Minter for
116
+ * `_minterFilter`, integrated with Art Blocks core contract
117
+ * at address `_genArt721Address`.
118
+ * @param _genArt721Address Art Blocks core contract address for
119
+ * which this contract will be a minter.
120
+ * @param _minterFilter Minter filter for which
121
+ * this will a filtered minter.
122
+ */
123
+ constructor(
124
+ address _genArt721Address,
125
+ address _minterFilter
126
+ ) ReentrancyGuard() MinterBase(_genArt721Address) {
127
+ genArt721CoreAddress = _genArt721Address;
128
+ // always populate immutable engine contracts, but only use appropriate
129
+ // interface based on isEngine in the rest of the contract
130
+ genArtCoreContract_Base = IGenArt721CoreContractV3_Base(
131
+ _genArt721Address
132
+ );
133
+ minterFilterAddress = _minterFilter;
134
+ minterFilter = IMinterFilterV0(_minterFilter);
135
+ require(
136
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
137
+ "Illegal contract pairing"
138
+ );
139
+ }
140
+
141
+ /**
142
+ * @notice Syncs local maximum invocations of project `_projectId` based on
143
+ * the value currently defined in the core contract.
144
+ * @param _projectId Project ID to set the maximum invocations for.
145
+ * @dev this enables gas reduction after maxInvocations have been reached -
146
+ * core contracts shall still enforce a maxInvocation check during mint.
147
+ */
148
+ function setProjectMaxInvocations(
149
+ uint256 _projectId
150
+ ) external onlyArtist(_projectId) {
151
+ uint256 maxInvocations;
152
+ uint256 invocations;
153
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
154
+ .projectStateData(_projectId);
155
+
156
+ // update storage with results
157
+ projectConfig[_projectId].maxInvocations = uint24(maxInvocations);
158
+
159
+ // We need to ensure maxHasBeenInvoked is correctly set after manually syncing the
160
+ // local maxInvocations value with the core contract's maxInvocations value.
161
+ // This synced value of maxInvocations from the core contract will always be greater
162
+ // than or equal to the previous value of maxInvocations stored locally.
163
+ projectConfig[_projectId].maxHasBeenInvoked =
164
+ invocations == maxInvocations;
165
+
166
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, maxInvocations);
167
+ }
168
+
169
+ /**
170
+ * @notice Manually sets the local maximum invocations of project `_projectId`
171
+ * with the provided `_maxInvocations`, checking that `_maxInvocations` is less
172
+ * than or equal to the value of project `_project_id`'s maximum invocations that is
173
+ * set on the core contract.
174
+ * @dev Note that a `_maxInvocations` of 0 can only be set if the current `invocations`
175
+ * value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
176
+ * this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
177
+ * @param _projectId Project ID to set the maximum invocations for.
178
+ * @param _maxInvocations Maximum invocations to set for the project.
179
+ */
180
+ function manuallyLimitProjectMaxInvocations(
181
+ uint256 _projectId,
182
+ uint256 _maxInvocations
183
+ ) external onlyArtist(_projectId) {
184
+ // CHECKS
185
+ // ensure that the manually set maxInvocations is not greater than what is set on the core contract
186
+ uint256 maxInvocations;
187
+ uint256 invocations;
188
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
189
+ .projectStateData(_projectId);
190
+ require(
191
+ _maxInvocations <= maxInvocations,
192
+ "Cannot increase project max invocations above core contract set project max invocations"
193
+ );
194
+ require(
195
+ _maxInvocations >= invocations,
196
+ "Cannot set project max invocations to less than current invocations"
197
+ );
198
+ // EFFECTS
199
+ // update storage with results
200
+ projectConfig[_projectId].maxInvocations = uint24(_maxInvocations);
201
+ // We need to ensure maxHasBeenInvoked is correctly set after manually setting the
202
+ // local maxInvocations value.
203
+ projectConfig[_projectId].maxHasBeenInvoked =
204
+ invocations == _maxInvocations;
205
+
206
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, _maxInvocations);
207
+ }
208
+
209
+ /**
210
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
211
+ * This method exists purely for interface-conformance purposes.
212
+ */
213
+ function togglePurchaseToDisabled(
214
+ uint256 _projectId
215
+ ) external view onlyArtist(_projectId) {
216
+ revert("Action not supported");
217
+ }
218
+
219
+ /**
220
+ * @notice projectId => has project reached its maximum number of
221
+ * invocations? Note that this returns a local cache of the core contract's
222
+ * state, and may be out of sync with the core contract. This is
223
+ * intentional, as it only enables gas optimization of mints after a
224
+ * project's maximum invocations has been reached. A false negative will
225
+ * only result in a gas cost increase, since the core contract will still
226
+ * enforce a maxInvocation check during minting. A false positive is not
227
+ * possible because the V3 core contract only allows maximum invocations
228
+ * to be reduced, not increased. Based on this rationale, we intentionally
229
+ * do not do input validation in this method as to whether or not the input
230
+ * `_projectId` is an existing project ID.
231
+ *
232
+ */
233
+ function projectMaxHasBeenInvoked(
234
+ uint256 _projectId
235
+ ) external view returns (bool) {
236
+ return projectConfig[_projectId].maxHasBeenInvoked;
237
+ }
238
+
239
+ /**
240
+ * @notice projectId => project's maximum number of invocations.
241
+ * Optionally synced with core contract value, for gas optimization.
242
+ * Note that this returns a local cache of the core contract's
243
+ * state, and may be out of sync with the core contract. This is
244
+ * intentional, as it only enables gas optimization of mints after a
245
+ * project's maximum invocations has been reached.
246
+ * @dev A number greater than the core contract's project max invocations
247
+ * will only result in a gas cost increase, since the core contract will
248
+ * still enforce a maxInvocation check during minting. A number less than
249
+ * the core contract's project max invocations is only possible when the
250
+ * project's max invocations have not been synced on this minter, since the
251
+ * V3 core contract only allows maximum invocations to be reduced, not
252
+ * increased. When this happens, the minter will enable minting, allowing
253
+ * the core contract to enforce the max invocations check. Based on this
254
+ * rationale, we intentionally do not do input validation in this method as
255
+ * to whether or not the input `_projectId` is an existing project ID.
256
+ */
257
+ function projectMaxInvocations(
258
+ uint256 _projectId
259
+ ) external view returns (uint256) {
260
+ return uint256(projectConfig[_projectId].maxInvocations);
261
+ }
262
+
263
+ /**
264
+ * @notice projectId => auction parameters
265
+ */
266
+ function projectAuctionParameters(
267
+ uint256 _projectId
268
+ )
269
+ external
270
+ view
271
+ returns (
272
+ uint256 timestampStart,
273
+ uint256 priceDecayHalfLifeSeconds,
274
+ uint256 startPrice,
275
+ uint256 basePrice
276
+ )
277
+ {
278
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
279
+ return (
280
+ _projectConfig.timestampStart,
281
+ _projectConfig.priceDecayHalfLifeSeconds,
282
+ _projectConfig.startPrice,
283
+ _projectConfig.basePrice
284
+ );
285
+ }
286
+
287
+ /**
288
+ * @notice Sets the minimum and maximum values that are settable for
289
+ * `_priceDecayHalfLifeSeconds` across all projects.
290
+ * @param _minimumPriceDecayHalfLifeSeconds Minimum price decay half life
291
+ * (in seconds).
292
+ * @param _maximumPriceDecayHalfLifeSeconds Maximum price decay half life
293
+ * (in seconds).
294
+ */
295
+ function setAllowablePriceDecayHalfLifeRangeSeconds(
296
+ uint256 _minimumPriceDecayHalfLifeSeconds,
297
+ uint256 _maximumPriceDecayHalfLifeSeconds
298
+ )
299
+ external
300
+ onlyCoreAdminACL(
301
+ this.setAllowablePriceDecayHalfLifeRangeSeconds.selector
302
+ )
303
+ {
304
+ require(
305
+ _maximumPriceDecayHalfLifeSeconds >
306
+ _minimumPriceDecayHalfLifeSeconds,
307
+ "Maximum half life must be greater than minimum"
308
+ );
309
+ require(
310
+ _minimumPriceDecayHalfLifeSeconds > 0,
311
+ "Half life of zero not allowed"
312
+ );
313
+ minimumPriceDecayHalfLifeSeconds = _minimumPriceDecayHalfLifeSeconds;
314
+ maximumPriceDecayHalfLifeSeconds = _maximumPriceDecayHalfLifeSeconds;
315
+ emit AuctionHalfLifeRangeSecondsUpdated(
316
+ _minimumPriceDecayHalfLifeSeconds,
317
+ _maximumPriceDecayHalfLifeSeconds
318
+ );
319
+ }
320
+
321
+ ////// Auction Functions
322
+ /**
323
+ * @notice Sets auction details for project `_projectId`.
324
+ * @param _projectId Project ID to set auction details for.
325
+ * @param _auctionTimestampStart Timestamp at which to start the auction.
326
+ * @param _priceDecayHalfLifeSeconds The half life with which to decay the
327
+ * price (in seconds).
328
+ * @param _startPrice Price at which to start the auction, in Wei.
329
+ * @param _basePrice Resting price of the auction, in Wei.
330
+ * @dev Note that it is intentionally supported here that the configured
331
+ * price may be explicitly set to `0`.
332
+ */
333
+ function setAuctionDetails(
334
+ uint256 _projectId,
335
+ uint256 _auctionTimestampStart,
336
+ uint256 _priceDecayHalfLifeSeconds,
337
+ uint256 _startPrice,
338
+ uint256 _basePrice
339
+ ) external onlyArtist(_projectId) {
340
+ // CHECKS
341
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
342
+ require(
343
+ _projectConfig.timestampStart == 0 ||
344
+ block.timestamp < _projectConfig.timestampStart,
345
+ "No modifications mid-auction"
346
+ );
347
+ require(
348
+ block.timestamp < _auctionTimestampStart,
349
+ "Only future auctions"
350
+ );
351
+ require(
352
+ _startPrice > _basePrice,
353
+ "Auction start price must be greater than auction end price"
354
+ );
355
+ require(
356
+ (_priceDecayHalfLifeSeconds >= minimumPriceDecayHalfLifeSeconds) &&
357
+ (_priceDecayHalfLifeSeconds <=
358
+ maximumPriceDecayHalfLifeSeconds),
359
+ "Price decay half life must fall between min and max allowable values"
360
+ );
361
+ // EFFECTS
362
+ _projectConfig.timestampStart = _auctionTimestampStart.toUint64();
363
+ _projectConfig.priceDecayHalfLifeSeconds = _priceDecayHalfLifeSeconds
364
+ .toUint64();
365
+ _projectConfig.startPrice = _startPrice;
366
+ _projectConfig.basePrice = _basePrice;
367
+
368
+ emit SetAuctionDetails(
369
+ _projectId,
370
+ _auctionTimestampStart,
371
+ _priceDecayHalfLifeSeconds,
372
+ _startPrice,
373
+ _basePrice
374
+ );
375
+ }
376
+
377
+ /**
378
+ * @notice Resets auction details for project `_projectId`, zero-ing out all
379
+ * relevant auction fields. Not intended to be used in normal auction
380
+ * operation, but rather only in case of the need to halt an auction.
381
+ * @param _projectId Project ID to set auction details for.
382
+ */
383
+ function resetAuctionDetails(
384
+ uint256 _projectId
385
+ ) external onlyCoreAdminACL(this.resetAuctionDetails.selector) {
386
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
387
+ // reset to initial values
388
+ _projectConfig.timestampStart = 0;
389
+ _projectConfig.priceDecayHalfLifeSeconds = 0;
390
+ _projectConfig.startPrice = 0;
391
+ _projectConfig.basePrice = 0;
392
+
393
+ emit ResetAuctionDetails(_projectId);
394
+ }
395
+
396
+ /**
397
+ * @notice Purchases a token from project `_projectId`.
398
+ * @param _projectId Project ID to mint a token on.
399
+ * @return tokenId Token ID of minted token
400
+ */
401
+ function purchase(
402
+ uint256 _projectId
403
+ ) external payable returns (uint256 tokenId) {
404
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
405
+ return tokenId;
406
+ }
407
+
408
+ /**
409
+ * @notice gas-optimized version of purchase(uint256).
410
+ */
411
+ function purchase_H4M(
412
+ uint256 _projectId
413
+ ) external payable returns (uint256 tokenId) {
414
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
415
+ return tokenId;
416
+ }
417
+
418
+ /**
419
+ * @notice Purchases a token from project `_projectId` and sets
420
+ * the token's owner to `_to`.
421
+ * @param _to Address to be the new token's owner.
422
+ * @param _projectId Project ID to mint a token on.
423
+ * @return tokenId Token ID of minted token
424
+ */
425
+ function purchaseTo(
426
+ address _to,
427
+ uint256 _projectId
428
+ ) external payable returns (uint256 tokenId) {
429
+ return purchaseTo_do6(_to, _projectId);
430
+ }
431
+
432
+ /**
433
+ * @notice gas-optimized version of purchaseTo(address, uint256).
434
+ */
435
+ function purchaseTo_do6(
436
+ address _to,
437
+ uint256 _projectId
438
+ ) public payable nonReentrant returns (uint256 tokenId) {
439
+ // CHECKS
440
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
441
+
442
+ // Note that `maxHasBeenInvoked` is only checked here to reduce gas
443
+ // consumption after a project has been fully minted.
444
+ // `_projectConfig.maxHasBeenInvoked` is locally cached to reduce
445
+ // gas consumption, but if not in sync with the core contract's value,
446
+ // the core contract also enforces its own max invocation check during
447
+ // minting.
448
+ require(
449
+ !_projectConfig.maxHasBeenInvoked,
450
+ "Maximum number of invocations reached"
451
+ );
452
+
453
+ // _getPrice reverts if auction is unconfigured or has not started
454
+ uint256 pricePerTokenInWei = _getPrice(_projectId);
455
+ require(
456
+ msg.value >= pricePerTokenInWei,
457
+ "Must send minimum value to mint!"
458
+ );
459
+
460
+ // EFFECTS
461
+ tokenId = minterFilter.mint(_to, _projectId, msg.sender);
462
+
463
+ // okay if this underflows because if statement will always eval false.
464
+ // this is only for gas optimization (core enforces maxInvocations).
465
+ unchecked {
466
+ if (tokenId % ONE_MILLION == _projectConfig.maxInvocations - 1) {
467
+ _projectConfig.maxHasBeenInvoked = true;
468
+ }
469
+ }
470
+
471
+ // INTERACTIONS
472
+ splitFundsETH(_projectId, pricePerTokenInWei, genArt721CoreAddress);
473
+
474
+ return tokenId;
475
+ }
476
+
477
+ /**
478
+ * @notice Gets price of minting a token on project `_projectId` given
479
+ * the project's AuctionParameters and current block timestamp.
480
+ * Reverts if auction has not yet started or auction is unconfigured.
481
+ * @param _projectId Project ID to get price of token for.
482
+ * @return current price of token in Wei
483
+ * @dev This method calculates price decay using a linear interpolation
484
+ * of exponential decay based on the artist-provided half-life for price
485
+ * decay, `_priceDecayHalfLifeSeconds`.
486
+ */
487
+ function _getPrice(uint256 _projectId) private view returns (uint256) {
488
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
489
+ // move parameters to memory if used more than once
490
+ uint256 _timestampStart = uint256(_projectConfig.timestampStart);
491
+ uint256 _priceDecayHalfLifeSeconds = uint256(
492
+ _projectConfig.priceDecayHalfLifeSeconds
493
+ );
494
+ uint256 _basePrice = _projectConfig.basePrice;
495
+
496
+ require(block.timestamp > _timestampStart, "Auction not yet started");
497
+ require(_priceDecayHalfLifeSeconds > 0, "Only configured auctions");
498
+ uint256 decayedPrice = _projectConfig.startPrice;
499
+ uint256 elapsedTimeSeconds;
500
+ unchecked {
501
+ // already checked that block.timestamp > _timestampStart above
502
+ elapsedTimeSeconds = block.timestamp - _timestampStart;
503
+ }
504
+ // Divide by two (via bit-shifting) for the number of entirely completed
505
+ // half-lives that have elapsed since auction start time.
506
+ unchecked {
507
+ // already required _priceDecayHalfLifeSeconds > 0
508
+ decayedPrice >>= elapsedTimeSeconds / _priceDecayHalfLifeSeconds;
509
+ }
510
+ // Perform a linear interpolation between partial half-life points, to
511
+ // approximate the current place on a perfect exponential decay curve.
512
+ unchecked {
513
+ // value of expression is provably always less than decayedPrice,
514
+ // so no underflow is possible when the subtraction assignment
515
+ // operator is used on decayedPrice.
516
+ decayedPrice -=
517
+ (decayedPrice *
518
+ (elapsedTimeSeconds % _priceDecayHalfLifeSeconds)) /
519
+ _priceDecayHalfLifeSeconds /
520
+ 2;
521
+ }
522
+ if (decayedPrice < _basePrice) {
523
+ // Price may not decay below stay `basePrice`.
524
+ return _basePrice;
525
+ }
526
+ return decayedPrice;
527
+ }
528
+
529
+ /**
530
+ * @notice Gets if price of token is configured, price of minting a
531
+ * token on project `_projectId`, and currency symbol and address to be
532
+ * used as payment. Supersedes any core contract price information.
533
+ * @param _projectId Project ID to get price information for.
534
+ * @return isConfigured true only if project's auction parameters have been
535
+ * configured on this minter
536
+ * @return tokenPriceInWei current price of token on this minter - invalid
537
+ * if auction has not yet been configured
538
+ * @return currencySymbol currency symbol for purchases of project on this
539
+ * minter. This minter always returns "ETH"
540
+ * @return currencyAddress currency address for purchases of project on
541
+ * this minter. This minter always returns null address, reserved for ether
542
+ */
543
+ function getPriceInfo(
544
+ uint256 _projectId
545
+ )
546
+ external
547
+ view
548
+ returns (
549
+ bool isConfigured,
550
+ uint256 tokenPriceInWei,
551
+ string memory currencySymbol,
552
+ address currencyAddress
553
+ )
554
+ {
555
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
556
+
557
+ isConfigured = (_projectConfig.startPrice > 0);
558
+ if (block.timestamp <= _projectConfig.timestampStart) {
559
+ // Provide a reasonable value for `tokenPriceInWei` when it would
560
+ // otherwise revert, using the starting price before auction starts.
561
+ tokenPriceInWei = _projectConfig.startPrice;
562
+ } else if (_projectConfig.startPrice == 0) {
563
+ // In the case of unconfigured auction, return price of zero when
564
+ // it would otherwise revert
565
+ tokenPriceInWei = 0;
566
+ } else {
567
+ tokenPriceInWei = _getPrice(_projectId);
568
+ }
569
+ currencySymbol = "ETH";
570
+ currencyAddress = address(0);
571
+ }
572
+ }