Contract Overview
Balance: 3.586 Ether
Transactions: 4 txns
 Latest 4 txns

TxHash Age From To Value [TxFee]
0x75dfeec0e214f9f8260bf0bbcd6b239a3a3ddbe3ba781645df73354ff0e1acad132 days 3 hrs ago0x5479a9ec6386db424b563ef059fc127042543a5d  IN   0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.5 Ether0.000056636
0x2233164ba9585a668fd7ac01a89c87e857fd65d33a7193e827914f2a2ac17c44221 days 22 hrs ago0x95096780efd48fa66483bc197677e89f37ca0cb5  IN   0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e81 Ether0.00079908
0x82b417b5184483fd40e1df5ce07f9794ce7a42cc7a9933ff5d5a2de95501a70b223 days 17 hrs ago0xaebbd80fd7dae979d965a3a5b09bbcd23eb40e5f  IN   0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.01 Ether0.0001052
0x79c6b9472d8de4eb64b0ba764c78fc8002fc7dad5047d826f72f3717b649e659223 days 17 hrs ago0xaebbd80fd7dae979d965a3a5b09bbcd23eb40e5f  IN    Contract Creation0 Ether0.00277565
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 25 Internal Txns, Click here To View More View All
ParentTxHash Block Age From To Value
0x75dfeec0e214f9f8260bf0bbcd6b239a3a3ddbe3ba781645df73354ff0e1acad4200788132 days 3 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0x75dfeec0e214f9f8260bf0bbcd6b239a3a3ddbe3ba781645df73354ff0e1acad4200788132 days 3 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xaf4e4d450fa37f1821e77833f38964cfb416ad316c473a8f32a0af998216afa54200530132 days 4 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xaf4e4d450fa37f1821e77833f38964cfb416ad316c473a8f32a0af998216afa54200530132 days 4 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xaf4e4d450fa37f1821e77833f38964cfb416ad316c473a8f32a0af998216afa54200530132 days 4 hrs ago0xc097039c5dfcc4081d5310e85d9a589c019225bd0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.5 Ether
0x14a43212dc3458b183309c90bcd9b11bb279cbc4f344a4b5d645dbe9de30c6e54200215132 days 5 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0x14a43212dc3458b183309c90bcd9b11bb279cbc4f344a4b5d645dbe9de30c6e54200215132 days 5 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0x14a43212dc3458b183309c90bcd9b11bb279cbc4f344a4b5d645dbe9de30c6e54200215132 days 5 hrs ago0xc097039c5dfcc4081d5310e85d9a589c019225bd0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.01 Ether
0x5d9f0cb5a8c966901ada8b595091ddf49020879f3fe48d52fedba2451b279ed04197577132 days 16 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0x5d9f0cb5a8c966901ada8b595091ddf49020879f3fe48d52fedba2451b279ed04197577132 days 16 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0x5d9f0cb5a8c966901ada8b595091ddf49020879f3fe48d52fedba2451b279ed04197577132 days 16 hrs ago0xc097039c5dfcc4081d5310e85d9a589c019225bd0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e81 Ether
0x9b3ac37e8092aa5c30460de5219f5549ddfd739993c7814fdbc292f9dea0c6824196553132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0x9b3ac37e8092aa5c30460de5219f5549ddfd739993c7814fdbc292f9dea0c6824196553132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0x9b3ac37e8092aa5c30460de5219f5549ddfd739993c7814fdbc292f9dea0c6824196553132 days 21 hrs ago0x9f4603fd43dae86deb22a0bf6a19d80e88fddd850x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.001 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x9f4603fd43dae86deb22a0bf6a19d80e88fddd850x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.002 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x9f4603fd43dae86deb22a0bf6a19d80e88fddd850x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.002 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x9f4603fd43dae86deb22a0bf6a19d80e88fddd850x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80.002 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
0xb3a45975501b8993d0f90290e2ed18b8843cdd20ece824ddac54ebe39ecee0104196496132 days 21 hrs ago0x3f48ad253d25ac0be2e357a9ebfed72313c4a9e80x00d348ba1303df186568a972e8a753125118c5760 Ether
[ Download CSV Export  ] 
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: AutomatedExchange
Compiler Version: v0.4.24+commit.e67f0147
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.18; // solhint-disable-line



// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
// ----------------------------------------------------------------------------
contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address tokenOwner) public constant returns (uint balance);
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);

    event Transfer(address indexed from, address indexed to, uint tokens);
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}

contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}

contract AutomatedExchange is ApproveAndCallFallBack{

    uint256 PSN=100000000000000;
    uint256 PSNH=50000000000000;
    address vrfAddress=0x00d348bA1303DF186568A972e8A753125118c576;
    ERC20Interface vrfcontract=ERC20Interface(vrfAddress);
    function AutomatedExchange() public{
    }
    //Tokens are sold by sending them to this contract with ApproveAndCall
    function receiveApproval(address from, uint256 tokens, address token, bytes data) public{
        //only allow this to be called from the token contract
        require(msg.sender==vrfAddress);
        uint256 tokenValue=calculateTokenSell(tokens);
        vrfcontract.transferFrom(from,this,tokens);
        from.transfer(tokenValue);
    }
    function buyTokens() public payable{
        uint256 tokensBought=calculateTokenBuy(msg.value,SafeMath.sub(this.balance,msg.value));
        vrfcontract.transfer(msg.sender,tokensBought);
    }
    //magic trade balancing algorithm
    function calculateTrade(uint256 rt,uint256 rs, uint256 bs) public view returns(uint256){
        //(PSN*bs)/(PSNH+((PSN*rs+PSNH*rt)/rt));
        return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt)));
    }
    function calculateTokenSell(uint256 tokens) public view returns(uint256){
        return calculateTrade(tokens,vrfcontract.balanceOf(this),this.balance);
    }
    function calculateTokenBuy(uint256 eth,uint256 contractBalance) public view returns(uint256){
        return calculateTrade(eth,contractBalance,vrfcontract.balanceOf(this));
    }
    function calculateTokenBuySimple(uint256 eth) public view returns(uint256){
        return calculateTokenBuy(eth,this.balance);
    }

    //allow sending eth to the contract
    function () public payable {}

    function getBalance() public view returns(uint256){
        return this.balance;
    }
    function getTokenBalance() public view returns(uint256){
        return vrfcontract.balanceOf(this);
    }
    function min(uint256 a, uint256 b) private pure returns (uint256) {
        return a < b ? a : b;
    }
}

library SafeMath {

  /**
  * @dev Multiplies two numbers, throws on overflow.
  */
  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    if (a == 0) {
      return 0;
    }
    uint256 c = a * b;
    assert(c / a == b);
    return c;
  }

  /**
  * @dev Integer division of two numbers, truncating the quotient.
  */
  function div(uint256 a, uint256 b) internal pure returns (uint256) {
    // assert(b > 0); // Solidity automatically throws when dividing by 0
    uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
  }

  /**
  * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
  */
  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
  }

  /**
  * @dev Adds two numbers, throws on overflow.
  */
  function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    assert(c >= a);
    return c;
  }
}

    Contract ABI  
[{"constant":true,"inputs":[],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"rt","type":"uint256"},{"name":"rs","type":"uint256"},{"name":"bs","type":"uint256"}],"name":"calculateTrade","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getTokenBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"eth","type":"uint256"},{"name":"contractBalance","type":"uint256"}],"name":"calculateTokenBuy","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"tokens","type":"uint256"},{"name":"token","type":"address"},{"name":"data","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"tokens","type":"uint256"}],"name":"calculateTokenSell","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"buyTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"eth","type":"uint256"}],"name":"calculateTokenBuySimple","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"}]

  Contract Creation Code Switch To Opcodes View
6080604052655af3107a4000600055652d79883d200060015560028054600160a060020a031990811672d348ba1303df186568a972e8a753125118c576179182905560038054909116600160a060020a039290921691909117905534801561006657600080fd5b50610640806100766000396000f30060806040526004361061008d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166312065fe0811461008f578063229824c4146100b657806382b2e257146100d45780638ebb5aee146100e95780638f4ffcb11461010457806393d5825e14610174578063d0febe4c1461018c578063f49e813514610194575b005b34801561009b57600080fd5b506100a46101ac565b60408051918252519081900360200190f35b3480156100c257600080fd5b506100a46004356024356044356101b1565b3480156100e057600080fd5b506100a46101fe565b3480156100f557600080fd5b506100a4600435602435610294565b34801561011057600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261008d94600160a060020a038135811695602480359660443590931695369560849492019181908401838280828437509497506103399650505050505050565b34801561018057600080fd5b506100a460043561043d565b61008d6104e4565b3480156101a057600080fd5b506100a4600435610599565b303190565b60006101f66101c2600054846105a6565b6101f16001546101e66101eb6101da6000548a6105a6565b6101e66001548c6105a6565b6105dc565b896105eb565b6105eb565b949350505050565b600354604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561026357600080fd5b505af1158015610277573d6000803e3d6000fd5b505050506040513d602081101561028d57600080fd5b5051905090565b600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000926103329286928692600160a060020a0316916370a0823191602480830192602092919082900301818a87803b15801561030157600080fd5b505af1158015610315573d6000803e3d6000fd5b505050506040513d602081101561032b57600080fd5b50516101b1565b9392505050565b600254600090600160a060020a0316331461035357600080fd5b61035c8461043d565b600354604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301523060248301526044820189905291519394509116916323b872dd916064808201926020929091908290030181600087803b1580156103d357600080fd5b505af11580156103e7573d6000803e3d6000fd5b505050506040513d60208110156103fd57600080fd5b5050604051600160a060020a0386169082156108fc029083906000818181858888f19350505050158015610435573d6000803e3d6000fd5b505050505050565b600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000926104de928592600160a060020a03909216916370a082319160248082019260209290919082900301818987803b1580156104ab57600080fd5b505af11580156104bf573d6000803e3d6000fd5b505050506040513d60208110156104d557600080fd5b505130316101b1565b92915050565b60006104fa346104f5303182610602565b610294565b600354604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018490529051929350600160a060020a039091169163a9059cbb916044808201926020929091908290030181600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b505050506040513d602081101561059457600080fd5b505050565b60006104de823031610294565b6000808315156105b957600091506105d5565b508282028284828115156105c957fe5b04146105d157fe5b8091505b5092915050565b6000828201838110156105d157fe5b60008082848115156105f957fe5b04949350505050565b60008282111561060e57fe5b509003905600a165627a7a72305820808d64d117b2af6a5165e07413bf3a88707420c123550eab1ce8391a05cd5b180029

   Swarm Source:
bzzr://808d64d117b2af6a5165e07413bf3a88707420c123550eab1ce8391a05cd5b18

 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward