concept: transferes

concept: transferes

pragma solidity ^0.4.2;

contract Forge{

    address owner;
    bytes32 public _name;
    address public _organiser;
    bytes32 public _url;
    uint public funds;

    function Forge() payable{
        owner = msg.sender;
    }

    // accecpt funds
    function receiveFunds() payable {
      funds += msg.value;
    }

    // release funds to organizer
    function payOrganiser() returns(bool){
          if(!_organiser.call.gas(20000).value(this.balance)())
            throw;
    }

    // set forge name
    function setName(bytes32 name) returns(bool){

        if(msg.sender==owner){
            _name = name;
            return true;
        }

        return false;
    }

    // set forge organiser
    function setOrganiser(address organiser) returns(bool){

        if(msg.sender==owner){
            _organiser = organiser;
            return true;
        }

        return false;
    }

    // set forge url (meetup, eventbrite, website etc)
    function setUrl(bytes32 url) returns(bool){

        if(msg.sender==owner){
            _url = url;
            return true;
        }

        return false;
    }

    function kill() returns(bool){
        if(msg.sender==owner){
            selfdestruct(msg.sender);
            return true;
        }

        return false;
    }
}

pragma solidity ^0.4.2;

contract Forge{

    address owner;
    bytes32 public _name;
    address public _organiser;
    bytes32 public _url;

    function Forge(){
        owner = msg.sender;
    }

    function payOrganiser() returns(bool){
        // http://ethereum.stackexchange.com/a/2971/4304
        return true; // targetAddress.call.gas(200000).value(this.balance)();
    }

    // set forge name
    function setName(bytes32 name) returns(bool){

        if(msg.sender==owner){
            _name = name;
            return true;
        }

        return false;
    }

    // set forge organiser
    function setOrganiser(address organiser) returns(bool){

        if(msg.sender==owner){
            _organiser = organiser;
            return true;
        }

        return false;
    }

    // set forge url (meetup, eventbrite, website etc)
    function setUrl(bytes32 url) returns(bool){

        if(msg.sender==owner){
            _url = url;
            return true;
        }

        return false;
    }

    function kill() returns(bool){
        if(msg.sender==owner){
            selfdestruct(msg.sender);
            return true;
        }
        return false;
    }
}


Commented Owned.sol

Commented Owned.sol

/**
 * Owned
 *
 * Inheritable contract that provides onlyOwner modifier.
 */
contract Owned {

    address owner;

    function Owned() {
        owner = msg.sender;
    }

	// only allows the owner to call the function
    modifier onlyOwner {
        if (msg.sender != owner) {
            throw;
        } else {
            _
        }
    }
}

contract Owned {

    address owner;

    function Owned() {
        owner = msg.sender;
    }

    modifier onlyOwner {
        if (msg.sender != owner) {
            throw;
        } else {
            _
        }
    }
}


AssertAddressPayableArray.sol

AssertAddressPayableArray.sol

pragma solidity >= 0.4.15 < 0.6.0;

library AssertAddressPayableArray {

    uint8 constant ZERO = uint8(byte('0'));
    uint8 constant A = uint8(byte('a'));

    /*
        Event: TestEvent

        Fired when an assertion is made.

        Params:
            result (bool) - Whether or not the assertion holds.
            message (string) - A message to display if the assertion does not hold.
    */
    event TestEvent(bool indexed result, string message);

    // ************************************** address payable[] **************************************

    /*
        Function: equal(address payable[])

        Assert that two 'address payable[]' are equal.

        : arrA.length == arrB.length

        and, for all valid indices 'i'

        : arrA[i] == arrB[i]

        Params:
            A (address payable[]) - The first array.
            B (address payable[]) - The second array.
            message (string) - A message that is sent if the assertion fails.

        Returns:
            result (bool) - The result.
    */
    function equal(address payable[] memory arrA, address payable[] memory arrB, string memory message) public returns (bool result) {
        result = arrA.length == arrB.length;
        if (result) {
            for (uint i = 0; i < arrA.length; i++) {
                if (arrA[i] != arrB[i]) {
                    result = false;
                    break;
                }
            }
        }
        _report(result, message);
    }

    /*
        Function: notEqual(address payable[])

        Assert that two 'address payable[]' are not equal.

        : arrA.length != arrB.length

        or, for some valid index 'i'

        : arrA[i] != arrB[i]

        Params:
            A (address payable[]) - The first string.
            B (address payable[]) - The second string.
            message (string) - A message that is sent if the assertion fails.

        Returns:
            result (bool) - The result.
    */
    function notEqual(address payable[] memory arrA, address payable[] memory arrB, string memory message) public returns (bool result) {
        result = arrA.length == arrB.length;
        if (result) {
            for (uint i = 0; i < arrA.length; i++) {
                if (arrA[i] != arrB[i]) {
                    result = false;
                    break;
                }
            }
        }
        result = !result;
        _report(result, message);
    }

    /*
        Function: lengthEqual(address payable[])

        Assert that the length of an 'address payable[]' is equal to a given value.

        : arr.length == length

        Params:
            arr (address payable[]) - The array.
            length (uint) - The length.
            message (string) - A message that is sent if the assertion fails.

        Returns:
            result (bool) - The result.
    */
    function lengthEqual(address payable[] memory arr, uint length, string memory message) public returns (bool result) {
        uint arrLength = arr.length;
        if (arrLength == length)
            _report(result, "");
        else
            _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message));
    }

    /*
        Function: lengthNotEqual(address payable[])

        Assert that the length of an 'address payable[]' is not equal to a given value.

        : arr.length != length

        Params:
            arr (address payable[]) - The array.
            length (uint) - The length.
            message (string) - A message that is sent if the assertion fails.

        Returns:
            result (bool) - The result.
    */
    function lengthNotEqual(address payable[] memory arr, uint length, string memory message) public returns (bool result) {
        uint arrLength = arr.length;
        if (arrLength != arr.length)
            _report(result, "");
        else
            _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message));
    }

    /******************************** internal ********************************/

        /*
            Function: _report

            Internal function for triggering <TestEvent>.

            Params:
                result (bool) - The test result (true or false).
                message (string) - The message that is sent if the assertion fails.
        */
    function _report(bool result, string memory message) internal {
        if(result)
            emit TestEvent(true, "");
        else
            emit TestEvent(false, message);
    }

    /*
        Function: _utoa(uint)

        Convert an  unsigned integer to a string.

        Params:
            n (uint) - The unsigned integer.
            radix (uint8) - A number between 2 and 16 (inclusive). Characters used are 0-9,a-f

        Returns:
            result (string) - The resulting string.
    */
    function _utoa(uint n, uint8 radix) internal pure returns (string memory) {
        if (n == 0 || radix < 2 || radix > 16)
            return '0';
        bytes memory bts = new bytes(256);
        uint i;
        while (n > 0) {
            bts[i++] = _utoa(uint8(n % radix)); // Turn it to ascii.
            n /= radix;
        }
        // Reverse
        bytes memory rev = new bytes(i);
        for (uint j = 0; j < i; j++)
            rev[j] = bts[i - j - 1];
        return string(rev);
    }

    /*
        Function: _utoa(uint8)

        Convert an unsigned 8-bit integer to its ASCII byte representation. Numbers 0-9 are converted to '0'-'9',
        numbers 10-16 to 'a'-'f'. Numbers larger then 16 return the null byte.

        Params:
            u (uint8) - The unsigned 8-bit integer.

        Returns:
            result (string) - The ASCII byte.
    */
    function _utoa(uint8 u) internal pure returns (byte) {
        if (u < 10)
            return byte(u + ZERO);
        else if (u < 16)
            return byte(u - 10 + A);
        else
            return 0;
    }

    /*
    function htoa(address addr) constant returns (string) {
        bytes memory bts = new bytes(40);
        bytes20 addrBts = bytes20(addr);
        for (uint i = 0; i < 20; i++) {
            bts[2*i] = addrBts[i] % 16;
            bts[2*i + 1] = (addrBts[i] / 16) % 16;
        }
        return string(bts);
    }
    */

    /*
        Function: _tag(string)

        Add a tag to a string. The 'value' and 'tag' strings are returned on the form "tag: value".

        Params:
            value (string) - The value.
            tag (string) - The tag.

        Returns:
            result (string) - "tag: value"
    */
    function _tag(string memory value, string memory tag) internal pure returns (string memory) {

        bytes memory valueB = bytes(value);
        bytes memory tagB = bytes(tag);

        uint vl = valueB.length;
        uint tl = tagB.length;

        bytes memory newB = new bytes(vl + tl + 2);

        uint i;
        uint j;

        for (i = 0; i < tl; i++)
            newB[j++] = tagB[i];
        newB[j++] = ':';
        newB[j++] = ' ';
        for (i = 0; i < vl; i++)
            newB[j++] = valueB[i];

        return string(newB);
    }

    /*
        Function: _tag(uint)

        Add a tag to an uint.

        Params:
            value (uint) - The value.
            tag (string) - The tag.

        Returns:
            result (string) - "tag: _utoa(value)"
    */
    function _tag(uint value, string memory tag) internal pure returns (string memory) {
        string memory nstr = _utoa(value, 10);
        return _tag(nstr, tag);
    }

    /*
        Function: _appendTagged(string, string)

        Append two tagged values to a string.

        Params:
            tagged0 (string) - The first tagged value.
            tagged1 (string) - The second tagged value.
            str (string) - The string.

        Returns:
            result (string) - "str (tagged0, tagged1)"
    */
    function _appendTagged(string memory tagged0, string memory tagged1, string memory str) internal pure returns (string memory) {

        bytes memory tagged0B = bytes(tagged0);
        bytes memory tagged1B = bytes(tagged1);
        bytes memory strB = bytes(str);

        uint sl = strB.length;
        uint t0l = tagged0B.length;
        uint t1l = tagged1B.length;

        bytes memory newB = new bytes(sl + t0l + t1l + 5);

        uint i;
        uint j;

        for (i = 0; i < sl; i++)
            newB[j++] = strB[i];
        newB[j++] = ' ';
        newB[j++] = '(';
        for (i = 0; i < t0l; i++)
            newB[j++] = tagged0B[i];
        newB[j++] = ',';
        newB[j++] = ' ';
        for (i = 0; i < t1l; i++)
            newB[j++] = tagged1B[i];
        newB[j++] = ')';

        return string(newB);
    }
}

error: pathspec 'packages/truffle-core/lib/testing/AssertAddressPayableArray.sol' did not match any file(s) known to git


upd rebate reward algorithm

upd rebate reward algorithm

contract coin {}

contract issuer {
    address public issuerAddr;
    address public coinAddr;
    coin public pluton;
    uint dayBtcVolume;
    uint volumeUpdateTimestamp;

    struct Rebate {
        uint plutonRewardRate;
        uint maxPlutonRewardRate;
        uint minPlutonRewardRate;
        uint minDayVolumeForReduce;
        uint dayRebateRateChange;
        uint plutonRewardRateReduceStep;
        uint plutonRewardRateReduce;
        uint baseUnitForRebate;
    }
    Rebate public rebate;

    modifier ownerCheck { if (msg.sender == issuerAddr) _ }

    /*Initial */
    function issuer(address _issuer, coin _plutonAddr) {
        issuerAddr = _issuer;
        coinAddr = _plutonAddr;

        rebate.baseUnitForRebate = 1000; // accrual 0,1%
        rebate.maxPlutonRewardRate = 30; // 3%
        rebate.plutonRewardRate = rebate.maxPlutonRewardRate; // 3%
        rebate.minPlutonRewardRate = 10; // 1%
        rebate.minDayVolumeForReduce = 500; // 500 BTC
        rebate.plutonRewardRateReduce = 1; // reduce 0,1% from every 100 BTC
        rebate.plutonRewardRateReduceStep = 100; // reduce step 100 BTC
        rebate.dayRebateRateChange = 0; // Initial data

        dayBtcVolume = 0;
        volumeUpdateTimestamp = now;

        pluton = coin(_plutonAddr);
    }

    /* issuer functions */

    function updRebateRate(uint _lastDayBtcVolume) returns(uint plutonRewardRate) {
        if(_lastDayBtcVolume > dayBtcVolume)
        {
            rebate.dayRebateRateChange = (_lastDayBtcVolume - dayBtcVolume) / rebate.plutonRewardRateReduceStep * rebate.plutonRewardRateReduce;
            if(rebate.dayRebateRateChange - rebate.plutonRewardRate < rebate.minPlutonRewardRate) {rebate.plutonRewardRate = rebate.minPlutonRewardRate;}
                else rebate.plutonRewardRate = rebate.plutonRewardRate - rebate.minPlutonRewardRate;
        } else {
            rebate.dayRebateRateChange = (dayBtcVolume - _lastDayBtcVolume) / rebate.plutonRewardRateReduceStep * rebate.plutonRewardRateReduce;
            if(rebate.dayRebateRateChange + rebate.plutonRewardRate > rebate.maxPlutonRewardRate) {rebate.plutonRewardRate = rebate.maxPlutonRewardRate;}
                else rebate.plutonRewardRate = rebate.plutonRewardRate + rebate.minPlutonRewardRate;
        }

        return(rebate.plutonRewardRate);

    }

    function getRebate(uint _btcAmount, string txID, address _btcSeller) ownerCheck returns(uint plutonReward) {

         //   pluton.emmision(plutonReward);
        //    pluton.transfer(plutonReward, _btcSeller);
    }

}

contract coin {}

contract issuer {
    address public issuerAddr;
    address public coinAddr;
    coin public pluton;

    struct Rebate {
        uint plutonRewardRate;
        uint plutonRewardRateReduceStep;
        uint plutonRewardRateReduce;
        uint requiredExchangeSpeed;
        uint currentExchangeSpeedRate;
        uint lastTimestamp;
        uint baseUnitForRebate;
        uint minPlutonRewardRate;
        uint currentExchangeSpeed;
    }
    Rebate public rebate;

    modifier ownerCheck { if (msg.sender == issuerAddr) _ }

    /*Initial */
    function issuer(address _issuer, coin _plutonAddr) {
        issuerAddr = _issuer;
        coinAddr = _plutonAddr;

        rebate.baseUnitForRebate = 1000; // accrual 0,1%
        rebate.plutonRewardRate = 30; // 3%
        rebate.minPlutonRewardRate = 10; // 1%

        rebate.plutonRewardRateReduce = 1; // reduce 0,1% from every plutonRewardRateReduceStep more in action more in action

        rebate.requiredExchangeSpeed = 10; // 10 BTC/sec
        rebate.plutonRewardRateReduceStep = 1; // for example: every 1 BTC/sec more in action reduce rate on plutonRewardRateReduce

        rebate.lastTimestamp = now;
        pluton = coin(_plutonAddr);
    }

    /* issuer functions */

    function getRebate(uint _btcAmount, string txID, address _btcSeller) ownerCheck returns(uint plutonReward) {
        rebate.currentExchangeSpeed =  _btcAmount / (now - rebate.lastTimestamp);
        uint reduce;
        reduce = (rebate.currentExchangeSpeed -  rebate.requiredExchangeSpeed) / rebate.plutonRewardRateReduceStep * rebate.plutonRewardRateReduce;
        if(reduce > rebate.currentExchangeSpeed) {rebate.plutonRewardRate = rebate.minPlutonRewardRate;}
        else if(rebate.currentExchangeSpeed > rebate.requiredExchangeSpeed) {
                rebate.plutonRewardRate = rebate.plutonRewardRate - reduce;}
                else {rebate.plutonRewardRate = rebate.plutonRewardRate + reduce;}

        plutonReward = _btcAmount * rebate.plutonRewardRate;
         //   pluton.emmision(plutonReward);
        //    pluton.transfer(plutonReward, _btcSeller);
    }

}


Fixed deadlock when marker point out of members

pragma solidity ^0.4.24;

import './LighthouseAPI.sol';
import './LighthouseABI.sol';
import './LiabilityFactory.sol';

contract LighthouseLib is LighthouseAPI, LighthouseABI {

    function refill(uint256 _value) external {
        require(xrt.transferFrom(msg.sender, this, _value));
        require(_value >= minimalFreeze);

        if (balances[msg.sender] == 0) {
            indexOf[msg.sender] = members.length;
            members.push(msg.sender);
        }
        balances[msg.sender] += _value;
    }

    function withdraw(uint256 _value) external {
        require(balances[msg.sender] >= _value);

        balances[msg.sender] -= _value;
        require(xrt.transfer(msg.sender, _value));

        // Drop member if quota go to zero
        if (quotaOf(msg.sender) == 0) {
            uint256 balance = balances[msg.sender];
            balances[msg.sender] = 0;
            require(xrt.transfer(msg.sender, balance));

            uint256 senderIndex = indexOf[msg.sender];
            uint256 lastIndex = members.length - 1;
            if (senderIndex < lastIndex)
                members[senderIndex] = members[lastIndex];
            members.length -= 1;
        }
    }

    function nextMember() internal
    { marker = (marker + 1) % members.length; }

    modifier quoted {
        if (quota == 0) {
            // Step over marker
            nextMember();

            // Allocate new quota
            quota = quotaOf(members[marker]);
        }

        // Consume one quota for transaction sending
        assert(quota > 0);
        quota -= 1;

        _;
    }

    modifier keepalive {
        if (timeoutBlocks < block.number - keepaliveBlock) {
            // Require to sender have a quota
            require(quotaOf(msg.sender) > 0);

            // Search keepalive sender
            do
                nextMember();
            while (msg.sender != members[marker]);

            // Allocate new quota
            quota = quotaOf(members[marker]);
        }

        _;
    }

    modifier member {
        // Zero members guard
        require(members.length > 0);

        // Only member with marker can to send transaction
        require(msg.sender == members[marker]);

        // Store transaction sending block
        keepaliveBlock = block.number;

        _;
    }

    function to(address _to, bytes _data) external keepalive quoted member {
        require(factory.gasUtilizing(_to) > 0);
        require(_to.call(_data));
    }

    function () external keepalive quoted member
    { require(factory.call(msg.data)); }
}

pragma solidity ^0.4.24;

import './LighthouseAPI.sol';
import './LighthouseABI.sol';
import './LiabilityFactory.sol';

contract LighthouseLib is LighthouseAPI, LighthouseABI {

    function refill(uint256 _value) external {
        require(xrt.transferFrom(msg.sender, this, _value));
        require(_value >= minimalFreeze);

        if (balances[msg.sender] == 0) {
            indexOf[msg.sender] = members.length;
            members.push(msg.sender);
        }
        balances[msg.sender] += _value;
    }

    function withdraw(uint256 _value) external {
        require(balances[msg.sender] >= _value);

        balances[msg.sender] -= _value;
        require(xrt.transfer(msg.sender, _value));

        // Drop member if quota go to zero
        if (quotaOf(msg.sender) == 0) {
            uint256 balance = balances[msg.sender];
            balances[msg.sender] = 0;
            require(xrt.transfer(msg.sender, balance));

            uint256 senderIndex = indexOf[msg.sender];
            uint256 lastIndex = members.length - 1;
            if (senderIndex < lastIndex)
                members[senderIndex] = members[lastIndex];
            members.length -= 1;
        }
    }

    function nextMember() internal
    { marker = (marker + 1) % members.length; }

    modifier quoted {
        if (quota == 0) {
            // Step over marker
            nextMember();

            // Allocate new quota
            quota = quotaOf(members[marker]);
        }

        // Consume one quota for transaction sending
        assert(quota > 0);
        quota -= 1;

        _;
    }

    modifier keepalive {
        if (timeoutBlocks < block.number - keepaliveBlock) {
            // Require to sender have a quota
            require(quotaOf(msg.sender) > 0);

            // Search keepalive sender
            while (msg.sender != members[marker])
                nextMember();

            // Allocate new quota
            quota = quotaOf(members[marker]);
        }

        _;
    }

    modifier member {
        // Zero members guard
        require(members.length > 0);

        // Only member with marker can to send transaction
        require(msg.sender == members[marker]);

        // Store transaction sending block
        keepaliveBlock = block.number;

        _;
    }

    function to(address _to, bytes _data) external keepalive quoted member {
        require(factory.gasUtilizing(_to) > 0);
        require(_to.call(_data));
    }

    function () external keepalive quoted member
    { require(factory.call(msg.data)); }
}


add license to mock

add license to mock

/*
    Copyright 2017-2018 Phillip A. Elsasser

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

pragma solidity ^0.4.23;

import "../libraries/OrderLib.sol";

/// @title OrderLibMock
/// Mock contract for library OrderLib.sol
/// OrderLibMock allows for direct calling of non-view library methods in solidity-coverage.
/// Functions are preceded by _ to indicate that they are a mock function and not
/// a function re-declaration.
contract OrderLibMock {
  using OrderLib for OrderLib.OrderMappings;
  using OrderLib for OrderLib.Order;

  function _getQtyFilledOrCancelledFromOrder(
      OrderLib.OrderMappings storage orderMappings,
      bytes32 orderHash
  ) internal view returns (int)
  {
      return OrderLib.getQtyFilledOrCancelledFromOrder(orderMappings, orderHash);
  }

  function _createOrderHash(
      address contractAddress,
      address[3] orderAddresses,
      uint[5] unsignedOrderValues,
      int orderQty
  ) public pure returns (bytes32)
  {
      return OrderLib.createOrderHash(
        contractAddress,
        orderAddresses,
        unsignedOrderValues,
        orderQty);
  }

  function _isValidSignature(
      address signerAddress,
      bytes32 hash,
      uint8 v,
      bytes32 r,
      bytes32 s
  ) public pure returns (bool)
  {
      return OrderLib.isValidSignature(
        signerAddress,
        hash,
        v,
        r,
        s);
  }

  function _createOrder(
      address contractAddress,
      address[3] orderAddresses,
      uint[5] unsignedOrderValues,
      int orderQty
  ) internal pure returns (OrderLib.Order order)
  {
      return OrderLib.createOrder(
        contractAddress,
        orderAddresses,
        unsignedOrderValues,
        orderQty);
  }

  function _addFilledQtyToOrder(OrderLib.OrderMappings storage orderMappings, bytes32 orderHash, int filledQty) internal {
      OrderLib.addFilledQtyToOrder(orderMappings, orderHash, filledQty);
  }

  function _addCancelledQtyToOrder(OrderLib.OrderMappings storage orderMappings, bytes32 orderHash, int cancelledQty) internal {
      OrderLib.addCancelledQtyToOrder(orderMappings, orderHash, cancelledQty);
  }

}

pragma solidity ^0.4.23;

import "../libraries/OrderLib.sol";

/// @title OrderLibMock
/// Mock contract for library OrderLib.sol
/// OrderLibMock allows for direct calling of non-view library methods.
/// functions are preceded by _ to indicate that they are a mock function and not
/// a function re-declaration.

contract OrderLibMock {
  using OrderLib for OrderLib.OrderMappings;
  using OrderLib for OrderLib.Order;

  function _getQtyFilledOrCancelledFromOrder(
      OrderLib.OrderMappings storage orderMappings,
      bytes32 orderHash
  ) internal view returns (int)
  {
      return OrderLib.getQtyFilledOrCancelledFromOrder(orderMappings, orderHash);
  }

  function _createOrderHash(
      address contractAddress,
      address[3] orderAddresses,
      uint[5] unsignedOrderValues,
      int orderQty
  ) public pure returns (bytes32)
  {
      return OrderLib.createOrderHash(
        contractAddress,
        orderAddresses,
        unsignedOrderValues,
        orderQty);
  }

  function _isValidSignature(
      address signerAddress,
      bytes32 hash,
      uint8 v,
      bytes32 r,
      bytes32 s
  ) public pure returns (bool)
  {
      return OrderLib.isValidSignature(
        signerAddress,
        hash,
        v,
        r,
        s);
  }

  function _createOrder(
      address contractAddress,
      address[3] orderAddresses,
      uint[5] unsignedOrderValues,
      int orderQty
  ) internal pure returns (OrderLib.Order order)
  {
      return OrderLib.createOrder(
        contractAddress,
        orderAddresses,
        unsignedOrderValues,
        orderQty);
  }

  function _addFilledQtyToOrder(OrderLib.OrderMappings storage orderMappings, bytes32 orderHash, int filledQty) internal {
      OrderLib.addFilledQtyToOrder(orderMappings, orderHash, filledQty);
  }

  function _addCancelledQtyToOrder(OrderLib.OrderMappings storage orderMappings, bytes32 orderHash, int cancelledQty) internal {
      OrderLib.addCancelledQtyToOrder(orderMappings, orderHash, cancelledQty);
  }

}


minor fixes

minor fixes

/**

  THIS IS JUST CROWDSALE DUMMY TO SHOW HOW MIGRATE FUNCTION WORKS
  IT IS NOT ACTUALLY REAL CONTRACT FOR CROWDSALE

**/

pragma solidity ^0.4.4;

import "./zeppelin/token/StandardToken.sol";
import "./zeppelin/lifecycle/Stoppable.sol";

//-----------TOKEN CONTRACT dummy
// This dummy need to remote invokation of function of PreSale contract.
// And this probably look ugly.

contract token is Stoppable {
  mapping (address => uint) public balances;
  address public manager=owner;
  event Migrated(address _prebuy,uint amount);

// TODO - change it to msg.sender.
  function DestroyMigr(address _prebuy) onlyManager{
  //  if (_prebuy!=msg.sender) throw;

    uint amt=balances[_prebuy];
    balances[_prebuy]=0;
    Migrated(_prebuy,amt);

  }

  /**
  modifier manager is for invoke migrate function.

  **/

    modifier onlyManager() {
      if (msg.sender == manager)
        _;
      else
        throw;
    }

    function transferManager(address newManager) onlyManager {
      if (newManager != address(0)) manager = newManager;
    }

  function balanceOf(address _owner) constant returns (uint balance)
  {
    return balances[_owner];
  }

 }

/*
 * CrowdsaleToken
 *
 * Simple ERC20 Token example, with crowdsale token creation
 */
contract CrowdSaleDum is StandardToken,Stoppable {

  string public name = "CrowdDummyToken";
  string public symbol = "CDT";
  uint public decimals = 18;

  event MigrationSt (address _prebuy,uint amount);

//  event initpresbal(uint inittok);

  event Buy(address indexed sender, uint eth, uint fbt);

  token public presaleTokenAddress;

  function CrowdSaleDum(token PresaleToken){
  presaleTokenAddress=token(PresaleToken);

  }

  // 1 ether = 500 example tokens

  uint PRICE = 500;

//Cap not set for this contract yet.
//  uint public etherCap = 20000 * 10**18; //max amount raised during crowdsale (200k USD)

  uint public saleTokenSupply = 0; //this will keep track of the token supply created during the presale
  uint public saleEtherRaised = 0; //this will keep track of the Ether raised during the presale

  function MigratePre(address _prebuyC){
  //  uint tokens=presaleTokenAddress.balances(_prebuyC);
  if (_prebuyC!=msg.sender) throw;
    uint tokens=presaleTokenAddress.balanceOf(_prebuyC);
  //  initpresbal(tokens);

    totalSupply = safeAdd(totalSupply, tokens);
    balances[_prebuyC] = safeAdd(balances[_prebuyC], tokens);
    presaleTokenAddress.DestroyMigr(_prebuyC);
  }

  function () payable {
    createTokens(msg.sender);
  }

  //Mul - умножение
  function createTokens(address recipient) payable {
    if (msg.value == 0) throw;

    uint tokens = safeMul(msg.value, getPrice());

    totalSupply = safeAdd(totalSupply, tokens);
    balances[recipient] = safeAdd(balances[recipient], tokens);

    saleTokenSupply = safeAdd(saleTokenSupply,tokens);
    saleEtherRaised = safeAdd(saleEtherRaised, msg.value);

    // I don't understand this
  //  if (!owner.call.value(msg.value)()) throw; //immediately send Ether to founder address

  // We can use it if we want immediately send.
  //if(!owner.send(msg.value)) throw;

    Buy(recipient, msg.value, tokens);

  }

  // replace this with any other price function
  function getPrice() constant returns (uint result){
    return PRICE;
  }

// For test only
  function destroy() { // so funds not locked in contract forever
    if (msg.sender == owner) {
      suicide(msg.sender); // send funds to organizer
    }
  }

//We have use this version of withdraw or we can use straight-forwarding function.
  function withdraw(){

  if(!owner.send(saleEtherRaised))
  throw;
  }

}

/**

  THIS IS JUST CROWDSALE DUMMY TO SHOW HOW MIGRATE FUNCTION WORKS
  IT IS NOT ACTUALLY REAL CONTRACT FOR CROWDSALE

**/

pragma solidity ^0.4.4;

import "./zeppelin/token/StandardToken.sol";
import "./zeppelin/lifecycle/Stoppable.sol";

//-----------TOKEN CONTRACT dummy
// This dummy need to remote invokation of function of PreSale contract.
// And this probably look ugly.

contract token is Stoppable {
  mapping (address => uint) public balances;
  address public manager=owner;
  event Migrated(address _prebuy,uint amount);

  function DestroyMigr(address _prebuy) onlyManager{
  //  if (_prebuy!=msg.sender) throw;

    uint amt=balances[_prebuy];
    balances[_prebuy]=0;
    Migrated(_prebuy,amt);

  }

  /**
  modifier manager is for invoke migrate function.

  **/

    modifier onlyManager() {
      if (msg.sender == manager)
        _;
      else
        throw;
    }

    function transferManager(address newManager) onlyManager {
      if (newManager != address(0)) manager = newManager;
    }

  function balanceOf(address _owner) constant returns (uint balance)
  {
    return balances[_owner];
  }

 }

/*
 * CrowdsaleToken
 *
 * Simple ERC20 Token example, with crowdsale token creation
 */
contract CrowdSaleDum is StandardToken,Stoppable {

  string public name = "CrowdDummyToken";
  string public symbol = "CDT";
  uint public decimals = 18;

  event MigrationSt (address _prebuy,uint amount);

//  event initpresbal(uint inittok);

  event Buy(address indexed sender, uint eth, uint fbt);

  token public presaleTokenAddress;

  function CrowdSaleDum(token PresaleToken){
  presaleTokenAddress=token(PresaleToken);

  }

  // 1 ether = 500 example tokens

  uint PRICE = 500;

//Cap not set for this contract yet.
//  uint public etherCap = 20000 * 10**18; //max amount raised during crowdsale (200k USD)

  uint public saleTokenSupply = 0; //this will keep track of the token supply created during the presale
  uint public saleEtherRaised = 0; //this will keep track of the Ether raised during the presale

  function MigratePre(address _prebuyC){
  //  uint tokens=presaleTokenAddress.balances(_prebuyC);
    uint tokens=presaleTokenAddress.balanceOf(_prebuyC);
  //  initpresbal(tokens);

    totalSupply = safeAdd(totalSupply, tokens);
    balances[_prebuyC] = safeAdd(balances[_prebuyC], tokens);
    presaleTokenAddress.DestroyMigr(_prebuyC);
  }

  function () payable {
    createTokens(msg.sender);
  }

  //Mul - умножение
  function createTokens(address recipient) payable {
    if (msg.value == 0) throw;

    uint tokens = safeMul(msg.value, getPrice());

    totalSupply = safeAdd(totalSupply, tokens);
    balances[recipient] = safeAdd(balances[recipient], tokens);

    saleTokenSupply = safeAdd(saleTokenSupply,tokens);
    saleEtherRaised = safeAdd(saleEtherRaised, msg.value);

    // I don't understand this
  //  if (!owner.call.value(msg.value)()) throw; //immediately send Ether to founder address

  // We can use it if we want immediately send.
  //if(!owner.send(msg.value)) throw;

    Buy(recipient, msg.value, tokens);

  }

  // replace this with any other price function
  function getPrice() constant returns (uint result){
    return PRICE;
  }

// For test only
  function destroy() { // so funds not locked in contract forever
    if (msg.sender == owner) {
      suicide(msg.sender); // send funds to organizer
    }
  }

//We have use this version of withdraw or we can use straight-forwarding function.
  function withdraw(){

  if(!owner.send(saleEtherRaised))
  throw;
  }

}


onlyOwner -> onlyContractOwner

onlyOwner -> onlyContractOwner

// Implements standard token interface
// From: https://github.com/slockit/DAO/blob/f640568e694a057aaeb64a0f1049fae27efe818b/Token.sol
// See also https://github.com/ethereum/wiki/wiki/Standardized_Contract_APIs

contract TokenInterface {
    mapping (address => uint256) balances;
    mapping (address => mapping (address => uint256)) allowed;

    /// Total amount of tokens
    uint256 public totalSupply;

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) constant returns (uint256 balance);

    /// @notice Send `_amount` tokens to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _amount) returns (bool success);

    /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
    /// is approved by `_from`
    /// @param _from The address of the origin of the transfer
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _amount) returns (bool success);

    /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
    /// its behalf
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _amount) returns (bool success);

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens of _owner that _spender is allowed
    /// to spend
    function allowance(
        address _owner,
        address _spender
    ) constant returns (uint256 remaining);

    event Transfer(address indexed _from, address indexed _to, uint256 _amount);
    event Approval(
        address indexed _owner,
        address indexed _spender,
        uint256 _amount
    );
}

contract DynamicToken is TokenInterface {
  address public contractOwner;
  address[] public accounts;
  mapping (address => bool) public accountExists;
  string[] public proofIds;
  mapping (string => bool) proofIdExists;
  uint256 public maxSupply;
  bool public closed;
  address public upgradedContract;

  event TransferFrom(address indexed _from, address indexed _to,  address indexed _spender, uint256 _amount);
  event Issue(address _from, address _to, uint256 _amount, string _proofId);
  event Burn(address _burnFrom, uint256 _amount, address _burner);
  event Close(address _closedBy);
  event Upgrade(address _upgradedContract);

  function DynamicToken() {
    contractOwner = msg.sender;     // contract owner is contract creator
    closed = false;
    maxSupply = 10**7;
    totalSupply = 0;
  }

  // restrict usage to only the owner
  modifier onlyContractOwner {
    if (msg.sender != contractOwner) throw;
    _
  }

  // check if the contract has been closed
  modifier notClosed {
    if (closed) throw;
    _
  }

  // no ether should be transfered to this contract
  modifier noEther() {if (msg.value > 0) throw; _}

  // accessors

  function getAccounts() noEther constant returns (address[] _accounts) {
    return accounts;
  }

  function balanceOf(address _owner) noEther constant returns(uint256 balance) {
    return balances[_owner];
  }

  function allowance(address _owner, address _spender) noEther constant returns (uint256 remaining) {
    return allowed[_owner][_spender];
  }

  // mutators

  // tokens are only issued in exchange for a unique proof of contribution
  function issue(address _to, uint256 _amount, string _proofId) notClosed onlyContractOwner noEther returns (bool success) {
    if (totalSupply + _amount < totalSupply) throw;     // Check for overflow
    if (balances[_to] + _amount < balances[_to]) throw; // Check for overflow
    if (proofIdExists[_proofId]) return false;
    if (totalSupply + _amount > maxSupply) return false;

    balances[_to] += _amount;
    totalSupply += _amount;
    _indexAccount(_to);
    _indexProofId(_proofId);
    Issue(msg.sender, _to, _amount, _proofId);
    return true;
  }

  function setMaxSupply(uint256 _maxSupply) notClosed onlyContractOwner noEther returns (bool success) {
    if (_maxSupply < totalSupply) throw;
    maxSupply = _maxSupply;
    return true;
  }

  function transferContractOwnership(address _newOwner) notClosed onlyContractOwner noEther returns (bool success) {
    contractOwner = _newOwner;
    return true;
  }

  function transfer(address _to, uint256 _amount) notClosed noEther returns (bool success) {
    return _transfer(msg.sender, _to, _amount);
  }

  function approve(address _spender, uint256 _amount) notClosed noEther returns (bool success) {
    allowed[msg.sender][_spender] = _amount;
    Approval(msg.sender, _spender, _amount);
    return true;
  }

  function transferFrom(address _from, address _to, uint256 _amount) notClosed noEther returns (bool success) {
    if (_amount > allowed[_from][msg.sender]) return false;
    if (!_transfer(_from, _to, _amount)) return false;

    allowed[_from][msg.sender] -= _amount;
    TransferFrom(_from, _to, msg.sender, _amount);
    return true;
  }

  function burn(address _burnFrom, uint256 _amount) notClosed noEther returns (bool success) {
    if( !(msg.sender == _burnFrom || msg.sender == contractOwner) ) throw;
    if (_amount > totalSupply) return false;  // check for underflow
    if (_amount > balances[_burnFrom]) return false;

    balances[_burnFrom] -= _amount;
    totalSupply -= _amount;
    Burn(_burnFrom, _amount, msg.sender);
    return true;
  }

  function upgrade(address _upgradedContract) notClosed onlyContractOwner noEther returns (bool success) {
    upgradedContract = _upgradedContract;
    close();
    Upgrade(_upgradedContract);
    return true;
  }

  function close() notClosed onlyContractOwner noEther returns (bool success) {
    closed = true;
    Close(msg.sender);
    return true;
  }

  function destroyContract() onlyContractOwner noEther {
    selfdestruct(contractOwner);
  }

  // private mutators

  function _transfer(address _from, address _to, uint256 _amount) notClosed private returns (bool success) {
    if (balances[_to] + _amount < balances[_to]) throw;  // Check for overflow
    if (_amount > balances[_from]) return false;

    balances[_to] += _amount;
    balances[_from] -= _amount;
    _indexAccount(_to);
    Transfer(_from, _to, _amount);
    return true;
  }

  function _indexAccount(address _account) private {
    if (accountExists[_account]) return;
    accountExists[_account] = true;
    accounts.push(_account);
  }

  function _indexProofId(string _proofId) private {
    if (proofIdExists[_proofId]) return;
    proofIdExists[_proofId] = true;
    proofIds.push(_proofId);
  }

  // throw on malformed calls
  function () {
    throw;
  }
}

// Implements standard token interface
// From: https://github.com/slockit/DAO/blob/f640568e694a057aaeb64a0f1049fae27efe818b/Token.sol
// See also https://github.com/ethereum/wiki/wiki/Standardized_Contract_APIs

contract TokenInterface {
    mapping (address => uint256) balances;
    mapping (address => mapping (address => uint256)) allowed;

    /// Total amount of tokens
    uint256 public totalSupply;

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) constant returns (uint256 balance);

    /// @notice Send `_amount` tokens to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _amount) returns (bool success);

    /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
    /// is approved by `_from`
    /// @param _from The address of the origin of the transfer
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _amount) returns (bool success);

    /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
    /// its behalf
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _amount) returns (bool success);

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens of _owner that _spender is allowed
    /// to spend
    function allowance(
        address _owner,
        address _spender
    ) constant returns (uint256 remaining);

    event Transfer(address indexed _from, address indexed _to, uint256 _amount);
    event Approval(
        address indexed _owner,
        address indexed _spender,
        uint256 _amount
    );
}

contract DynamicToken is TokenInterface {
  address public contractOwner;
  address[] public accounts;
  mapping (address => bool) public accountExists;
  string[] public proofIds;
  mapping (string => bool) proofIdExists;
  uint256 public maxSupply;
  bool public closed;
  address public upgradedContract;

  event TransferFrom(address indexed _from, address indexed _to,  address indexed _spender, uint256 _amount);
  event Issue(address _from, address _to, uint256 _amount, string _proofId);
  event Burn(address _burnFrom, uint256 _amount, address _burner);
  event Close(address _closedBy);
  event Upgrade(address _upgradedContract);

  function DynamicToken() {
    contractOwner = msg.sender;     // contract owner is contract creator
    closed = false;
    maxSupply = 10**7;
    totalSupply = 0;
  }

  // restrict usage to only the owner
  modifier onlyOwner {
    if (msg.sender != contractOwner) throw;
    _
  }

  // check if the contract has been closed
  modifier notClosed {
    if (closed) throw;
    _
  }

  // no ether should be transfered to this contract
  modifier noEther() {if (msg.value > 0) throw; _}

  // accessors

  function getAccounts() noEther constant returns (address[] _accounts) {
    return accounts;
  }

  function balanceOf(address _owner) noEther constant returns(uint256 balance) {
    return balances[_owner];
  }

  function allowance(address _owner, address _spender) noEther constant returns (uint256 remaining) {
    return allowed[_owner][_spender];
  }

  // mutators

  // tokens are only issued in exchange for a unique proof of contribution
  function issue(address _to, uint256 _amount, string _proofId) notClosed onlyOwner noEther returns (bool success) {
    if (totalSupply + _amount < totalSupply) throw;     // Check for overflow
    if (balances[_to] + _amount < balances[_to]) throw; // Check for overflow
    if (proofIdExists[_proofId]) return false;
    if (totalSupply + _amount > maxSupply) return false;

    balances[_to] += _amount;
    totalSupply += _amount;
    _indexAccount(_to);
    _indexProofId(_proofId);
    Issue(msg.sender, _to, _amount, _proofId);
    return true;
  }

  function setMaxSupply(uint256 _maxSupply) notClosed onlyOwner noEther returns (bool success) {
    if (_maxSupply < totalSupply) throw;
    maxSupply = _maxSupply;
    return true;
  }

  function transferContractOwnership(address _newOwner) notClosed onlyOwner noEther returns (bool success) {
    contractOwner = _newOwner;
    return true;
  }

  function transfer(address _to, uint256 _amount) notClosed noEther returns (bool success) {
    return _transfer(msg.sender, _to, _amount);
  }

  function approve(address _spender, uint256 _amount) notClosed noEther returns (bool success) {
    allowed[msg.sender][_spender] = _amount;
    Approval(msg.sender, _spender, _amount);
    return true;
  }

  function transferFrom(address _from, address _to, uint256 _amount) notClosed noEther returns (bool success) {
    if (_amount > allowed[_from][msg.sender]) return false;
    if (!_transfer(_from, _to, _amount)) return false;

    allowed[_from][msg.sender] -= _amount;
    TransferFrom(_from, _to, msg.sender, _amount);
    return true;
  }

  function burn(address _burnFrom, uint256 _amount) notClosed noEther returns (bool success) {
    if( !(msg.sender == _burnFrom || msg.sender == contractOwner) ) throw;
    if (_amount > totalSupply) return false;  // check for underflow
    if (_amount > balances[_burnFrom]) return false;

    balances[_burnFrom] -= _amount;
    totalSupply -= _amount;
    Burn(_burnFrom, _amount, msg.sender);
    return true;
  }

  function upgrade(address _upgradedContract) notClosed onlyOwner noEther returns (bool success) {
    upgradedContract = _upgradedContract;
    close();
    Upgrade(_upgradedContract);
    return true;
  }

  function close() notClosed onlyOwner noEther returns (bool success) {
    closed = true;
    Close(msg.sender);
    return true;
  }

  function destroyContract() onlyOwner noEther {
    selfdestruct(contractOwner);
  }

  // private mutators

  function _transfer(address _from, address _to, uint256 _amount) notClosed private returns (bool success) {
    if (balances[_to] + _amount < balances[_to]) throw;  // Check for overflow
    if (_amount > balances[_from]) return false;

    balances[_to] += _amount;
    balances[_from] -= _amount;
    _indexAccount(_to);
    Transfer(_from, _to, _amount);
    return true;
  }

  function _indexAccount(address _account) private {
    if (accountExists[_account]) return;
    accountExists[_account] = true;
    accounts.push(_account);
  }

  function _indexProofId(string _proofId) private {
    if (proofIdExists[_proofId]) return;
    proofIdExists[_proofId] = true;
    proofIds.push(_proofId);
  }

  // throw on malformed calls
  function () {
    throw;
  }
}


Preliminary version of PresaleToken contract

pragma solidity ^0.4.4;

// ERC20 token interface is implemented only partially.
// Token transfer is prohibited due to spec (see PRESALE-SPEC.md),
// hence some functions are left undefined:
//  - transfer, transferFrom,
//  - approve, allowance.

contract PresaleToken {

    /// @dev Constructor
    /// @param _tokenManager Token manager address.
    function PresaleToken(address _tokenManager) {
        tokenManager = _tokenManager;
    }

    /*/
     *  Constants
    /*/
    string public name = "DilationPresaleToken";
    string public symbol = "DPT";
    uint   public decimals = 18;

    uint private PRICE = 200; // 200 DPT per Ether
    uint private TOKEN_SUPPLY_LIMIT = 4000000;

    /*/
     *  Token state
    /*/

    enum Phase {
        Created,
        Running,
        Paused,
        Migrating,
        Migrated
    }
    Phase public currentPhase = Phase.Created;

    uint public totalSupply = 0; // amount of tokens already sold
    mapping (address => uint256) private balance;

    // Token manager has exclusive priveleges to call administrative
    // functions on this contract.
    address private tokenManager;
    // Crowdsale manager has exclusive priveleges to burn presale tokens.
    address private crowdsaleManager;

    modifier onlyTokenManager()     { if(msg.sender != tokenManager) throw; _; }
    modifier onlyCrowdsaleManager() { if(msg.sender != crowdsaleManager) throw; _; }

    /*/
     *  Events
    /*/

    event LogBuy(address indexed owner, uint value);
    event LogBurn(address indexed owner, uint value);
    event LogPhaseSwitch(Phase newPhase);

    /*/
     *  Public functions
    /*/

    /// @dev Lets buy you some tokens.
    function buy() public payable {
        // Available only if presale is running.
        if(currentPhase != Phase.Running) throw;

        if(msg.value == 0) throw;
        uint newTokens = msg.value * PRICE;
        if (totalSupply + newTokens > TOKEN_SUPPLY_LIMIT) throw;
        balance[msg.sender] += newTokens;
        totalSupply += newTokens;
        LogBuy(msg.sender, newTokens);
    }

    /// @dev Returns number of tokens owned by given address.
    /// @param _owner Address of token owner.
    function burn(address _owner) public {
        // Available only during migration phase
        if(currentPhase != Phase.Migrating) throw;

        uint tokens = balance[_owner];
        if(tokens == 0) throw;
        balance[_owner] = 0;
        totalSupply -= tokens;
        LogBurn(_owner, tokens);

        // Automatically switch phase when migration is done.
        if(totalSupply == 0) setPhase(Phase.Migrated);
    }

    /// @dev Returns number of tokens owned by given address.
    /// @param _owner Address of token owner.
    function balanceOf(address _owner) constant returns (uint256) {
        return balance[_owner];
    }

    /*/
     *  Administrative functions
    /*/

    function setPhase(Phase _nextPhase) public
        onlyTokenManager
    {
        bool canSwitchPhase
            =  (currentPhase == Phase.Created && _nextPhase == Phase.Running)
            || (currentPhase == Phase.Running && _nextPhase == Phase.Paused)
                // switch to migration phase only if crowdsale manager is set
            || ((currentPhase == Phase.Running || currentPhase == Phase.Paused)
                && _nextPhase == Phase.Migrating
                && crowdsaleManager != 0x0)
            || (currentPhase == Phase.Paused && _nextPhase == Phase.Running)
            || (currentPhase == Phase.Migrating && _nextPhase == Phase.Migrated
                && totalSupply == 0);

        if(!canSwitchPhase) throw;
        else {
            currentPhase = _nextPhase;
            LogPhaseSwitch(_nextPhase);
        }
    }

    function withdrawEther() public
        onlyTokenManager
    {
        // Available at any phase.
        if(this.balance == 0 || !tokenManager.send(this.balance)) throw;
    }

    function setCrowdsaleManager(address _mgr) public
        onlyTokenManager
    {
        // You can't change crowdsale contract when migration is in progress.
        if(currentPhase == Phase.Migrating) throw;
        crowdsaleManager = _mgr;
    }

    function selfdestruct() public
        onlyTokenManager
    {
        // Available only if nothing hapened yet or if presale is totally
        // completed.
        if(currentPhase != Phase.Created || currentPhase != Phase.Migrated)
          throw;
        suicide(tokenManager); // send remaining funds to tokenManager
    }
}

error: pathspec 'contracts/PresaleToken.sol' did not match any file(s) known to git


Removed referenceBlock

Removed referenceBlock

import "lib/random.sol";
import "userMaster.sol";
import "tag.sol";
import "user.sol";
import "tagMaster.sol";

/*
@type: contract
@name: Assessment
@purpose: To facilitate the assessment process
*/
contract Assessment
{
  address assessee; //The address of the user being assessed
  address[] assessorPool; //The addresses of the user's that the assessors are randomly selected from
  mapping (address => uint) assessors; //A mapping of the assessors to their current status
  uint calledAssessors = 0; //The number of assessors that have been called to assess
  address[] finalAssessors; //The addresses of the final set of assessors who have completed the assessment process
  address tag; //The address of the tag that is being assessed
  address userMaster; //The address of the UserMaster
  address tagMaster; //The address of the TagMaster
  address random; //The address of the Random contract
  uint poolSizeRemaining; //The remaining number of users to be added to the assessor pool
  uint numberOfAssessors; //The number of assessors requested for this assessment
  mapping(address => int) assessmentResults; //Pass/Fail and Score given by assessors
  mapping(int => bool) inRewardCluster; //A bool that reflects whether or not a score is within the largest cluster of scores
  mapping(address => string[]) data; //IFFS hashes of data that can be passed between the assessors and the assessee for the assessment to occur
  address[] potentialAssessors; //The addresses of those randomly selected to be assessors (but may not have confirmed yes)
  int finalScore; //The final score of the assessee
  uint referenceTime; //Time used as reference to determine how much time has passed for a certain portion of the assessment
  uint numberCancelled = 0; //The number of assessors who have refused to join the assessment
  uint doneAssessors = 0; //The number of assessors that are done assessing
  uint resultsSet = 0; //The number of assessors who have set their score for the assessee
  uint assessmentTime; //The amount of time allotted for the assessors to judge the assessee and determine their score

  /*
  @type: modifier
  @name: onlyTag
  @purpose: to only allow the Tag contract that spawned this assessment to call a function to which this modifier is applied
  */
  modifier onlyTag()
  {
    if(msg.sender != tag) //checks if msg.sender is the tag that spawned this assessment
    {
      throw; //throws the function call if not
    }
    _;
  }

  /*
  @type: modifier
  @name: onlyThis
  @purpose: to only allow the this contract to call a function to which this modifier is applied
  */
  modifier onlyThis()
  {
    if(msg.sender != address(this)) //Checks if msg.sender is this contract
    {
      throw; //Throws out the function call if it isn't
    }
    _;
  }

  /*
  @type: modifier
  @name: onlyAssessorAssessee
  @purpose: to only allow the assessors and assessee to call a function to which this modifier is applied
  */
  modifier onlyAssessorAssessee()
  {
    if(msg.sender != assessee && assessors[msg.sender] == 0) //Checks if msg.sender has the same address as either the assessee or an assessor
    {
      throw; //Throws the function call if not
    }
    _;
  }

  /*
  @type: modifier
  @name: onlyTagAssessment
  @purpose: to only allow the this contract or the Tag contract that spawned it to call a function to which this modifier is applied
  */
  modifier onlyTagAssessment()
  {
    if(msg.sender != address(this) && msg.sender != tag) //Checks if msg.sender has the same address as this contract or the Tag that spawned it
    {
      throw; //Throws the function call if not
    }
    _;
  }

  function Assessment(address assesseeAddress, address tagAddress, address userMasterAddress, address tagMasterAddress, address randomAddress, uint time)
  {
    assessee = assesseeAddress;
    tag = tagAddress;
    userMaster = userMasterAddress;
    tagMaster = tagMasterAddress;
    random = randomAddress;
    referenceTime = block.timestamp;
    assessmentTime = time;
    User(assessee).notification("Assessment made", tag, 0);
  }

  event PotentialAssessorSet(address _potentialAssessor);
  event DataSet(address _dataSetter, uint _index);

  function setNumberOfAssessors(uint number) onlyTag()
  {
    numberOfAssessors = number;
  }

  function getNumberOfAssessors() onlyTag() constant returns(uint)
  {
    return numberOfAssessors;
  }

  function setAssessmentPoolSize(uint sizeRemaining) onlyTag()
  {
    if(poolSizeRemaining > 0)
    {
      poolSizeRemaining = sizeRemaining;
    }
  }

  function getAssessmentPoolSize() onlyTag() constant returns(uint)
  {
    return poolSizeRemaining;
  }

  function addToAssessorPool(address potentialAddress) onlyTag()
  {
    assessorPool.push(potentialAddress);
  }

  function setPotentialAssessor(uint needed)
  {
    if(assessorPool.length - calledAssessors < needed)
    {
      cancelAssessment();
    }
    else if(msg.sender == address(this) || msg.sender == tag)
    {
      bool potentialAssessorSet = false;
      numberCancelled = 0;
      uint randomNumber = Random(random).getRandom(assessorPool.length, assessorPool.length);
      for(uint i = 0; i < needed; i++)
      {
        while(potentialAssessorSet == false)
        {
          address randomAssessor = assessorPool[randomNumber];
          if(assessors[randomAssessor] == 0)
          {
            assessors[randomAssessor] = 3;
            potentialAssessors.push(randomAssessor);
            calledAssessors++;
            User(randomAssessor).notification("Called As A Potential Assessor",tag, 1);
            randomNumber = Random(random).getRandom(assessorPool.length, randomNumber);
            PotentialAssessorSet(randomAssessor);
            potentialAssessorSet = true;
          }
        }
        potentialAssessorSet = false;
      }
      referenceTime = now;
    }
  }

  function getAssessorPoolLength() onlyTag() constant returns(uint)
  {
    return assessorPool.length;
  }

  function confirmAssessor(uint confirm)
  {
    if(assessors[msg.sender] != 0 && now - referenceTime <= 300)
    {
      assessors[msg.sender] = confirm;
      if(confirm == 1)
      {
        User(msg.sender).notification("Confirmed As Assessing", tag, 2);
        finalAssessors.push(msg.sender);
        referenceTime = now;
      }
      if(confirm == 2)
      {
        User(msg.sender).notification("Confirmed As Not Assessing", tag, 3);
        numberCancelled ++;
      }
    }
    if(now - referenceTime > 300)
    {
      for(uint i = 0; i < potentialAssessors.length; i++)
      {
        if(assessors[potentialAssessors[i]] == 3)
        {
          User(potentialAssessors[i]).notification("Did Not Respond In Time To Be Assessor", tag, 4);
          assessors[potentialAssessors[i]] = 4;
          numberCancelled++;
        }
      }
      setPotentialAssessor(numberCancelled);
    }
    if(numberCancelled == 0)
    {
      notifyStart();
    }
  }

  function notifyStart() onlyThis()
  {
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      User(finalAssessors[i]).notification("Assessment Has Started", tag, 17);
    }
    User(assessee).notification("Assessment Has Started", tag, 17);
    referenceTime = now;
  }

  function setData(string newData) onlyAssessorAssessee()
  {
    data[msg.sender].push(newData);
    DataSet(msg.sender, data[msg.sender].length - 1);
  }

  function getData(address dataSetter, uint index) constant returns(string)
  {
    return data[dataSetter][index];
  }

  function cancelAssessment() onlyTagAssessment()
  {
    User(assessee).notification("Assessment Cancled", tag, 8);
    Tag(tag).pay(assessee, UserMaster(userMaster).getTokenBalance(assessee) + int(assessmentTime*numberOfAssessors));
    User(assessee).notification("You have been refunded for your assessment", tag, 20);
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      User(finalAssessors[i]).notification("Assessment Cancled", tag, 8);
    }
    suicide(tagMaster);
  }

  function doneAssessing()
  {
    if(assessors[msg.sender] == 1)
    {
      assessors[msg.sender] = 5;
      doneAssessors++;
    }
    if(referenceTime - now > assessmentTime && doneAssessors != finalAssessors.length)
    {
      for(uint i = 0; i < finalAssessors.length; i++)
      {
        if(assessors[finalAssessors[i]] == 1)
        {
          assessors[finalAssessors[i]] = 5;
          doneAssessors++;
        }
      }
    }
    if(doneAssessors == finalAssessors.length)
    {
      for(uint n = 0; n < finalAssessors.length; n++)
      {
        User(finalAssessors[n]).notification("Send in Score", tag, 18);
      }
      referenceTime = block.number; //use referenceTime to refer to the block number instead of timestamp
    }
  }

  function setResult(int score)
  {
    if(doneAssessors == finalAssessors.length && assessors[msg.sender] == 5 && block.number - referenceTime == 5)
    {
      assessmentResults[msg.sender] = score;
      assessors[msg.sender] = 6;
      resultsSet++;
    }
    if(resultsSet < finalAssessors.length && block.number - referenceTime > 5)
    {
      for(uint i = 0; i < finalAssessors.length; i++)
      {
        if(assessors[finalAssessors[i]] == 5)
        {
          assessmentResults[finalAssessors[i]] = 0;
          assessors[finalAssessors[i]] = 6;
          resultsSet++;
        }
      }
    }
    if(resultsSet == finalAssessors.length)
    {
      calculateResult();
    }
  }

  function calculateMAD(int[] scores, int n) onlyThis() constant returns(int)
  {
    int meanScore;
    int totalRelativeDistance;
    int meanAbsoluteDeviation;
    for(uint j = 0; j < scores.length; j++)
    {
      meanScore += scores[j];
      inRewardCluster[scores[j]] = false;
    }
    meanScore /= n;
    for(uint k = 0; k < scores.length; k++)
    {
      int distanceFromMean = scores[k] - meanScore;
      if(distanceFromMean < 0)
      {
        distanceFromMean *= -1;
      }
      totalRelativeDistance += distanceFromMean;
    }
    meanAbsoluteDeviation = totalRelativeDistance/n;
    return meanAbsoluteDeviation;
  }

  function calculateResult() onlyThis()
  {
    mapping(uint => int[]) clusters;
    int[] memory scores = new int[] (finalAssessors.length);
    uint largestClusterIndex = 0;
    int averageScore;
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      scores[i] = assessmentResults[finalAssessors[i]];
    }
    int meanAbsoluteDeviation = calculateMAD(scores,int(numberOfAssessors));
    for(uint l = 0; l < scores.length; l++)
    {
      for(uint m = 0; m < scores.length; m++)
      {
        if(scores[l] - scores[m] <= meanAbsoluteDeviation)
        {
          clusters[l].push(scores[m]);
        }
      }
      if(clusters[l].length > clusters[largestClusterIndex].length)
      {
        largestClusterIndex = l;
      }
    }
    for(uint o = 0; o < clusters[largestClusterIndex].length; o++)
    {
      averageScore += clusters[largestClusterIndex][o];
      inRewardCluster[clusters[largestClusterIndex][o]] = true;
    }
    averageScore /= int(clusters[largestClusterIndex].length);
    finalScore = averageScore;
    payout(clusters[largestClusterIndex].length);
  }

  function payout(uint largestSize) onlyThis()
  {
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      int score = assessmentResults[finalAssessors[i]];
      int scoreDistance = ((score - finalScore)*100)/finalScore;
      if(scoreDistance < 0)
      {
        scoreDistance *= -1;
      }
      int payoutValue = (int(assessmentTime*finalAssessors.length)/(100 - scoreDistance)) * int(finalAssessors.length/largestSize);
      if(inRewardCluster[score] == true)
      {
        Tag(tag).pay(finalAssessors[i], UserMaster(userMaster).getTokenBalance(finalAssessors[i]) + payoutValue);
        User(finalAssessors[i]).notification("You Have Received Payment For Your Assessment", tag, 15);
      }
      if(inRewardCluster[score] == false)
      {
        Tag(tag).pay(finalAssessors[i], UserMaster(userMaster).getTokenBalance(finalAssessors[i]) - payoutValue);
        User(finalAssessors[i]).notification("You Have Received A Fine For Your Assessment", tag, 16);
      }
    }
    returnResults();
  }

  function returnResults() onlyThis()
  {
    Tag(tag).finishAssessment(finalScore, assessee, address(this));
  }
}

import "lib/random.sol";
import "userMaster.sol";
import "tag.sol";
import "user.sol";
import "tagMaster.sol";

/*
@type: contract
@name: Assessment
@purpose: To facilitate the assessment process
*/
contract Assessment
{
  address assessee; //The address of the user being assessed
  address[] assessorPool; //The addresses of the user's that the assessors are randomly selected from
  mapping (address => uint) assessors; //A mapping of the assessors to their current status
  uint calledAssessors = 0; //The number of assessors that have been called to assess
  address[] finalAssessors; //The addresses of the final set of assessors who have completed the assessment process
  address tag; //The address of the tag that is being assessed
  address userMaster; //The address of the UserMaster
  address tagMaster; //The address of the TagMaster
  address random; //The address of the Random contract
  uint poolSizeRemaining; //The remaining number of users to be added to the assessor pool
  uint numberOfAssessors; //The number of assessors requested for this assessment
  mapping(address => int) assessmentResults; //Pass/Fail and Score given by assessors
  mapping(int => bool) inRewardCluster; //A bool that reflects whether or not a score is within the largest cluster of scores
  mapping(address => string[]) data; //IFFS hashes of data that can be passed between the assessors and the assessee for the assessment to occur
  address[] potentialAssessors; //The addresses of those randomly selected to be assessors (but may not have confirmed yes)
  int finalScore; //The final score of the assessee
  uint referenceTime; //Time used as reference to determine how much time has passed for a certain portion of the assessment
  uint referenceBlock; //Block used as reference to determine how many blocks have passed for a certain portion of the assessment
  uint numberCancelled = 0; //The number of assessors who have refused to join the assessment
  uint doneAssessors = 0; //The number of assessors that are done assessing
  uint resultsSet = 0; //The number of assessors who have set their score for the assessee
  uint assessmentTime; //The amount of time allotted for the assessors to judge the assessee and determine their score

  /*
  @type: modifier
  @name: onlyTag
  @purpose: to only allow the Tag contract that spawned this assessment to call a function to which this modifier is applied
  */
  modifier onlyTag()
  {
    if(msg.sender != tag) //checks if msg.sender is the tag that spawned this assessment
    {
      throw; //throws the function call if not
    }
    _;
  }

  /*
  @type: modifier
  @name: onlyThis
  @purpose: to only allow the this contract to call a function to which this modifier is applied
  */
  modifier onlyThis()
  {
    if(msg.sender != address(this)) //Checks if msg.sender is this contract
    {
      throw; //Throws out the function call if it isn't
    }
    _;
  }

  /*
  @type: modifier
  @name: onlyAssessorAssessee
  @purpose: to only allow the assessors and assessee to call a function to which this modifier is applied
  */
  modifier onlyAssessorAssessee()
  {
    if(msg.sender != assessee && assessors[msg.sender] == 0) //Checks if msg.sender has the same address as either the assessee or an assessor
    {
      throw; //Throws the function call if not
    }
    _;
  }

  /*
  @type: modifier
  @name: onlyTagAssessment
  @purpose: to only allow the this contract or the Tag contract that spawned it to call a function to which this modifier is applied
  */
  modifier onlyTagAssessment()
  {
    if(msg.sender != address(this) && msg.sender != tag) //Checks if msg.sender has the same address as this contract or the Tag that spawned it
    {
      throw; //Throws the function call if not
    }
    _;
  }

  function Assessment(address assesseeAddress, address tagAddress, address userMasterAddress, address tagMasterAddress, address randomAddress, uint time)
  {
    assessee = assesseeAddress;
    tag = tagAddress;
    userMaster = userMasterAddress;
    tagMaster = tagMasterAddress;
    random = randomAddress;
    referenceTime = block.timestamp;
    referenceBlock = block.number;
    assessmentTime = time;
    User(assessee).notification("Assessment made", tag, 0);
  }

  event PotentialAssessorSet(address _potentialAssessor);
  event DataSet(address _dataSetter, uint _index);

  function getReferenceBlock() onlyTag() returns(uint)
  {
    return referenceBlock;
  }
  function setNumberOfAssessors(uint number) onlyTag()
  {
    numberOfAssessors = number;
  }

  function getNumberOfAssessors() onlyTag() constant returns(uint)
  {
    return numberOfAssessors;
  }

  function setAssessmentPoolSize(uint sizeRemaining) onlyTag()
  {
    if(poolSizeRemaining > 0)
    {
      poolSizeRemaining = sizeRemaining;
    }
  }

  function getAssessmentPoolSize() onlyTag() constant returns(uint)
  {
    return poolSizeRemaining;
  }

  function addToAssessorPool(address potentialAddress) onlyTag()
  {
    assessorPool.push(potentialAddress);
  }

  function setPotentialAssessor(uint needed)
  {
    if(assessorPool.length - calledAssessors < needed)
    {
      cancelAssessment();
    }
    else if(msg.sender == address(this) || msg.sender == tag)
    {
      bool potentialAssessorSet = false;
      numberCancelled = 0;
      uint randomNumber = Random(random).getRandom(assessorPool.length, assessorPool.length);
      for(uint i = 0; i < needed; i++)
      {
        while(potentialAssessorSet == false)
        {
          address randomAssessor = assessorPool[randomNumber];
          if(assessors[randomAssessor] == 0)
          {
            assessors[randomAssessor] = 3;
            potentialAssessors.push(randomAssessor);
            calledAssessors++;
            User(randomAssessor).notification("Called As A Potential Assessor",tag, 1);
            randomNumber = Random(random).getRandom(assessorPool.length, randomNumber);
            PotentialAssessorSet(randomAssessor);
            potentialAssessorSet = true;
          }
        }
        potentialAssessorSet = false;
      }
      referenceTime = now;
    }
  }

  function getAssessorPoolLength() onlyTag() constant returns(uint)
  {
    return assessorPool.length;
  }

  function confirmAssessor(uint confirm)
  {
    if(assessors[msg.sender] != 0 && now - referenceTime <= 300)
    {
      assessors[msg.sender] = confirm;
      if(confirm == 1)
      {
        User(msg.sender).notification("Confirmed As Assessing", tag, 2);
        finalAssessors.push(msg.sender);
        referenceTime = now;
      }
      if(confirm == 2)
      {
        User(msg.sender).notification("Confirmed As Not Assessing", tag, 3);
        numberCancelled ++;
      }
    }
    if(now - referenceTime > 300)
    {
      for(uint i = 0; i < potentialAssessors.length; i++)
      {
        if(assessors[potentialAssessors[i]] == 3)
        {
          User(potentialAssessors[i]).notification("Did Not Respond In Time To Be Assessor", tag, 4);
          assessors[potentialAssessors[i]] = 4;
          numberCancelled++;
        }
      }
      setPotentialAssessor(numberCancelled);
    }
    if(numberCancelled == 0)
    {
      notifyStart();
    }
  }

  function notifyStart() onlyThis()
  {
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      User(finalAssessors[i]).notification("Assessment Has Started", tag, 17);
    }
    User(assessee).notification("Assessment Has Started", tag, 17);
    referenceTime = now;
  }

  function setData(string newData) onlyAssessorAssessee()
  {
    data[msg.sender].push(newData);
    DataSet(msg.sender, data[msg.sender].length - 1);
  }

  function getData(address dataSetter, uint index) constant returns(string)
  {
    return data[dataSetter][index];
  }

  function cancelAssessment() onlyTagAssessment()
  {
    User(assessee).notification("Assessment Cancled", tag, 8);
    Tag(tag).pay(assessee, UserMaster(userMaster).getTokenBalance(assessee) + int(assessmentTime*numberOfAssessors));
    User(assessee).notification("You have been refunded for your assessment", tag, 20);
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      User(finalAssessors[i]).notification("Assessment Cancled", tag, 8);
    }
    suicide(tagMaster);
  }

  function doneAssessing()
  {
    if(assessors[msg.sender] == 1)
    {
      assessors[msg.sender] = 5;
      doneAssessors++;
    }
    if(referenceTime - now > assessmentTime && doneAssessors != finalAssessors.length)
    {
      for(uint i = 0; i < finalAssessors.length; i++)
      {
        if(assessors[finalAssessors[i]] == 1)
        {
          assessors[finalAssessors[i]] = 5;
          doneAssessors++;
        }
      }
    }
    if(doneAssessors == finalAssessors.length)
    {
      for(uint n = 0; n < finalAssessors.length; n++)
      {
        User(finalAssessors[n]).notification("Send in Score", tag, 18);
      }
      referenceTime = block.number; //use referenceTime to refer to the block number instead of timestamp
    }
  }

  function setResult(int score)
  {
    if(doneAssessors == finalAssessors.length && assessors[msg.sender] == 5 && block.number - referenceTime == 5)
    {
      assessmentResults[msg.sender] = score;
      assessors[msg.sender] = 6;
      resultsSet++;
    }
    if(resultsSet < finalAssessors.length && block.number - referenceTime > 5)
    {
      for(uint i = 0; i < finalAssessors.length; i++)
      {
        if(assessors[finalAssessors[i]] == 5)
        {
          assessmentResults[finalAssessors[i]] = 0;
          assessors[finalAssessors[i]] = 6;
          resultsSet++;
        }
      }
    }
    if(resultsSet == finalAssessors.length)
    {
      calculateResult();
    }
  }

  function calculateMAD(int[] scores, int n) onlyThis() constant returns(int)
  {
    int meanScore;
    int totalRelativeDistance;
    int meanAbsoluteDeviation;
    for(uint j = 0; j < scores.length; j++)
    {
      meanScore += scores[j];
      inRewardCluster[scores[j]] = false;
    }
    meanScore /= n;
    for(uint k = 0; k < scores.length; k++)
    {
      int distanceFromMean = scores[k] - meanScore;
      if(distanceFromMean < 0)
      {
        distanceFromMean *= -1;
      }
      totalRelativeDistance += distanceFromMean;
    }
    meanAbsoluteDeviation = totalRelativeDistance/n;
    return meanAbsoluteDeviation;
  }

  function calculateResult() onlyThis()
  {
    mapping(uint => int[]) clusters;
    int[] memory scores = new int[] (finalAssessors.length);
    uint largestClusterIndex = 0;
    int averageScore;
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      scores[i] = assessmentResults[finalAssessors[i]];
    }
    int meanAbsoluteDeviation = calculateMAD(scores,int(numberOfAssessors));
    for(uint l = 0; l < scores.length; l++)
    {
      for(uint m = 0; m < scores.length; m++)
      {
        if(scores[l] - scores[m] <= meanAbsoluteDeviation)
        {
          clusters[l].push(scores[m]);
        }
      }
      if(clusters[l].length > clusters[largestClusterIndex].length)
      {
        largestClusterIndex = l;
      }
    }
    for(uint o = 0; o < clusters[largestClusterIndex].length; o++)
    {
      averageScore += clusters[largestClusterIndex][o];
      inRewardCluster[clusters[largestClusterIndex][o]] = true;
    }
    averageScore /= int(clusters[largestClusterIndex].length);
    finalScore = averageScore;
    payout(clusters[largestClusterIndex].length);
  }

  function payout(uint largestSize) onlyThis()
  {
    for(uint i = 0; i < finalAssessors.length; i++)
    {
      int score = assessmentResults[finalAssessors[i]];
      int scoreDistance = ((score - finalScore)*100)/finalScore;
      if(scoreDistance < 0)
      {
        scoreDistance *= -1;
      }
      int payoutValue = (int(assessmentTime*finalAssessors.length)/(100 - scoreDistance)) * int(finalAssessors.length/largestSize);
      if(inRewardCluster[score] == true)
      {
        Tag(tag).pay(finalAssessors[i], UserMaster(userMaster).getTokenBalance(finalAssessors[i]) + payoutValue);
        User(finalAssessors[i]).notification("You Have Received Payment For Your Assessment", tag, 15);
      }
      if(inRewardCluster[score] == false)
      {
        Tag(tag).pay(finalAssessors[i], UserMaster(userMaster).getTokenBalance(finalAssessors[i]) - payoutValue);
        User(finalAssessors[i]).notification("You Have Received A Fine For Your Assessment", tag, 16);
      }
    }
    returnResults();
  }

  function returnResults() onlyThis()
  {
    Tag(tag).finishAssessment(finalScore, assessee, address(this));
  }
}