Contract 0x7De39e18D6878F17c94B9c7F8C9EC451438ab710

 
Txn Hash
Block
From
To
Value
0x2675cd86bc9cb3662c6f49418d2333b274a07a7b0eb3c07c924d0d6adcc5e06545255442017-11-10 10:19:111210 days 11 hrs agoLoopring: Deployer 1 IN  Contract Creation0 Ether0.0262846510
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LoopringProtocolImpl

Compiler Version
v0.4.18+commit.9cf6e910

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2017-11-10
*/

/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.18;
/// @title Ownable
/// @dev The Ownable contract has an owner address, and provides basic
///      authorization control functions, this simplifies the implementation of
///      "user permissions".
contract Ownable {
    address public owner;
    /// @dev The Ownable constructor sets the original `owner` of the contract
    ///      to the sender.
    function Ownable() public {
        owner = msg.sender;
    }
    /// @dev Throws if called by any account other than the owner.
    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }
    /// @dev Allows the current owner to transfer control of the contract to a
    ///      newOwner.
    /// @param newOwner The address to transfer ownership to.
    function transferOwnership(address newOwner) onlyOwner public {
        if (newOwner != address(0)) {
            owner = newOwner;
        }
    }
}/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/// @title UintUtil
/// @author Daniel Wang - <[email protected]>
/// @dev uint utility functions
library MathUint {
    function mul(uint a, uint b) internal pure returns (uint c) {
        c = a * b;
        require(a == 0 || c / a == b);
    }
    function sub(uint a, uint b) internal pure returns (uint) {
        require(b <= a);
        return a - b;
    }
    function add(uint a, uint b) internal pure returns (uint c) {
        c = a + b;
        require(c >= a);
    }
    function tolerantSub(uint a, uint b) internal pure returns (uint c) {
        return (a >= b) ? a - b : 0;
    }
    /// @dev calculate the square of Coefficient of Variation (CV)
    /// https://en.wikipedia.org/wiki/Coefficient_of_variation
    function cvsquare(
        uint[] arr,
        uint scale
        )
        internal
        pure
        returns (uint)
    {
        uint len = arr.length;
        require(len > 1);
        require(scale > 0);
        uint avg = 0;
        for (uint i = 0; i < len; i++) {
            avg += arr[i];
        }
        avg = avg / len;
        if (avg == 0) {
            return 0;
        }
        uint cvs = 0;
        uint s = 0;
        for (i = 0; i < len; i++) {
            s = arr[i] > avg ? arr[i] - avg : avg - arr[i];
            cvs += mul(s, s);
        }
        return (mul(mul(cvs, scale) / avg, scale) / avg) / (len - 1);
    }
}
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/// @title ERC20 interface
/// @dev see https://github.com/ethereum/EIPs/issues/20
contract ERC20 {
    uint public totalSupply;
	
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    function balanceOf(address who) view public returns (uint256);
    function allowance(address owner, address spender) view public returns (uint256);
    function transfer(address to, uint256 value) public returns (bool);
    function transferFrom(address from, address to, uint256 value) public returns (bool);
    function approve(address spender, uint256 value) public returns (bool);
}
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/// @title Loopring Token Exchange Protocol Contract Interface
/// @author Daniel Wang - <[email protected]>
/// @author Kongliang Zhong - <[email protected]>
contract LoopringProtocol {
    ////////////////////////////////////////////////////////////////////////////
    /// Constants                                                            ///
    ////////////////////////////////////////////////////////////////////////////
    uint    public constant FEE_SELECT_LRC               = 0;
    uint    public constant FEE_SELECT_MARGIN_SPLIT      = 1;
    uint    public constant FEE_SELECT_MAX_VALUE         = 1;
    uint8   public constant MARGIN_SPLIT_PERCENTAGE_BASE = 100;
    ////////////////////////////////////////////////////////////////////////////
    /// Structs                                                              ///
    ////////////////////////////////////////////////////////////////////////////
    /// @param tokenS       Token to sell.
    /// @param tokenB       Token to buy.
    /// @param amountS      Maximum amount of tokenS to sell.
    /// @param amountB      Minimum amount of tokenB to buy if all amountS sold.
    /// @param timestamp    Indicating when this order is created/signed.
    /// @param ttl          Indicating after how many seconds from `timestamp`
    ///                     this order will expire.
    /// @param salt         A random number to make this order's hash unique.
    /// @param lrcFee       Max amount of LRC to pay for miner. The real amount
    ///                     to pay is proportional to fill amount.
    /// @param buyNoMoreThanAmountB -
    ///                     If true, this order does not accept buying more
    ///                     than `amountB`.
    /// @param marginSplitPercentage -
    ///                     The percentage of margin paid to miner.
    /// @param v            ECDSA signature parameter v.
    /// @param r            ECDSA signature parameters r.
    /// @param s            ECDSA signature parameters s.
    struct Order {
        address owner;
        address tokenS;
        address tokenB;
        uint    amountS;
        uint    amountB;
        uint    lrcFee;
        bool    buyNoMoreThanAmountB;
        uint8   marginSplitPercentage;
    }
    ////////////////////////////////////////////////////////////////////////////
    /// Public Functions                                                     ///
    ////////////////////////////////////////////////////////////////////////////
    /// @dev Submit a order-ring for validation and settlement.
    /// @param addressList  List of each order's owner and tokenS. Note that next
    ///                     order's `tokenS` equals this order's `tokenB`.
    /// @param uintArgsList List of uint-type arguments in this order:
    ///                     amountS, amountB, timestamp, ttl, salt, lrcFee,
    ///                     rateAmountS.
    /// @param uint8ArgsList -
    ///                     List of unit8-type arguments, in this order:
    ///                     marginSplitPercentageList, feeSelectionList.
    /// @param buyNoMoreThanAmountBList -
    ///                     This indicates when a order should be considered
    ///                     as 'completely filled'.
    /// @param vList        List of v for each order. This list is 1-larger than
    ///                     the previous lists, with the last element being the
    ///                     v value of the ring signature.
    /// @param rList        List of r for each order. This list is 1-larger than
    ///                     the previous lists, with the last element being the
    ///                     r value of the ring signature.
    /// @param sList        List of s for each order. This list is 1-larger than
    ///                     the previous lists, with the last element being the
    ///                     s value of the ring signature.
    /// @param ringminer    The address that signed this tx.
    /// @param feeRecepient The recepient address for fee collection. If this is
    ///                     '0x0', all fees will be paid to the address who had
    ///                     signed this transaction, not `msg.sender`. Noted if
    ///                     LRC need to be paid back to order owner as the result
    ///                     of fee selection model, LRC will also be sent from
    ///                     this address.
    function submitRing(
        address[2][]    addressList,
        uint[7][]       uintArgsList,
        uint8[2][]      uint8ArgsList,
        bool[]          buyNoMoreThanAmountBList,
        uint8[]         vList,
        bytes32[]       rList,
        bytes32[]       sList,
        address         ringminer,
        address         feeRecepient
        ) public;
    /// @dev Cancel a order. cancel amount(amountS or amountB) can be specified
    ///      in orderValues.
    /// @param addresses          owner, tokenS, tokenB
    /// @param orderValues        amountS, amountB, timestamp, ttl, salt, lrcFee,
    ///                           cancelAmountS, and cancelAmountB.
    /// @param buyNoMoreThanAmountB -
    ///                           This indicates when a order should be considered
    ///                           as 'completely filled'.
    /// @param marginSplitPercentage -
    ///                           Percentage of margin split to share with miner.
    /// @param v                  Order ECDSA signature parameter v.
    /// @param r                  Order ECDSA signature parameters r.
    /// @param s                  Order ECDSA signature parameters s.
    function cancelOrder(
        address[3] addresses,
        uint[7]    orderValues,
        bool       buyNoMoreThanAmountB,
        uint8      marginSplitPercentage,
        uint8      v,
        bytes32    r,
        bytes32    s
        ) public;
    /// @dev   Set a cutoff timestamp to invalidate all orders whose timestamp
    ///        is smaller than or equal to the new value of the address's cutoff
    ///        timestamp.
    /// @param cutoff The cutoff timestamp, will default to `block.timestamp`
    ///        if it is 0.
    function setCutoff(uint cutoff) public;
}
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/// @title Token Register Contract
/// @author Kongliang Zhong - <[email protected]>,
/// @author Daniel Wang - <[email protected]>.
library MathBytes32 {
    function xorReduce(
        bytes32[]   arr,
        uint        len
        )
        internal
        pure
        returns (bytes32 res)
    {
        res = arr[0];
        for (uint i = 1; i < len; i++) {
            res ^= arr[i];
        }
    }
}
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/// @title Token Register Contract
/// @author Kongliang Zhong - <[email protected]>,
/// @author Daniel Wang - <[email protected]>.
library MathUint8 {
    function xorReduce(
        uint8[] arr,
        uint    len
        )
        internal
        pure
        returns (uint8 res)
    {
        res = arr[0];
        for (uint i = 1; i < len; i++) {
            res ^= arr[i];
        }
    }
}
/// @title Ring Hash Registry Contract
/// @author Kongliang Zhong - <[email protected]>,
/// @author Daniel Wang - <[email protected]>.
contract RinghashRegistry {
    using MathBytes32   for bytes32[];
    using MathUint8     for uint8[];
    uint public blocksToLive;
    struct Submission {
        address ringminer;
        uint block;
    }
    mapping (bytes32 => Submission) submissions;
    ////////////////////////////////////////////////////////////////////////////
    /// Events                                                               ///
    ////////////////////////////////////////////////////////////////////////////
    event RinghashSubmitted(
        address indexed _ringminer,
        bytes32 indexed _ringhash
    );
    ////////////////////////////////////////////////////////////////////////////
    /// Constructor                                                          ///
    ////////////////////////////////////////////////////////////////////////////
    function RinghashRegistry(uint _blocksToLive)
        public
    {
        require(_blocksToLive > 0);
        blocksToLive = _blocksToLive;
    }
    ////////////////////////////////////////////////////////////////////////////
    /// Public Functions                                                     ///
    ////////////////////////////////////////////////////////////////////////////
    function submitRinghash(
        address     ringminer,
        bytes32     ringhash
        )
        public
    {
        require(canSubmit(ringhash, ringminer)); //, "Ringhash submitted");
        submissions[ringhash] = Submission(ringminer, block.number);
        RinghashSubmitted(ringminer, ringhash);
    }
    function batchSubmitRinghash(
        address[]     ringminerList,
        bytes32[]     ringhashList
        )
        public
    {
        uint size = ringminerList.length;
        require(size > 0);
        require(size == ringhashList.length);
        for (uint i = 0; i < size; i++) {
            submitRinghash(ringminerList[i], ringhashList[i]);
        }
    }
    /// @dev Calculate the hash of a ring.
    function calculateRinghash(
        uint        ringSize,
        uint8[]     vList,
        bytes32[]   rList,
        bytes32[]   sList
        )
        public
        pure
        returns (bytes32)
    {
        require(
            ringSize == vList.length - 1 && (
            ringSize == rList.length - 1 && (
            ringSize == sList.length - 1))
        ); //, "invalid ring data");
        return keccak256(
            vList.xorReduce(ringSize),
            rList.xorReduce(ringSize),
            sList.xorReduce(ringSize)
        );
    }
     /// return value attributes[2] contains the following values in this order:
     /// canSubmit, isReserved.
    function computeAndGetRinghashInfo(
        uint        ringSize,
        address     ringminer,
        uint8[]     vList,
        bytes32[]   rList,
        bytes32[]   sList
        )
        external
        view
        returns (bytes32 ringhash, bool[2] attributes)
    {
        ringhash = calculateRinghash(
            ringSize,
            vList,
            rList,
            sList
        );
        attributes[0] = canSubmit(ringhash, ringminer);
        attributes[1] = isReserved(ringhash, ringminer);
    }
    /// @return true if a ring's hash can be submitted;
    /// false otherwise.
    function canSubmit(
        bytes32 ringhash,
        address ringminer)
        public
        view
        returns (bool)
    {
        var submission = submissions[ringhash];
        return (
            submission.ringminer == address(0) || (
            submission.block + blocksToLive < block.number) || (
            submission.ringminer == ringminer)
        );
    }
    /// @return true if a ring's hash was submitted and still valid;
    /// false otherwise.
    function isReserved(
        bytes32 ringhash,
        address ringminer)
        public
        view
        returns (bool)
    {
        var submission = submissions[ringhash];
        return (
            submission.block + blocksToLive >= block.number && (
            submission.ringminer == ringminer)
        );
    }
}
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/// @title Token Register Contract
/// @author Kongliang Zhong - <[email protected]>,
/// @author Daniel Wang - <[email protected]>.
contract TokenRegistry is Ownable {
    address[] public tokens;
    mapping (address => bool) tokenMap;
    mapping (string => address) tokenSymbolMap;
    function registerToken(address _token, string _symbol)
        external
        onlyOwner
    {
        require(_token != address(0));
        require(!isTokenRegisteredBySymbol(_symbol));
        require(!isTokenRegistered(_token));
        tokens.push(_token);
        tokenMap[_token] = true;
        tokenSymbolMap[_symbol] = _token;
    }
    function unregisterToken(address _token, string _symbol)
        external
        onlyOwner
    {
        require(_token != address(0));
        require(tokenSymbolMap[_symbol] == _token);
        delete tokenSymbolMap[_symbol];
        delete tokenMap[_token];
        for (uint i = 0; i < tokens.length; i++) {
            if (tokens[i] == _token) {
                tokens[i] = tokens[tokens.length - 1];
                tokens.length --;
                break;
            }
        }
    }
    function isTokenRegisteredBySymbol(string symbol)
        public
        view
        returns (bool)
    {
        return tokenSymbolMap[symbol] != address(0);
    }
    function isTokenRegistered(address _token)
        public
        view
        returns (bool)
    {
        return tokenMap[_token];
    }
    function areAllTokensRegistered(address[] tokenList)
        public
        view
        returns (bool)
    {
        for (uint i = 0; i < tokenList.length; i++) {
            if (!tokenMap[tokenList[i]]) {
                return false;
            }
        }
        return true;
    }
    function getAddressBySymbol(string symbol)
        public
        constant
        returns (address)
    {
        return tokenSymbolMap[symbol];
    }
}
/*
  Copyright 2017 Loopring Project Ltd (Loopring Foundation).
  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.
*/
/// @title TokenTransferDelegate - Acts as a middle man to transfer ERC20 tokens
/// on behalf of different versions of Loopring protocol to avoid ERC20
/// re-authorization.
/// @author Daniel Wang - <[email protected]>.
contract TokenTransferDelegate is Ownable {
    using MathUint for uint;
    ////////////////////////////////////////////////////////////////////////////
    /// Variables                                                            ///
    ////////////////////////////////////////////////////////////////////////////
    mapping(address => AddressInfo) private addressInfos;
    address public latestAddress;
    ////////////////////////////////////////////////////////////////////////////
    /// Structs                                                              ///
    ////////////////////////////////////////////////////////////////////////////
    struct AddressInfo {
        address previous;
        uint32  index;
        bool    authorized;
    }
    ////////////////////////////////////////////////////////////////////////////
    /// Modifiers                                                            ///
    ////////////////////////////////////////////////////////////////////////////
    modifier onlyAuthorized() {
        if (isAddressAuthorized(msg.sender) == false) {
            revert();
        }
        _;
    }
    ////////////////////////////////////////////////////////////////////////////
    /// Events                                                               ///
    ////////////////////////////////////////////////////////////////////////////
    event AddressAuthorized(address indexed addr, uint32 number);
    event AddressDeauthorized(address indexed addr, uint32 number);
    ////////////////////////////////////////////////////////////////////////////
    /// Public Functions                                                     ///
    ////////////////////////////////////////////////////////////////////////////
    /// @dev Add a Loopring protocol address.
    /// @param addr A loopring protocol address.
    function authorizeAddress(address addr)
        onlyOwner
        external
    {
        AddressInfo storage addrInfo = addressInfos[addr];
        if (addrInfo.index != 0) { // existing
            if (addrInfo.authorized == false) { // re-authorize
                addrInfo.authorized = true;
                AddressAuthorized(addr, addrInfo.index);
            }
        } else {
            address prev = latestAddress;
            if (prev == address(0)) {
                addrInfo.index = 1;
                addrInfo.authorized = true;
            } else {
                addrInfo.previous = prev;
                addrInfo.index = addressInfos[prev].index + 1;
            }
            addrInfo.authorized = true;
            latestAddress = addr;
            AddressAuthorized(addr, addrInfo.index);
        }
    }
    /// @dev Remove a Loopring protocol address.
    /// @param addr A loopring protocol address.
    function deauthorizeAddress(address addr)
        onlyOwner
        external
    {
        uint32 index = addressInfos[addr].index;
        if (index != 0) {
            addressInfos[addr].authorized = false;
            AddressDeauthorized(addr, index);
        }
    }
    function isAddressAuthorized(address addr)
        public
        view
        returns (bool)
    {
        return addressInfos[addr].authorized;
    }
    function getLatestAuthorizedAddresses(uint max)
        external
        view
        returns (address[] addresses)
    {
        addresses = new address[](max);
        address addr = latestAddress;
        AddressInfo memory addrInfo;
        uint count = 0;
        while (addr != address(0) && max < count) {
            addrInfo = addressInfos[addr];
            if (addrInfo.index == 0) {
                break;
            }
            addresses[count++] = addr;
            addr = addrInfo.previous;
        }
    }
    /// @dev Invoke ERC20 transferFrom method.
    /// @param token Address of token to transfer.
    /// @param from Address to transfer token from.
    /// @param to Address to transfer token to.
    /// @param value Amount of token to transfer.
    function transferToken(
        address token,
        address from,
        address to,
        uint    value)
        onlyAuthorized
        external
    {
        if (value > 0 && from != to) {
            require(
                ERC20(token).transferFrom(from, to, value)
            );
        }
    }
    function batchTransferToken(
        uint ringSize, 
        address lrcTokenAddress,
        address feeRecipient,
        bytes32[] batch)
        onlyAuthorized
        external
    {
        require(batch.length == ringSize * 6);
        uint p = ringSize * 2;
        var lrc = ERC20(lrcTokenAddress);
        for (uint i = 0; i < ringSize; i++) {
            uint prev = ((i + ringSize - 1) % ringSize);
            address tokenS = address(batch[i]);
            address owner = address(batch[ringSize + i]);
            address prevOwner = address(batch[ringSize + prev]);
            
            // Pay tokenS to previous order, or to miner as previous order's
            // margin split or/and this order's margin split.
            ERC20 _tokenS;
            // Try to create ERC20 instances only once per token.
            if (owner != prevOwner || owner != feeRecipient && batch[p+1] != 0) {
                _tokenS = ERC20(tokenS);
            }
            // Here batch[p] has been checked not to be 0.
            if (owner != prevOwner) {
                require(
                    _tokenS.transferFrom(owner, prevOwner, uint(batch[p]))
                );
            }
            if (owner != feeRecipient) {
                if (batch[p+1] != 0) {
                    require(
                        _tokenS.transferFrom(owner, feeRecipient, uint(batch[p+1]))
                    );
                } 
                if (batch[p+2] != 0) {
                    require(
                        lrc.transferFrom(feeRecipient, owner, uint(batch[p+2]))
                    );
                }
                if (batch[p+3] != 0) {
                    require(
                        lrc.transferFrom(owner, feeRecipient, uint(batch[p+3]))
                    );
                }
            }
            p += 4;
        }
    }
}
/// @title Loopring Token Exchange Protocol Implementation Contract v1
/// @author Daniel Wang - <[email protected]>,
/// @author Kongliang Zhong - <[email protected]>
contract LoopringProtocolImpl is LoopringProtocol {
    using MathUint for uint;
    ////////////////////////////////////////////////////////////////////////////
    /// Variables                                                            ///
    ////////////////////////////////////////////////////////////////////////////
    address public  lrcTokenAddress             = address(0);
    address public  tokenRegistryAddress        = address(0);
    address public  ringhashRegistryAddress     = address(0);
    address public  delegateAddress             = address(0);
    uint    public  maxRingSize                 = 0;
    uint64  public  ringIndex                   = 0;
    // Exchange rate (rate) is the amount to sell or sold divided by the amount
    // to buy or bought.
    //
    // Rate ratio is the ratio between executed rate and an order's original
    // rate.
    //
    // To require all orders' rate ratios to have coefficient ofvariation (CV)
    // smaller than 2.5%, for an example , rateRatioCVSThreshold should be:
    //     `(0.025 * RATE_RATIO_SCALE)^2` or 62500.
    uint    public  rateRatioCVSThreshold       = 0;
    uint    public constant RATE_RATIO_SCALE    = 10000;
    uint64  public constant ENTERED_MASK        = 1 << 63;
    // The following map is used to keep trace of order fill and cancellation
    // history.
    mapping (bytes32 => uint) public cancelledOrFilled;
    // A map from address to its cutoff timestamp.
    mapping (address => uint) public cutoffs;
    ////////////////////////////////////////////////////////////////////////////
    /// Structs                                                              ///
    ////////////////////////////////////////////////////////////////////////////
    struct Rate {
        uint amountS;
        uint amountB;
    }
    /// @param order        The original order
    /// @param orderHash    The order's hash
    /// @param feeSelection -
    ///                     A miner-supplied value indicating if LRC (value = 0)
    ///                     or margin split is choosen by the miner (value = 1).
    ///                     We may support more fee model in the future.
    /// @param rate         Exchange rate provided by miner.
    /// @param availableAmountS -
    ///                     The actual spendable amountS.
    /// @param fillAmountS  Amount of tokenS to sell, calculated by protocol.
    /// @param lrcReward    The amount of LRC paid by miner to order owner in
    ///                     exchange for margin split.
    /// @param lrcFee       The amount of LR paid by order owner to miner.
    /// @param splitS      TokenS paid to miner.
    /// @param splitB      TokenB paid to miner.
    struct OrderState {
        Order   order;
        bytes32 orderHash;
        uint8   feeSelection;
        Rate    rate;
        uint    availableAmountS;
        uint    fillAmountS;
        uint    lrcReward;
        uint    lrcFee;
        uint    splitS;
        uint    splitB;
    }
    ////////////////////////////////////////////////////////////////////////////
    /// Events                                                               ///
    ////////////////////////////////////////////////////////////////////////////
    event RingMined(
        uint                _ringIndex,
        uint                _time,
        uint                _blocknumber,
        bytes32     indexed _ringhash,
        address     indexed _miner,
        address     indexed _feeRecipient,
        bool                _isRinghashReserved
    );
    event OrderFilled(
        uint                _ringIndex,
        uint                _time,
        uint                _blocknumber,
        bytes32     indexed _ringhash,
        bytes32             _prevOrderHash,
        bytes32     indexed _orderHash,
        bytes32              _nextOrderHash,
        uint                _amountS,
        uint                _amountB,
        uint                _lrcReward,
        uint                _lrcFee
    );
    event OrderCancelled(
        uint                _time,
        uint                _blocknumber,
        bytes32     indexed _orderHash,
        uint                _amountCancelled
    );
    event CutoffTimestampChanged(
        uint                _time,
        uint                _blocknumber,
        address     indexed _address,
        uint                _cutoff
    );
    ////////////////////////////////////////////////////////////////////////////
    /// Constructor                                                          ///
    ////////////////////////////////////////////////////////////////////////////
    function LoopringProtocolImpl(
        address _lrcTokenAddress,
        address _tokenRegistryAddress,
        address _ringhashRegistryAddress,
        address _delegateAddress,
        uint    _maxRingSize,
        uint    _rateRatioCVSThreshold
        )
        public
    {
        require(address(0) != _lrcTokenAddress);
        require(address(0) != _tokenRegistryAddress);
        require(address(0) != _ringhashRegistryAddress);
        require(address(0) != _delegateAddress);
        require(_maxRingSize > 1);
        require(_rateRatioCVSThreshold > 0);
        lrcTokenAddress = _lrcTokenAddress;
        tokenRegistryAddress = _tokenRegistryAddress;
        ringhashRegistryAddress = _ringhashRegistryAddress;
        delegateAddress = _delegateAddress;
        maxRingSize = _maxRingSize;
        rateRatioCVSThreshold = _rateRatioCVSThreshold;
    }
    ////////////////////////////////////////////////////////////////////////////
    /// Public Functions                                                     ///
    ////////////////////////////////////////////////////////////////////////////
    /// @dev Disable default function.
    function ()
        payable
        public
    {
        revert();
    }
    /// @dev Submit a order-ring for validation and settlement.
    /// @param addressList  List of each order's tokenS. Note that next order's
    ///                     `tokenS` equals this order's `tokenB`.
    /// @param uintArgsList List of uint-type arguments in this order:
    ///                     amountS, amountB, timestamp, ttl, salt, lrcFee,
    ///                     rateAmountS.
    /// @param uint8ArgsList -
    ///                     List of unit8-type arguments, in this order:
    ///                     marginSplitPercentageList,feeSelectionList.
    /// @param buyNoMoreThanAmountBList -
    ///                     This indicates when a order should be considered
    ///                     as 'completely filled'.
    /// @param vList        List of v for each order. This list is 1-larger than
    ///                     the previous lists, with the last element being the
    ///                     v value of the ring signature.
    /// @param rList        List of r for each order. This list is 1-larger than
    ///                     the previous lists, with the last element being the
    ///                     r value of the ring signature.
    /// @param sList        List of s for each order. This list is 1-larger than
    ///                     the previous lists, with the last element being the
    ///                     s value of the ring signature.
    /// @param ringminer    The address that signed this tx.
    /// @param feeRecipient The Recipient address for fee collection. If this is
    ///                     '0x0', all fees will be paid to the address who had
    ///                     signed this transaction, not `msg.sender`. Noted if
    ///                     LRC need to be paid back to order owner as the result
    ///                     of fee selection model, LRC will also be sent from
    ///                     this address.
    function submitRing(
        address[2][]  addressList,
        uint[7][]     uintArgsList,
        uint8[2][]    uint8ArgsList,
        bool[]        buyNoMoreThanAmountBList,
        uint8[]       vList,
        bytes32[]     rList,
        bytes32[]     sList,
        address       ringminer,
        address       feeRecipient
        )
        public
    {
        // Check if the highest bit of ringIndex is '1'.
        require(ringIndex & ENTERED_MASK != ENTERED_MASK); // "attempted to re-ent submitRing function");
        // Set the highest bit of ringIndex to '1'.
        ringIndex |= ENTERED_MASK;
        //Check ring size
        uint ringSize = addressList.length;
        require(ringSize > 1 && ringSize <= maxRingSize); // "invalid ring size");
        verifyInputDataIntegrity(
            ringSize,
            addressList,
            uintArgsList,
            uint8ArgsList,
            buyNoMoreThanAmountBList,
            vList,
            rList,
            sList
        );
        verifyTokensRegistered(ringSize, addressList);
        var (ringhash, ringhashAttributes) = RinghashRegistry(
            ringhashRegistryAddress
        ).computeAndGetRinghashInfo(
            ringSize,
            ringminer,
            vList,
            rList,
            sList
        );
        //Check if we can submit this ringhash.
        require(ringhashAttributes[0]); // "Ring claimed by others");
        verifySignature(
            ringminer,
            ringhash,
            vList[ringSize],
            rList[ringSize],
            sList[ringSize]
        );
        TokenTransferDelegate delegate = TokenTransferDelegate(delegateAddress);
        //Assemble input data into structs so we can pass them to other functions.
        var orders = assembleOrders(
            delegate,
            addressList,
            uintArgsList,
            uint8ArgsList,
            buyNoMoreThanAmountBList,
            vList,
            rList,
            sList
        );
        if (feeRecipient == address(0)) {
            feeRecipient = ringminer;
        }
        handleRing(
            delegate,
            ringSize,
            ringhash,
            orders,
            ringminer,
            feeRecipient,
            ringhashAttributes[1]
        );
        ringIndex = ringIndex ^ ENTERED_MASK + 1;
    }
    /// @dev Cancel a order. cancel amount(amountS or amountB) can be specified
    ///      in orderValues.
    /// @param addresses          owner, tokenS, tokenB
    /// @param orderValues        amountS, amountB, timestamp, ttl, salt, lrcFee,
    ///                           cancelAmountS, and cancelAmountB.
    /// @param buyNoMoreThanAmountB -
    ///                           This indicates when a order should be considered
    ///                           as 'completely filled'.
    /// @param marginSplitPercentage -
    ///                           Percentage of margin split to share with miner.
    /// @param v                  Order ECDSA signature parameter v.
    /// @param r                  Order ECDSA signature parameters r.
    /// @param s                  Order ECDSA signature parameters s.
    function cancelOrder(
        address[3] addresses,
        uint[7]    orderValues,
        bool       buyNoMoreThanAmountB,
        uint8      marginSplitPercentage,
        uint8      v,
        bytes32    r,
        bytes32    s
        )
        public
    {
        uint cancelAmount = orderValues[6];
        require(cancelAmount > 0); // "amount to cancel is zero");
        var order = Order(
            addresses[0],
            addresses[1],
            addresses[2],
            orderValues[0],
            orderValues[1],
            orderValues[5],
            buyNoMoreThanAmountB,
            marginSplitPercentage
        );
        require(msg.sender == order.owner); // "cancelOrder not submitted by order owner");
        bytes32 orderHash = calculateOrderHash(
            order,
            orderValues[2], // timestamp
            orderValues[3], // ttl
            orderValues[4]  // salt
        );
        verifySignature(
            order.owner,
            orderHash,
            v,
            r,
            s
        );
        cancelledOrFilled[orderHash] = cancelledOrFilled[orderHash].add(cancelAmount);
        OrderCancelled(
            block.timestamp,
            block.number,
            orderHash,
            cancelAmount
        );
    }
    /// @dev   Set a cutoff timestamp to invalidate all orders whose timestamp
    ///        is smaller than or equal to the new value of the address's cutoff
    ///        timestamp.
    /// @param cutoff The cutoff timestamp, will default to `block.timestamp`
    ///        if it is 0.
    function setCutoff(uint cutoff)
        public
    {
        uint t = cutoff;
        if (t == 0) {
            t = block.timestamp;
        }
        require(cutoffs[msg.sender] < t); // "attempted to set cutoff to a smaller value");
        cutoffs[msg.sender] = t;
        CutoffTimestampChanged(
            block.timestamp,
            block.number,
            msg.sender,
            t
        );
    }
    ////////////////////////////////////////////////////////////////////////////
    /// Internal & Private Functions                                         ///
    ////////////////////////////////////////////////////////////////////////////
    /// @dev Validate a ring.
    function verifyRingHasNoSubRing(
        uint          ringSize,
        OrderState[]  orders
        )
        private
        pure
    {
        // Check the ring has no sub-ring.
        for (uint i = 0; i < ringSize - 1; i++) {
            address tokenS = orders[i].order.tokenS;
            for (uint j = i + 1; j < ringSize; j++) {
                require(tokenS != orders[j].order.tokenS); // "found sub-ring");
            }
        }
    }
    function verifyTokensRegistered(
        uint          ringSize,
        address[2][]  addressList
        )
        private
        view
    {
        // Extract the token addresses
        var tokens = new address[](ringSize);
        for (uint i = 0; i < ringSize; i++) {
            tokens[i] = addressList[i][1];
        }
        // Test all token addresses at once
        require(
            TokenRegistry(tokenRegistryAddress).areAllTokensRegistered(tokens)
        ); // "token not registered");
    }
    function handleRing(
        TokenTransferDelegate delegate,
        uint          ringSize,
        bytes32       ringhash,
        OrderState[]  orders,
        address       miner,
        address       feeRecipient,
        bool          isRinghashReserved
        )
        private
    {
        // Do the hard work.
        verifyRingHasNoSubRing(ringSize, orders);
        // Exchange rates calculation are performed by ring-miners as solidity
        // cannot get power-of-1/n operation, therefore we have to verify
        // these rates are correct.
        verifyMinerSuppliedFillRates(ringSize, orders);
        // Scale down each order independently by substracting amount-filled and
        // amount-cancelled. Order owner's current balance and allowance are
        // not taken into consideration in these operations.
        scaleRingBasedOnHistoricalRecords(ringSize, orders);
        // Based on the already verified exchange rate provided by ring-miners,
        // we can furthur scale down orders based on token balance and allowance,
        // then find the smallest order of the ring, then calculate each order's
        // `fillAmountS`.
        calculateRingFillAmount(ringSize, orders);
        address _lrcTokenAddress = lrcTokenAddress;
        // Calculate each order's `lrcFee` and `lrcRewrard` and splict how much
        // of `fillAmountS` shall be paid to matching order or miner as margin
        // split.
        calculateRingFees(
            delegate,
            ringSize,
            orders,
            feeRecipient,
            _lrcTokenAddress
        );
        /// Make payments.
        settleRing(
            delegate,
            ringSize,
            orders,
            ringhash,
            feeRecipient,
            _lrcTokenAddress
        );
        RingMined(
            ringIndex ^ ENTERED_MASK,
            block.timestamp,
            block.number,
            ringhash,
            miner,
            feeRecipient,
            isRinghashReserved
        );
    }
    function createTransferBatch(
        uint          ringSize,
        OrderState[]  orders
        )
        private
        pure
        returns (bytes32[] batch)
    {
        batch = new bytes32[](ringSize * 6); // ringSize * (tokenS + owner) + ringSize * 4 amounts
        
        uint p = ringSize * 2;
        for (uint i = 0; i < ringSize; i++) {
            var state = orders[i];
            var prev = orders[(i + ringSize - 1) % ringSize];
			
            // Store tokenS and owner of every order
            batch[i] = bytes32(state.order.tokenS);
            batch[ringSize + i] = bytes32(state.order.owner);
		    
            // Store all amounts
            batch[p] = bytes32(state.fillAmountS - prev.splitB);
            batch[p+1] = bytes32(prev.splitB + state.splitS);
            batch[p+2] = bytes32(state.lrcReward);
            batch[p+3] = bytes32(state.lrcFee);
            p += 4;
        }
        return batch;
    }
    function settleRing(
        TokenTransferDelegate delegate,
        uint          ringSize,
        OrderState[]  orders,
        bytes32       ringhash,
        address       feeRecipient,
        address       _lrcTokenAddress
        )
        private
    {
        for (uint i = 0; i < ringSize; i++) {
            var state = orders[i];
            var prev = orders[(i + ringSize - 1) % ringSize];
            var next = orders[(i + 1) % ringSize];
            // Update fill records
            if (state.order.buyNoMoreThanAmountB) {
                cancelledOrFilled[state.orderHash] += next.fillAmountS;
            } else {
                cancelledOrFilled[state.orderHash] += state.fillAmountS;
            }
            OrderFilled(
                ringIndex ^ ENTERED_MASK,
                block.timestamp,
                block.number,
                ringhash,
                prev.orderHash,
                state.orderHash,
                next.orderHash,
                state.fillAmountS + state.splitS,
                next.fillAmountS - state.splitB,
                state.lrcReward,
                state.lrcFee
            );
        }
        delegate.batchTransferToken(ringSize, _lrcTokenAddress, feeRecipient,
            createTransferBatch(
                ringSize,
                orders
            )
        );
    }
    /// @dev Verify miner has calculte the rates correctly.
    function verifyMinerSuppliedFillRates(
        uint          ringSize,
        OrderState[]  orders
        )
        private
        view
    {
        var rateRatios = new uint[](ringSize);
        uint _rateRatioScale = RATE_RATIO_SCALE;
        for (uint i = 0; i < ringSize; i++) {
            uint s1b0 = orders[i].rate.amountS.mul(orders[i].order.amountB);
            uint s0b1 = orders[i].order.amountS.mul(orders[i].rate.amountB);
            require(s1b0 <= s0b1); // "miner supplied exchange rate provides invalid discount");
            rateRatios[i] = _rateRatioScale.mul(s1b0) / s0b1;
        }
        uint cvs = MathUint.cvsquare(rateRatios, _rateRatioScale);
        require(cvs <= rateRatioCVSThreshold); // "miner supplied exchange rate is not evenly discounted");
    }
    /// @dev Calculate each order's fee or LRC reward.
    function calculateRingFees(
        TokenTransferDelegate delegate,
        uint            ringSize,
        OrderState[]    orders,
        address         feeRecipient,
        address         _lrcTokenAddress
        )
        private
        view
    {
        uint minerLrcSpendable = getSpendable(
            delegate,
            _lrcTokenAddress,
            feeRecipient
        );
        uint8 _marginSplitPercentageBase = MARGIN_SPLIT_PERCENTAGE_BASE;
        for (uint i = 0; i < ringSize; i++) {
            var state = orders[i];
            var next = orders[(i + 1) % ringSize];
            uint lrcSpendable = getSpendable(
                delegate,
                _lrcTokenAddress,
                state.order.owner
            );
            // If order doesn't have enough LRC, set margin split to 100%.
            if (lrcSpendable < state.lrcFee) {
                state.lrcFee = lrcSpendable;
                state.order.marginSplitPercentage = _marginSplitPercentageBase;
            }
            // When an order's LRC fee is 0 or smaller than the specified fee,
            // we help miner automatically select margin-split.
            if (state.lrcFee == 0) {
                state.order.marginSplitPercentage = _marginSplitPercentageBase;
            }
            if (state.feeSelection == FEE_SELECT_MARGIN_SPLIT || state.lrcFee == 0) {
                // Only calculate split when miner has enough LRC;
                // otherwise all splits are 0.
                if (minerLrcSpendable >= state.lrcFee) {
                    uint split;
                    if (state.order.buyNoMoreThanAmountB) {
                        split = (next.fillAmountS.mul(
                            state.order.amountS
                        ) / state.order.amountB).sub(
                            state.fillAmountS
                        );
                    } else {
                        split = next.fillAmountS.sub(
                            state.fillAmountS.mul(
                                state.order.amountB
                            ) / state.order.amountS
                        );
                    }
                    if (state.order.marginSplitPercentage != _marginSplitPercentageBase) {
                        split = split.mul(
                            state.order.marginSplitPercentage
                        ) / _marginSplitPercentageBase;
                    }
                    if (state.order.buyNoMoreThanAmountB) {
                        state.splitS = split;
                    } else {
                        state.splitB = split;
                    }
                    // This implicits order with smaller index in the ring will
                    // be paid LRC reward first, so the orders in the ring does
                    // mater.
                    if (split > 0) {
                        minerLrcSpendable = minerLrcSpendable.sub(state.lrcFee);
                        state.lrcReward = state.lrcFee;
                    }
                    state.lrcFee = 0;
                }
            } else if (state.feeSelection == FEE_SELECT_LRC) {
                minerLrcSpendable += state.lrcFee;
            } else {
                revert(); // "unsupported fee selection value");
            }
        }
    }
    /// @dev Calculate each order's fill amount.
    function calculateRingFillAmount(
        uint          ringSize,
        OrderState[]  orders
        )
        private
        pure 
    {
        uint smallestIdx = 0;
        uint i;
        uint j;
        for (i = 0; i < ringSize; i++) {
            j = (i + 1) % ringSize;
            smallestIdx = calculateOrderFillAmount(
                orders[i],
                orders[j],
                i,
                j,
                smallestIdx
            );
        }
        for (i = 0; i < smallestIdx; i++) {
            calculateOrderFillAmount(
                orders[i],
                orders[(i + 1) % ringSize],
                0,               // Not needed
                0,               // Not needed
                0                // Not needed
            );
        }
    }
    /// @return The smallest order's index.
    function calculateOrderFillAmount(
        OrderState        state,
        OrderState        next,
        uint              i,
        uint              j,
        uint              smallestIdx
        )
        private
        pure
        returns (uint newSmallestIdx)
    {
        // Default to the same smallest index
        newSmallestIdx = smallestIdx;
        uint fillAmountB = state.fillAmountS.mul(
            state.rate.amountB
        ) / state.rate.amountS;
        if (state.order.buyNoMoreThanAmountB) {
            if (fillAmountB > state.order.amountB) {
                fillAmountB = state.order.amountB;
                state.fillAmountS = fillAmountB.mul(
                    state.rate.amountS
                ) / state.rate.amountB;
                newSmallestIdx = i;
            }
        }
        state.lrcFee = state.order.lrcFee.mul(
            state.fillAmountS
        ) / state.order.amountS;
        if (fillAmountB <= next.fillAmountS) {
            next.fillAmountS = fillAmountB;
        } else {
            newSmallestIdx = j;
        }
    }
    /// @dev Scale down all orders based on historical fill or cancellation
    ///      stats but key the order's original exchange rate.
    function scaleRingBasedOnHistoricalRecords(
        uint          ringSize,
        OrderState[]  orders
        )
        private
        view
    {
        for (uint i = 0; i < ringSize; i++) {
            var state = orders[i];
            var order = state.order;
            uint amount;
            if (order.buyNoMoreThanAmountB) {
                amount = order.amountB.tolerantSub(
                    cancelledOrFilled[state.orderHash]
                );
                order.amountS = amount.mul(order.amountS) / order.amountB;
                order.lrcFee = amount.mul(order.lrcFee) / order.amountB;
                order.amountB = amount;
            } else {
                amount = order.amountS.tolerantSub(
                    cancelledOrFilled[state.orderHash]
                );
                order.amountB = amount.mul(order.amountB) / order.amountS;
                order.lrcFee = amount.mul(order.lrcFee) / order.amountS;
                order.amountS = amount;
            }
            require(order.amountS > 0); // "amountS is zero");
            require(order.amountB > 0); // "amountB is zero");
            state.fillAmountS = (
                order.amountS < state.availableAmountS ?
                order.amountS : state.availableAmountS
            );
        }
    }
    /// @return Amount of ERC20 token that can be spent by this contract.
    function getSpendable(
        TokenTransferDelegate delegate,
        address tokenAddress,
        address tokenOwner
        )
        private
        view
        returns (uint)
    {
        var token = ERC20(tokenAddress);
        uint allowance = token.allowance(
            tokenOwner,
            address(delegate)
        );
        uint balance = token.balanceOf(tokenOwner);
        return (allowance < balance ? allowance : balance);
    }
    /// @dev verify input data's basic integrity.
    function verifyInputDataIntegrity(
        uint          ringSize,
        address[2][]  addressList,
        uint[7][]     uintArgsList,
        uint8[2][]    uint8ArgsList,
        bool[]        buyNoMoreThanAmountBList,
        uint8[]       vList,
        bytes32[]     rList,
        bytes32[]     sList
        )
        private
        pure
    {
        require(ringSize == addressList.length); // "ring data is inconsistent - addressList");
        require(ringSize == uintArgsList.length); // "ring data is inconsistent - uintArgsList");
        require(ringSize == uint8ArgsList.length); // "ring data is inconsistent - uint8ArgsList");
        require(ringSize == buyNoMoreThanAmountBList.length); // "ring data is inconsistent - buyNoMoreThanAmountBList");
        require(ringSize + 1 == vList.length); // "ring data is inconsistent - vList");
        require(ringSize + 1 == rList.length); // "ring data is inconsistent - rList");
        require(ringSize + 1 == sList.length); // "ring data is inconsistent - sList");
        // Validate ring-mining related arguments.
        for (uint i = 0; i < ringSize; i++) {
            require(uintArgsList[i][6] > 0); // "order rateAmountS is zero");
            require(uint8ArgsList[i][1] <= FEE_SELECT_MAX_VALUE); // "invalid order fee selection");
        }
    }
    /// @dev        assmble order parameters into Order struct.
    /// @return     A list of orders.
    function assembleOrders(
        TokenTransferDelegate delegate,
        address[2][]    addressList,
        uint[7][]       uintArgsList,
        uint8[2][]      uint8ArgsList,
        bool[]          buyNoMoreThanAmountBList,
        uint8[]         vList,
        bytes32[]       rList,
        bytes32[]       sList
        )
        private
        view
        returns (OrderState[] orders)
    {
        uint ringSize = addressList.length;
        orders = new OrderState[](ringSize);
        for (uint i = 0; i < ringSize; i++) {
            var order = Order(
                addressList[i][0],
                addressList[i][1],
                addressList[(i + 1) % ringSize][1],
                uintArgsList[i][0],
                uintArgsList[i][1],
                uintArgsList[i][5],
                buyNoMoreThanAmountBList[i],
                uint8ArgsList[i][0]
            );
            bytes32 orderHash = calculateOrderHash(
                order,
                uintArgsList[i][2], // timestamp
                uintArgsList[i][3], // ttl
                uintArgsList[i][4]  // salt
            );
            verifySignature(
                order.owner,
                orderHash,
                vList[i],
                rList[i],
                sList[i]
            );
            validateOrder(
                order,
                uintArgsList[i][2], // timestamp
                uintArgsList[i][3], // ttl
                uintArgsList[i][4]  // salt
            );
            orders[i] = OrderState(
                order,
                orderHash,
                uint8ArgsList[i][1],  // feeSelection
                Rate(uintArgsList[i][6], order.amountB),
                getSpendable(delegate, order.tokenS, order.owner),
                0,   // fillAmountS
                0,   // lrcReward
                0,   // lrcFee
                0,   // splitS
                0    // splitB
            );
            require(orders[i].availableAmountS > 0); // "order spendable amountS is zero");
        }
    }
    /// @dev validate order's parameters are OK.
    function validateOrder(
        Order        order,
        uint         timestamp,
        uint         ttl,
        uint         salt
        )
        private
        view
    {
        require(order.owner != address(0)); // "invalid order owner");
        require(order.tokenS != address(0)); // "invalid order tokenS");
        require(order.tokenB != address(0)); // "invalid order tokenB");
        require(order.amountS != 0); // "invalid order amountS");
        require(order.amountB != 0); // "invalid order amountB");
        require(timestamp <= block.timestamp); // "order is too early to match");
        require(timestamp > cutoffs[order.owner]); // "order is cut off");
        require(ttl != 0); // "order ttl is 0");
        require(timestamp + ttl > block.timestamp); // "order is expired");
        require(salt != 0); // "invalid order salt");
        require(order.marginSplitPercentage <= MARGIN_SPLIT_PERCENTAGE_BASE); // "invalid order marginSplitPercentage");
    }
    /// @dev Get the Keccak-256 hash of order with specified parameters.
    function calculateOrderHash(
        Order        order,
        uint         timestamp,
        uint         ttl,
        uint         salt
        )
        private
        view
        returns (bytes32)
    {
        return keccak256(
            address(this),
            order.owner,
            order.tokenS,
            order.tokenB,
            order.amountS,
            order.amountB,
            timestamp,
            ttl,
            salt,
            order.lrcFee,
            order.buyNoMoreThanAmountB,
            order.marginSplitPercentage
        );
    }
    /// @dev Verify signer's signature.
    function verifySignature(
        address signer,
        bytes32 hash,
        uint8   v,
        bytes32 r,
        bytes32 s
        )
        private
        pure
    {
        require(
            signer == ecrecover(
                keccak256("\x19Ethereum Signed Message:\n32", hash),
                v,
                r,
                s
            )
        ); // "invalid signature");
    }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[],"name":"ENTERED_MASK","outputs":[{"name":"","type":"uint64"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"FEE_SELECT_MAX_VALUE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MARGIN_SPLIT_PERCENTAGE_BASE","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ringIndex","outputs":[{"name":"","type":"uint64"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addresses","type":"address[3]"},{"name":"orderValues","type":"uint256[7]"},{"name":"buyNoMoreThanAmountB","type":"bool"},{"name":"marginSplitPercentage","type":"uint8"},{"name":"v","type":"uint8"},{"name":"r","type":"bytes32"},{"name":"s","type":"bytes32"}],"name":"cancelOrder","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"RATE_RATIO_SCALE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lrcTokenAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"cancelledOrFilled","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokenRegistryAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"delegateAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addressList","type":"address[2][]"},{"name":"uintArgsList","type":"uint256[7][]"},{"name":"uint8ArgsList","type":"uint8[2][]"},{"name":"buyNoMoreThanAmountBList","type":"bool[]"},{"name":"vList","type":"uint8[]"},{"name":"rList","type":"bytes32[]"},{"name":"sList","type":"bytes32[]"},{"name":"ringminer","type":"address"},{"name":"feeRecipient","type":"address"}],"name":"submitRing","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxRingSize","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ringhashRegistryAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"cutoff","type":"uint256"}],"name":"setCutoff","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"FEE_SELECT_LRC","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"cutoffs","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"rateRatioCVSThreshold","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"FEE_SELECT_MARGIN_SPLIT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_lrcTokenAddress","type":"address"},{"name":"_tokenRegistryAddress","type":"address"},{"name":"_ringhashRegistryAddress","type":"address"},{"name":"_delegateAddress","type":"address"},{"name":"_maxRingSize","type":"uint256"},{"name":"_rateRatioCVSThreshold","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_ringIndex","type":"uint256"},{"indexed":false,"name":"_time","type":"uint256"},{"indexed":false,"name":"_blocknumber","type":"uint256"},{"indexed":true,"name":"_ringhash","type":"bytes32"},{"indexed":true,"name":"_miner","type":"address"},{"indexed":true,"name":"_feeRecipient","type":"address"},{"indexed":false,"name":"_isRinghashReserved","type":"bool"}],"name":"RingMined","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_ringIndex","type":"uint256"},{"indexed":false,"name":"_time","type":"uint256"},{"indexed":false,"name":"_blocknumber","type":"uint256"},{"indexed":true,"name":"_ringhash","type":"bytes32"},{"indexed":false,"name":"_prevOrderHash","type":"bytes32"},{"indexed":true,"name":"_orderHash","type":"bytes32"},{"indexed":false,"name":"_nextOrderHash","type":"bytes32"},{"indexed":false,"name":"_amountS","type":"uint256"},{"indexed":false,"name":"_amountB","type":"uint256"},{"indexed":false,"name":"_lrcReward","type":"uint256"},{"indexed":false,"name":"_lrcFee","type":"uint256"}],"name":"OrderFilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_time","type":"uint256"},{"indexed":false,"name":"_blocknumber","type":"uint256"},{"indexed":true,"name":"_orderHash","type":"bytes32"},{"indexed":false,"name":"_amountCancelled","type":"uint256"}],"name":"OrderCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_time","type":"uint256"},{"indexed":false,"name":"_blocknumber","type":"uint256"},{"indexed":true,"name":"_address","type":"address"},{"indexed":false,"name":"_cutoff","type":"uint256"}],"name":"CutoffTimestampChanged","type":"event"}]

606060405260008054600160a060020a031990811682556001805482169055600280548216905560038054909116905560048190556005805467ffffffffffffffff1916905560065534156200005457600080fd5b60405160c08062002478833981016040528080519190602001805191906020018051919060200180519190602001805191906020018051915050600160a060020a0386161515620000a457600080fd5b600160a060020a0385161515620000ba57600080fd5b600160a060020a0384161515620000d057600080fd5b600160a060020a0383161515620000e657600080fd5b60018211620000f457600080fd5b600081116200010257600080fd5b60008054600160a060020a03978816600160a060020a031991821617909155600180549688169682169690961790955560028054948716948616949094179093556003805492909516919093161790925560045560065561230f80620001696000396000f3006060604052600436106100e25763ffffffff60e060020a6000350416631879749981146100e757806326ea9268146101175780632db237bb1461013c57806341ffbc1f1461016557806347a99e43146101785780634a63864b146101f95780634c0a65321461020c5780635511f3191461023b5780635be2aca0146102515780636d96a2aa14610264578063ca35947d14610277578063cbc12d13146104f1578063d21b96ab14610504578063d7bf911014610517578063db71d8b61461052d578063de794c1e14610540578063df565ca21461055f578063e95d716c14610117575b600080fd5b34156100f257600080fd5b6100fa610572565b60405167ffffffffffffffff909116815260200160405180910390f35b341561012257600080fd5b61012a61057e565b60405190815260200160405180910390f35b341561014757600080fd5b61014f610583565b60405160ff909116815260200160405180910390f35b341561017057600080fd5b6100fa610588565b341561018357600080fd5b6101f760046064816003606060405190810160405291908282606080828437820191505050505091908060e001906007806020026040519081016040529190828260e08082843750939550505050813515159160ff6020820135811692506040820135169060608101359060800135610598565b005b341561020457600080fd5b61012a610704565b341561021757600080fd5b61021f61070a565b604051600160a060020a03909116815260200160405180910390f35b341561024657600080fd5b61012a600435610719565b341561025c57600080fd5b61021f61072b565b341561026f57600080fd5b61021f61073a565b341561028257600080fd5b6101f760046024813581810190830135806020818102016040519081016040528181529291906000602085015b828210156102ee5760408083028601906002908051908101604052809291908260026020028082843750505091835250506001909101906020016102af565b505050505091908035906020019082018035906020019080806020026020016040519081016040528181529291906000602085015b8282101561035f5760e08083028601906007906040519081016040529190828260e0808284375050509183525050600190910190602001610323565b505050505091908035906020019082018035906020019080806020026020016040519081016040528181529291906000602085015b828210156103d3576040808302860190600290805190810160405280929190826002602002808284375050509183525050600190910190602001610394565b5050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375094965050600160a060020a0385358116956020013516935061074992505050565b34156104fc57600080fd5b61012a610a1f565b341561050f57600080fd5b61021f610a25565b341561052257600080fd5b6101f7600435610a34565b341561053857600080fd5b61012a610ace565b341561054b57600080fd5b61012a600160a060020a0360043516610ad3565b341561056a57600080fd5b61012a610ae5565b67800000000000000081565b600181565b606481565b60055467ffffffffffffffff1681565b60006105a26121ef565b600060c08901519250600083116105b857600080fd5b610100604051908101604052808b51600160a060020a031681526020018b60016020020151600160a060020a0316815260200160408c0151600160a060020a031681526020018a5181526020018a60016020020151815260200160a08b01518152891515602082015260ff891660409091015291508151600160a060020a031633600160a060020a031614151561064e57600080fd5b61066a8260408b015160608c01518c60045b6020020151610aeb565b905061067a825182888888610bcd565b600081815260076020526040902054610699908463ffffffff610c9216565b600082815260076020526040908190209190915581907fdb6b2087bc479399a384085a4ff023f244b32682c168d31c93b82194caa7be88904290439087905180848152602001838152602001828152602001935050505060405180910390a250505050505050505050565b61271081565b600054600160a060020a031681565b60076020526000908152604090205481565b600154600160a060020a031681565b600354600160a060020a031681565b600080610754612233565b600061075e61225a565b600554678000000000000000908116141561077857600080fd5b6005805467ffffffffffffffff808216678000000000000000171667ffffffffffffffff199091161790558d5194506001851180156107b957506004548511155b15156107c457600080fd5b6107d4858f8f8f8f8f8f8f610ca8565b6107de858f610d7d565b600254600160a060020a03166393d9bf3086898d8d8d6000604051606001526040518663ffffffff1660e060020a0281526004018086815260200185600160a060020a0316600160a060020a03168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561087557808201518382015260200161085d565b50505050905001848103835286818151815260200191508051906020019060200280838360005b838110156108b457808201518382015260200161089c565b50505050905001848103825285818151815260200191508051906020019060200280838360005b838110156108f35780820151838201526020016108db565b5050505090500198505050505050505050606060405180830381600087803b151561091d57600080fd5b6102c65a03f1151561092e57600080fd5b505050604051805160608201604052945060200192508251151561095157600080fd5b61099d87858c888151811061096257fe5b906020019060200201518c898151811061097857fe5b906020019060200201518c8a8151811061098e57fe5b90602001906020020151610bcd565b600354600160a060020a031691506109bb828f8f8f8f8f8f8f610eb7565b9050600160a060020a03861615156109d1578695505b6109e4828686848b8b60208a0151611235565b50506005805467ffffffffffffffff808216678000000000000001181667ffffffffffffffff19909116179055505050505050505050505050565b60045481565b600254600160a060020a031681565b80801515610a3f5750425b600160a060020a033316600090815260086020526040902054819010610a6457600080fd5b600160a060020a033316600081815260086020526040908190208390557fa87844964a2ae1d9b974561ed9c7d33df8fd2285707aae42744c4ccd280a65f8904290439085905180848152602001838152602001828152602001935050505060405180910390a25050565b600081565b60086020526000908152604090205481565b60065481565b600030855186602001518760400151886060015189608001518989898d60a001518e60c001518f60e001516040516c01000000000000000000000000600160a060020a039d8e16810282529b8d168c026014820152998c168b0260288b015297909a16909802603c88015260508701949094526070860192909252609085015260b084015260d083015260f08201929092527f0100000000000000000000000000000000000000000000000000000000000000921515830261011082015260ff9091169091026101118201526101120160405180910390209050949350505050565b6001846040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0160405180910390208484846040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f11515610c6b57600080fd5b505060206040510351600160a060020a03868116911614610c8b57600080fd5b5050505050565b81810182811015610ca257600080fd5b92915050565b600087518914610cb757600080fd5b86518914610cc457600080fd5b85518914610cd157600080fd5b84518914610cde57600080fd5b835160018a0114610cee57600080fd5b825160018a0114610cfe57600080fd5b815160018a0114610d0e57600080fd5b5060005b88811015610d72576000878281518110610d2857fe5b9060200190602002015160c0015111610d4057600080fd5b6001868281518110610d4e57fe5b906020019060200201516020015160ff161115610d6a57600080fd5b600101610d12565b505050505050505050565b610d8561225a565b600083604051805910610d955750595b90808252806020026020018201604052509150600090505b83811015610dfa57828181518110610dc157fe5b9060200190602002015160200151828281518110610ddb57fe5b600160a060020a03909216602092830290910190910152600101610dad565b600154600160a060020a03166316066e69836000604051602001526040518263ffffffff1660e060020a0281526004018080602001828103825283818151815260200191508051906020019060200280838360005b83811015610e67578082015183820152602001610e4f565b5050505090500192505050602060405180830381600087803b1515610e8b57600080fd5b6102c65a03f11515610e9c57600080fd5b505050604051805190501515610eb157600080fd5b50505050565b610ebf61225a565b600080610eca6121ef565b60008b51935083604051805910610ede5750595b908082528060200260200182016040528015610f1457816020015b610f0161226c565b815260200190600190039081610ef95790505b509450600092505b8383101561122557610100604051908101604052808d8581518110610f3d57fe5b9060200190602002015151600160a060020a031681526020018d8581518110610f6257fe5b9060200190602002015160200151600160a060020a031681526020018d8686600101811515610f8d57fe5b0681518110610f9857fe5b9060200190602002015160200151600160a060020a031681526020018c8581518110610fc057fe5b906020019060200201515181526020018c8581518110610fdc57fe5b906020019060200201516020015181526020018c8581518110610ffb57fe5b9060200190602002015160a0015181526020018a858151811061101a57fe5b90602001906020020151151581526020018b858151811061103757fe5b906020019060200201515160ff169052915061109e828c858151811061105957fe5b90602001906020020151604001518d868151811061107357fe5b90602001906020020151606001518e878151811061108d57fe5b906020019060200201516004610660565b90506110de8251828a86815181106110b257fe5b906020019060200201518a87815181106110c857fe5b906020019060200201518a888151811061098e57fe5b611135828c85815181106110ee57fe5b90602001906020020151604001518d868151811061110857fe5b90602001906020020151606001518e878151811061112257fe5b9060200190602002015160800151611315565b61014060405190810160409081528382526020820183905281018b858151811061115b57fe5b906020019060200201516020015160ff16815260200160408051908101604052808e878151811061118857fe5b9060200190602002015160c001518152602001856080015181525081526020016111b88f856020015186516113f6565b81526020016000815260200160008152602001600081526020016000815260200160008152508584815181106111ea57fe5b60209081029091010152600085848151811061120257fe5b90602001906020020151608001511161121a57600080fd5b600190920191610f1c565b5050505098975050505050505050565b60006112418786611502565b61124b8786611583565b61125587866116c6565b61125f878661187d565b50600054600160a060020a0316611279888887868561193f565b611287888887898786611b81565b600554600160a060020a03808516919086169088907f4108ba28a2df317b9d4c4a2a42b33aa556bfebc994f9b4ba275fe337bf5898989067ffffffffffffffff166780000000000000001842438860405167ffffffffffffffff9094168452602084019290925260408084019190915290151560608301526080909101905180910390a45050505050505050565b60008451600160a060020a0316141561132d57600080fd5b60006020850151600160a060020a0316141561134857600080fd5b60006040850151600160a060020a0316141561136357600080fd5b8360600151151561137357600080fd5b8360800151151561138357600080fd5b4283111561139057600080fd5b600860008551600160a060020a0316815260208101919091526040016000205483116113bb57600080fd5b8115156113c757600080fd5b42838301116113d557600080fd5b8015156113e157600080fd5b606460e085015160ff161115610eb157600080fd5b6000828180600160a060020a03831663dd62ed3e8689846040516020015260405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b151561145957600080fd5b6102c65a03f1151561146a57600080fd5b5050506040518051925050600160a060020a0383166370a082318660006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b15156114cc57600080fd5b6102c65a03f115156114dd57600080fd5b50505060405180519150508082106114f557806114f7565b815b979650505050505050565b600080805b60018503831015610c8b5783838151811061151e57fe5b906020019060200201515160200151915050600182015b848110156115785783818151811061154957fe5b906020019060200201515160200151600160a060020a038381169116141561157057600080fd5b600101611535565b600190920191611507565b61158b61225a565b6000806000806000876040518059106115a15750595b908082528060200260200182016040525095506127109450600093505b878410156116a05761160b8785815181106115d557fe5b9060200190602002015151608001518886815181106115f057fe5b9060200190602002015160600151519063ffffffff611e0d16565b925061165587858151811061161c57fe5b90602001906020020151606001516020015188868151811061163a57fe5b9060200190602002015151606001519063ffffffff611e0d16565b91508183111561166457600080fd5b81611675868563ffffffff611e0d16565b81151561167e57fe5b0486858151811061168b57fe5b602090810290910101526001909301926115be565b6116aa8686611e32565b6006549091508111156116bc57600080fd5b5050505050505050565b60006116d061226c565b6116d86121ef565b60008093505b85841015611875578484815181106116f257fe5b906020019060200201519250825191508160c001511561179a5761173a600760008560200151815260208101919091526040016000205460808401519063ffffffff611f7116565b905081608001516117568360600151839063ffffffff611e0d16565b81151561175f57fe5b046060830152608082015161177f8360a00151839063ffffffff611e0d16565b81151561178857fe5b0460a083015260808201819052611824565b6117c8600760008560200151815260208101919091526040016000205460608401519063ffffffff611f7116565b905081606001516117e48360800151839063ffffffff611e0d16565b8115156117ed57fe5b046080830152606082015161180d8360a00151839063ffffffff611e0d16565b81151561181657fe5b0460a0830152606082018190525b600082606001511161183557600080fd5b600082608001511161184657600080fd5b826080015182606001511061185f578260800151611865565b81606001515b60a08401526001909301926116de565b505050505050565b600080805b848210156118df57848260010181151561189857fe5b0690506118d28483815181106118aa57fe5b906020019060200201518583815181106118c057fe5b90602001906020020151848487611f8d565b9250600190910190611882565b600091505b82821015610c8b576119338483815181106118fb57fe5b9060200190602002015185878560010181151561191457fe5b068151811061191f57fe5b906020019060200201516000806000611f8d565b506001909101906118e4565b600080600061194c61226c565b61195461226c565b6000806119628c898b6113f6565b965060649550600094505b8a851015611b735789858151811061198157fe5b906020019060200201519350898b8660010181151561199c57fe5b06815181106119a757fe5b9060200190602002015192506119c08c898651516113f6565b91508360e001518210156119e55760e0840182905285845160ff90911660e091909101525b8360e001511515611a005785845160ff90911660e091909101525b6001846040015160ff161480611a1857508360e00151155b15611b4e578360e001518710611b4957835160c0015115611a7857611a718460a00151855160800151611a5b8751606001518760a001519063ffffffff611e0d16565b811515611a6457fe5b049063ffffffff61206516565b9050611ab9565b611ab6845160600151611a9b8651608001518760a001519063ffffffff611e0d16565b811515611aa457fe5b048460a001519063ffffffff61206516565b90505b60ff8616845160e0015160ff1614611af55760ff8616611ae8855160e00151839060ff1663ffffffff611e0d16565b811515611af157fe5b0490505b835160c0015115611b0d576101008401819052611b16565b61012084018190525b6000811115611b4157611b348460e00151889063ffffffff61206516565b96508360e0015160c08501525b600060e08501525b611b68565b6000846040015160ff1614156100e2578360e00151870196505b60019094019361196d565b505050505050505050505050565b6000611b8b61226c565b611b9361226c565b611b9b61226c565b600093505b88841015611d3957878481518110611bb457fe5b906020019060200201519250878960018b870103811515611bd157fe5b0681518110611bdc57fe5b906020019060200201519150878985600101811515611bf757fe5b0681518110611c0257fe5b906020019060200201519050825160c0015115611c43578060a001516007600085602001518152602081019190915260400160002080549091019055611c69565b8260a0015160076000856020015181526020810191909152604001600020805490910190555b826020015160055488907f102d9c1f12fffa0396bbcfbb243611201f5e38e1e3f43f1e3c7037a0102dcb9d9067ffffffffffffffff16678000000000000000184243602088015187602001518a61010001518b60a00151018b61012001518a60a00151038c60c001518d60e0015160405167ffffffffffffffff909916895260208901979097526040808901969096526060880194909452608087019290925260a086015260c085015260e0840152610100830191909152610120909101905180910390a3600190930192611ba0565b89600160a060020a03166335a506638a8789611d558e8e612074565b60405160e060020a63ffffffff871602815260048101858152600160a060020a03808616602484015284166044830152608060648301908152909160840183818151815260200191508051906020019060200280838360005b83811015611dc6578082015183820152602001611dae565b5050505090500195505050505050600060405180830381600087803b1515611ded57600080fd5b6102c65a03f11515611dfe57600080fd5b50505050505050505050505050565b818102821580611e275750818382811515611e2457fe5b04145b1515610ca257600080fd5b6000806000806000808751945060018511611e4c57600080fd5b60008711611e5957600080fd5b60009350600092505b84831015611e8f57878381518110611e7657fe5b9060200190602002015190930192600190920191611e62565b8484811515611e9a57fe5b049350831515611ead5760009550611f66565b5060009150819050805b84831015611f2c5783888481518110611ecc57fe5b9060200190602002015111611ef857878381518110611ee757fe5b906020019060200201518403611f11565b83888481518110611f0557fe5b90602001906020020151035b9050611f1d8182611e0d565b60019093019290910190611eb7565b6001850384611f4f86611f3f868c611e0d565b811515611f4857fe5b048a611e0d565b811515611f5857fe5b04811515611f6257fe5b0495505b505050505092915050565b600081831015611f82576000611f86565b8183035b9392505050565b806000606087015151611fb38860600151602001518960a001519063ffffffff611e0d16565b811515611fbc57fe5b049050865160c001511561201157865160800151811115612011578651608001519050866060015160200151611ffe886060015151839063ffffffff611e0d16565b81151561200757fe5b0460a08801528491505b8651606001516120318860a00151895160a001519063ffffffff611e0d16565b81151561203a57fe5b0460e088015260a086015181116120575760a0860181905261205b565b8391505b5095945050505050565b600082821115611f8257600080fd5b61207c61225a565b60008061208761226c565b61208f61226c565b866006026040518059106120a05750595b90808252806020026020018201604052509450866002029350600092505b868310156121e5578583815181106120d257fe5b90602001906020020151915085876001898601038115156120ef57fe5b06815181106120fa57fe5b906020019060200201519050815160200151600160a060020a031685848151811061212157fe5b60209081029091010152815151600160a060020a0316858885018151811061214557fe5b602090810290910101526101208101518260a001510385858151811061216757fe5b602090810290910101526101008201518161012001510185600186018151811061218d57fe5b6020908102909101015260c08201518560028601815181106121ab57fe5b6020908102909101015260e08201518560038601815181106121c957fe5b60209081029091010152600493909301926001909201916120be565b5050505092915050565b6101006040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e082015290565b604080519081016040526002815b6000815260001990910190602001816122415790505090565b60206040519081016040526000815290565b610240604051908101604052806122816121ef565b8152600060208201819052604082015260600161229c6122cc565b81526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805190810160405260008082526020820152905600a165627a7a7230582065c0b75b2085813c8833ed6caaec43d732f9b773134963bf818dd3ad9c18542b0029000000000000000000000000ef68e7c694f40c8202821edf525de3782458639f000000000000000000000000b3f998f70f0a99fd11902dd238b3b92156040ca00000000000000000000000000d038d2a8942d54df1b6ce8d802ab1d071d3046c0000000000000000000000006eee3497d91ed600646f4e31000329ef2e5d210e0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000f424

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000ef68e7c694f40c8202821edf525de3782458639f000000000000000000000000b3f998f70f0a99fd11902dd238b3b92156040ca00000000000000000000000000d038d2a8942d54df1b6ce8d802ab1d071d3046c0000000000000000000000006eee3497d91ed600646f4e31000329ef2e5d210e0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000f424

-----Decoded View---------------
Arg [0] : _lrcTokenAddress (address): 0xef68e7c694f40c8202821edf525de3782458639f
Arg [1] : _tokenRegistryAddress (address): 0xb3f998f70f0a99fd11902dd238b3b92156040ca0
Arg [2] : _ringhashRegistryAddress (address): 0x0d038d2a8942d54df1b6ce8d802ab1d071d3046c
Arg [3] : _delegateAddress (address): 0x6eee3497d91ed600646f4e31000329ef2e5d210e
Arg [4] : _maxRingSize (uint256): 5
Arg [5] : _rateRatioCVSThreshold (uint256): 62500

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000ef68e7c694f40c8202821edf525de3782458639f
Arg [1] : 000000000000000000000000b3f998f70f0a99fd11902dd238b3b92156040ca0
Arg [2] : 0000000000000000000000000d038d2a8942d54df1b6ce8d802ab1d071d3046c
Arg [3] : 0000000000000000000000006eee3497d91ed600646f4e31000329ef2e5d210e
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [5] : 000000000000000000000000000000000000000000000000000000000000f424


Swarm Source

bzzr://65c0b75b2085813c8833ed6caaec43d732f9b773134963bf818dd3ad9c18542b
Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.