Skip to content
673 changes: 335 additions & 338 deletions contracts/DSTContract.sol

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions contracts/EventInfo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@
pragma solidity ^0.4.0;

/**
*
* EventInfo - imutable class that denotes
*
* EventInfo - immutable class that denotes
* the time of the virtual accelerator hack
* event
*
*
*/
contract EventInfo{


uint constant HACKATHON_5_WEEKS = 60 * 60 * 24 * 7 * 5;
uint constant T_1_WEEK = 60 * 60 * 24 * 7;

uint eventStart = 1479391200; // Thu, 17 Nov 2016 14:00:00 GMT
uint eventEnd = eventStart + HACKATHON_5_WEEKS;


/**
* getEventStart - return the start of the event time
*/
function getEventStart() constant returns (uint result){
*/
function getEventStart() constant returns (uint result){
return eventStart;
}
}

/**
* getEventEnd - return the end of the event time
*/
function getEventEnd() constant returns (uint result){
*/
function getEventEnd() constant returns (uint result){
return eventEnd;
}
}


/**
* getVotingStart - the voting starts 1 week after the
* getVotingStart - the voting starts 1 week after the
* event starts
*/
*/
function getVotingStart() constant returns (uint result){
return eventStart+ T_1_WEEK;
}

/**
* getTradingStart - the DST tokens trading starts 1 week
* getTradingStart - the DST tokens trading starts 1 week
* after the event starts
*/
*/
function getTradingStart() constant returns (uint result){
return eventStart+ T_1_WEEK;
}

/**
* getNow - helper class to check what time the contract see
*/
function getNow() constant returns (uint result){
function getNow() constant returns (uint result){
return now;
}
}

}
98 changes: 49 additions & 49 deletions contracts/HackerGold.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity ^0.4.0;
/**
*
* @title Hacker Gold
*
*
* The official token powering the hack.ether.camp virtual accelerator.
* This is the only way to acquire tokens from startups during the event.
*
Expand All @@ -15,14 +15,14 @@ pragma solidity ^0.4.0;
*/
contract HackerGold is StandardToken {

// Name of the token
// Name of the token
string public name = "HackerGold";

// Decimal places
uint8 public decimals = 3;
// Token abbreviation
// Token abbreviation
string public symbol = "HKG";

// 1 ether = 200 hkg
uint BASE_PRICE = 200;
// 1 ether = 150 hkg
Expand All @@ -33,153 +33,153 @@ contract HackerGold is StandardToken {
uint SAFETY_LIMIT = 4000000 ether;
// Zeros after the point
uint DECIMAL_ZEROS = 1000;

// Total value in wei
uint totalValue;

// Address of multisig wallet holding ether from sale
address wallet;

// Structure of sale increase milestones
struct milestones_struct {
uint p1;
uint p2;
uint p2;
uint p3;
uint p4;
uint p5;
uint p6;
}
// Milestones instance
milestones_struct milestones;

/**
* Constructor of the contract.
*
*
* Passes address of the account holding the value.
* HackerGold contract itself does not hold any value
*
*
* @param multisig address of MultiSig wallet which will hold the value
*/
function HackerGold(address multisig) {

wallet = multisig;

// set time periods for sale
milestones = milestones_struct(

1476972000, // P1: GMT: 20-Oct-2016 14:00 => The Sale Starts
1478181600, // P2: GMT: 03-Nov-2016 14:00 => 1st Price Ladder
1479391200, // P3: GMT: 17-Nov-2016 14:00 => Price Stable,
1478181600, // P2: GMT: 03-Nov-2016 14:00 => 1st Price Ladder
1479391200, // P3: GMT: 17-Nov-2016 14:00 => Price Stable,
// Hackathon Starts
1480600800, // P4: GMT: 01-Dec-2016 14:00 => 2nd Price Ladder
1481810400, // P5: GMT: 15-Dec-2016 14:00 => Price Stable
1482415200 // P6: GMT: 22-Dec-2016 14:00 => Sale Ends, Hackathon Ends
);

}


/**
* Fallback function: called on ether sent.
*
* It calls to createHKG function with msg.sender
*
* It calls to createHKG function with msg.sender
* as a value for holder argument
*/
function () payable {
createHKG(msg.sender);
}

/**
* Creates HKG tokens.
*
*
* Runs sanity checks including safety cap
* Then calculates current price by getPrice() function, creates HKG tokens
* Finally sends a value of transaction to the wallet
*
*
* Note: due to lack of floating point types in Solidity,
* contract assumes that last 3 digits in tokens amount are stood after the point.
* It means that if stored HKG balance is 100000, then its real value is 100 HKG
*
*
* @param holder token holder
*/
function createHKG(address holder) payable {

if (now < milestones.p1) throw;
if (now >= milestones.p6) throw;
if (msg.value == 0) throw;

// safety cap
if (getTotalValue() + msg.value > SAFETY_LIMIT) throw;
if (getTotalValue() + msg.value > SAFETY_LIMIT) throw;

uint tokens = msg.value * getPrice() * DECIMAL_ZEROS / 1 ether;

totalSupply += tokens;
balances[holder] += tokens;
totalValue += msg.value;

if (!wallet.send(msg.value)) throw;
}

/**
* Denotes complete price structure during the sale.
*
* @return HKG amount per 1 ETH for the current moment in time
*/
function getPrice() constant returns (uint result) {

if (now < milestones.p1) return 0;

if (now >= milestones.p1 && now < milestones.p2) {

return BASE_PRICE;
}

if (now >= milestones.p2 && now < milestones.p3) {
uint days_in = 1 + (now - milestones.p2) / 1 days;

uint days_in = 1 + (now - milestones.p2) / 1 days;
return BASE_PRICE - days_in * 25 / 7; // daily decrease 3.5
}

if (now >= milestones.p3 && now < milestones.p4) {

return MID_PRICE;
}

if (now >= milestones.p4 && now < milestones.p5) {
days_in = 1 + (now - milestones.p4) / 1 days;

days_in = 1 + (now - milestones.p4) / 1 days;
return MID_PRICE - days_in * 25 / 7; // daily decrease 3.5
}

if (now >= milestones.p5 && now < milestones.p6) {

return FIN_PRICE;
}

if (now >= milestones.p6){

return 0;
}

}

/**
* Returns total stored HKG amount.
*
*
* Contract assumes that last 3 digits of this value are behind the decimal place. i.e. 10001 is 10.001
* Thus, result of this function should be divided by 1000 to get HKG value
*
*
* @return result stored HKG amount
*/
function getTotalSupply() constant returns (uint result) {
return totalSupply;
}
}

/**
* It is used for test purposes.
*
*
* Returns the result of 'now' statement of Solidity language
*
*
* @return unix timestamp for current moment in time
*/
function getNow() constant returns (uint result) {
Expand All @@ -188,10 +188,10 @@ contract HackerGold is StandardToken {

/**
* Returns total value passed through the contract
*
*
* @return result total value in wei
*/
function getTotalValue() constant returns (uint result) {
return totalValue;
return totalValue;
}
}
Loading