ETH Price: $2,516.89 (-0.13%)

Transaction Decoder

Block:
10361848 at Jun-29-2020 04:40:03 PM +UTC
Transaction Fee:
0.006497232 ETH $16.35
Gas Used:
154,696 Gas / 42 Gwei

Account State Difference:

  Address   Before After State Difference Code
(Mining Express)
80.535059205731309286 Eth80.541556437731309286 Eth0.006497232
0xc1758EEa...92845188a
0.020537890333749486 Eth
Nonce: 7243
0.014040658333749486 Eth
Nonce: 7244
0.006497232

Execution Trace

Vyper_contract.tokenToTokenSwapInput( tokens_sold=5927310461473902956329, min_tokens_bought=6822239795855254371616, min_eth_bought=1, deadline=1593449699, token_addr=0xa12BD9d0f059349055a3Dc4e38833171B4ad2A35 )
  • Vyper_contract.tokenToTokenSwapInput( tokens_sold=5927310461473902956329, min_tokens_bought=6822239795855254371616, min_eth_bought=1, deadline=1593449699, token_addr=0xa12BD9d0f059349055a3Dc4e38833171B4ad2A35 )
    • Vyper_contract.getExchange( token=0xa12BD9d0f059349055a3Dc4e38833171B4ad2A35 ) => ( out=0xB807e5b53f26e67062FD2185DBdf1B77Fb799797 )
    • H3X.balanceOf( _user=0x86FAF3BC431E42b708dCF479ce766a403cbfd07c ) => ( 12466951139884192667139664 )
    • H3X.transferFrom( _from=0xc1758EEa027f8D92e6ddd13d17e19E592845188a, _to=0x86FAF3BC431E42b708dCF479ce766a403cbfd07c, _tokens=5927310461473902956329 ) => ( True )
    • ETH 0.036167765544901172 Vyper_contract.ethToTokenTransferInput( min_tokens=6822239795855254371616, deadline=1593449699, recipient=0xc1758EEa027f8D92e6ddd13d17e19E592845188a )
      • ETH 0.036167765544901172 Vyper_contract.ethToTokenTransferInput( min_tokens=6822239795855254371616, deadline=1593449699, recipient=0xc1758EEa027f8D92e6ddd13d17e19E592845188a )
        • PoWM.balanceOf( _user=0xB807e5b53f26e67062FD2185DBdf1B77Fb799797 ) => ( 2063179451367340690904907 )
          File 1 of 6: Vyper_contract
          # @title Uniswap Exchange Interface V1
          # @notice Source code found at https://github.com/uniswap
          # @notice Use at your own risk
          
          contract Factory():
              def getExchange(token_addr: address) -> address: constant
          
          contract Exchange():
              def getEthToTokenOutputPrice(tokens_bought: uint256) -> uint256(wei): constant
              def ethToTokenTransferInput(min_tokens: uint256, deadline: timestamp, recipient: address) -> uint256: modifying
              def ethToTokenTransferOutput(tokens_bought: uint256, deadline: timestamp, recipient: address) -> uint256(wei): modifying
          
          TokenPurchase: event({buyer: indexed(address), eth_sold: indexed(uint256(wei)), tokens_bought: indexed(uint256)})
          EthPurchase: event({buyer: indexed(address), tokens_sold: indexed(uint256), eth_bought: indexed(uint256(wei))})
          AddLiquidity: event({provider: indexed(address), eth_amount: indexed(uint256(wei)), token_amount: indexed(uint256)})
          RemoveLiquidity: event({provider: indexed(address), eth_amount: indexed(uint256(wei)), token_amount: indexed(uint256)})
          Transfer: event({_from: indexed(address), _to: indexed(address), _value: uint256})
          Approval: event({_owner: indexed(address), _spender: indexed(address), _value: uint256})
          
          name: public(bytes32)                             # Uniswap V1
          symbol: public(bytes32)                           # UNI-V1
          decimals: public(uint256)                         # 18
          totalSupply: public(uint256)                      # total number of UNI in existence
          balances: uint256[address]                        # UNI balance of an address
          allowances: (uint256[address])[address]           # UNI allowance of one address on another
          token: address(ERC20)                             # address of the ERC20 token traded on this contract
          factory: Factory                                  # interface for the factory that created this contract
          
          # @dev This function acts as a contract constructor which is not currently supported in contracts deployed
          #      using create_with_code_of(). It is called once by the factory during contract creation.
          @public
          def setup(token_addr: address):
              assert (self.factory == ZERO_ADDRESS and self.token == ZERO_ADDRESS) and token_addr != ZERO_ADDRESS
              self.factory = msg.sender
              self.token = token_addr
              self.name = 0x556e697377617020563100000000000000000000000000000000000000000000
              self.symbol = 0x554e492d56310000000000000000000000000000000000000000000000000000
              self.decimals = 18
          
          # @notice Deposit ETH and Tokens (self.token) at current ratio to mint UNI tokens.
          # @dev min_liquidity does nothing when total UNI supply is 0.
          # @param min_liquidity Minimum number of UNI sender will mint if total UNI supply is greater than 0.
          # @param max_tokens Maximum number of tokens deposited. Deposits max amount if total UNI supply is 0.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return The amount of UNI minted.
          @public
          @payable
          def addLiquidity(min_liquidity: uint256, max_tokens: uint256, deadline: timestamp) -> uint256:
              assert deadline > block.timestamp and (max_tokens > 0 and msg.value > 0)
              total_liquidity: uint256 = self.totalSupply
              if total_liquidity > 0:
                  assert min_liquidity > 0
                  eth_reserve: uint256(wei) = self.balance - msg.value
                  token_reserve: uint256 = self.token.balanceOf(self)
                  token_amount: uint256 = msg.value * token_reserve / eth_reserve + 1
                  liquidity_minted: uint256 = msg.value * total_liquidity / eth_reserve
                  assert max_tokens >= token_amount and liquidity_minted >= min_liquidity
                  self.balances[msg.sender] += liquidity_minted
                  self.totalSupply = total_liquidity + liquidity_minted
                  assert self.token.transferFrom(msg.sender, self, token_amount)
                  log.AddLiquidity(msg.sender, msg.value, token_amount)
                  log.Transfer(ZERO_ADDRESS, msg.sender, liquidity_minted)
                  return liquidity_minted
              else:
                  assert (self.factory != ZERO_ADDRESS and self.token != ZERO_ADDRESS) and msg.value >= 1000000000
                  assert self.factory.getExchange(self.token) == self
                  token_amount: uint256 = max_tokens
                  initial_liquidity: uint256 = as_unitless_number(self.balance)
                  self.totalSupply = initial_liquidity
                  self.balances[msg.sender] = initial_liquidity
                  assert self.token.transferFrom(msg.sender, self, token_amount)
                  log.AddLiquidity(msg.sender, msg.value, token_amount)
                  log.Transfer(ZERO_ADDRESS, msg.sender, initial_liquidity)
                  return initial_liquidity
          
          # @dev Burn UNI tokens to withdraw ETH and Tokens at current ratio.
          # @param amount Amount of UNI burned.
          # @param min_eth Minimum ETH withdrawn.
          # @param min_tokens Minimum Tokens withdrawn.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return The amount of ETH and Tokens withdrawn.
          @public
          def removeLiquidity(amount: uint256, min_eth: uint256(wei), min_tokens: uint256, deadline: timestamp) -> (uint256(wei), uint256):
              assert (amount > 0 and deadline > block.timestamp) and (min_eth > 0 and min_tokens > 0)
              total_liquidity: uint256 = self.totalSupply
              assert total_liquidity > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_amount: uint256(wei) = amount * self.balance / total_liquidity
              token_amount: uint256 = amount * token_reserve / total_liquidity
              assert eth_amount >= min_eth and token_amount >= min_tokens
              self.balances[msg.sender] -= amount
              self.totalSupply = total_liquidity - amount
              send(msg.sender, eth_amount)
              assert self.token.transfer(msg.sender, token_amount)
              log.RemoveLiquidity(msg.sender, eth_amount, token_amount)
              log.Transfer(msg.sender, ZERO_ADDRESS, amount)
              return eth_amount, token_amount
          
          # @dev Pricing function for converting between ETH and Tokens.
          # @param input_amount Amount of ETH or Tokens being sold.
          # @param input_reserve Amount of ETH or Tokens (input type) in exchange reserves.
          # @param output_reserve Amount of ETH or Tokens (output type) in exchange reserves.
          # @return Amount of ETH or Tokens bought.
          @private
          @constant
          def getInputPrice(input_amount: uint256, input_reserve: uint256, output_reserve: uint256) -> uint256:
              assert input_reserve > 0 and output_reserve > 0
              input_amount_with_fee: uint256 = input_amount * 997
              numerator: uint256 = input_amount_with_fee * output_reserve
              denominator: uint256 = (input_reserve * 1000) + input_amount_with_fee
              return numerator / denominator
          
          # @dev Pricing function for converting between ETH and Tokens.
          # @param output_amount Amount of ETH or Tokens being bought.
          # @param input_reserve Amount of ETH or Tokens (input type) in exchange reserves.
          # @param output_reserve Amount of ETH or Tokens (output type) in exchange reserves.
          # @return Amount of ETH or Tokens sold.
          @private
          @constant
          def getOutputPrice(output_amount: uint256, input_reserve: uint256, output_reserve: uint256) -> uint256:
              assert input_reserve > 0 and output_reserve > 0
              numerator: uint256 = input_reserve * output_amount * 1000
              denominator: uint256 = (output_reserve - output_amount) * 997
              return numerator / denominator + 1
          
          @private
          def ethToTokenInput(eth_sold: uint256(wei), min_tokens: uint256, deadline: timestamp, buyer: address, recipient: address) -> uint256:
              assert deadline >= block.timestamp and (eth_sold > 0 and min_tokens > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_bought: uint256 = self.getInputPrice(as_unitless_number(eth_sold), as_unitless_number(self.balance - eth_sold), token_reserve)
              assert tokens_bought >= min_tokens
              assert self.token.transfer(recipient, tokens_bought)
              log.TokenPurchase(buyer, eth_sold, tokens_bought)
              return tokens_bought
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies exact input (msg.value).
          # @dev User cannot specify minimum output or deadline.
          @public
          @payable
          def __default__():
              self.ethToTokenInput(msg.value, 1, block.timestamp, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies exact input (msg.value) and minimum output.
          # @param min_tokens Minimum Tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of Tokens bought.
          @public
          @payable
          def ethToTokenSwapInput(min_tokens: uint256, deadline: timestamp) -> uint256:
              return self.ethToTokenInput(msg.value, min_tokens, deadline, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens and transfers Tokens to recipient.
          # @dev User specifies exact input (msg.value) and minimum output
          # @param min_tokens Minimum Tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output Tokens.
          # @return Amount of Tokens bought.
          @public
          @payable
          def ethToTokenTransferInput(min_tokens: uint256, deadline: timestamp, recipient: address) -> uint256:
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.ethToTokenInput(msg.value, min_tokens, deadline, msg.sender, recipient)
          
          @private
          def ethToTokenOutput(tokens_bought: uint256, max_eth: uint256(wei), deadline: timestamp, buyer: address, recipient: address) -> uint256(wei):
              assert deadline >= block.timestamp and (tokens_bought > 0 and max_eth > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_sold: uint256 = self.getOutputPrice(tokens_bought, as_unitless_number(self.balance - max_eth), token_reserve)
              # Throws if eth_sold > max_eth
              eth_refund: uint256(wei) = max_eth - as_wei_value(eth_sold, 'wei')
              if eth_refund > 0:
                  send(buyer, eth_refund)
              assert self.token.transfer(recipient, tokens_bought)
              log.TokenPurchase(buyer, as_wei_value(eth_sold, 'wei'), tokens_bought)
              return as_wei_value(eth_sold, 'wei')
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies maximum input (msg.value) and exact output.
          # @param tokens_bought Amount of tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of ETH sold.
          @public
          @payable
          def ethToTokenSwapOutput(tokens_bought: uint256, deadline: timestamp) -> uint256(wei):
              return self.ethToTokenOutput(tokens_bought, msg.value, deadline, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens and transfers Tokens to recipient.
          # @dev User specifies maximum input (msg.value) and exact output.
          # @param tokens_bought Amount of tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output Tokens.
          # @return Amount of ETH sold.
          @public
          @payable
          def ethToTokenTransferOutput(tokens_bought: uint256, deadline: timestamp, recipient: address) -> uint256(wei):
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.ethToTokenOutput(tokens_bought, msg.value, deadline, msg.sender, recipient)
          
          @private
          def tokenToEthInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp, buyer: address, recipient: address) -> uint256(wei):
              assert deadline >= block.timestamp and (tokens_sold > 0 and min_eth > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              wei_bought: uint256(wei) = as_wei_value(eth_bought, 'wei')
              assert wei_bought >= min_eth
              send(recipient, wei_bought)
              assert self.token.transferFrom(buyer, self, tokens_sold)
              log.EthPurchase(buyer, tokens_sold, wei_bought)
              return wei_bought
          
          
          # @notice Convert Tokens to ETH.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_eth Minimum ETH purchased.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of ETH bought.
          @public
          def tokenToEthSwapInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp) -> uint256(wei):
              return self.tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, msg.sender)
          
          # @notice Convert Tokens to ETH and transfers ETH to recipient.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_eth Minimum ETH purchased.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @return Amount of ETH bought.
          @public
          def tokenToEthTransferInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp, recipient: address) -> uint256(wei):
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, recipient)
          
          @private
          def tokenToEthOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp, buyer: address, recipient: address) -> uint256:
              assert deadline >= block.timestamp and eth_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_sold: uint256 = self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
              # tokens sold is always > 0
              assert max_tokens >= tokens_sold
              send(recipient, eth_bought)
              assert self.token.transferFrom(buyer, self, tokens_sold)
              log.EthPurchase(buyer, tokens_sold, eth_bought)
              return tokens_sold
          
          # @notice Convert Tokens to ETH.
          # @dev User specifies maximum input and exact output.
          # @param eth_bought Amount of ETH purchased.
          # @param max_tokens Maximum Tokens sold.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of Tokens sold.
          @public
          def tokenToEthSwapOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp) -> uint256:
              return self.tokenToEthOutput(eth_bought, max_tokens, deadline, msg.sender, msg.sender)
          
          # @notice Convert Tokens to ETH and transfers ETH to recipient.
          # @dev User specifies maximum input and exact output.
          # @param eth_bought Amount of ETH purchased.
          # @param max_tokens Maximum Tokens sold.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @return Amount of Tokens sold.
          @public
          def tokenToEthTransferOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp, recipient: address) -> uint256:
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.tokenToEthOutput(eth_bought, max_tokens, deadline, msg.sender, recipient)
          
          @private
          def tokenToTokenInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, buyer: address, recipient: address, exchange_addr: address) -> uint256:
              assert (deadline >= block.timestamp and tokens_sold > 0) and (min_tokens_bought > 0 and min_eth_bought > 0)
              assert exchange_addr != self and exchange_addr != ZERO_ADDRESS
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              wei_bought: uint256(wei) = as_wei_value(eth_bought, 'wei')
              assert wei_bought >= min_eth_bought
              assert self.token.transferFrom(buyer, self, tokens_sold)
              tokens_bought: uint256 = Exchange(exchange_addr).ethToTokenTransferInput(min_tokens_bought, deadline, recipient, value=wei_bought)
              log.EthPurchase(buyer, tokens_sold, wei_bought)
              return tokens_bought
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr).
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (token_addr) bought.
          @public
          def tokenToTokenSwapInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr) and transfers
          #         Tokens (token_addr) to recipient.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (token_addr) bought.
          @public
          def tokenToTokenTransferInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, recipient: address, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, recipient, exchange_addr)
          
          @private
          def tokenToTokenOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, buyer: address, recipient: address, exchange_addr: address) -> uint256:
              assert deadline >= block.timestamp and (tokens_bought > 0 and max_eth_sold > 0)
              assert exchange_addr != self and exchange_addr != ZERO_ADDRESS
              eth_bought: uint256(wei) = Exchange(exchange_addr).getEthToTokenOutputPrice(tokens_bought)
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_sold: uint256 = self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
              # tokens sold is always > 0
              assert max_tokens_sold >= tokens_sold and max_eth_sold >= eth_bought
              assert self.token.transferFrom(buyer, self, tokens_sold)
              eth_sold: uint256(wei) = Exchange(exchange_addr).ethToTokenTransferOutput(tokens_bought, deadline, recipient, value=eth_bought)
              log.EthPurchase(buyer, tokens_sold, eth_bought)
              return tokens_sold
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr).
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToTokenSwapOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr) and transfers
          #         Tokens (token_addr) to recipient.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToTokenTransferOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, recipient: address, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token).
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (exchange_addr.token) bought.
          @public
          def tokenToExchangeSwapInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, exchange_addr: address) -> uint256:
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token) and transfers
          #         Tokens (exchange_addr.token) to recipient.
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (exchange_addr.token) bought.
          @public
          def tokenToExchangeTransferInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, recipient: address, exchange_addr: address) -> uint256:
              assert recipient != self
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token).
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToExchangeSwapOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, exchange_addr: address) -> uint256:
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token) and transfers
          #         Tokens (exchange_addr.token) to recipient.
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToExchangeTransferOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, recipient: address, exchange_addr: address) -> uint256:
              assert recipient != self
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Public price function for ETH to Token trades with an exact input.
          # @param eth_sold Amount of ETH sold.
          # @return Amount of Tokens that can be bought with input ETH.
          @public
          @constant
          def getEthToTokenInputPrice(eth_sold: uint256(wei)) -> uint256:
              assert eth_sold > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              return self.getInputPrice(as_unitless_number(eth_sold), as_unitless_number(self.balance), token_reserve)
          
          # @notice Public price function for ETH to Token trades with an exact output.
          # @param tokens_bought Amount of Tokens bought.
          # @return Amount of ETH needed to buy output Tokens.
          @public
          @constant
          def getEthToTokenOutputPrice(tokens_bought: uint256) -> uint256(wei):
              assert tokens_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_sold: uint256 = self.getOutputPrice(tokens_bought, as_unitless_number(self.balance), token_reserve)
              return as_wei_value(eth_sold, 'wei')
          
          # @notice Public price function for Token to ETH trades with an exact input.
          # @param tokens_sold Amount of Tokens sold.
          # @return Amount of ETH that can be bought with input Tokens.
          @public
          @constant
          def getTokenToEthInputPrice(tokens_sold: uint256) -> uint256(wei):
              assert tokens_sold > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              return as_wei_value(eth_bought, 'wei')
          
          # @notice Public price function for Token to ETH trades with an exact output.
          # @param eth_bought Amount of output ETH.
          # @return Amount of Tokens needed to buy output ETH.
          @public
          @constant
          def getTokenToEthOutputPrice(eth_bought: uint256(wei)) -> uint256:
              assert eth_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              return self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
          
          # @return Address of Token that is sold on this exchange.
          @public
          @constant
          def tokenAddress() -> address:
              return self.token
          
          # @return Address of factory that created this exchange.
          @public
          @constant
          def factoryAddress() -> address(Factory):
              return self.factory
          
          # ERC20 compatibility for exchange liquidity modified from
          # https://github.com/ethereum/vyper/blob/master/examples/tokens/ERC20.vy
          @public
          @constant
          def balanceOf(_owner : address) -> uint256:
              return self.balances[_owner]
          
          @public
          def transfer(_to : address, _value : uint256) -> bool:
              self.balances[msg.sender] -= _value
              self.balances[_to] += _value
              log.Transfer(msg.sender, _to, _value)
              return True
          
          @public
          def transferFrom(_from : address, _to : address, _value : uint256) -> bool:
              self.balances[_from] -= _value
              self.balances[_to] += _value
              self.allowances[_from][msg.sender] -= _value
              log.Transfer(_from, _to, _value)
              return True
          
          @public
          def approve(_spender : address, _value : uint256) -> bool:
              self.allowances[msg.sender][_spender] = _value
              log.Approval(msg.sender, _spender, _value)
              return True
          
          @public
          @constant
          def allowance(_owner : address, _spender : address) -> uint256:
              return self.allowances[_owner][_spender]

          File 2 of 6: Vyper_contract
          # @title Uniswap Exchange Interface V1
          # @notice Source code found at https://github.com/uniswap
          # @notice Use at your own risk
          
          contract Factory():
              def getExchange(token_addr: address) -> address: constant
          
          contract Exchange():
              def getEthToTokenOutputPrice(tokens_bought: uint256) -> uint256(wei): constant
              def ethToTokenTransferInput(min_tokens: uint256, deadline: timestamp, recipient: address) -> uint256: modifying
              def ethToTokenTransferOutput(tokens_bought: uint256, deadline: timestamp, recipient: address) -> uint256(wei): modifying
          
          TokenPurchase: event({buyer: indexed(address), eth_sold: indexed(uint256(wei)), tokens_bought: indexed(uint256)})
          EthPurchase: event({buyer: indexed(address), tokens_sold: indexed(uint256), eth_bought: indexed(uint256(wei))})
          AddLiquidity: event({provider: indexed(address), eth_amount: indexed(uint256(wei)), token_amount: indexed(uint256)})
          RemoveLiquidity: event({provider: indexed(address), eth_amount: indexed(uint256(wei)), token_amount: indexed(uint256)})
          Transfer: event({_from: indexed(address), _to: indexed(address), _value: uint256})
          Approval: event({_owner: indexed(address), _spender: indexed(address), _value: uint256})
          
          name: public(bytes32)                             # Uniswap V1
          symbol: public(bytes32)                           # UNI-V1
          decimals: public(uint256)                         # 18
          totalSupply: public(uint256)                      # total number of UNI in existence
          balances: uint256[address]                        # UNI balance of an address
          allowances: (uint256[address])[address]           # UNI allowance of one address on another
          token: address(ERC20)                             # address of the ERC20 token traded on this contract
          factory: Factory                                  # interface for the factory that created this contract
          
          # @dev This function acts as a contract constructor which is not currently supported in contracts deployed
          #      using create_with_code_of(). It is called once by the factory during contract creation.
          @public
          def setup(token_addr: address):
              assert (self.factory == ZERO_ADDRESS and self.token == ZERO_ADDRESS) and token_addr != ZERO_ADDRESS
              self.factory = msg.sender
              self.token = token_addr
              self.name = 0x556e697377617020563100000000000000000000000000000000000000000000
              self.symbol = 0x554e492d56310000000000000000000000000000000000000000000000000000
              self.decimals = 18
          
          # @notice Deposit ETH and Tokens (self.token) at current ratio to mint UNI tokens.
          # @dev min_liquidity does nothing when total UNI supply is 0.
          # @param min_liquidity Minimum number of UNI sender will mint if total UNI supply is greater than 0.
          # @param max_tokens Maximum number of tokens deposited. Deposits max amount if total UNI supply is 0.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return The amount of UNI minted.
          @public
          @payable
          def addLiquidity(min_liquidity: uint256, max_tokens: uint256, deadline: timestamp) -> uint256:
              assert deadline > block.timestamp and (max_tokens > 0 and msg.value > 0)
              total_liquidity: uint256 = self.totalSupply
              if total_liquidity > 0:
                  assert min_liquidity > 0
                  eth_reserve: uint256(wei) = self.balance - msg.value
                  token_reserve: uint256 = self.token.balanceOf(self)
                  token_amount: uint256 = msg.value * token_reserve / eth_reserve + 1
                  liquidity_minted: uint256 = msg.value * total_liquidity / eth_reserve
                  assert max_tokens >= token_amount and liquidity_minted >= min_liquidity
                  self.balances[msg.sender] += liquidity_minted
                  self.totalSupply = total_liquidity + liquidity_minted
                  assert self.token.transferFrom(msg.sender, self, token_amount)
                  log.AddLiquidity(msg.sender, msg.value, token_amount)
                  log.Transfer(ZERO_ADDRESS, msg.sender, liquidity_minted)
                  return liquidity_minted
              else:
                  assert (self.factory != ZERO_ADDRESS and self.token != ZERO_ADDRESS) and msg.value >= 1000000000
                  assert self.factory.getExchange(self.token) == self
                  token_amount: uint256 = max_tokens
                  initial_liquidity: uint256 = as_unitless_number(self.balance)
                  self.totalSupply = initial_liquidity
                  self.balances[msg.sender] = initial_liquidity
                  assert self.token.transferFrom(msg.sender, self, token_amount)
                  log.AddLiquidity(msg.sender, msg.value, token_amount)
                  log.Transfer(ZERO_ADDRESS, msg.sender, initial_liquidity)
                  return initial_liquidity
          
          # @dev Burn UNI tokens to withdraw ETH and Tokens at current ratio.
          # @param amount Amount of UNI burned.
          # @param min_eth Minimum ETH withdrawn.
          # @param min_tokens Minimum Tokens withdrawn.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return The amount of ETH and Tokens withdrawn.
          @public
          def removeLiquidity(amount: uint256, min_eth: uint256(wei), min_tokens: uint256, deadline: timestamp) -> (uint256(wei), uint256):
              assert (amount > 0 and deadline > block.timestamp) and (min_eth > 0 and min_tokens > 0)
              total_liquidity: uint256 = self.totalSupply
              assert total_liquidity > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_amount: uint256(wei) = amount * self.balance / total_liquidity
              token_amount: uint256 = amount * token_reserve / total_liquidity
              assert eth_amount >= min_eth and token_amount >= min_tokens
              self.balances[msg.sender] -= amount
              self.totalSupply = total_liquidity - amount
              send(msg.sender, eth_amount)
              assert self.token.transfer(msg.sender, token_amount)
              log.RemoveLiquidity(msg.sender, eth_amount, token_amount)
              log.Transfer(msg.sender, ZERO_ADDRESS, amount)
              return eth_amount, token_amount
          
          # @dev Pricing function for converting between ETH and Tokens.
          # @param input_amount Amount of ETH or Tokens being sold.
          # @param input_reserve Amount of ETH or Tokens (input type) in exchange reserves.
          # @param output_reserve Amount of ETH or Tokens (output type) in exchange reserves.
          # @return Amount of ETH or Tokens bought.
          @private
          @constant
          def getInputPrice(input_amount: uint256, input_reserve: uint256, output_reserve: uint256) -> uint256:
              assert input_reserve > 0 and output_reserve > 0
              input_amount_with_fee: uint256 = input_amount * 997
              numerator: uint256 = input_amount_with_fee * output_reserve
              denominator: uint256 = (input_reserve * 1000) + input_amount_with_fee
              return numerator / denominator
          
          # @dev Pricing function for converting between ETH and Tokens.
          # @param output_amount Amount of ETH or Tokens being bought.
          # @param input_reserve Amount of ETH or Tokens (input type) in exchange reserves.
          # @param output_reserve Amount of ETH or Tokens (output type) in exchange reserves.
          # @return Amount of ETH or Tokens sold.
          @private
          @constant
          def getOutputPrice(output_amount: uint256, input_reserve: uint256, output_reserve: uint256) -> uint256:
              assert input_reserve > 0 and output_reserve > 0
              numerator: uint256 = input_reserve * output_amount * 1000
              denominator: uint256 = (output_reserve - output_amount) * 997
              return numerator / denominator + 1
          
          @private
          def ethToTokenInput(eth_sold: uint256(wei), min_tokens: uint256, deadline: timestamp, buyer: address, recipient: address) -> uint256:
              assert deadline >= block.timestamp and (eth_sold > 0 and min_tokens > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_bought: uint256 = self.getInputPrice(as_unitless_number(eth_sold), as_unitless_number(self.balance - eth_sold), token_reserve)
              assert tokens_bought >= min_tokens
              assert self.token.transfer(recipient, tokens_bought)
              log.TokenPurchase(buyer, eth_sold, tokens_bought)
              return tokens_bought
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies exact input (msg.value).
          # @dev User cannot specify minimum output or deadline.
          @public
          @payable
          def __default__():
              self.ethToTokenInput(msg.value, 1, block.timestamp, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies exact input (msg.value) and minimum output.
          # @param min_tokens Minimum Tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of Tokens bought.
          @public
          @payable
          def ethToTokenSwapInput(min_tokens: uint256, deadline: timestamp) -> uint256:
              return self.ethToTokenInput(msg.value, min_tokens, deadline, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens and transfers Tokens to recipient.
          # @dev User specifies exact input (msg.value) and minimum output
          # @param min_tokens Minimum Tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output Tokens.
          # @return Amount of Tokens bought.
          @public
          @payable
          def ethToTokenTransferInput(min_tokens: uint256, deadline: timestamp, recipient: address) -> uint256:
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.ethToTokenInput(msg.value, min_tokens, deadline, msg.sender, recipient)
          
          @private
          def ethToTokenOutput(tokens_bought: uint256, max_eth: uint256(wei), deadline: timestamp, buyer: address, recipient: address) -> uint256(wei):
              assert deadline >= block.timestamp and (tokens_bought > 0 and max_eth > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_sold: uint256 = self.getOutputPrice(tokens_bought, as_unitless_number(self.balance - max_eth), token_reserve)
              # Throws if eth_sold > max_eth
              eth_refund: uint256(wei) = max_eth - as_wei_value(eth_sold, 'wei')
              if eth_refund > 0:
                  send(buyer, eth_refund)
              assert self.token.transfer(recipient, tokens_bought)
              log.TokenPurchase(buyer, as_wei_value(eth_sold, 'wei'), tokens_bought)
              return as_wei_value(eth_sold, 'wei')
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies maximum input (msg.value) and exact output.
          # @param tokens_bought Amount of tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of ETH sold.
          @public
          @payable
          def ethToTokenSwapOutput(tokens_bought: uint256, deadline: timestamp) -> uint256(wei):
              return self.ethToTokenOutput(tokens_bought, msg.value, deadline, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens and transfers Tokens to recipient.
          # @dev User specifies maximum input (msg.value) and exact output.
          # @param tokens_bought Amount of tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output Tokens.
          # @return Amount of ETH sold.
          @public
          @payable
          def ethToTokenTransferOutput(tokens_bought: uint256, deadline: timestamp, recipient: address) -> uint256(wei):
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.ethToTokenOutput(tokens_bought, msg.value, deadline, msg.sender, recipient)
          
          @private
          def tokenToEthInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp, buyer: address, recipient: address) -> uint256(wei):
              assert deadline >= block.timestamp and (tokens_sold > 0 and min_eth > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              wei_bought: uint256(wei) = as_wei_value(eth_bought, 'wei')
              assert wei_bought >= min_eth
              send(recipient, wei_bought)
              assert self.token.transferFrom(buyer, self, tokens_sold)
              log.EthPurchase(buyer, tokens_sold, wei_bought)
              return wei_bought
          
          
          # @notice Convert Tokens to ETH.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_eth Minimum ETH purchased.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of ETH bought.
          @public
          def tokenToEthSwapInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp) -> uint256(wei):
              return self.tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, msg.sender)
          
          # @notice Convert Tokens to ETH and transfers ETH to recipient.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_eth Minimum ETH purchased.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @return Amount of ETH bought.
          @public
          def tokenToEthTransferInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp, recipient: address) -> uint256(wei):
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, recipient)
          
          @private
          def tokenToEthOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp, buyer: address, recipient: address) -> uint256:
              assert deadline >= block.timestamp and eth_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_sold: uint256 = self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
              # tokens sold is always > 0
              assert max_tokens >= tokens_sold
              send(recipient, eth_bought)
              assert self.token.transferFrom(buyer, self, tokens_sold)
              log.EthPurchase(buyer, tokens_sold, eth_bought)
              return tokens_sold
          
          # @notice Convert Tokens to ETH.
          # @dev User specifies maximum input and exact output.
          # @param eth_bought Amount of ETH purchased.
          # @param max_tokens Maximum Tokens sold.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of Tokens sold.
          @public
          def tokenToEthSwapOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp) -> uint256:
              return self.tokenToEthOutput(eth_bought, max_tokens, deadline, msg.sender, msg.sender)
          
          # @notice Convert Tokens to ETH and transfers ETH to recipient.
          # @dev User specifies maximum input and exact output.
          # @param eth_bought Amount of ETH purchased.
          # @param max_tokens Maximum Tokens sold.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @return Amount of Tokens sold.
          @public
          def tokenToEthTransferOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp, recipient: address) -> uint256:
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.tokenToEthOutput(eth_bought, max_tokens, deadline, msg.sender, recipient)
          
          @private
          def tokenToTokenInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, buyer: address, recipient: address, exchange_addr: address) -> uint256:
              assert (deadline >= block.timestamp and tokens_sold > 0) and (min_tokens_bought > 0 and min_eth_bought > 0)
              assert exchange_addr != self and exchange_addr != ZERO_ADDRESS
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              wei_bought: uint256(wei) = as_wei_value(eth_bought, 'wei')
              assert wei_bought >= min_eth_bought
              assert self.token.transferFrom(buyer, self, tokens_sold)
              tokens_bought: uint256 = Exchange(exchange_addr).ethToTokenTransferInput(min_tokens_bought, deadline, recipient, value=wei_bought)
              log.EthPurchase(buyer, tokens_sold, wei_bought)
              return tokens_bought
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr).
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (token_addr) bought.
          @public
          def tokenToTokenSwapInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr) and transfers
          #         Tokens (token_addr) to recipient.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (token_addr) bought.
          @public
          def tokenToTokenTransferInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, recipient: address, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, recipient, exchange_addr)
          
          @private
          def tokenToTokenOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, buyer: address, recipient: address, exchange_addr: address) -> uint256:
              assert deadline >= block.timestamp and (tokens_bought > 0 and max_eth_sold > 0)
              assert exchange_addr != self and exchange_addr != ZERO_ADDRESS
              eth_bought: uint256(wei) = Exchange(exchange_addr).getEthToTokenOutputPrice(tokens_bought)
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_sold: uint256 = self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
              # tokens sold is always > 0
              assert max_tokens_sold >= tokens_sold and max_eth_sold >= eth_bought
              assert self.token.transferFrom(buyer, self, tokens_sold)
              eth_sold: uint256(wei) = Exchange(exchange_addr).ethToTokenTransferOutput(tokens_bought, deadline, recipient, value=eth_bought)
              log.EthPurchase(buyer, tokens_sold, eth_bought)
              return tokens_sold
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr).
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToTokenSwapOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr) and transfers
          #         Tokens (token_addr) to recipient.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToTokenTransferOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, recipient: address, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token).
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (exchange_addr.token) bought.
          @public
          def tokenToExchangeSwapInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, exchange_addr: address) -> uint256:
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token) and transfers
          #         Tokens (exchange_addr.token) to recipient.
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (exchange_addr.token) bought.
          @public
          def tokenToExchangeTransferInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, recipient: address, exchange_addr: address) -> uint256:
              assert recipient != self
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token).
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToExchangeSwapOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, exchange_addr: address) -> uint256:
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token) and transfers
          #         Tokens (exchange_addr.token) to recipient.
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToExchangeTransferOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, recipient: address, exchange_addr: address) -> uint256:
              assert recipient != self
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Public price function for ETH to Token trades with an exact input.
          # @param eth_sold Amount of ETH sold.
          # @return Amount of Tokens that can be bought with input ETH.
          @public
          @constant
          def getEthToTokenInputPrice(eth_sold: uint256(wei)) -> uint256:
              assert eth_sold > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              return self.getInputPrice(as_unitless_number(eth_sold), as_unitless_number(self.balance), token_reserve)
          
          # @notice Public price function for ETH to Token trades with an exact output.
          # @param tokens_bought Amount of Tokens bought.
          # @return Amount of ETH needed to buy output Tokens.
          @public
          @constant
          def getEthToTokenOutputPrice(tokens_bought: uint256) -> uint256(wei):
              assert tokens_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_sold: uint256 = self.getOutputPrice(tokens_bought, as_unitless_number(self.balance), token_reserve)
              return as_wei_value(eth_sold, 'wei')
          
          # @notice Public price function for Token to ETH trades with an exact input.
          # @param tokens_sold Amount of Tokens sold.
          # @return Amount of ETH that can be bought with input Tokens.
          @public
          @constant
          def getTokenToEthInputPrice(tokens_sold: uint256) -> uint256(wei):
              assert tokens_sold > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              return as_wei_value(eth_bought, 'wei')
          
          # @notice Public price function for Token to ETH trades with an exact output.
          # @param eth_bought Amount of output ETH.
          # @return Amount of Tokens needed to buy output ETH.
          @public
          @constant
          def getTokenToEthOutputPrice(eth_bought: uint256(wei)) -> uint256:
              assert eth_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              return self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
          
          # @return Address of Token that is sold on this exchange.
          @public
          @constant
          def tokenAddress() -> address:
              return self.token
          
          # @return Address of factory that created this exchange.
          @public
          @constant
          def factoryAddress() -> address(Factory):
              return self.factory
          
          # ERC20 compatibility for exchange liquidity modified from
          # https://github.com/ethereum/vyper/blob/master/examples/tokens/ERC20.vy
          @public
          @constant
          def balanceOf(_owner : address) -> uint256:
              return self.balances[_owner]
          
          @public
          def transfer(_to : address, _value : uint256) -> bool:
              self.balances[msg.sender] -= _value
              self.balances[_to] += _value
              log.Transfer(msg.sender, _to, _value)
              return True
          
          @public
          def transferFrom(_from : address, _to : address, _value : uint256) -> bool:
              self.balances[_from] -= _value
              self.balances[_to] += _value
              self.allowances[_from][msg.sender] -= _value
              log.Transfer(_from, _to, _value)
              return True
          
          @public
          def approve(_spender : address, _value : uint256) -> bool:
              self.allowances[msg.sender][_spender] = _value
              log.Approval(msg.sender, _spender, _value)
              return True
          
          @public
          @constant
          def allowance(_owner : address, _spender : address) -> uint256:
              return self.allowances[_owner][_spender]

          File 3 of 6: Vyper_contract
          contract Exchange():
              def setup(token_addr: address): modifying
          
          NewExchange: event({token: indexed(address), exchange: indexed(address)})
          
          exchangeTemplate: public(address)
          tokenCount: public(uint256)
          token_to_exchange: address[address]
          exchange_to_token: address[address]
          id_to_token: address[uint256]
          
          @public
          def initializeFactory(template: address):
              assert self.exchangeTemplate == ZERO_ADDRESS
              assert template != ZERO_ADDRESS
              self.exchangeTemplate = template
          
          @public
          def createExchange(token: address) -> address:
              assert token != ZERO_ADDRESS
              assert self.exchangeTemplate != ZERO_ADDRESS
              assert self.token_to_exchange[token] == ZERO_ADDRESS
              exchange: address = create_with_code_of(self.exchangeTemplate)
              Exchange(exchange).setup(token)
              self.token_to_exchange[token] = exchange
              self.exchange_to_token[exchange] = token
              token_id: uint256 = self.tokenCount + 1
              self.tokenCount = token_id
              self.id_to_token[token_id] = token
              log.NewExchange(token, exchange)
              return exchange
          
          @public
          @constant
          def getExchange(token: address) -> address:
              return self.token_to_exchange[token]
          
          @public
          @constant
          def getToken(exchange: address) -> address:
              return self.exchange_to_token[exchange]
          
          @public
          @constant
          def getTokenWithId(token_id: uint256) -> address:
              return self.id_to_token[token_id]

          File 4 of 6: H3X
          /**
           * 
           * Richard Hart is Satoshi.                                                               
           * 
          */
          
          pragma solidity ^0.5.13;
          
          interface Callable {
          	function tokenCallback(address _from, uint256 _tokens, bytes calldata _data) external returns (bool);
          }
          
          contract H3X {
          
          	uint256 constant private FLOAT_SCALAR = 2**64;
          	uint256 constant private INITIAL_SUPPLY = 3e26; // 
          	uint256 constant private BURN_RATE = 10; // 10% per tx
          	uint256 constant private SUPPLY_FLOOR = 1; // 1% of 300M = 3M
          	uint256 constant private MIN_FREEZE_AMOUNT = 1e20; // 100 minimum
          
          	string constant public name = "H3X";
          	string constant public symbol = "H3X";
          	uint8 constant public decimals = 18;
          
          	struct User {
          		bool whitelisted;
          		uint256 balance;
          		uint256 frozen;
          		mapping(address => uint256) allowance;
          		int256 scaledPayout;
          	}
          
          	struct Info {
          		uint256 totalSupply;
          		uint256 totalFrozen;
          		mapping(address => User) users;
          		uint256 scaledPayoutPerToken;
          		address admin;
          	}
          	Info private info;
          
          
          	event Transfer(address indexed from, address indexed to, uint256 tokens);
          	event Approval(address indexed owner, address indexed spender, uint256 tokens);
          	event Whitelist(address indexed user, bool status);
          	event Freeze(address indexed owner, uint256 tokens);
          	event Unfreeze(address indexed owner, uint256 tokens);
          	event Collect(address indexed owner, uint256 tokens);
          	event Burn(uint256 tokens);
          
          
          	constructor() public {
          		info.admin = msg.sender;
          		info.totalSupply = INITIAL_SUPPLY;
          		info.users[msg.sender].balance = INITIAL_SUPPLY;
          		emit Transfer(address(0x0), msg.sender, INITIAL_SUPPLY);
          		whitelist(msg.sender, true);
          	}
          
          	function freeze(uint256 _tokens) external {
          		_freeze(_tokens);
          	}
          
          	function unfreeze(uint256 _tokens) external {
          		_unfreeze(_tokens);
          	}
          
          	function collect() external returns (uint256) {
          		uint256 _dividends = dividendsOf(msg.sender);
          		require(_dividends >= 0);
          		info.users[msg.sender].scaledPayout += int256(_dividends * FLOAT_SCALAR);
          		info.users[msg.sender].balance += _dividends;
          		emit Transfer(address(this), msg.sender, _dividends);
          		emit Collect(msg.sender, _dividends);
          		return _dividends;
          	}
          
          	function burn(uint256 _tokens) external {
          		require(balanceOf(msg.sender) >= _tokens);
          		info.users[msg.sender].balance -= _tokens;
          		uint256 _burnedAmount = _tokens;
          		if (info.totalFrozen > 0) {
          			_burnedAmount /= 2;
          			info.scaledPayoutPerToken += _burnedAmount * FLOAT_SCALAR / info.totalFrozen;
          			emit Transfer(msg.sender, address(this), _burnedAmount);
          		}
          		info.totalSupply -= _burnedAmount;
          		emit Transfer(msg.sender, address(0x0), _burnedAmount);
          		emit Burn(_burnedAmount);
          	}
          
          	function distribute(uint256 _tokens) external {
          		require(info.totalFrozen > 0);
          		require(balanceOf(msg.sender) >= _tokens);
          		info.users[msg.sender].balance -= _tokens;
          		info.scaledPayoutPerToken += _tokens * FLOAT_SCALAR / info.totalFrozen;
          		emit Transfer(msg.sender, address(this), _tokens);
          	}
          
          	function transfer(address _to, uint256 _tokens) external returns (bool) {
          		_transfer(msg.sender, _to, _tokens);
          		return true;
          	}
          
          	function approve(address _spender, uint256 _tokens) external returns (bool) {
          		info.users[msg.sender].allowance[_spender] = _tokens;
          		emit Approval(msg.sender, _spender, _tokens);
          		return true;
          	}
          
          	function transferFrom(address _from, address _to, uint256 _tokens) external returns (bool) {
          		require(info.users[_from].allowance[msg.sender] >= _tokens);
          		info.users[_from].allowance[msg.sender] -= _tokens;
          		_transfer(_from, _to, _tokens);
          		return true;
          	}
          
          	function transferAndCall(address _to, uint256 _tokens, bytes calldata _data) external returns (bool) {
          		uint256 _transferred = _transfer(msg.sender, _to, _tokens);
          		uint32 _size;
          		assembly {
          			_size := extcodesize(_to)
          		}
          		if (_size > 0) {
          			require(Callable(_to).tokenCallback(msg.sender, _transferred, _data));
          		}
          		return true;
          	}
          
          	function bulkTransfer(address[] calldata _receivers, uint256[] calldata _amounts) external {
          		require(_receivers.length == _amounts.length);
          		for (uint256 i = 0; i < _receivers.length; i++) {
          			_transfer(msg.sender, _receivers[i], _amounts[i]);
          		}
          	}
          
          	function whitelist(address _user, bool _status) public {
          		require(msg.sender == info.admin);
          		info.users[_user].whitelisted = _status;
          		emit Whitelist(_user, _status);
          	}
          
          
          	function totalSupply() public view returns (uint256) {
          		return info.totalSupply;
          	}
          
          	function totalFrozen() public view returns (uint256) {
          		return info.totalFrozen;
          	}
          
          	function balanceOf(address _user) public view returns (uint256) {
          		return info.users[_user].balance - frozenOf(_user);
          	}
          
          	function frozenOf(address _user) public view returns (uint256) {
          		return info.users[_user].frozen;
          	}
          
          	function dividendsOf(address _user) public view returns (uint256) {
          		return uint256(int256(info.scaledPayoutPerToken * info.users[_user].frozen) - info.users[_user].scaledPayout) / FLOAT_SCALAR;
          	}
          
          	function allowance(address _user, address _spender) public view returns (uint256) {
          		return info.users[_user].allowance[_spender];
          	}
          
          	function isWhitelisted(address _user) public view returns (bool) {
          		return info.users[_user].whitelisted;
          	}
          
          	function allInfoFor(address _user) public view returns (uint256 totalTokenSupply, uint256 totalTokensFrozen, uint256 userBalance, uint256 userFrozen, uint256 userDividends) {
          		return (totalSupply(), totalFrozen(), balanceOf(_user), frozenOf(_user), dividendsOf(_user));
          	}
          
          
          	function _transfer(address _from, address _to, uint256 _tokens) internal returns (uint256) {
          		require(balanceOf(_from) >= _tokens);
          		info.users[_from].balance -= _tokens;
          		uint256 _burnedAmount = _tokens * BURN_RATE / 100;
          		if (totalSupply() - _burnedAmount < INITIAL_SUPPLY * SUPPLY_FLOOR / 100 || isWhitelisted(_from)) {
          			_burnedAmount = 0;
          		}
          		uint256 _transferred = _tokens - _burnedAmount;
          		info.users[_to].balance += _transferred;
          		emit Transfer(_from, _to, _transferred);
          		if (_burnedAmount > 0) {
          			if (info.totalFrozen > 0) {
          				_burnedAmount /= 2;
          				info.scaledPayoutPerToken += _burnedAmount * FLOAT_SCALAR / info.totalFrozen;
          				emit Transfer(_from, address(this), _burnedAmount);
          			}
          			info.totalSupply -= _burnedAmount;
          			emit Transfer(_from, address(0x0), _burnedAmount);
          			emit Burn(_burnedAmount);
          		}
          		return _transferred;
          	}
          
          	function _freeze(uint256 _amount) internal {
          		require(balanceOf(msg.sender) >= _amount);
          		require(frozenOf(msg.sender) + _amount >= MIN_FREEZE_AMOUNT);
          		info.totalFrozen += _amount;
          		info.users[msg.sender].frozen += _amount;
          		info.users[msg.sender].scaledPayout += int256(_amount * info.scaledPayoutPerToken);
          		emit Transfer(msg.sender, address(this), _amount);
          		emit Freeze(msg.sender, _amount);
          	}
          
          	function _unfreeze(uint256 _amount) internal {
          		require(frozenOf(msg.sender) >= _amount);
          		uint256 _burnedAmount = _amount * BURN_RATE / 100;
          		info.scaledPayoutPerToken += _burnedAmount * FLOAT_SCALAR / info.totalFrozen;
          		info.totalFrozen -= _amount;
          		info.users[msg.sender].balance -= _burnedAmount;
          		info.users[msg.sender].frozen -= _amount;
          		info.users[msg.sender].scaledPayout -= int256(_amount * info.scaledPayoutPerToken);
          		emit Transfer(address(this), msg.sender, _amount - _burnedAmount);
          		emit Unfreeze(msg.sender, _amount);
          	}
          }

          File 5 of 6: Vyper_contract
          # @title Uniswap Exchange Interface V1
          # @notice Source code found at https://github.com/uniswap
          # @notice Use at your own risk
          
          contract Factory():
              def getExchange(token_addr: address) -> address: constant
          
          contract Exchange():
              def getEthToTokenOutputPrice(tokens_bought: uint256) -> uint256(wei): constant
              def ethToTokenTransferInput(min_tokens: uint256, deadline: timestamp, recipient: address) -> uint256: modifying
              def ethToTokenTransferOutput(tokens_bought: uint256, deadline: timestamp, recipient: address) -> uint256(wei): modifying
          
          TokenPurchase: event({buyer: indexed(address), eth_sold: indexed(uint256(wei)), tokens_bought: indexed(uint256)})
          EthPurchase: event({buyer: indexed(address), tokens_sold: indexed(uint256), eth_bought: indexed(uint256(wei))})
          AddLiquidity: event({provider: indexed(address), eth_amount: indexed(uint256(wei)), token_amount: indexed(uint256)})
          RemoveLiquidity: event({provider: indexed(address), eth_amount: indexed(uint256(wei)), token_amount: indexed(uint256)})
          Transfer: event({_from: indexed(address), _to: indexed(address), _value: uint256})
          Approval: event({_owner: indexed(address), _spender: indexed(address), _value: uint256})
          
          name: public(bytes32)                             # Uniswap V1
          symbol: public(bytes32)                           # UNI-V1
          decimals: public(uint256)                         # 18
          totalSupply: public(uint256)                      # total number of UNI in existence
          balances: uint256[address]                        # UNI balance of an address
          allowances: (uint256[address])[address]           # UNI allowance of one address on another
          token: address(ERC20)                             # address of the ERC20 token traded on this contract
          factory: Factory                                  # interface for the factory that created this contract
          
          # @dev This function acts as a contract constructor which is not currently supported in contracts deployed
          #      using create_with_code_of(). It is called once by the factory during contract creation.
          @public
          def setup(token_addr: address):
              assert (self.factory == ZERO_ADDRESS and self.token == ZERO_ADDRESS) and token_addr != ZERO_ADDRESS
              self.factory = msg.sender
              self.token = token_addr
              self.name = 0x556e697377617020563100000000000000000000000000000000000000000000
              self.symbol = 0x554e492d56310000000000000000000000000000000000000000000000000000
              self.decimals = 18
          
          # @notice Deposit ETH and Tokens (self.token) at current ratio to mint UNI tokens.
          # @dev min_liquidity does nothing when total UNI supply is 0.
          # @param min_liquidity Minimum number of UNI sender will mint if total UNI supply is greater than 0.
          # @param max_tokens Maximum number of tokens deposited. Deposits max amount if total UNI supply is 0.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return The amount of UNI minted.
          @public
          @payable
          def addLiquidity(min_liquidity: uint256, max_tokens: uint256, deadline: timestamp) -> uint256:
              assert deadline > block.timestamp and (max_tokens > 0 and msg.value > 0)
              total_liquidity: uint256 = self.totalSupply
              if total_liquidity > 0:
                  assert min_liquidity > 0
                  eth_reserve: uint256(wei) = self.balance - msg.value
                  token_reserve: uint256 = self.token.balanceOf(self)
                  token_amount: uint256 = msg.value * token_reserve / eth_reserve + 1
                  liquidity_minted: uint256 = msg.value * total_liquidity / eth_reserve
                  assert max_tokens >= token_amount and liquidity_minted >= min_liquidity
                  self.balances[msg.sender] += liquidity_minted
                  self.totalSupply = total_liquidity + liquidity_minted
                  assert self.token.transferFrom(msg.sender, self, token_amount)
                  log.AddLiquidity(msg.sender, msg.value, token_amount)
                  log.Transfer(ZERO_ADDRESS, msg.sender, liquidity_minted)
                  return liquidity_minted
              else:
                  assert (self.factory != ZERO_ADDRESS and self.token != ZERO_ADDRESS) and msg.value >= 1000000000
                  assert self.factory.getExchange(self.token) == self
                  token_amount: uint256 = max_tokens
                  initial_liquidity: uint256 = as_unitless_number(self.balance)
                  self.totalSupply = initial_liquidity
                  self.balances[msg.sender] = initial_liquidity
                  assert self.token.transferFrom(msg.sender, self, token_amount)
                  log.AddLiquidity(msg.sender, msg.value, token_amount)
                  log.Transfer(ZERO_ADDRESS, msg.sender, initial_liquidity)
                  return initial_liquidity
          
          # @dev Burn UNI tokens to withdraw ETH and Tokens at current ratio.
          # @param amount Amount of UNI burned.
          # @param min_eth Minimum ETH withdrawn.
          # @param min_tokens Minimum Tokens withdrawn.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return The amount of ETH and Tokens withdrawn.
          @public
          def removeLiquidity(amount: uint256, min_eth: uint256(wei), min_tokens: uint256, deadline: timestamp) -> (uint256(wei), uint256):
              assert (amount > 0 and deadline > block.timestamp) and (min_eth > 0 and min_tokens > 0)
              total_liquidity: uint256 = self.totalSupply
              assert total_liquidity > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_amount: uint256(wei) = amount * self.balance / total_liquidity
              token_amount: uint256 = amount * token_reserve / total_liquidity
              assert eth_amount >= min_eth and token_amount >= min_tokens
              self.balances[msg.sender] -= amount
              self.totalSupply = total_liquidity - amount
              send(msg.sender, eth_amount)
              assert self.token.transfer(msg.sender, token_amount)
              log.RemoveLiquidity(msg.sender, eth_amount, token_amount)
              log.Transfer(msg.sender, ZERO_ADDRESS, amount)
              return eth_amount, token_amount
          
          # @dev Pricing function for converting between ETH and Tokens.
          # @param input_amount Amount of ETH or Tokens being sold.
          # @param input_reserve Amount of ETH or Tokens (input type) in exchange reserves.
          # @param output_reserve Amount of ETH or Tokens (output type) in exchange reserves.
          # @return Amount of ETH or Tokens bought.
          @private
          @constant
          def getInputPrice(input_amount: uint256, input_reserve: uint256, output_reserve: uint256) -> uint256:
              assert input_reserve > 0 and output_reserve > 0
              input_amount_with_fee: uint256 = input_amount * 997
              numerator: uint256 = input_amount_with_fee * output_reserve
              denominator: uint256 = (input_reserve * 1000) + input_amount_with_fee
              return numerator / denominator
          
          # @dev Pricing function for converting between ETH and Tokens.
          # @param output_amount Amount of ETH or Tokens being bought.
          # @param input_reserve Amount of ETH or Tokens (input type) in exchange reserves.
          # @param output_reserve Amount of ETH or Tokens (output type) in exchange reserves.
          # @return Amount of ETH or Tokens sold.
          @private
          @constant
          def getOutputPrice(output_amount: uint256, input_reserve: uint256, output_reserve: uint256) -> uint256:
              assert input_reserve > 0 and output_reserve > 0
              numerator: uint256 = input_reserve * output_amount * 1000
              denominator: uint256 = (output_reserve - output_amount) * 997
              return numerator / denominator + 1
          
          @private
          def ethToTokenInput(eth_sold: uint256(wei), min_tokens: uint256, deadline: timestamp, buyer: address, recipient: address) -> uint256:
              assert deadline >= block.timestamp and (eth_sold > 0 and min_tokens > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_bought: uint256 = self.getInputPrice(as_unitless_number(eth_sold), as_unitless_number(self.balance - eth_sold), token_reserve)
              assert tokens_bought >= min_tokens
              assert self.token.transfer(recipient, tokens_bought)
              log.TokenPurchase(buyer, eth_sold, tokens_bought)
              return tokens_bought
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies exact input (msg.value).
          # @dev User cannot specify minimum output or deadline.
          @public
          @payable
          def __default__():
              self.ethToTokenInput(msg.value, 1, block.timestamp, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies exact input (msg.value) and minimum output.
          # @param min_tokens Minimum Tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of Tokens bought.
          @public
          @payable
          def ethToTokenSwapInput(min_tokens: uint256, deadline: timestamp) -> uint256:
              return self.ethToTokenInput(msg.value, min_tokens, deadline, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens and transfers Tokens to recipient.
          # @dev User specifies exact input (msg.value) and minimum output
          # @param min_tokens Minimum Tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output Tokens.
          # @return Amount of Tokens bought.
          @public
          @payable
          def ethToTokenTransferInput(min_tokens: uint256, deadline: timestamp, recipient: address) -> uint256:
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.ethToTokenInput(msg.value, min_tokens, deadline, msg.sender, recipient)
          
          @private
          def ethToTokenOutput(tokens_bought: uint256, max_eth: uint256(wei), deadline: timestamp, buyer: address, recipient: address) -> uint256(wei):
              assert deadline >= block.timestamp and (tokens_bought > 0 and max_eth > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_sold: uint256 = self.getOutputPrice(tokens_bought, as_unitless_number(self.balance - max_eth), token_reserve)
              # Throws if eth_sold > max_eth
              eth_refund: uint256(wei) = max_eth - as_wei_value(eth_sold, 'wei')
              if eth_refund > 0:
                  send(buyer, eth_refund)
              assert self.token.transfer(recipient, tokens_bought)
              log.TokenPurchase(buyer, as_wei_value(eth_sold, 'wei'), tokens_bought)
              return as_wei_value(eth_sold, 'wei')
          
          # @notice Convert ETH to Tokens.
          # @dev User specifies maximum input (msg.value) and exact output.
          # @param tokens_bought Amount of tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of ETH sold.
          @public
          @payable
          def ethToTokenSwapOutput(tokens_bought: uint256, deadline: timestamp) -> uint256(wei):
              return self.ethToTokenOutput(tokens_bought, msg.value, deadline, msg.sender, msg.sender)
          
          # @notice Convert ETH to Tokens and transfers Tokens to recipient.
          # @dev User specifies maximum input (msg.value) and exact output.
          # @param tokens_bought Amount of tokens bought.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output Tokens.
          # @return Amount of ETH sold.
          @public
          @payable
          def ethToTokenTransferOutput(tokens_bought: uint256, deadline: timestamp, recipient: address) -> uint256(wei):
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.ethToTokenOutput(tokens_bought, msg.value, deadline, msg.sender, recipient)
          
          @private
          def tokenToEthInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp, buyer: address, recipient: address) -> uint256(wei):
              assert deadline >= block.timestamp and (tokens_sold > 0 and min_eth > 0)
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              wei_bought: uint256(wei) = as_wei_value(eth_bought, 'wei')
              assert wei_bought >= min_eth
              send(recipient, wei_bought)
              assert self.token.transferFrom(buyer, self, tokens_sold)
              log.EthPurchase(buyer, tokens_sold, wei_bought)
              return wei_bought
          
          
          # @notice Convert Tokens to ETH.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_eth Minimum ETH purchased.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of ETH bought.
          @public
          def tokenToEthSwapInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp) -> uint256(wei):
              return self.tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, msg.sender)
          
          # @notice Convert Tokens to ETH and transfers ETH to recipient.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_eth Minimum ETH purchased.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @return Amount of ETH bought.
          @public
          def tokenToEthTransferInput(tokens_sold: uint256, min_eth: uint256(wei), deadline: timestamp, recipient: address) -> uint256(wei):
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.tokenToEthInput(tokens_sold, min_eth, deadline, msg.sender, recipient)
          
          @private
          def tokenToEthOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp, buyer: address, recipient: address) -> uint256:
              assert deadline >= block.timestamp and eth_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_sold: uint256 = self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
              # tokens sold is always > 0
              assert max_tokens >= tokens_sold
              send(recipient, eth_bought)
              assert self.token.transferFrom(buyer, self, tokens_sold)
              log.EthPurchase(buyer, tokens_sold, eth_bought)
              return tokens_sold
          
          # @notice Convert Tokens to ETH.
          # @dev User specifies maximum input and exact output.
          # @param eth_bought Amount of ETH purchased.
          # @param max_tokens Maximum Tokens sold.
          # @param deadline Time after which this transaction can no longer be executed.
          # @return Amount of Tokens sold.
          @public
          def tokenToEthSwapOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp) -> uint256:
              return self.tokenToEthOutput(eth_bought, max_tokens, deadline, msg.sender, msg.sender)
          
          # @notice Convert Tokens to ETH and transfers ETH to recipient.
          # @dev User specifies maximum input and exact output.
          # @param eth_bought Amount of ETH purchased.
          # @param max_tokens Maximum Tokens sold.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @return Amount of Tokens sold.
          @public
          def tokenToEthTransferOutput(eth_bought: uint256(wei), max_tokens: uint256, deadline: timestamp, recipient: address) -> uint256:
              assert recipient != self and recipient != ZERO_ADDRESS
              return self.tokenToEthOutput(eth_bought, max_tokens, deadline, msg.sender, recipient)
          
          @private
          def tokenToTokenInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, buyer: address, recipient: address, exchange_addr: address) -> uint256:
              assert (deadline >= block.timestamp and tokens_sold > 0) and (min_tokens_bought > 0 and min_eth_bought > 0)
              assert exchange_addr != self and exchange_addr != ZERO_ADDRESS
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              wei_bought: uint256(wei) = as_wei_value(eth_bought, 'wei')
              assert wei_bought >= min_eth_bought
              assert self.token.transferFrom(buyer, self, tokens_sold)
              tokens_bought: uint256 = Exchange(exchange_addr).ethToTokenTransferInput(min_tokens_bought, deadline, recipient, value=wei_bought)
              log.EthPurchase(buyer, tokens_sold, wei_bought)
              return tokens_bought
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr).
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (token_addr) bought.
          @public
          def tokenToTokenSwapInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr) and transfers
          #         Tokens (token_addr) to recipient.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (token_addr) bought.
          @public
          def tokenToTokenTransferInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, recipient: address, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, recipient, exchange_addr)
          
          @private
          def tokenToTokenOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, buyer: address, recipient: address, exchange_addr: address) -> uint256:
              assert deadline >= block.timestamp and (tokens_bought > 0 and max_eth_sold > 0)
              assert exchange_addr != self and exchange_addr != ZERO_ADDRESS
              eth_bought: uint256(wei) = Exchange(exchange_addr).getEthToTokenOutputPrice(tokens_bought)
              token_reserve: uint256 = self.token.balanceOf(self)
              tokens_sold: uint256 = self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
              # tokens sold is always > 0
              assert max_tokens_sold >= tokens_sold and max_eth_sold >= eth_bought
              assert self.token.transferFrom(buyer, self, tokens_sold)
              eth_sold: uint256(wei) = Exchange(exchange_addr).ethToTokenTransferOutput(tokens_bought, deadline, recipient, value=eth_bought)
              log.EthPurchase(buyer, tokens_sold, eth_bought)
              return tokens_sold
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr).
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToTokenSwapOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (token_addr) and transfers
          #         Tokens (token_addr) to recipient.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToTokenTransferOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, recipient: address, token_addr: address) -> uint256:
              exchange_addr: address = self.factory.getExchange(token_addr)
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token).
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (exchange_addr.token) bought.
          @public
          def tokenToExchangeSwapInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, exchange_addr: address) -> uint256:
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token) and transfers
          #         Tokens (exchange_addr.token) to recipient.
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies exact input and minimum output.
          # @param tokens_sold Amount of Tokens sold.
          # @param min_tokens_bought Minimum Tokens (token_addr) purchased.
          # @param min_eth_bought Minimum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (exchange_addr.token) bought.
          @public
          def tokenToExchangeTransferInput(tokens_sold: uint256, min_tokens_bought: uint256, min_eth_bought: uint256(wei), deadline: timestamp, recipient: address, exchange_addr: address) -> uint256:
              assert recipient != self
              return self.tokenToTokenInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token).
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param exchange_addr The address of the exchange for the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToExchangeSwapOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, exchange_addr: address) -> uint256:
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, msg.sender, exchange_addr)
          
          # @notice Convert Tokens (self.token) to Tokens (exchange_addr.token) and transfers
          #         Tokens (exchange_addr.token) to recipient.
          # @dev Allows trades through contracts that were not deployed from the same factory.
          # @dev User specifies maximum input and exact output.
          # @param tokens_bought Amount of Tokens (token_addr) bought.
          # @param max_tokens_sold Maximum Tokens (self.token) sold.
          # @param max_eth_sold Maximum ETH purchased as intermediary.
          # @param deadline Time after which this transaction can no longer be executed.
          # @param recipient The address that receives output ETH.
          # @param token_addr The address of the token being purchased.
          # @return Amount of Tokens (self.token) sold.
          @public
          def tokenToExchangeTransferOutput(tokens_bought: uint256, max_tokens_sold: uint256, max_eth_sold: uint256(wei), deadline: timestamp, recipient: address, exchange_addr: address) -> uint256:
              assert recipient != self
              return self.tokenToTokenOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, msg.sender, recipient, exchange_addr)
          
          # @notice Public price function for ETH to Token trades with an exact input.
          # @param eth_sold Amount of ETH sold.
          # @return Amount of Tokens that can be bought with input ETH.
          @public
          @constant
          def getEthToTokenInputPrice(eth_sold: uint256(wei)) -> uint256:
              assert eth_sold > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              return self.getInputPrice(as_unitless_number(eth_sold), as_unitless_number(self.balance), token_reserve)
          
          # @notice Public price function for ETH to Token trades with an exact output.
          # @param tokens_bought Amount of Tokens bought.
          # @return Amount of ETH needed to buy output Tokens.
          @public
          @constant
          def getEthToTokenOutputPrice(tokens_bought: uint256) -> uint256(wei):
              assert tokens_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_sold: uint256 = self.getOutputPrice(tokens_bought, as_unitless_number(self.balance), token_reserve)
              return as_wei_value(eth_sold, 'wei')
          
          # @notice Public price function for Token to ETH trades with an exact input.
          # @param tokens_sold Amount of Tokens sold.
          # @return Amount of ETH that can be bought with input Tokens.
          @public
          @constant
          def getTokenToEthInputPrice(tokens_sold: uint256) -> uint256(wei):
              assert tokens_sold > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              eth_bought: uint256 = self.getInputPrice(tokens_sold, token_reserve, as_unitless_number(self.balance))
              return as_wei_value(eth_bought, 'wei')
          
          # @notice Public price function for Token to ETH trades with an exact output.
          # @param eth_bought Amount of output ETH.
          # @return Amount of Tokens needed to buy output ETH.
          @public
          @constant
          def getTokenToEthOutputPrice(eth_bought: uint256(wei)) -> uint256:
              assert eth_bought > 0
              token_reserve: uint256 = self.token.balanceOf(self)
              return self.getOutputPrice(as_unitless_number(eth_bought), token_reserve, as_unitless_number(self.balance))
          
          # @return Address of Token that is sold on this exchange.
          @public
          @constant
          def tokenAddress() -> address:
              return self.token
          
          # @return Address of factory that created this exchange.
          @public
          @constant
          def factoryAddress() -> address(Factory):
              return self.factory
          
          # ERC20 compatibility for exchange liquidity modified from
          # https://github.com/ethereum/vyper/blob/master/examples/tokens/ERC20.vy
          @public
          @constant
          def balanceOf(_owner : address) -> uint256:
              return self.balances[_owner]
          
          @public
          def transfer(_to : address, _value : uint256) -> bool:
              self.balances[msg.sender] -= _value
              self.balances[_to] += _value
              log.Transfer(msg.sender, _to, _value)
              return True
          
          @public
          def transferFrom(_from : address, _to : address, _value : uint256) -> bool:
              self.balances[_from] -= _value
              self.balances[_to] += _value
              self.allowances[_from][msg.sender] -= _value
              log.Transfer(_from, _to, _value)
              return True
          
          @public
          def approve(_spender : address, _value : uint256) -> bool:
              self.allowances[msg.sender][_spender] = _value
              log.Approval(msg.sender, _spender, _value)
              return True
          
          @public
          @constant
          def allowance(_owner : address, _spender : address) -> uint256:
              return self.allowances[_owner][_spender]

          File 6 of 6: PoWM
          pragma solidity ^0.6.10;
          
          //Powm Coin Master Contract
          
          contract PoWM {
              uint256 constant private INITIAL_SUPPLY = 8e26;
          	string constant public name = "PoWM";
          	string constant public symbol = "POWM";
          	uint256 constant private POINT_AT = 2**64;
          	uint256 constant private MIN_STAKING_AMOUNT = 2e19;
          	uint256 constant private MIN_CIRCULATION = 1;
          	uint256 constant private DEFLATION_QUANT = 12;
          	uint8 constant public decimals = 18;
          	event Whitelist(address indexed user, bool status);
          	event Stakelist(address indexed user, bool status);
          	event AddedStaker(address indexed user);
          	event Stake(address indexed owner, uint256 tokens);
          	event Burn(uint256 tokens);
          	event Unstake(address indexed owner, uint256 tokens);
          	event Withdrawal(address indexed owner, uint256 tokens);
          	event Transfer(address indexed from, address indexed to, uint256 tokens);
          	event Approval(address indexed owner, address indexed spender, uint256 tokens);
          	function stakersCount() public view returns(uint total) {
                  return stakers.length;
              }
              function stakersAll() public view returns( address  [] memory){
                  return stakers;
              }
          	struct Entity {
          	    uint256 stakerIndex;
          		bool whitelisted;
          		bool stakelisted;
          		uint256 invites;
          		uint256 balance;
          		uint256 frozen;
          		mapping(address => uint256) allowance;
          		int256 scaledPayout;
          	}
          	struct Entities {
          		uint256 totalSupply;
          		uint256 totalStaked;
          		mapping(address => Entity) users;
          		uint256 scaledPayoutPerToken;
          		address admin;
          	}
          	Entities private info;
          	address[] public stakers;
          	constructor() public {
          		info.admin = msg.sender;
          		info.totalSupply = INITIAL_SUPPLY;
          		whitelist(msg.sender, true);
          		info.users[msg.sender].balance = INITIAL_SUPPLY;
          		emit Transfer(address(0x0), msg.sender, INITIAL_SUPPLY);
          	}
          
          	function withdraw_dividends() external returns (uint256) {
          		uint256 _dividends = dividendsOf(msg.sender);
          		require(_dividends >= 0);
          		info.users[msg.sender].scaledPayout += int256(_dividends * POINT_AT);
          		info.users[msg.sender].balance += _dividends;
          		emit Transfer(address(this), msg.sender, _dividends);
          		emit Withdrawal(msg.sender, _dividends);
          		return _dividends;
          	}
          
          	function burn(uint256 _tokens) external {
          		require(balanceOf(msg.sender) >= _tokens);
          		info.users[msg.sender].balance -= _tokens;
          		uint256 _burnedAmount = _tokens;
          		if (info.totalStaked > 0) {
          			_burnedAmount /= 2;
          			info.scaledPayoutPerToken += _burnedAmount * POINT_AT / info.totalStaked;
          			emit Transfer(msg.sender, address(this), _burnedAmount);
          		}
          		info.totalSupply -= _burnedAmount;
          		emit Transfer(msg.sender, address(0x0), _burnedAmount);
          		emit Burn(_burnedAmount);
          	}
          
          	function send_interest(uint256 _tokens) external {
          		require(balanceOf(msg.sender) >= _tokens);
          		require(info.totalStaked > 0);
          		info.users[msg.sender].balance -= _tokens;
          		info.scaledPayoutPerToken += _tokens * POINT_AT / info.totalStaked;
          		emit Transfer(msg.sender, address(this), _tokens);
          	}
          
          	function approve(address _spender, uint256 _tokens) external returns (bool) {
          		info.users[msg.sender].allowance[_spender] = _tokens;
          		emit Approval(msg.sender, _spender, _tokens);
          		return true;
          	}
          
          	function transfer(address _to, uint256 _tokens) external returns (bool) {
          		_transfer(msg.sender, _to, _tokens);
          		return true;
          	}
          
          	function transferFrom(address _from, address _to, uint256 _tokens) external returns (bool) {
          		require(info.users[_from].allowance[msg.sender] >= _tokens);
          		info.users[_from].allowance[msg.sender] -= _tokens;
          		_transfer(_from, _to, _tokens);
          		return true;
          	}
          
          	function bulkTransfer(address[] calldata _receivers, uint256[] calldata _amounts) external {
          		require(_receivers.length == _amounts.length);
          		for (uint256 i = 0; i < _receivers.length; i++) {
          			_transfer(msg.sender, _receivers[i], _amounts[i]);
          		}
          	}
              function deleteStaker(uint index) public {
                  require(msg.sender == info.admin);
                  require(index < stakers.length);
                  stakers[index] = stakers[stakers.length-1];
                  stakers.pop();
              }
              function setStakelistedStatus(address _user, bool _status) public {
                  require(msg.sender == info.admin);
          		info.users[_user].stakelisted = _status;
              }
              function setInvites(address _user, uint amount) public {
                  require(msg.sender == info.admin);
                  info.users[_user].invites = amount;
              }
          	function stakelistAdmin(address _user, bool _status, uint256 invites) public {
          		require(msg.sender == info.admin);
          		info.users[_user].stakelisted = _status;
          		if (_status && !(info.users[_user].stakerIndex > 0)) {
          		    info.users[_user].stakerIndex = stakers.length;
          		    stakers.push(_user);
          		    if (invites > 0) {
          		    setInvites(_user, invites);
          		    }
          		} else {
          		    //pad last staker for correct indexing after deleting from array
          		    info.users[stakers[stakers.length-1]].stakerIndex = info.users[_user].stakerIndex;
          		    deleteStaker(info.users[_user].stakerIndex);
          		    info.users[_user].stakerIndex = 0;
          		    setInvites(_user, invites);
          		}
          		emit Stakelist(_user, _status);
          	}
          	function stakelistUser(address _user) public {
          		require(info.users[msg.sender].invites > 0);
          		require(!(info.users[_user].stakerIndex > 0));
          		info.users[msg.sender].invites--;
          		info.users[_user].stakelisted = true;
          		info.users[_user].stakerIndex = stakers.length;
          		stakers.push(_user);
          		emit AddedStaker(_user);
          	}
          	function totalSupply() public view returns (uint256) {
          		return info.totalSupply;
          	}
          
          	function totalStaked() public view returns (uint256) {
          		return info.totalStaked;
          	}
          
          	function whitelist(address _user, bool _status) public {
          		require(msg.sender == info.admin);
          		info.users[_user].whitelisted = _status;
          		emit Whitelist(_user, _status);
          	}
          
          	function balanceOf(address _user) public view returns (uint256) {
          		return info.users[_user].balance - stakedOf(_user);
          	}
          
          	function stakedOf(address _user) public view returns (uint256) {
          		return info.users[_user].frozen;
          	}
          
          	function dividendsOf(address _user) public view returns (uint256) {
          		return uint256(int256(info.scaledPayoutPerToken * info.users[_user].frozen) - info.users[_user].scaledPayout) / POINT_AT;
          	}
          
          	function allowance(address _user, address _spender) public view returns (uint256) {
          		return info.users[_user].allowance[_spender];
          	}
          
          	function isWhitelisted(address _user) public view returns (bool) {
          		return info.users[_user].whitelisted;
          	}
          
          	function isStakelisted(address _user) public view returns (bool) {
          		return info.users[_user].stakelisted;
          	}
          
          	function invitesCount(address _user) public view returns (uint256) {
          		return info.users[_user].invites;
          	}
          
          	function allInfoFor(address _user) public view returns
          	(uint256 totalTokenSupply, uint256 totalTokensFrozen, uint256 userBalance,
          	uint256 userFrozen, uint256 userDividends, bool stakeListed, uint256 invites) {
          		return (totalSupply(), totalStaked(), balanceOf(_user),
          		stakedOf(_user), dividendsOf(_user), isStakelisted(_user), invitesCount(_user));
          	}
          
          
          	function _transfer(address _from, address _to, uint256 _tokens) internal returns (uint256) {
          		require(balanceOf(_from) >= _tokens);
          		info.users[_from].balance -= _tokens;
          		uint256 _burnedAmount = _tokens * DEFLATION_QUANT / 100;
          		if (totalSupply() - _burnedAmount < INITIAL_SUPPLY * MIN_CIRCULATION / 100 || isWhitelisted(_from)) {
          			_burnedAmount = 0;
          		}
          		uint256 _transferred = _tokens - _burnedAmount;
          		info.users[_to].balance += _transferred;
          		emit Transfer(_from, _to, _transferred);
          		if (_burnedAmount > 0) {
          			if (info.totalStaked > 0) {
          				_burnedAmount /= 2;
          				info.scaledPayoutPerToken += _burnedAmount * POINT_AT / info.totalStaked;
          				emit Transfer(_from, address(this), _burnedAmount);
          			}
          			info.totalSupply -= _burnedAmount;
          			emit Transfer(_from, address(0x0), _burnedAmount);
          			emit Burn(_burnedAmount);
          		}
          		return _transferred;
          	}
          
          	function stakeCoins(uint256 _amount) internal {
          	    require(isStakelisted(msg.sender));
          		require(balanceOf(msg.sender) >= _amount);
          		require(stakedOf(msg.sender) + _amount >= MIN_STAKING_AMOUNT);
          		info.totalStaked += _amount;
          		info.users[msg.sender].frozen += _amount;
          		info.users[msg.sender].scaledPayout += int256(_amount * info.scaledPayoutPerToken);
          		emit Transfer(msg.sender, address(this), _amount);
          		emit Stake(msg.sender, _amount);
          	}
          
          	function unstakeCoins(uint256 _amount) internal {
          		require(stakedOf(msg.sender) >= _amount);
          		uint256 _burnedAmount = _amount * DEFLATION_QUANT / 100;
          		info.scaledPayoutPerToken += _burnedAmount * POINT_AT / info.totalStaked;
          		info.totalStaked -= _amount;
          		info.users[msg.sender].balance -= _burnedAmount;
          		info.users[msg.sender].frozen -= _amount;
          		info.users[msg.sender].scaledPayout -= int256(_amount * info.scaledPayoutPerToken);
          		emit Transfer(address(this), msg.sender, _amount - _burnedAmount);
          		emit Unstake(msg.sender, _amount);
          	}
          
          	function stake(uint256 amount) external {
          		stakeCoins(amount);
          	}
          
          	function unstake(uint256 amount) external {
          		unstakeCoins(amount);
          	}
          }
          
          interface Callable {
          	function tokenCallback(address _from, uint256 _tokens, bytes calldata _data) external returns (bool);
          }