def Div(a, b): """ Integer division of two numbers, truncating the quotient. """ Require(b > 0) c = a / b return c
def Add(a, b): """ Adds two numbers, throws on overflow. """ c = a + b Require(c >= a) return c
def disableInitialStage(addr): """ In case the amassador quota is not met, the administrator can manually disable the ambassador phase. """ Require(onlyAdmin(addr))
def Sub(a, b): """ Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). :param a: operand a :param b: operand b :return: a - b if a - b > 0 or revert the transaction. """ Require(a >= b) return a - b
def Mul(a, b): """ Multiplies two numbers, throws on overflow. :param a: operand a :param b: operand b :return: a - b if a - b > 0 or revert the transaction. """ if a == 0: return 0 c = a * b Require(c / a == b) return c
def buy(account, ongAmount, referredBy): """ Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) """ CheckWitness(account) _undividedDividends = Div(Mul(ongAmount, dividendFee_), 100) _referralBonus = Div(Mul(ongAmount, referralFee_), 100) _dividends = Sub(_undividedDividends, _referralBonus) _taxedOng = Sub(ongAmount - _undividedDividends) _amountOfTokens = OngToToken(_taxedOng) Require(_amountOfTokens > 0 & Add(_amountOfTokens, tokenSupply_) > tokenSupply_) if(referredBy != 0 & referredBy != account & tokenBalanceOf(referredBy) >= statingRequirement_): i = 0
def setSymbol(admin, _symbol): Require(onlyAdmin(admin)) symbol = _symbol return True
def setName(admin, _name): Require(onlyAdmin(admin)) name = _name return True
def setStakingRequirement(admin, _amountOfTokens): Require(onlyAdmin(admin)) statingRequirement_ = _amountOfTokens Notify("statingRequirement", statingRequirement_) return True
def deleteAdmin(fromAdmin, deletedAdmin): Require(onlyAdmin(fromAdmin, deletedAdmin)) key = concatKey(ADMIN_PREFIX, deletedAdmin) Delete(GetContext(), key) Notify(["deleteAdmin", fromAdmin, deletedAdmin])
def addAdmin(fromAdmin, newAdmin): Require(onlyAdmin(fromAdmin)) key = concatKey(ADMIN_PREFIX, newAdmin) Put(GetContext(), key, True) Notify(["addAdmin", fromAdmin, newAdmin]) return True