ETH Price: $3,337.93 (-1.17%)

Contract

0x818E6FECD516Ecc3849DAf6845e3EC868087B755
 

Multichain Info

1 address found via
Transaction Hash
Method
Block
From
To
0xd99bc4bdab918257300a651d0c48513636c26dff6621af0940e565942614f038 Trade(pending)2024-12-22 9:19:1725 hrs ago1734859157IN
Kyber: Proxy
0 ETH(Pending)(Pending)
0x2e260b545dc8065b45afd37f1f10ee57f762a087750d7d2b36c1adf83147d8e4 Trade(pending)2024-12-22 2:58:2631 hrs ago1734836306IN
Kyber: Proxy
0.00015 ETH(Pending)(Pending)
Trade With Hint204534162024-08-04 6:32:35141 days ago1722753155IN
Kyber: Proxy
0 ETH0.000313411
Trade204533702024-08-04 6:23:23141 days ago1722752603IN
Kyber: Proxy
0 ETH0.000051631
Trade204533602024-08-04 6:21:23141 days ago1722752483IN
Kyber: Proxy
0 ETH0.000419991
Trade204533252024-08-04 6:14:11141 days ago1722752051IN
Kyber: Proxy
0 ETH0.000312931
Trade204533122024-08-04 6:11:35141 days ago1722751895IN
Kyber: Proxy
0.00117442 ETH0.000590671
Trade204532752024-08-04 6:04:11141 days ago1722751451IN
Kyber: Proxy
0.001704 ETH0.000185081
Trade204532302024-08-04 5:55:11141 days ago1722750911IN
Kyber: Proxy
0 ETH0.000364431
Trade204532132024-08-04 5:51:47141 days ago1722750707IN
Kyber: Proxy
0.0004 ETH0.000099321
Trade204531342024-08-04 5:35:47141 days ago1722749747IN
Kyber: Proxy
0 ETH0.000312771
Trade204531312024-08-04 5:35:11141 days ago1722749711IN
Kyber: Proxy
0 ETH0.000590091
Trade204531112024-08-04 5:31:11141 days ago1722749471IN
Kyber: Proxy
0 ETH0.000591171
Trade204530482024-08-04 5:18:35141 days ago1722748715IN
Kyber: Proxy
0.00056894 ETH0.000591261
Trade204530332024-08-04 5:15:35141 days ago1722748535IN
Kyber: Proxy
0.00036734 ETH0.000185081
Trade204530082024-08-04 5:10:35141 days ago1722748235IN
Kyber: Proxy
0.000004 ETH0.000096321
Trade204529392024-08-04 4:56:47141 days ago1722747407IN
Kyber: Proxy
0.0001 ETH0.00009621
Trade204528442024-08-04 4:37:47141 days ago1722746267IN
Kyber: Proxy
0.00040681 ETH0.000510021
Trade204528322024-08-04 4:35:23141 days ago1722746123IN
Kyber: Proxy
0.004 ETH0.000591361
Trade204527222024-08-04 4:13:23141 days ago1722744803IN
Kyber: Proxy
0.00040681 ETH0.000510011
Trade204519152024-08-04 1:31:35141 days ago1722735095IN
Kyber: Proxy
0.00115 ETH0.000157291
Trade204517882024-08-04 1:05:59141 days ago1722733559IN
Kyber: Proxy
0.00482407 ETH0.000469091
Trade204477072024-08-03 11:26:23141 days ago1722684383IN
Kyber: Proxy
0.00000001 ETH0.000402981
Trade With Hint204292382024-07-31 21:32:35144 days ago1722461555IN
Kyber: Proxy
0 ETH0.004108120
Trade204156422024-07-29 23:54:35146 days ago1722297275IN
Kyber: Proxy
0 ETH0.000590411
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
204533122024-08-04 6:11:35141 days ago1722751895
Kyber: Proxy
0.00117442 ETH
204532752024-08-04 6:04:11141 days ago1722751451
Kyber: Proxy
0.001704 ETH
204532132024-08-04 5:51:47141 days ago1722750707
Kyber: Proxy
0.0004 ETH
204530482024-08-04 5:18:35141 days ago1722748715
Kyber: Proxy
0.00056894 ETH
204530332024-08-04 5:15:35141 days ago1722748535
Kyber: Proxy
0.00036734 ETH
204530082024-08-04 5:10:35141 days ago1722748235
Kyber: Proxy
0.000004 ETH
204529392024-08-04 4:56:47141 days ago1722747407
Kyber: Proxy
0.0001 ETH
204528442024-08-04 4:37:47141 days ago1722746267
Kyber: Proxy
0.00040681 ETH
204528322024-08-04 4:35:23141 days ago1722746123
Kyber: Proxy
0.004 ETH
204527222024-08-04 4:13:23141 days ago1722744803
Kyber: Proxy
0.00040681 ETH
204519152024-08-04 1:31:35141 days ago1722735095
Kyber: Proxy
0.00115 ETH
204517882024-08-04 1:05:59141 days ago1722733559
Kyber: Proxy
0.00482407 ETH
204477072024-08-03 11:26:23141 days ago1722684383
Kyber: Proxy
0.00000001 ETH
204090832024-07-29 1:57:35147 days ago1722218255
Kyber: Proxy
0.04 ETH
204090782024-07-29 1:56:35147 days ago1722218195
Kyber: Proxy
0.00637182 ETH
204085422024-07-29 0:08:59147 days ago1722211739
Kyber: Proxy
0.007116 ETH
204085282024-07-29 0:06:11147 days ago1722211571
Kyber: Proxy
0.00045257 ETH
204083162024-07-28 23:23:35147 days ago1722209015
Kyber: Proxy
0.00129738 ETH
201938282024-06-29 0:41:11177 days ago1719621671
Kyber: Proxy
0.00114539 ETH
199172912024-05-21 9:08:47216 days ago1716282527
Kyber: Proxy
1.55320231 ETH
199172912024-05-21 9:08:47216 days ago1716282527
Kyber: Proxy
1.55320231 ETH
179811852023-08-24 1:07:59487 days ago1692839279
Kyber: Proxy
1 wei
179811852023-08-24 1:07:59487 days ago1692839279
Kyber: Proxy
1 wei
179811852023-08-24 1:07:59487 days ago1692839279
Kyber: Proxy
1 wei
179811852023-08-24 1:07:59487 days ago1692839279
Kyber: Proxy
1 wei
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xC14f3423...AB1B4947D
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
KyberNetworkProxy

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 2018-07-03
*/

pragma solidity 0.4.18;

// File: contracts/ERC20Interface.sol

// https://github.com/ethereum/EIPs/issues/20
interface ERC20 {
    function totalSupply() public view returns (uint supply);
    function balanceOf(address _owner) public view returns (uint balance);
    function transfer(address _to, uint _value) public returns (bool success);
    function transferFrom(address _from, address _to, uint _value) public returns (bool success);
    function approve(address _spender, uint _value) public returns (bool success);
    function allowance(address _owner, address _spender) public view returns (uint remaining);
    function decimals() public view returns(uint digits);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
}

// File: contracts/KyberNetworkInterface.sol

/// @title Kyber Network interface
interface KyberNetworkInterface {
    function maxGasPrice() public view returns(uint);
    function getUserCapInWei(address user) public view returns(uint);
    function getUserCapInTokenWei(address user, ERC20 token) public view returns(uint);
    function enabled() public view returns(bool);
    function info(bytes32 id) public view returns(uint);

    function getExpectedRate(ERC20 src, ERC20 dest, uint srcQty) public view
        returns (uint expectedRate, uint slippageRate);

    function tradeWithHint(address trader, ERC20 src, uint srcAmount, ERC20 dest, address destAddress,
        uint maxDestAmount, uint minConversionRate, address walletId, bytes hint) public payable returns(uint);
}

// File: contracts/KyberNetworkProxyInterface.sol

/// @title Kyber Network interface
interface KyberNetworkProxyInterface {
    function maxGasPrice() public view returns(uint);
    function getUserCapInWei(address user) public view returns(uint);
    function getUserCapInTokenWei(address user, ERC20 token) public view returns(uint);
    function enabled() public view returns(bool);
    function info(bytes32 id) public view returns(uint);

    function getExpectedRate(ERC20 src, ERC20 dest, uint srcQty) public view
        returns (uint expectedRate, uint slippageRate);

    function tradeWithHint(ERC20 src, uint srcAmount, ERC20 dest, address destAddress, uint maxDestAmount,
        uint minConversionRate, address walletId, bytes hint) public payable returns(uint);
}

// File: contracts/SimpleNetworkInterface.sol

/// @title simple interface for Kyber Network 
interface SimpleNetworkInterface {
    function swapTokenToToken(ERC20 src, uint srcAmount, ERC20 dest, uint minConversionRate) public returns(uint);
    function swapEtherToToken(ERC20 token, uint minConversionRate) public payable returns(uint);
    function swapTokenToEther(ERC20 token, uint srcAmount, uint minConversionRate) public returns(uint);
}

// File: contracts/Utils.sol

/// @title Kyber constants contract
contract Utils {

    ERC20 constant internal ETH_TOKEN_ADDRESS = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee);
    uint  constant internal PRECISION = (10**18);
    uint  constant internal MAX_QTY   = (10**28); // 10B tokens
    uint  constant internal MAX_RATE  = (PRECISION * 10**6); // up to 1M tokens per ETH
    uint  constant internal MAX_DECIMALS = 18;
    uint  constant internal ETH_DECIMALS = 18;
    mapping(address=>uint) internal decimals;

    function setDecimals(ERC20 token) internal {
        if (token == ETH_TOKEN_ADDRESS) decimals[token] = ETH_DECIMALS;
        else decimals[token] = token.decimals();
    }

    function getDecimals(ERC20 token) internal view returns(uint) {
        if (token == ETH_TOKEN_ADDRESS) return ETH_DECIMALS; // save storage access
        uint tokenDecimals = decimals[token];
        // technically, there might be token with decimals 0
        // moreover, very possible that old tokens have decimals 0
        // these tokens will just have higher gas fees.
        if(tokenDecimals == 0) return token.decimals();

        return tokenDecimals;
    }

    function calcDstQty(uint srcQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) {
        require(srcQty <= MAX_QTY);
        require(rate <= MAX_RATE);

        if (dstDecimals >= srcDecimals) {
            require((dstDecimals - srcDecimals) <= MAX_DECIMALS);
            return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION;
        } else {
            require((srcDecimals - dstDecimals) <= MAX_DECIMALS);
            return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals)));
        }
    }

    function calcSrcQty(uint dstQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) {
        require(dstQty <= MAX_QTY);
        require(rate <= MAX_RATE);
        
        //source quantity is rounded up. to avoid dest quantity being too low.
        uint numerator;
        uint denominator;
        if (srcDecimals >= dstDecimals) {
            require((srcDecimals - dstDecimals) <= MAX_DECIMALS);
            numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals)));
            denominator = rate;
        } else {
            require((dstDecimals - srcDecimals) <= MAX_DECIMALS);
            numerator = (PRECISION * dstQty);
            denominator = (rate * (10**(dstDecimals - srcDecimals)));
        }
        return (numerator + denominator - 1) / denominator; //avoid rounding down errors
    }
}

// File: contracts/Utils2.sol

contract Utils2 is Utils {

    /// @dev get the balance of a user.
    /// @param token The token type
    /// @return The balance
    function getBalance(ERC20 token, address user) public view returns(uint) {
        if (token == ETH_TOKEN_ADDRESS)
            return user.balance;
        else
            return token.balanceOf(user);
    }

    function getDecimalsSafe(ERC20 token) internal returns(uint) {

        if (decimals[token] == 0) {
            setDecimals(token);
        }

        return decimals[token];
    }

    function calcDestAmount(ERC20 src, ERC20 dest, uint srcAmount, uint rate) internal view returns(uint) {
        return calcDstQty(srcAmount, getDecimals(src), getDecimals(dest), rate);
    }

    function calcSrcAmount(ERC20 src, ERC20 dest, uint destAmount, uint rate) internal view returns(uint) {
        return calcSrcQty(destAmount, getDecimals(src), getDecimals(dest), rate);
    }

    function calcRateFromQty(uint srcAmount, uint destAmount, uint srcDecimals, uint dstDecimals)
        internal pure returns(uint)
    {
        require(srcAmount <= MAX_QTY);
        require(destAmount <= MAX_QTY);

        if (dstDecimals >= srcDecimals) {
            require((dstDecimals - srcDecimals) <= MAX_DECIMALS);
            return (destAmount * PRECISION / ((10 ** (dstDecimals - srcDecimals)) * srcAmount));
        } else {
            require((srcDecimals - dstDecimals) <= MAX_DECIMALS);
            return (destAmount * PRECISION * (10 ** (srcDecimals - dstDecimals)) / srcAmount);
        }
    }
}

// File: contracts/PermissionGroups.sol

contract PermissionGroups {

    address public admin;
    address public pendingAdmin;
    mapping(address=>bool) internal operators;
    mapping(address=>bool) internal alerters;
    address[] internal operatorsGroup;
    address[] internal alertersGroup;
    uint constant internal MAX_GROUP_SIZE = 50;

    function PermissionGroups() public {
        admin = msg.sender;
    }

    modifier onlyAdmin() {
        require(msg.sender == admin);
        _;
    }

    modifier onlyOperator() {
        require(operators[msg.sender]);
        _;
    }

    modifier onlyAlerter() {
        require(alerters[msg.sender]);
        _;
    }

    function getOperators () external view returns(address[]) {
        return operatorsGroup;
    }

    function getAlerters () external view returns(address[]) {
        return alertersGroup;
    }

    event TransferAdminPending(address pendingAdmin);

    /**
     * @dev Allows the current admin to set the pendingAdmin address.
     * @param newAdmin The address to transfer ownership to.
     */
    function transferAdmin(address newAdmin) public onlyAdmin {
        require(newAdmin != address(0));
        TransferAdminPending(pendingAdmin);
        pendingAdmin = newAdmin;
    }

    /**
     * @dev Allows the current admin to set the admin in one tx. Useful initial deployment.
     * @param newAdmin The address to transfer ownership to.
     */
    function transferAdminQuickly(address newAdmin) public onlyAdmin {
        require(newAdmin != address(0));
        TransferAdminPending(newAdmin);
        AdminClaimed(newAdmin, admin);
        admin = newAdmin;
    }

    event AdminClaimed( address newAdmin, address previousAdmin);

    /**
     * @dev Allows the pendingAdmin address to finalize the change admin process.
     */
    function claimAdmin() public {
        require(pendingAdmin == msg.sender);
        AdminClaimed(pendingAdmin, admin);
        admin = pendingAdmin;
        pendingAdmin = address(0);
    }

    event AlerterAdded (address newAlerter, bool isAdd);

    function addAlerter(address newAlerter) public onlyAdmin {
        require(!alerters[newAlerter]); // prevent duplicates.
        require(alertersGroup.length < MAX_GROUP_SIZE);

        AlerterAdded(newAlerter, true);
        alerters[newAlerter] = true;
        alertersGroup.push(newAlerter);
    }

    function removeAlerter (address alerter) public onlyAdmin {
        require(alerters[alerter]);
        alerters[alerter] = false;

        for (uint i = 0; i < alertersGroup.length; ++i) {
            if (alertersGroup[i] == alerter) {
                alertersGroup[i] = alertersGroup[alertersGroup.length - 1];
                alertersGroup.length--;
                AlerterAdded(alerter, false);
                break;
            }
        }
    }

    event OperatorAdded(address newOperator, bool isAdd);

    function addOperator(address newOperator) public onlyAdmin {
        require(!operators[newOperator]); // prevent duplicates.
        require(operatorsGroup.length < MAX_GROUP_SIZE);

        OperatorAdded(newOperator, true);
        operators[newOperator] = true;
        operatorsGroup.push(newOperator);
    }

    function removeOperator (address operator) public onlyAdmin {
        require(operators[operator]);
        operators[operator] = false;

        for (uint i = 0; i < operatorsGroup.length; ++i) {
            if (operatorsGroup[i] == operator) {
                operatorsGroup[i] = operatorsGroup[operatorsGroup.length - 1];
                operatorsGroup.length -= 1;
                OperatorAdded(operator, false);
                break;
            }
        }
    }
}

// File: contracts/Withdrawable.sol

/**
 * @title Contracts that should be able to recover tokens or ethers
 * @author Ilan Doron
 * @dev This allows to recover any tokens or Ethers received in a contract.
 * This will prevent any accidental loss of tokens.
 */
contract Withdrawable is PermissionGroups {

    event TokenWithdraw(ERC20 token, uint amount, address sendTo);

    /**
     * @dev Withdraw all ERC20 compatible tokens
     * @param token ERC20 The address of the token contract
     */
    function withdrawToken(ERC20 token, uint amount, address sendTo) external onlyAdmin {
        require(token.transfer(sendTo, amount));
        TokenWithdraw(token, amount, sendTo);
    }

    event EtherWithdraw(uint amount, address sendTo);

    /**
     * @dev Withdraw Ethers
     */
    function withdrawEther(uint amount, address sendTo) external onlyAdmin {
        sendTo.transfer(amount);
        EtherWithdraw(amount, sendTo);
    }
}

// File: contracts/KyberNetworkProxy.sol

////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @title Kyber Network proxy for main contract
contract KyberNetworkProxy is KyberNetworkProxyInterface, SimpleNetworkInterface, Withdrawable, Utils2 {

    KyberNetworkInterface public kyberNetworkContract;

    function KyberNetworkProxy(address _admin) public {
        require(_admin != address(0));
        admin = _admin;
    }

    /// @notice use token address ETH_TOKEN_ADDRESS for ether
    /// @dev makes a trade between src and dest token and send dest token to destAddress
    /// @param src Src token
    /// @param srcAmount amount of src tokens
    /// @param dest   Destination token
    /// @param destAddress Address to send tokens to
    /// @param maxDestAmount A limit on the amount of dest tokens
    /// @param minConversionRate The minimal conversion rate. If actual rate is lower, trade is canceled.
    /// @param walletId is the wallet ID to send part of the fees
    /// @return amount of actual dest tokens
    function trade(
        ERC20 src,
        uint srcAmount,
        ERC20 dest,
        address destAddress,
        uint maxDestAmount,
        uint minConversionRate,
        address walletId
    )
        public
        payable
        returns(uint)
    {
        bytes memory hint;

        return tradeWithHint(
            src,
            srcAmount,
            dest,
            destAddress,
            maxDestAmount,
            minConversionRate,
            walletId,
            hint
        );
    }

    /// @dev makes a trade between src and dest token and send dest tokens to msg sender
    /// @param src Src token
    /// @param srcAmount amount of src tokens
    /// @param dest Destination token
    /// @param minConversionRate The minimal conversion rate. If actual rate is lower, trade is canceled.
    /// @return amount of actual dest tokens
    function swapTokenToToken(
        ERC20 src,
        uint srcAmount,
        ERC20 dest,
        uint minConversionRate
    )
        public
        returns(uint)
    {
        bytes memory hint;

        return tradeWithHint(
            src,
            srcAmount,
            dest,
            msg.sender,
            MAX_QTY,
            minConversionRate,
            0,
            hint
        );
    }

    /// @dev makes a trade from Ether to token. Sends token to msg sender
    /// @param token Destination token
    /// @param minConversionRate The minimal conversion rate. If actual rate is lower, trade is canceled.
    /// @return amount of actual dest tokens
    function swapEtherToToken(ERC20 token, uint minConversionRate) public payable returns(uint) {
        bytes memory hint;

        return tradeWithHint(
            ETH_TOKEN_ADDRESS,
            msg.value,
            token,
            msg.sender,
            MAX_QTY,
            minConversionRate,
            0,
            hint
        );
    }

    /// @dev makes a trade from token to Ether, sends Ether to msg sender
    /// @param token Src token
    /// @param srcAmount amount of src tokens
    /// @param minConversionRate The minimal conversion rate. If actual rate is lower, trade is canceled.
    /// @return amount of actual dest tokens
    function swapTokenToEther(ERC20 token, uint srcAmount, uint minConversionRate) public returns(uint) {
        bytes memory hint;

        return tradeWithHint(
            token,
            srcAmount,
            ETH_TOKEN_ADDRESS,
            msg.sender,
            MAX_QTY,
            minConversionRate,
            0,
            hint
        );
    }

    struct UserBalance {
        uint srcBalance;
        uint destBalance;
    }

    event ExecuteTrade(address indexed trader, ERC20 src, ERC20 dest, uint actualSrcAmount, uint actualDestAmount);

    /// @notice use token address ETH_TOKEN_ADDRESS for ether
    /// @dev makes a trade between src and dest token and send dest token to destAddress
    /// @param src Src token
    /// @param srcAmount amount of src tokens
    /// @param dest Destination token
    /// @param destAddress Address to send tokens to
    /// @param maxDestAmount A limit on the amount of dest tokens
    /// @param minConversionRate The minimal conversion rate. If actual rate is lower, trade is canceled.
    /// @param walletId is the wallet ID to send part of the fees
    /// @param hint will give hints for the trade.
    /// @return amount of actual dest tokens
    function tradeWithHint(
        ERC20 src,
        uint srcAmount,
        ERC20 dest,
        address destAddress,
        uint maxDestAmount,
        uint minConversionRate,
        address walletId,
        bytes hint
    )
        public
        payable
        returns(uint)
    {
        require(src == ETH_TOKEN_ADDRESS || msg.value == 0);
        
        UserBalance memory userBalanceBefore;

        userBalanceBefore.srcBalance = getBalance(src, msg.sender);
        userBalanceBefore.destBalance = getBalance(dest, destAddress);

        if (src == ETH_TOKEN_ADDRESS) {
            userBalanceBefore.srcBalance += msg.value;
        } else {
            require(src.transferFrom(msg.sender, kyberNetworkContract, srcAmount));
        }

        uint reportedDestAmount = kyberNetworkContract.tradeWithHint.value(msg.value)(
            msg.sender,
            src,
            srcAmount,
            dest,
            destAddress,
            maxDestAmount,
            minConversionRate,
            walletId,
            hint
        );

        TradeOutcome memory tradeOutcome = calculateTradeOutcome(
            userBalanceBefore.srcBalance,
            userBalanceBefore.destBalance,
            src,
            dest,
            destAddress
        );

        require(reportedDestAmount == tradeOutcome.userDeltaDestAmount);
        require(tradeOutcome.userDeltaDestAmount <= maxDestAmount);
        require(tradeOutcome.actualRate >= minConversionRate);

        ExecuteTrade(msg.sender, src, dest, tradeOutcome.userDeltaSrcAmount, tradeOutcome.userDeltaDestAmount);
        return tradeOutcome.userDeltaDestAmount;
    }

    event KyberNetworkSet(address newNetworkContract, address oldNetworkContract);

    function setKyberNetworkContract(KyberNetworkInterface _kyberNetworkContract) public onlyAdmin {

        require(_kyberNetworkContract != address(0));

        KyberNetworkSet(_kyberNetworkContract, kyberNetworkContract);

        kyberNetworkContract = _kyberNetworkContract;
    }

    function getExpectedRate(ERC20 src, ERC20 dest, uint srcQty)
        public view
        returns(uint expectedRate, uint slippageRate)
    {
        return kyberNetworkContract.getExpectedRate(src, dest, srcQty);
    }

    function getUserCapInWei(address user) public view returns(uint) {
        return kyberNetworkContract.getUserCapInWei(user);
    }

    function getUserCapInTokenWei(address user, ERC20 token) public view returns(uint) {
        return kyberNetworkContract.getUserCapInTokenWei(user, token);
    }

    function maxGasPrice() public view returns(uint) {
        return kyberNetworkContract.maxGasPrice();
    }

    function enabled() public view returns(bool) {
        return kyberNetworkContract.enabled();
    }

    function info(bytes32 field) public view returns(uint) {
        return kyberNetworkContract.info(field);
    }

    struct TradeOutcome {
        uint userDeltaSrcAmount;
        uint userDeltaDestAmount;
        uint actualRate;
    }

    function calculateTradeOutcome (uint srcBalanceBefore, uint destBalanceBefore, ERC20 src, ERC20 dest,
        address destAddress)
        internal returns(TradeOutcome outcome)
    {
        uint userSrcBalanceAfter;
        uint userDestBalanceAfter;

        userSrcBalanceAfter = getBalance(src, msg.sender);
        userDestBalanceAfter = getBalance(dest, destAddress);

        //protect from underflow
        require(userDestBalanceAfter > destBalanceBefore);
        require(srcBalanceBefore > userSrcBalanceAfter);

        outcome.userDeltaDestAmount = userDestBalanceAfter - destBalanceBefore;
        outcome.userDeltaSrcAmount = srcBalanceBefore - userSrcBalanceAfter;

        outcome.actualRate = calcRateFromQty(
                outcome.userDeltaSrcAmount,
                outcome.userDeltaDestAmount,
                getDecimalsSafe(src),
                getDecimalsSafe(dest)
            );
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"alerter","type":"address"}],"name":"removeAlerter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"enabled","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingAdmin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getOperators","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"srcAmount","type":"uint256"},{"name":"dest","type":"address"},{"name":"destAddress","type":"address"},{"name":"maxDestAmount","type":"uint256"},{"name":"minConversionRate","type":"uint256"},{"name":"walletId","type":"address"},{"name":"hint","type":"bytes"}],"name":"tradeWithHint","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"srcAmount","type":"uint256"},{"name":"minConversionRate","type":"uint256"}],"name":"swapTokenToEther","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"amount","type":"uint256"},{"name":"sendTo","type":"address"}],"name":"withdrawToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxGasPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newAlerter","type":"address"}],"name":"addAlerter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"kyberNetworkContract","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"user","type":"address"}],"name":"getUserCapInWei","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"srcAmount","type":"uint256"},{"name":"dest","type":"address"},{"name":"minConversionRate","type":"uint256"}],"name":"swapTokenToToken","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"claimAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"minConversionRate","type":"uint256"}],"name":"swapEtherToToken","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"newAdmin","type":"address"}],"name":"transferAdminQuickly","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getAlerters","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"dest","type":"address"},{"name":"srcQty","type":"uint256"}],"name":"getExpectedRate","outputs":[{"name":"expectedRate","type":"uint256"},{"name":"slippageRate","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"user","type":"address"},{"name":"token","type":"address"}],"name":"getUserCapInTokenWei","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOperator","type":"address"}],"name":"addOperator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_kyberNetworkContract","type":"address"}],"name":"setKyberNetworkContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"operator","type":"address"}],"name":"removeOperator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"field","type":"bytes32"}],"name":"info","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"srcAmount","type":"uint256"},{"name":"dest","type":"address"},{"name":"destAddress","type":"address"},{"name":"maxDestAmount","type":"uint256"},{"name":"minConversionRate","type":"uint256"},{"name":"walletId","type":"address"}],"name":"trade","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"},{"name":"sendTo","type":"address"}],"name":"withdrawEther","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"token","type":"address"},{"name":"user","type":"address"}],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_admin","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"trader","type":"address"},{"indexed":false,"name":"src","type":"address"},{"indexed":false,"name":"dest","type":"address"},{"indexed":false,"name":"actualSrcAmount","type":"uint256"},{"indexed":false,"name":"actualDestAmount","type":"uint256"}],"name":"ExecuteTrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newNetworkContract","type":"address"},{"indexed":false,"name":"oldNetworkContract","type":"address"}],"name":"KyberNetworkSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"token","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"sendTo","type":"address"}],"name":"TokenWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"sendTo","type":"address"}],"name":"EtherWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"pendingAdmin","type":"address"}],"name":"TransferAdminPending","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newAdmin","type":"address"},{"indexed":false,"name":"previousAdmin","type":"address"}],"name":"AdminClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newAlerter","type":"address"},{"indexed":false,"name":"isAdd","type":"bool"}],"name":"AlerterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newOperator","type":"address"},{"indexed":false,"name":"isAdd","type":"bool"}],"name":"OperatorAdded","type":"event"}]

Deployed Bytecode

0x6060604052600436106101455763ffffffff60e060020a60003504166301a12fd3811461014a578063238dafe01461016b578063267822471461019257806327a099d8146101c157806329589f61146102275780633bba21dc146102ad5780633ccdbb28146102d25780633de39c11146102fb578063408ee7fe1461030e5780634f61ff8b1461032d5780636432679f146103405780637409e2eb1461035f57806375829def1461038b57806377f50f97146103aa5780637a2a0456146103bd5780637acc8678146103d45780637c423f54146103f3578063809a9e55146104065780638eaaeecf146104465780639870d7fe1461046b578063abd188a81461048a578063ac8a584a146104a9578063b64a097e146104c8578063cb3c28c7146104de578063ce56c45414610510578063d4fac45d14610532578063f851a44014610557575b600080fd5b341561015557600080fd5b610169600160a060020a036004351661056a565b005b341561017657600080fd5b61017e6106da565b604051901515815260200160405180910390f35b341561019d57600080fd5b6101a5610744565b604051600160a060020a03909116815260200160405180910390f35b34156101cc57600080fd5b6101d4610753565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156102135780820151838201526020016101fb565b505050509050019250505060405180910390f35b61029b600160a060020a036004803582169160248035926044358316926064358116926084359260a4359260c43516916101049060e43590810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496506107bb95505050505050565b60405190815260200160405180910390f35b34156102b857600080fd5b61029b600160a060020a0360043516602435604435610ad9565b34156102dd57600080fd5b610169600160a060020a036004358116906024359060443516610b1d565b341561030657600080fd5b61029b610c14565b341561031957600080fd5b610169600160a060020a0360043516610c5e565b341561033857600080fd5b6101a5610d5a565b341561034b57600080fd5b61029b600160a060020a0360043516610d69565b341561036a57600080fd5b61029b600160a060020a036004358116906024359060443516606435610de4565b341561039657600080fd5b610169600160a060020a0360043516610e15565b34156103b557600080fd5b610169610eb0565b61029b600160a060020a0360043516602435610f4a565b34156103df57600080fd5b610169600160a060020a0360043516610f8d565b34156103fe57600080fd5b6101d461106f565b341561041157600080fd5b61042e600160a060020a03600435811690602435166044356110d5565b60405191825260208201526040908101905180910390f35b341561045157600080fd5b61029b600160a060020a0360043581169060243516611171565b341561047657600080fd5b610169600160a060020a03600435166111f7565b341561049557600080fd5b610169600160a060020a03600435166112c7565b34156104b457600080fd5b610169600160a060020a036004351661136c565b34156104d357600080fd5b61029b6004356114d8565b61029b600160a060020a03600435811690602435906044358116906064358116906084359060a4359060c4351661152b565b341561051b57600080fd5b610169600435600160a060020a0360243516611552565b341561053d57600080fd5b61029b600160a060020a03600435811690602435166115e5565b341561056257600080fd5b6101a5611696565b6000805433600160a060020a0390811691161461058657600080fd5b600160a060020a03821660009081526003602052604090205460ff1615156105ad57600080fd5b50600160a060020a0381166000908152600360205260408120805460ff191690555b6005548110156106d65781600160a060020a03166005828154811015156105f257fe5b600091825260209091200154600160a060020a031614156106ce5760058054600019810190811061061f57fe5b60009182526020909120015460058054600160a060020a03909216918390811061064557fe5b60009182526020909120018054600160a060020a031916600160a060020a039290921691909117905560058054906106819060001983016118c1565b507f5611bf3e417d124f97bf2c788843ea8bb502b66079fbee02158ef30b172cb762826000604051600160a060020a039092168252151560208201526040908101905180910390a16106d6565b6001016105cf565b5050565b600754600090600160a060020a031663238dafe082604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561072457600080fd5b6102c65a03f1151561073557600080fd5b50505060405180519150505b90565b600154600160a060020a031681565b61075b6118ea565b60048054806020026020016040519081016040528092919081815260200182805480156107b157602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610793575b5050505050905090565b60006107c56118fc565b60006107cf611913565b600160a060020a038c1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14806107f8575034155b151561080357600080fd5b61080d8c336115e5565b83526108198a8a6115e5565b6020840152600160a060020a038c1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610851573483818151019052506108e8565b600754600160a060020a03808e16916323b872dd913391168e60006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156108c257600080fd5b6102c65a03f115156108d357600080fd5b5050506040518051905015156108e857600080fd5b600754600160a060020a031663088322ef34338f8f8f8f8f8f8f8f60006040516020015260405160e060020a63ffffffff8d16028152600160a060020a03808b16600483019081528a82166024840152604483018a90528882166064840152878216608484015260a4830187905260c4830186905290841660e4830152610120610104830190815290916101240183818151815260200191508051906020019080838360005b838110156109a657808201518382015260200161098e565b50505050905090810190601f1680156109d35780820380516001836020036101000a031916815260200191505b509a50505050505050505050506020604051808303818588803b15156109f857600080fd5b6125ee5a03f11515610a0957600080fd5b5050505060405180519250610a289050835184602001518e8d8d6116a5565b905080602001518214610a3a57600080fd5b8781602001511115610a4b57600080fd5b8681604001511015610a5c57600080fd5b600160a060020a0333167f1849bd6a030a1bca28b83437fd3de96f3d27a5d172fa7e9c78e7b61468928a398d8c84518560200151604051600160a060020a0394851681529290931660208301526040808301919091526060820192909252608001905180910390a280602001519c9b505050505050505050505050565b6000610ae36118ea565b610b14858573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee336b204fce5e3e25026110000000886000886107bb565b95945050505050565b60005433600160a060020a03908116911614610b3857600080fd5b82600160a060020a031663a9059cbb828460006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610b9557600080fd5b6102c65a03f11515610ba657600080fd5b505050604051805190501515610bbb57600080fd5b7f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e6838383604051600160a060020a03938416815260208101929092529091166040808301919091526060909101905180910390a1505050565b600754600090600160a060020a0316633de39c1182604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561072457600080fd5b60005433600160a060020a03908116911614610c7957600080fd5b600160a060020a03811660009081526003602052604090205460ff1615610c9f57600080fd5b60055460329010610caf57600080fd5b7f5611bf3e417d124f97bf2c788843ea8bb502b66079fbee02158ef30b172cb762816001604051600160a060020a039092168252151560208201526040908101905180910390a1600160a060020a0381166000908152600360205260409020805460ff191660019081179091556005805490918101610d2e83826118c1565b5060009182526020909120018054600160a060020a031916600160a060020a0392909216919091179055565b600754600160a060020a031681565b600754600090600160a060020a0316636432679f83836040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610dc457600080fd5b6102c65a03f11515610dd557600080fd5b50505060405180519392505050565b6000610dee6118ea565b610e0b868686336b204fce5e3e25026110000000886000886107bb565b9695505050505050565b60005433600160a060020a03908116911614610e3057600080fd5b600160a060020a0381161515610e4557600080fd5b6001547f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc4090600160a060020a0316604051600160a060020a03909116815260200160405180910390a160018054600160a060020a031916600160a060020a0392909216919091179055565b60015433600160a060020a03908116911614610ecb57600080fd5b6001546000547f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed91600160a060020a039081169116604051600160a060020a039283168152911660208201526040908101905180910390a16001805460008054600160a060020a0319908116600160a060020a03841617909155169055565b6000610f546118ea565b610f8573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee3486336b204fce5e3e25026110000000886000886107bb565b949350505050565b60005433600160a060020a03908116911614610fa857600080fd5b600160a060020a0381161515610fbd57600080fd5b7f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc4081604051600160a060020a03909116815260200160405180910390a16000547f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed908290600160a060020a0316604051600160a060020a039283168152911660208201526040908101905180910390a160008054600160a060020a031916600160a060020a0392909216919091179055565b6110776118ea565b60058054806020026020016040519081016040528092919081815260200182805480156107b157602002820191906000526020600020908154600160a060020a03168152600190910190602001808311610793575050505050905090565b6007546000908190600160a060020a031663809a9e55868686856040516040015260405160e060020a63ffffffff8616028152600160a060020a03938416600482015291909216602482015260448101919091526064016040805180830381600087803b151561114457600080fd5b6102c65a03f1151561115557600080fd5b5050506040518051906020018051905091509150935093915050565b600754600090600160a060020a0316638eaaeecf8484846040516020015260405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b15156111d457600080fd5b6102c65a03f115156111e557600080fd5b50505060405180519150505b92915050565b60005433600160a060020a0390811691161461121257600080fd5b600160a060020a03811660009081526002602052604090205460ff161561123857600080fd5b6004546032901061124857600080fd5b7f091a7a4b85135fdd7e8dbc18b12fabe5cc191ea867aa3c2e1a24a102af61d58b816001604051600160a060020a039092168252151560208201526040908101905180910390a1600160a060020a0381166000908152600260205260409020805460ff191660019081179091556004805490918101610d2e83826118c1565b60005433600160a060020a039081169116146112e257600080fd5b600160a060020a03811615156112f757600080fd5b6007547f8936e1f096bf0a8c9df862b3d1d5b82774cad78116200175f00b5b7ba3010b02908290600160a060020a0316604051600160a060020a039283168152911660208201526040908101905180910390a160078054600160a060020a031916600160a060020a0392909216919091179055565b6000805433600160a060020a0390811691161461138857600080fd5b600160a060020a03821660009081526002602052604090205460ff1615156113af57600080fd5b50600160a060020a0381166000908152600260205260408120805460ff191690555b6004548110156106d65781600160a060020a03166004828154811015156113f457fe5b600091825260209091200154600160a060020a031614156114d05760048054600019810190811061142157fe5b60009182526020909120015460048054600160a060020a03909216918390811061144757fe5b60009182526020909120018054600160a060020a031916600160a060020a039290921691909117905560048054600019019061148390826118c1565b507f091a7a4b85135fdd7e8dbc18b12fabe5cc191ea867aa3c2e1a24a102af61d58b826000604051600160a060020a039092168252151560208201526040908101905180910390a16106d6565b6001016113d1565b600754600090600160a060020a031663b64a097e83836040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610dc457600080fd5b60006115356118ea565b61154589898989898989886107bb565b9998505050505050505050565b60005433600160a060020a0390811691161461156d57600080fd5b600160a060020a03811682156108fc0283604051600060405180830381858888f19350505050151561159e57600080fd5b7fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de8282604051918252600160a060020a031660208201526040908101905180910390a15050565b6000600160a060020a03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561161d5750600160a060020a038116316111f1565b82600160a060020a03166370a082318360006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561167457600080fd5b6102c65a03f1151561168557600080fd5b5050506040518051905090506111f1565b600054600160a060020a031681565b6116ad611913565b6000806116ba86336115e5565b91506116c685856115e5565b90508681116116d457600080fd5b8188116116e057600080fd5b8681036020840152818803835261170e835184602001516117008961171f565b6117098961171f565b611763565b604084015250909695505050505050565b600160a060020a038116600090815260066020526040812054151561174757611747826117fe565b50600160a060020a031660009081526006602052604090205490565b60006b204fce5e3e2502611000000085111561177e57600080fd5b6b204fce5e3e2502611000000084111561179757600080fd5b8282106117d257601283830311156117ae57600080fd5b84838303600a0a02670de0b6b3a764000085028115156117ca57fe5b049050610f85565b601282840311156117e257600080fd5b84828403600a0a670de0b6b3a76400008602028115156117ca57fe5b600160a060020a03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561184457600160a060020a0381166000908152600660205260409020601290556118be565b80600160a060020a031663313ce5676000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561188a57600080fd5b6102c65a03f1151561189b57600080fd5b5050506040518051600160a060020a038316600090815260066020526040902055505b50565b8154818355818115116118e5576000838152602090206118e5918101908301611935565b505050565b60206040519081016040526000815290565b604080519081016040526000808252602082015290565b6060604051908101604052806000815260200160008152602001600081525090565b61074191905b8082111561194f576000815560010161193b565b50905600a165627a7a72305820ae71dd6239f7d143bf7d308b1a1ca8ad767ca7ae5966d3c0dd1f98a64bd45b2f0029

Swarm Source

bzzr://ae71dd6239f7d143bf7d308b1a1ca8ad767ca7ae5966d3c0dd1f98a64bd45b2f

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.