-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hyperbolic Auction Smart Contract Full
133 lines (81 loc) · 3.67 KB
/
Hyperbolic Auction Smart Contract Full
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
//Read-Only Functions
function tokenPrice() public view returns (uint256)
//Calculates the average price of each token from all commitments.
function priceFunction() public view returns (uint256)
//Returns auction price in any time.
function clearingPrice() public view returns (uint256)
//Returns the current price of the token. The current price is proportional to the total period of the auction and the current time elapsed.
function totalTokensCommitted() public view returns (uint256)
//Calculates total amount of tokens committed at current auction price.
function calculateCommitment(uint256 _commitment) public view returns (uint256)
//Calculates the amount able to be committed during an auction.
function auctionSuccessful() public view returns (bool)
//Returns True if token price is greater or equal to the clearing price.
function auctionEnded() public view returns (bool)
//n Returns True if auction is successful or auction time has ended.
function finalized() public view returns (bool)
//Returns True if auction is finalized.
function finalizeTimeExpired() public view returns (bool)
//Returns true if 14 days have passed since the end of the auction.
function tokensClaimable(address _user) public view returns (uint256)
//Returns number of tokens user is able to claim.
function getBaseInformation() external view returns(
address token,
uint64 startTime,
uint64 endTime,
bool finalized
)
//Returns basic information: auction token, auction start time, auction end time, auction status
//init function
//Init functions can only be called once
function initAuction(
address _funder,
address _token,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
address _paymentCurrency,
uint256 _factor,
uint256 _minimumPrice,
address _operator,
address _pointList,
address payable _wallet
) public
//Name
/Description
_funder The address that funds the auction
_token The address of the token to be auctioned
_totalTokens
The total number of tokens for auction
_startTime
Auction start time
_endTime
Auction end time
_paymentCurrency
The currency the hyperbolic auction accepts as payment. Can be ETH or token
_factor
Inflection point of the auction
_minimumPrice
The minimum auction price
_operator
Address that can finalize auction
_pointList
Address that will manage auction approvals
_wallet
Address where collected funds will be forwarded to/
function commitEth(
address payable _beneficiary,
bool readAndAgreedToMarketParticipationAgreement
) public payable
/Use ETH to buy tokens. Checks the amount of ETH to commit and adds the commitment. Refunds the buyer if commit is too high. Requires Market Participation Agreement./
function commitTokens(
uint256 _amount,
bool readAndAgreedToMarketParticipationAgreement
) public
//Buy Tokens by committing approved ERC20 tokens to this contract address. Requires Market Participation Agreement.
function finalizeAuction() public
/We can finalize the market auction if we have the required role or the time for auction has expired. If the auction is successfully finalized, the payment is forwarded to the specified wallet. If the auction is not successful, all the auction token is sent back to the wallet./
function withdrawTokens() public
//If the auction was successful it transfers the claimed tokens to the buyer. If not successful sends the funds back to the buyer.
function cancelAuction() public
/Can call this function to cancel the auction if need be. Only the admin can cancel the auction. If the auction is finalized or fund is already raised, the auction can not be cancelled./