@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,442 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ import "../../../../interfaces/0.8.x/IGenArt721CoreContractV1.sol";
5
+ import "../../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
+ import "../../../../interfaces/0.8.x/IFilteredMinterV0.sol";
7
+
8
+ import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
9
+
10
+ pragma solidity 0.8.9;
11
+
12
+ /**
13
+ * @title Filtered Minter contract that allows tokens to be minted with ETH.
14
+ * Pricing is achieved using an automated Dutch-auction mechanism.
15
+ * @author Art Blocks Inc.
16
+ */
17
+ contract MinterDAExpV1 is ReentrancyGuard, IFilteredMinterV0 {
18
+ /// Auction details updated for project `projectId`.
19
+ event SetAuctionDetails(
20
+ uint256 indexed projectId,
21
+ uint256 _auctionTimestampStart,
22
+ uint256 _priceDecayHalfLifeSeconds,
23
+ uint256 _startPrice,
24
+ uint256 _basePrice
25
+ );
26
+
27
+ /// Auction details cleared for project `projectId`.
28
+ event ResetAuctionDetails(uint256 indexed projectId);
29
+
30
+ /// Maximum and minimum allowed price decay half lifes updated.
31
+ event AuctionHalfLifeRangeSecondsUpdated(
32
+ uint256 _minimumPriceDecayHalfLifeSeconds,
33
+ uint256 _maximumPriceDecayHalfLifeSeconds
34
+ );
35
+
36
+ /// Core contract address this minter interacts with
37
+ address public immutable genArt721CoreAddress;
38
+
39
+ /// This contract handles cores with interface IV1
40
+ IGenArt721CoreContractV1 private immutable genArtCoreContract;
41
+
42
+ /// Minter filter address this minter interacts with
43
+ address public immutable minterFilterAddress;
44
+
45
+ /// Minter filter this minter may interact with.
46
+ IMinterFilterV0 private immutable minterFilter;
47
+
48
+ /// minterType for this minter
49
+ string public constant minterType = "MinterDAExpV1";
50
+
51
+ uint256 constant ONE_MILLION = 1_000_000;
52
+
53
+ /// projectId => has project reached its maximum number of invocations?
54
+ mapping(uint256 => bool) public projectMaxHasBeenInvoked;
55
+ /// projectId => project's maximum number of invocations
56
+ mapping(uint256 => uint256) public projectMaxInvocations;
57
+
58
+ /// Minimum price decay half life: price must decay with a half life of at
59
+ /// least this amount (must cut in half at least every N seconds).
60
+ uint256 public minimumPriceDecayHalfLifeSeconds = 300; // 5 minutes
61
+ /// Maximum price decay half life: price may decay with a half life of no
62
+ /// more than this amount (may cut in half at no more than every N seconds).
63
+ uint256 public maximumPriceDecayHalfLifeSeconds = 3600; // 60 minutes
64
+
65
+ /// projectId => auction parameters
66
+ mapping(uint256 => AuctionParameters) public projectAuctionParameters;
67
+ struct AuctionParameters {
68
+ uint256 timestampStart;
69
+ uint256 priceDecayHalfLifeSeconds;
70
+ uint256 startPrice;
71
+ uint256 basePrice;
72
+ }
73
+
74
+ modifier onlyCoreWhitelisted() {
75
+ require(
76
+ genArtCoreContract.isWhitelisted(msg.sender),
77
+ "Only Core whitelisted"
78
+ );
79
+ _;
80
+ }
81
+
82
+ modifier onlyArtist(uint256 _projectId) {
83
+ require(
84
+ (msg.sender ==
85
+ genArtCoreContract.projectIdToArtistAddress(_projectId)),
86
+ "Only Artist"
87
+ );
88
+ _;
89
+ }
90
+
91
+ /**
92
+ * @notice Initializes contract to be a Filtered Minter for
93
+ * `_minterFilter`, integrated with Art Blocks core contract
94
+ * at address `_genArt721Address`.
95
+ * @param _genArt721Address Art Blocks core contract address for
96
+ * which this contract will be a minter.
97
+ * @param _minterFilter Minter filter for which
98
+ * this will a filtered minter.
99
+ */
100
+ constructor(
101
+ address _genArt721Address,
102
+ address _minterFilter
103
+ ) ReentrancyGuard() {
104
+ genArt721CoreAddress = _genArt721Address;
105
+ genArtCoreContract = IGenArt721CoreContractV1(_genArt721Address);
106
+ minterFilterAddress = _minterFilter;
107
+ minterFilter = IMinterFilterV0(_minterFilter);
108
+ require(
109
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
110
+ "Illegal contract pairing"
111
+ );
112
+ }
113
+
114
+ /**
115
+ * @notice Sets the maximum invocations of project `_projectId` based
116
+ * on the value currently defined in the core contract.
117
+ * @param _projectId Project ID to set the maximum invocations for.
118
+ * @dev also checks and may refresh projectMaxHasBeenInvoked for project
119
+ * @dev this enables gas reduction after maxInvocations have been reached -
120
+ * core contracts shall still enforce a maxInvocation check during mint.
121
+ */
122
+ function setProjectMaxInvocations(
123
+ uint256 _projectId
124
+ ) external onlyCoreWhitelisted {
125
+ uint256 invocations;
126
+ uint256 maxInvocations;
127
+ (, , invocations, maxInvocations, , , , , ) = genArtCoreContract
128
+ .projectTokenInfo(_projectId);
129
+ // update storage with results
130
+ projectMaxInvocations[_projectId] = maxInvocations;
131
+ if (invocations < maxInvocations) {
132
+ projectMaxHasBeenInvoked[_projectId] = false;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
138
+ * This method exists purely for interface-conformance purposes.
139
+ */
140
+ function togglePurchaseToDisabled(
141
+ uint256 _projectId
142
+ ) external view onlyArtist(_projectId) {
143
+ revert("Action not supported");
144
+ }
145
+
146
+ /**
147
+ * @notice Sets the minimum and maximum values that are settable for
148
+ * `_priceDecayHalfLifeSeconds` across all projects.
149
+ * @param _minimumPriceDecayHalfLifeSeconds Minimum price decay half life
150
+ * (in seconds).
151
+ * @param _maximumPriceDecayHalfLifeSeconds Maximum price decay half life
152
+ * (in seconds).
153
+ */
154
+ function setAllowablePriceDecayHalfLifeRangeSeconds(
155
+ uint256 _minimumPriceDecayHalfLifeSeconds,
156
+ uint256 _maximumPriceDecayHalfLifeSeconds
157
+ ) external onlyCoreWhitelisted {
158
+ require(
159
+ _maximumPriceDecayHalfLifeSeconds >
160
+ _minimumPriceDecayHalfLifeSeconds,
161
+ "Maximum half life must be greater than minimum"
162
+ );
163
+ require(
164
+ _minimumPriceDecayHalfLifeSeconds > 0,
165
+ "Half life of zero not allowed"
166
+ );
167
+ minimumPriceDecayHalfLifeSeconds = _minimumPriceDecayHalfLifeSeconds;
168
+ maximumPriceDecayHalfLifeSeconds = _maximumPriceDecayHalfLifeSeconds;
169
+ emit AuctionHalfLifeRangeSecondsUpdated(
170
+ _minimumPriceDecayHalfLifeSeconds,
171
+ _maximumPriceDecayHalfLifeSeconds
172
+ );
173
+ }
174
+
175
+ ////// Auction Functions
176
+ /**
177
+ * @notice Sets auction details for project `_projectId`.
178
+ * @param _projectId Project ID to set auction details for.
179
+ * @param _auctionTimestampStart Timestamp at which to start the auction.
180
+ * @param _priceDecayHalfLifeSeconds The half life with which to decay the
181
+ * price (in seconds).
182
+ * @param _startPrice Price at which to start the auction, in Wei.
183
+ * @param _basePrice Resting price of the auction, in Wei.
184
+ */
185
+ function setAuctionDetails(
186
+ uint256 _projectId,
187
+ uint256 _auctionTimestampStart,
188
+ uint256 _priceDecayHalfLifeSeconds,
189
+ uint256 _startPrice,
190
+ uint256 _basePrice
191
+ ) external onlyArtist(_projectId) {
192
+ AuctionParameters memory auctionParams = projectAuctionParameters[
193
+ _projectId
194
+ ];
195
+ require(
196
+ auctionParams.timestampStart == 0 ||
197
+ block.timestamp < auctionParams.timestampStart,
198
+ "No modifications mid-auction"
199
+ );
200
+ require(
201
+ block.timestamp < _auctionTimestampStart,
202
+ "Only future auctions"
203
+ );
204
+ require(
205
+ _startPrice > _basePrice,
206
+ "Auction start price must be greater than auction end price"
207
+ );
208
+ require(
209
+ (_priceDecayHalfLifeSeconds >= minimumPriceDecayHalfLifeSeconds) &&
210
+ (_priceDecayHalfLifeSeconds <=
211
+ maximumPriceDecayHalfLifeSeconds),
212
+ "Price decay half life must fall between min and max allowable values"
213
+ );
214
+ projectAuctionParameters[_projectId] = AuctionParameters(
215
+ _auctionTimestampStart,
216
+ _priceDecayHalfLifeSeconds,
217
+ _startPrice,
218
+ _basePrice
219
+ );
220
+ emit SetAuctionDetails(
221
+ _projectId,
222
+ _auctionTimestampStart,
223
+ _priceDecayHalfLifeSeconds,
224
+ _startPrice,
225
+ _basePrice
226
+ );
227
+ }
228
+
229
+ /**
230
+ * @notice Resets auction details for project `_projectId`, zero-ing out all
231
+ * relevant auction fields. Not intended to be used in normal auction
232
+ * operation, but rather only in case of the need to halt an auction.
233
+ * @param _projectId Project ID to set auction details for.
234
+ */
235
+ function resetAuctionDetails(
236
+ uint256 _projectId
237
+ ) external onlyCoreWhitelisted {
238
+ delete projectAuctionParameters[_projectId];
239
+ emit ResetAuctionDetails(_projectId);
240
+ }
241
+
242
+ /**
243
+ * @notice Purchases a token from project `_projectId`.
244
+ * @param _projectId Project ID to mint a token on.
245
+ * @return tokenId Token ID of minted token
246
+ */
247
+ function purchase(
248
+ uint256 _projectId
249
+ ) external payable returns (uint256 tokenId) {
250
+ tokenId = purchaseTo(msg.sender, _projectId);
251
+ return tokenId;
252
+ }
253
+
254
+ /**
255
+ * @notice Purchases a token from project `_projectId` and sets
256
+ * the token's owner to `_to`.
257
+ * @param _to Address to be the new token's owner.
258
+ * @param _projectId Project ID to mint a token on.
259
+ * @return tokenId Token ID of minted token
260
+ */
261
+ function purchaseTo(
262
+ address _to,
263
+ uint256 _projectId
264
+ ) public payable nonReentrant returns (uint256 tokenId) {
265
+ // CHECKS
266
+ require(
267
+ !projectMaxHasBeenInvoked[_projectId],
268
+ "Maximum number of invocations reached"
269
+ );
270
+
271
+ // _getPrice reverts if auction is unconfigured or has not started
272
+ uint256 currentPriceInWei = _getPrice(_projectId);
273
+ require(
274
+ msg.value >= currentPriceInWei,
275
+ "Must send minimum value to mint!"
276
+ );
277
+
278
+ // EFFECTS
279
+ tokenId = minterFilter.mint(_to, _projectId, msg.sender);
280
+ // what if projectMaxInvocations[_projectId] is 0 (default value)?
281
+ // that is intended, so that by default the minter allows infinite transactions,
282
+ // allowing the artblocks contract to stop minting
283
+ // uint256 tokenInvocation = tokenId % ONE_MILLION;
284
+ if (
285
+ projectMaxInvocations[_projectId] > 0 &&
286
+ tokenId % ONE_MILLION == projectMaxInvocations[_projectId] - 1
287
+ ) {
288
+ projectMaxHasBeenInvoked[_projectId] = true;
289
+ }
290
+
291
+ // INTERACTIONS
292
+ _splitFundsETHAuction(_projectId, currentPriceInWei);
293
+ return tokenId;
294
+ }
295
+
296
+ /**
297
+ * @dev splits ETH funds between sender (if refund), foundation,
298
+ * artist, and artist's additional payee for a token purchased on
299
+ * project `_projectId`.
300
+ * @dev utilizes transfer() to send ETH, which may fail if access
301
+ * lists are not properly populated when purchasing tokens.
302
+ * @param _projectId Project ID for which funds shall be split.
303
+ * @param _currentPriceInWei Current price of token, in Wei.
304
+ */
305
+ function _splitFundsETHAuction(
306
+ uint256 _projectId,
307
+ uint256 _currentPriceInWei
308
+ ) internal {
309
+ if (msg.value > 0) {
310
+ uint256 refund = msg.value - _currentPriceInWei;
311
+ if (refund > 0) {
312
+ (bool success_, ) = msg.sender.call{value: refund}("");
313
+ require(success_, "Refund failed");
314
+ }
315
+ uint256 foundationAmount = (_currentPriceInWei *
316
+ genArtCoreContract.artblocksPercentage()) / 100;
317
+ if (foundationAmount > 0) {
318
+ (bool success_, ) = genArtCoreContract.artblocksAddress().call{
319
+ value: foundationAmount
320
+ }("");
321
+ require(success_, "Foundation payment failed");
322
+ }
323
+ uint256 projectFunds = _currentPriceInWei - foundationAmount;
324
+ uint256 additionalPayeeAmount;
325
+ if (
326
+ genArtCoreContract.projectIdToAdditionalPayeePercentage(
327
+ _projectId
328
+ ) > 0
329
+ ) {
330
+ additionalPayeeAmount =
331
+ (projectFunds *
332
+ genArtCoreContract.projectIdToAdditionalPayeePercentage(
333
+ _projectId
334
+ )) /
335
+ 100;
336
+ if (additionalPayeeAmount > 0) {
337
+ (bool success_, ) = genArtCoreContract
338
+ .projectIdToAdditionalPayee(_projectId)
339
+ .call{value: additionalPayeeAmount}("");
340
+ require(success_, "Additional payment failed");
341
+ }
342
+ }
343
+ uint256 creatorFunds = projectFunds - additionalPayeeAmount;
344
+ if (creatorFunds > 0) {
345
+ (bool success_, ) = genArtCoreContract
346
+ .projectIdToArtistAddress(_projectId)
347
+ .call{value: creatorFunds}("");
348
+ require(success_, "Artist payment failed");
349
+ }
350
+ }
351
+ }
352
+
353
+ /**
354
+ * @notice Gets price of minting a token on project `_projectId` given
355
+ * the project's AuctionParameters and current block timestamp.
356
+ * Reverts if auction has not yet started or auction is unconfigured.
357
+ * @param _projectId Project ID to get price of token for.
358
+ * @return current price of token in Wei
359
+ * @dev This method calculates price decay using a linear interpolation
360
+ * of exponential decay based on the artist-provided half-life for price
361
+ * decay, `_priceDecayHalfLifeSeconds`.
362
+ */
363
+ function _getPrice(uint256 _projectId) private view returns (uint256) {
364
+ AuctionParameters memory auctionParams = projectAuctionParameters[
365
+ _projectId
366
+ ];
367
+ require(
368
+ block.timestamp > auctionParams.timestampStart,
369
+ "Auction not yet started"
370
+ );
371
+ require(
372
+ auctionParams.priceDecayHalfLifeSeconds > 0,
373
+ "Only configured auctions"
374
+ );
375
+ uint256 decayedPrice = auctionParams.startPrice;
376
+ uint256 elapsedTimeSeconds = block.timestamp -
377
+ auctionParams.timestampStart;
378
+ // Divide by two (via bit-shifting) for the number of entirely completed
379
+ // half-lives that have elapsed since auction start time.
380
+ decayedPrice >>=
381
+ elapsedTimeSeconds /
382
+ auctionParams.priceDecayHalfLifeSeconds;
383
+ // Perform a linear interpolation between partial half-life points, to
384
+ // approximate the current place on a perfect exponential decay curve.
385
+ decayedPrice -=
386
+ (decayedPrice *
387
+ (elapsedTimeSeconds %
388
+ auctionParams.priceDecayHalfLifeSeconds)) /
389
+ auctionParams.priceDecayHalfLifeSeconds /
390
+ 2;
391
+ if (decayedPrice < auctionParams.basePrice) {
392
+ // Price may not decay below stay `basePrice`.
393
+ return auctionParams.basePrice;
394
+ }
395
+ return decayedPrice;
396
+ }
397
+
398
+ /**
399
+ * @notice Gets if price of token is configured, price of minting a
400
+ * token on project `_projectId`, and currency symbol and address to be
401
+ * used as payment. Supersedes any core contract price information.
402
+ * @param _projectId Project ID to get price information for.
403
+ * @return isConfigured true only if project's auction parameters have been
404
+ * configured on this minter
405
+ * @return tokenPriceInWei current price of token on this minter - invalid
406
+ * if auction has not yet been configured
407
+ * @return currencySymbol currency symbol for purchases of project on this
408
+ * minter. This minter always returns "ETH"
409
+ * @return currencyAddress currency address for purchases of project on
410
+ * this minter. This minter always returns null address, reserved for ether
411
+ */
412
+ function getPriceInfo(
413
+ uint256 _projectId
414
+ )
415
+ external
416
+ view
417
+ returns (
418
+ bool isConfigured,
419
+ uint256 tokenPriceInWei,
420
+ string memory currencySymbol,
421
+ address currencyAddress
422
+ )
423
+ {
424
+ AuctionParameters memory auctionParams = projectAuctionParameters[
425
+ _projectId
426
+ ];
427
+ isConfigured = (auctionParams.startPrice > 0);
428
+ if (block.timestamp <= auctionParams.timestampStart) {
429
+ // Provide a reasonable value for `tokenPriceInWei` when it would
430
+ // otherwise revert, using the starting price before auction starts.
431
+ tokenPriceInWei = auctionParams.startPrice;
432
+ } else if (auctionParams.startPrice == 0) {
433
+ // In the case of unconfigured auction, return price of zero when
434
+ // it would otherwise revert
435
+ tokenPriceInWei = 0;
436
+ } else {
437
+ tokenPriceInWei = _getPrice(_projectId);
438
+ }
439
+ currencySymbol = "ETH";
440
+ currencyAddress = address(0);
441
+ }
442
+ }
@@ -1,9 +1,9 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-only
2
2
  // Created By: Art Blocks Inc.
3
3
 
4
- import "../../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
5
- import "../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
- import "../../../interfaces/0.8.x/IFilteredMinterDAExpV0.sol";
4
+ import "../../../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
5
+ import "../../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
+ import "../../../../interfaces/0.8.x/IFilteredMinterDAExpV0.sol";
7
7
 
8
8
  import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
9
9
  import "@openzeppelin-4.5/contracts/utils/math/SafeCast.sol";
@@ -1,9 +1,9 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-only
2
2
  // Created By: Art Blocks Inc.
3
3
 
4
- import "../../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
5
- import "../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
- import "../../../interfaces/0.8.x/IFilteredMinterDAExpV1.sol";
4
+ import "../../../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
5
+ import "../../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
+ import "../../../../interfaces/0.8.x/IFilteredMinterDAExpV1.sol";
7
7
 
8
8
  import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
9
9
  import "@openzeppelin-4.5/contracts/utils/math/SafeCast.sol";
@@ -1,9 +1,9 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-only
2
2
  // Created By: Art Blocks Inc.
3
3
 
4
- import "../../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
5
- import "../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
- import "../../../interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol";
4
+ import "../../../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
5
+ import "../../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
+ import "../../../../interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol";
7
7
 
8
8
  import "@openzeppelin-4.7/contracts/security/ReentrancyGuard.sol";
9
9
  import "@openzeppelin-4.7/contracts/utils/math/SafeCast.sol";