-
Notifications
You must be signed in to change notification settings - Fork 104
/
HyperbolicAuction.sol
687 lines (595 loc) · 26.3 KB
/
HyperbolicAuction.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
//----------------------------------------------------------------------------------
// I n s t a n t
//
// .:mmm. .:mmm:. .ii. .:SSSSSSSSSSSSS. .oOOOOOOOOOOOo.
// .mMM'':Mm. .:MM'':Mm:. .II: :SSs.......... .oOO'''''''''''OOo.
// .:Mm' ':Mm. .:Mm' 'MM:. .II: 'sSSSSSSSSSSSSS:. :OO. .OO:
// .'mMm' ':MM:.:MMm' ':MM:. .II: .:...........:SS. 'OOo:.........:oOO'
// 'mMm' ':MMmm' 'mMm: II: 'sSSSSSSSSSSSSS' 'oOOOOOOOOOOOO'
//
//----------------------------------------------------------------------------------
//
// Chef Gonpachi's Hyperbolic Auction
////
// A declining price auction with fair price discovery on a hyperbolic curve.
//
// Inspired by DutchSwap's Dutch Auctions
// https://github.com/deepyr/DutchSwap
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// Made for Sushi.com
//
// Enjoy. (c) Chef Gonpachi, Kusatoshi, SSMikazu 2021
// <https://github.com/chefgonpachi/MISO/>
//
// ---------------------------------------------------------------------
// SPDX-License-Identifier: GPL-3.0
// ---------------------------------------------------------------------
import "../OpenZeppelin/utils/ReentrancyGuard.sol";
import "../Access/MISOAccessControls.sol";
import "../Utils/SafeTransfer.sol";
import "../Utils/BoringBatchable.sol";
import "../Utils/BoringERC20.sol";
import "../Utils/BoringMath.sol";
import "../Utils/Documents.sol";
import "../interfaces/IPointList.sol";
import "../interfaces/IMisoMarket.sol";
/// @notice Attribution to delta.financial
/// @notice Attribution to dutchswap.com
contract HyperbolicAuction is IMisoMarket, MISOAccessControls, BoringBatchable, SafeTransfer, Documents , ReentrancyGuard {
using BoringERC20 for IERC20;
using BoringMath for uint256;
using BoringMath128 for uint128;
using BoringMath64 for uint64;
// MISOMarket template id.
/// @dev For different marketplace types, this must be incremented.
uint256 public constant override marketTemplate = 4;
/// @dev The placeholder ETH address.
address private constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @notice Main market variables.
struct MarketInfo {
uint64 startTime;
uint64 endTime;
uint128 totalTokens;
}
MarketInfo public marketInfo;
/// @notice Market price variables.
struct MarketPrice {
uint128 minimumPrice;
uint128 alpha;
// GP: Can be added later as exponent factor
// uint16 factor;
}
MarketPrice public marketPrice;
/// @notice Market dynamic variables.
struct MarketStatus {
uint128 commitmentsTotal;
bool finalized;
bool usePointList;
}
MarketStatus public marketStatus;
/// @notice The token being sold.
address public auctionToken;
/// @notice The currency the auction accepts for payment. Can be ETH or token address.
address public paymentCurrency;
/// @notice Where the auction funds will get paid.
address payable public wallet;
/// @notice Address that manages auction approvals.
address public pointList;
/// @notice The commited amount of accounts.
mapping(address => uint256) public commitments;
/// @notice Amount of tokens to claim per address.
mapping(address => uint256) public claimed;
/// @notice Event for updating auction times. Needs to be before auction starts.
event AuctionTimeUpdated(uint256 startTime, uint256 endTime);
/// @notice Event for updating auction prices. Needs to be before auction starts.
event AuctionPriceUpdated( uint256 minimumPrice);
/// @notice Event for updating auction wallet. Needs to be before auction starts.
event AuctionWalletUpdated(address wallet);
event AddedCommitment(address addr, uint256 commitment);
/// @notice Event for finalization of the auction.
event AuctionFinalized();
/// @notice Event for cancellation of the auction.
event AuctionCancelled();
/**
* @notice Initializes main contract variables and transfers funds for the auction.
* @dev Init function
* @param _funder The address that funds the token for crowdsale
* @param _token Address of the token being sold
* @param _paymentCurrency The currency the crowdsale accepts for payment. Can be ETH or token address
* @param _totalTokens The total number of tokens to sell in auction
* @param _startTime Auction start time
* @param _endTime Auction end time
* @param _factor Inflection point of the auction
* @param _minimumPrice The minimum auction price
* @param _admin Address that can finalize auction.
* @param _pointList Address that will manage auction approvals.
* @param _wallet Address where collected funds will be forwarded to
*/
function initAuction(
address _funder,
address _token,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
address _paymentCurrency,
uint256 _factor,
uint256 _minimumPrice,
address _admin,
address _pointList,
address payable _wallet
) public {
require(_startTime < 10000000000, "HyperbolicAuction: enter an unix timestamp in seconds, not miliseconds");
require(_endTime < 10000000000, "HyperbolicAuction: enter an unix timestamp in seconds, not miliseconds");
require(_startTime >= block.timestamp, "HyperbolicAuction: start time is before current time");
require(_totalTokens > 0,"HyperbolicAuction: total tokens must be greater than zero");
require(_endTime > _startTime, "HyperbolicAuction: end time must be older than start time");
require(_minimumPrice > 0, "HyperbolicAuction: minimum price must be greater than 0");
require(_wallet != address(0), "HyperbolicAuction: wallet is the zero address");
require(_admin != address(0), "HyperbolicAuction: admin is the zero address");
require(_token != address(0), "HyperbolicAuction: token is the zero address");
require(IERC20(_token).decimals() == 18, "HyperbolicAuction: Token does not have 18 decimals");
if (_paymentCurrency != ETH_ADDRESS) {
require(IERC20(_paymentCurrency).decimals() > 0, "HyperbolicAuction: Payment currency is not ERC20");
}
marketInfo.startTime = BoringMath.to64(_startTime);
marketInfo.endTime = BoringMath.to64(_endTime);
marketInfo.totalTokens = BoringMath.to128(_totalTokens);
marketPrice.minimumPrice = BoringMath.to128(_minimumPrice);
auctionToken = _token;
paymentCurrency = _paymentCurrency;
wallet = _wallet;
initAccessControls(_admin);
_setList(_pointList);
// factor = exponent which can later be used to alter the curve
uint256 _duration = _endTime - _startTime;
uint256 _alpha = _duration.mul(_minimumPrice);
marketPrice.alpha = BoringMath.to128(_alpha);
_safeTransferFrom(_token, _funder, _totalTokens);
}
///--------------------------------------------------------
/// Auction Pricing
///--------------------------------------------------------
/**
* @notice Calculates the average price of each token from all commitments.
* @return Average token price.
*/
function tokenPrice() public view returns (uint256) {
return uint256(marketStatus.commitmentsTotal)
.mul(1e18).div(uint256(marketInfo.totalTokens));
}
/**
* @notice Returns auction price in any time.
* @return Fixed start price or minimum price if outside of auction time, otherwise calculated current price.
*/
function priceFunction() public view returns (uint256) {
/// @dev Return Auction Price
if (block.timestamp <= uint256(marketInfo.startTime)) {
return uint256(-1);
}
if (block.timestamp >= uint256(marketInfo.endTime)) {
return uint256(marketPrice.minimumPrice);
}
return _currentPrice();
}
/// @notice The current clearing price of the Hyperbolic auction
function clearingPrice() public view returns (uint256) {
/// @dev If auction successful, return tokenPrice
if (tokenPrice() > priceFunction()) {
return tokenPrice();
}
return priceFunction();
}
/**
* @notice Calculates price during the auction.
* @return Current auction price.
*/
function _currentPrice() private view returns (uint256) {
uint256 elapsed = block.timestamp.sub(uint256(marketInfo.startTime));
uint256 currentPrice = uint256(marketPrice.alpha).div(elapsed);
return currentPrice;
}
///--------------------------------------------------------
/// Commit to buying tokens!
///--------------------------------------------------------
/**
* @notice Buy Tokens by committing ETH to this contract address
* @dev Needs sufficient gas limit for additional state changes
*/
receive() external payable {
revertBecauseUserDidNotProvideAgreement();
}
/**
* @dev Attribution to the awesome delta.financial contracts
*/
function marketParticipationAgreement() public pure returns (string memory) {
return "I understand that I'm interacting with a smart contract. I understand that tokens commited are subject to the token issuer and local laws where applicable. I reviewed code of the smart contract and understand it fully. I agree to not hold developers or other people associated with the project liable for any losses or misunderstandings";
}
/**
* @dev Not using modifiers is a purposeful choice for code readability.
*/
function revertBecauseUserDidNotProvideAgreement() internal pure {
revert("No agreement provided, please review the smart contract before interacting with it");
}
/**
* @notice Checks the amount of ETH to commit and adds the commitment. Refunds the buyer if commit is too high.
* @param _beneficiary Auction participant ETH address.
*/
function commitEth(
address payable _beneficiary,
bool readAndAgreedToMarketParticipationAgreement
)
public payable
{
require(paymentCurrency == ETH_ADDRESS, "HyperbolicAuction: payment currency is not ETH address");
// Get ETH able to be committed
if(readAndAgreedToMarketParticipationAgreement == false) {
revertBecauseUserDidNotProvideAgreement();
}
require(msg.value > 0, "HyperbolicAuction: Value must be higher than 0");
uint256 ethToTransfer = calculateCommitment(msg.value);
/// @notice Accept ETH Payments.
uint256 ethToRefund = msg.value.sub(ethToTransfer);
if (ethToTransfer > 0) {
_addCommitment(_beneficiary, ethToTransfer);
}
/// @notice Return any ETH to be refunded.
if (ethToRefund > 0) {
_beneficiary.transfer(ethToRefund);
}
/// @notice Revert if commitmentsTotal exceeds the balance
require(marketStatus.commitmentsTotal <= address(this).balance, "DutchAuction: The committed ETH exceeds the balance");
}
/**
* @notice Buy Tokens by commiting approved ERC20 tokens to this contract address.
* @param _amount Amount of tokens to commit.
*/
function commitTokens(uint256 _amount, bool readAndAgreedToMarketParticipationAgreement) public {
commitTokensFrom(msg.sender, _amount, readAndAgreedToMarketParticipationAgreement);
}
/// @dev Users must approve contract prior to committing tokens to auction
function commitTokensFrom(
address _from,
uint256 _amount,
bool readAndAgreedToMarketParticipationAgreement
)
public nonReentrant
{
require(paymentCurrency != ETH_ADDRESS, "HyperbolicAuction: payment currency is not a token");
if(readAndAgreedToMarketParticipationAgreement == false) {
revertBecauseUserDidNotProvideAgreement();
}
uint256 tokensToTransfer = calculateCommitment(_amount);
if (tokensToTransfer > 0) {
_safeTransferFrom(paymentCurrency, msg.sender, tokensToTransfer);
_addCommitment(_from, tokensToTransfer);
}
}
/**
* @notice Calculates total amount of tokens committed at current auction price.
* @return Number of tokens commited.
*/
function totalTokensCommitted() public view returns (uint256) {
return uint256(marketStatus.commitmentsTotal).mul(1e18).div(clearingPrice());
}
/**
* @notice Calculates the amout able to be committed during an auction.
* @param _commitment Commitment user would like to make.
* @return Amount allowed to commit.
*/
function calculateCommitment(uint256 _commitment) public view returns (uint256 ) {
uint256 maxCommitment = uint256(marketInfo.totalTokens).mul(clearingPrice()).div(1e18);
if (uint256(marketStatus.commitmentsTotal).add(_commitment) > maxCommitment) {
return maxCommitment.sub(uint256(marketStatus.commitmentsTotal));
}
return _commitment;
}
/**
* @notice Updates commitment for this address and total commitment of the auction.
* @param _addr Bidders address.
* @param _commitment The amount to commit.
*/
function _addCommitment(address _addr, uint256 _commitment) internal {
require(block.timestamp >= uint256(marketInfo.startTime) && block.timestamp <= uint256(marketInfo.endTime), "HyperbolicAuction: outside auction hours");
MarketStatus storage status = marketStatus;
require(!status.finalized, "HyperbolicAuction: auction already finalized");
uint256 newCommitment = commitments[_addr].add(_commitment);
if (status.usePointList) {
require(IPointList(pointList).hasPoints(_addr, newCommitment));
}
commitments[_addr] = newCommitment;
status.commitmentsTotal = BoringMath.to128(uint256(status.commitmentsTotal).add(_commitment));
emit AddedCommitment(_addr, _commitment);
}
///--------------------------------------------------------
/// Finalize Auction
///--------------------------------------------------------
/**
* @notice Successful if tokens sold equals totalTokens.
* @return True if tokenPrice is bigger or equal clearingPrice.
*/
function auctionSuccessful() public view returns (bool) {
return tokenPrice() >= clearingPrice();
}
/**
* @notice Checks if the auction has ended.
* @return True if auction is successful or time has ended.
*/
function auctionEnded() public view returns (bool) {
return auctionSuccessful() || block.timestamp > uint256(marketInfo.endTime);
}
/**
* @return Returns true if market has been finalized
*/
function finalized() public view returns (bool) {
return marketStatus.finalized;
}
/**
* @return Returns true if 7 days have passed since the end of the auction
*/
function finalizeTimeExpired() public view returns (bool) {
return uint256(marketInfo.endTime) + 7 days < block.timestamp;
}
/**
* @notice Auction finishes successfully above the reserve
* @dev Transfer contract funds to initialized wallet.
*/
function finalize()
public nonReentrant
{
require(hasAdminRole(msg.sender)
|| wallet == msg.sender
|| hasSmartContractRole(msg.sender)
|| finalizeTimeExpired(), "HyperbolicAuction: sender must be an admin");
MarketStatus storage status = marketStatus;
MarketInfo storage info = marketInfo;
require(!status.finalized, "HyperbolicAuction: auction already finalized");
if (auctionSuccessful()) {
/// @dev Successful auction
/// @dev Transfer contributed tokens to wallet.
_safeTokenPayment(paymentCurrency, wallet, uint256(status.commitmentsTotal));
} else {
/// @dev Failed auction
/// @dev Return auction tokens back to wallet.
require(block.timestamp > uint256(info.endTime), "HyperbolicAuction: auction has not finished yet");
_safeTokenPayment(auctionToken, wallet, uint256(info.totalTokens));
}
status.finalized = true;
emit AuctionFinalized();
}
/**
* @notice Cancel Auction
* @dev Admin can cancel the auction before it starts
*/
function cancelAuction() public nonReentrant
{
require(hasAdminRole(msg.sender));
MarketStatus storage status = marketStatus;
require(!status.finalized, "HyperbolicAuction: auction already finalized");
require( uint256(status.commitmentsTotal) == 0, "HyperbolicAuction: auction already committed" );
_safeTokenPayment(auctionToken, wallet, uint256(marketInfo.totalTokens));
status.finalized = true;
emit AuctionCancelled();
}
/**
* @notice How many tokens the user is able to claim.
* @param _user Auction participant address.
* @return claimerCommitment User commitments reduced by already claimed tokens.
*/
function tokensClaimable(address _user) public view returns (uint256 claimerCommitment) {
if (commitments[_user] == 0) return 0;
uint256 unclaimedTokens = IERC20(auctionToken).balanceOf(address(this));
claimerCommitment = commitments[_user].mul(uint256(marketInfo.totalTokens)).div(uint256(marketStatus.commitmentsTotal));
claimerCommitment = claimerCommitment.sub(claimed[_user]);
if(claimerCommitment > unclaimedTokens){
claimerCommitment = unclaimedTokens;
}
}
/// @notice Withdraws bought tokens, or returns commitment if the sale is unsuccessful.
function withdrawTokens() public {
withdrawTokens(msg.sender);
}
/// @notice Withdraw your tokens once the Auction has ended.
function withdrawTokens(address payable beneficiary)
public nonReentrant
{
if (auctionSuccessful()) {
require(marketStatus.finalized, "HyperbolicAuction: not finalized");
/// @dev Successful auction! Transfer claimed tokens.
uint256 tokensToClaim = tokensClaimable(beneficiary);
require(tokensToClaim > 0, "HyperbolicAuction: no tokens to claim");
claimed[beneficiary] = claimed[beneficiary].add(tokensToClaim);
_safeTokenPayment(auctionToken, beneficiary, tokensToClaim);
} else {
/// @dev Auction did not meet reserve price.
/// @dev Return committed funds back to user.
require(block.timestamp > uint256(marketInfo.endTime), "HyperbolicAuction: auction has not finished yet");
uint256 fundsCommitted = commitments[beneficiary];
commitments[beneficiary] = 0; // Stop multiple withdrawals and free some gas
_safeTokenPayment(paymentCurrency, beneficiary, fundsCommitted);
}
}
//--------------------------------------------------------
// Documents
//--------------------------------------------------------
function setDocument(string calldata _name, string calldata _data) external {
require(hasAdminRole(msg.sender) );
_setDocument( _name, _data);
}
function setDocuments(string[] calldata _name, string[] calldata _data) external {
require(hasAdminRole(msg.sender) );
uint256 numDocs = _name.length;
for (uint256 i = 0; i < numDocs; i++) {
_setDocument( _name[i], _data[i]);
}
}
function removeDocument(string calldata _name) external {
require(hasAdminRole(msg.sender));
_removeDocument(_name);
}
//--------------------------------------------------------
// Point Lists
//--------------------------------------------------------
function setList(address _list) external {
require(hasAdminRole(msg.sender));
_setList(_list);
}
function enableList(bool _status) external {
require(hasAdminRole(msg.sender));
marketStatus.usePointList = _status;
}
function _setList(address _pointList) private {
if (_pointList != address(0)) {
pointList = _pointList;
marketStatus.usePointList = true;
}
}
//--------------------------------------------------------
// Setter Functions
//--------------------------------------------------------
/**
* @notice Admin can set start and end time through this function.
* @param _startTime Auction start time.
* @param _endTime Auction end time.
*/
function setAuctionTime(uint256 _startTime, uint256 _endTime) external {
require(hasAdminRole(msg.sender));
require(_startTime < 10000000000, "HyperbolicAuction: enter an unix timestamp in seconds, not miliseconds");
require(_endTime < 10000000000, "HyperbolicAuction: enter an unix timestamp in seconds, not miliseconds");
require(_startTime >= block.timestamp, "HyperbolicAuction: start time is before current time");
require(_endTime > _startTime, "HyperbolicAuction: end time must be older than start price");
require(marketStatus.commitmentsTotal == 0, "HyperbolicAuction: auction cannot have already started");
marketInfo.startTime = BoringMath.to64(_startTime);
marketInfo.endTime = BoringMath.to64(_endTime);
uint64 _duration = marketInfo.endTime - marketInfo.startTime;
uint256 _alpha = uint256(_duration).mul(uint256(marketPrice.minimumPrice));
marketPrice.alpha = BoringMath.to128(_alpha);
emit AuctionTimeUpdated(_startTime,_endTime);
}
/**
* @notice Admin can set start and min price through this function.
* @param _minimumPrice Auction minimum price.
*/
function setAuctionPrice( uint256 _minimumPrice) external {
require(hasAdminRole(msg.sender));
require(_minimumPrice > 0, "HyperbolicAuction: minimum price must be greater than 0");
require(marketStatus.commitmentsTotal == 0, "HyperbolicAuction: auction cannot have already started");
marketPrice.minimumPrice = BoringMath.to128(_minimumPrice);
uint64 _duration = marketInfo.endTime - marketInfo.startTime;
uint256 _alpha = uint256(_duration).mul(uint256(marketPrice.minimumPrice));
marketPrice.alpha = BoringMath.to128(_alpha);
emit AuctionPriceUpdated(_minimumPrice);
}
/**
* @notice Admin can set the auction wallet through this function.
* @param _wallet Auction wallet is where funds will be sent.
*/
function setAuctionWallet(address payable _wallet) external {
require(hasAdminRole(msg.sender));
require(_wallet != address(0), "HyperbolicAuction: wallet is the zero address");
wallet = _wallet;
emit AuctionWalletUpdated(_wallet);
}
///--------------------------------------------------------
/// Market Launchers
///--------------------------------------------------------
function init(bytes calldata _data) external override payable {
}
/**
* @notice Decodes and hands auction data to the initAuction function.
* @param _data Encoded data for initialization.
*/
function initMarket(bytes calldata _data) public override {
(
address _funder,
address _token,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
address _paymentCurrency,
uint256 _factor,
uint256 _minimumPrice,
address _admin,
address _pointList,
address payable _wallet
) = abi.decode(_data, (
address,
address,
uint256,
uint256,
uint256,
address,
uint256,
uint256,
address,
address,
address
));
initAuction(_funder, _token, _totalTokens, _startTime, _endTime, _paymentCurrency, _factor, _minimumPrice, _admin, _pointList, _wallet);
}
/**
* @notice Collects data to initialize the auction and encodes them.
* @param _funder The address that funds the token for crowdsale.
* @param _token Address of the token being sold.
* @param _totalTokens The total number of tokens to sell in auction.
* @param _startTime Auction start time.
* @param _endTime Auction end time.
* @param _paymentCurrency The currency the crowdsale accepts for payment. Can be ETH or token address.
* @param _factor Inflection point of the auction.
* @param _minimumPrice The minimum auction price.
* @param _wallet Address where collected funds will be forwarded to.
* @return _data All the data in bytes format.
*/
function getAuctionInitData(
address _funder,
address _token,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
address _paymentCurrency,
uint256 _factor,
uint256 _minimumPrice,
address _admin,
address _pointList,
address payable _wallet
)
external pure returns (bytes memory _data) {
return abi.encode(
_funder,
_token,
_totalTokens,
_startTime,
_endTime,
_paymentCurrency,
_factor,
_minimumPrice,
_admin,
_pointList,
_wallet
);
}
function getBaseInformation() external view returns(
address ,
uint64 ,
uint64 ,
bool
) {
return (auctionToken, marketInfo.startTime, marketInfo.endTime, marketStatus.finalized);
}
function getTotalTokens() external view returns(uint256) {
return uint256(marketInfo.totalTokens);
}
}