Contract Overview
Balance: 0.01 Ether
Ether Value: $1.77 (@ $176.94/ETH)
Transactions: 3 txns
Misc:
Address Watch: Add To Watch List
Contract Creator: 0xaebbd80fd7dae979d965a3a5b09bbcd23eb40e5fat txn 0x94060e89fd4f801766eb9f4274d0a13ffa733711f1ed814abf5f9de3edffcf05
Token Balance:
 Latest 3 txns

TxHash Age From To Value [TxFee]
0x87bb2a50f088dd6e52c211e8fa7d5cab19b33a704aeb4e711679a8e993512ed692 days 14 hrs ago0xaebbd80fd7dae979d965a3a5b09bbcd23eb40e5f  IN   0x286a090b31462890cd9bf9f167b610ed8aa8bd1a0 Ether0.000049416
0x60f5f8d2aa385e3f4961feed814da65c26c78342c648182db97db86a7bad5c55128 days 7 hrs ago0xaebbd80fd7dae979d965a3a5b09bbcd23eb40e5f  IN   0x286a090b31462890cd9bf9f167b610ed8aa8bd1a0.01 Ether0.0002104
0x94060e89fd4f801766eb9f4274d0a13ffa733711f1ed814abf5f9de3edffcf05128 days 7 hrs ago0xaebbd80fd7dae979d965a3a5b09bbcd23eb40e5f  IN    Contract Creation0 Ether0.006106474
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
View All
ParentTxHash Block Age From To Value
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 Text: 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;
}

// ----------------------------------------------------------------------------
// This is an automated token exchange. It lets you buy and sell a specific token for Ethereum.
// The more eth in the contract the higher the token price, the more tokens in the contract
// the lower the token price. The formula is the same as for Ether Shrimp Farm.
// There are no fees except gas cost.
// ----------------------------------------------------------------------------

contract AutomatedExchange is ApproveAndCallFallBack{

    uint256 PSN=100000000000000;
    uint256 PSNH=50000000000000;
    address tokenAddress=0x841D34aF2018D9487199678eDd47Dd46B140690B;
    ERC20Interface tokenContract=ERC20Interface(tokenAddress);
    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==tokenAddress);
        uint256 tokenValue=calculateTokenSell(tokens);
        tokenContract.transferFrom(from,this,tokens);
        from.transfer(tokenValue);
    }
    function buyTokens() public payable{
        uint256 tokensBought=calculateTokenBuy(msg.value,SafeMath.sub(this.balance,msg.value));
        tokenContract.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,tokenContract.balanceOf(this),this.balance);
    }
    function calculateTokenBuy(uint256 eth,uint256 contractBalance) public view returns(uint256){
        return calculateTrade(eth,contractBalance,tokenContract.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 tokenContract.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
6080604052655af3107a4000600055652d79883d200060015560028054600160a060020a031990811673841d34af2018d9487199678edd47dd46b140690b179182905560038054909116600160a060020a039290921691909117905534801561006757600080fd5b50610640806100776000396000f30060806040526004361061008d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166312065fe0811461008f578063229824c4146100b657806382b2e257146100d45780638ebb5aee146100e95780638f4ffcb11461010457806393d5825e14610174578063d0febe4c1461018c578063f49e813514610194575b005b34801561009b57600080fd5b506100a46101ac565b60408051918252519081900360200190f35b3480156100c257600080fd5b506100a46004356024356044356101b1565b3480156100e057600080fd5b506100a46101fe565b3480156100f557600080fd5b506100a4600435602435610294565b34801561011057600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261008d94600160a060020a038135811695602480359660443590931695369560849492019181908401838280828437509497506103399650505050505050565b34801561018057600080fd5b506100a460043561043d565b61008d6104e4565b3480156101a057600080fd5b506100a4600435610599565b303190565b60006101f66101c2600054846105a6565b6101f16001546101e66101eb6101da6000548a6105a6565b6101e66001548c6105a6565b6105dc565b896105eb565b6105eb565b949350505050565b600354604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561026357600080fd5b505af1158015610277573d6000803e3d6000fd5b505050506040513d602081101561028d57600080fd5b5051905090565b600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000926103329286928692600160a060020a0316916370a0823191602480830192602092919082900301818a87803b15801561030157600080fd5b505af1158015610315573d6000803e3d6000fd5b505050506040513d602081101561032b57600080fd5b50516101b1565b9392505050565b600254600090600160a060020a0316331461035357600080fd5b61035c8461043d565b600354604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301523060248301526044820189905291519394509116916323b872dd916064808201926020929091908290030181600087803b1580156103d357600080fd5b505af11580156103e7573d6000803e3d6000fd5b505050506040513d60208110156103fd57600080fd5b5050604051600160a060020a0386169082156108fc029083906000818181858888f19350505050158015610435573d6000803e3d6000fd5b505050505050565b600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000926104de928592600160a060020a03909216916370a082319160248082019260209290919082900301818987803b1580156104ab57600080fd5b505af11580156104bf573d6000803e3d6000fd5b505050506040513d60208110156104d557600080fd5b505130316101b1565b92915050565b60006104fa346104f5303182610602565b610294565b600354604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018490529051929350600160a060020a039091169163a9059cbb916044808201926020929091908290030181600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b505050506040513d602081101561059457600080fd5b505050565b60006104de823031610294565b6000808315156105b957600091506105d5565b508282028284828115156105c957fe5b04146105d157fe5b8091505b5092915050565b6000828201838110156105d157fe5b60008082848115156105f957fe5b04949350505050565b60008282111561060e57fe5b509003905600a165627a7a723058204d14017ad8111c8b0c940018cb7cf1b980c4f6830d3de46ee01a3f45da2e6db70029

   Swarm Source:
bzzr://4d14017ad8111c8b0c940018cb7cf1b980c4f6830d3de46ee01a3f45da2e6db7

 

View All
Block Age transaction Difficulty GasUsed Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.