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