Skip to main content
Version: V1

setup

ParameterDescription
token_addrEthereum address of an ERC20 Token

Smart Contract

# Can only be called by factory contract during createExchange()
setup(token_addr: address):

Web3

// Can only be called by factory contract during createExchange()
exchangeContract.methods.setup((token: String)).send()

addLiquidity

ParameterTypeDescription
msg.valueuint256Amount of ETH added
min_liquidityuint256Minimum minted liquidity
max_tokensuint256Maximum ERC20 tokens added
deadlineuint256Transaction deadline
Returns
uint256Amount of liquidity tokens minted

Smart Contract

@payable
addLiquidity(
min_liquidity: uint256,
max_tokens: uint256,
deadline: uint256
): uint256

Web3

exchangeContract.methods.addLiquidity(min_liquidity, max_tokens, deadline).send({ value: ethValue })

removeLiquidity

ParameterTypeDescription
amountuint256Amount of liquidity burned
min_ethuint256Minimum ETH removed
min_tokensuint256Minimum ERC20 tokens removed
deadlineuint256Transaction deadline
Returns
uint256Amount of ETH removed
uint256Amount of ERC20 tokens removed.

Smart Contract

removeLiquidity(
amount: uint256;
min_eth: uint256,
min_tokens: uint256,
deadline: uint256
): (uint256, uint256)

Web3

exchangeContract.methods.removeLiquidity(amount, min_eth, min_tokens, deadline).send()

default

ParameterTypeDescription
msg.valueuint256Amount of ETH sold

Smart Contract

# Default function in Vyper replaces the "fallback" function in Solidity
@payable
__default__():

Web3

web3.eth.sendTransaction({ value: ethAmount })

ethToTokenSwapInput

ParameterTypeDescription
msg.valueuint256Amount of ETH sold
min_tokensuint256Minimum ERC20 tokens bought
deadlineuint256Transaction deadline
Returns
uint256Amount of ERC20 tokens bought

Smart Contract

@payable
ethToTokenSwapInput(
min_tokens: uint256,
deadline: uint256
): uint256

Web3

exchangeContract.methods.ethToTokenSwapInput(min_liquidity, max_tokens, deadline).send({ value: ethValue })

ethToTokenTransferInput

ParameterTypeDescription
msg.valueuint256Amount of ETH sold
min_tokensuint256Minimum ERC20 tokens bought
deadlineuint256Transaction deadline
recipientaddressAddress that receives ERC20 tokens
Returns
uint256Amount of ERC20 tokens bought

Smart Contract

@payable
ethToTokenTransferInput(
min_tokens: uint256,
deadline: uint256,
recipient: address
): uint256

Web3

exchangeContract.methods
.ethToTokenTransferInput(min_liquidity, max_tokens, deadline, recipient)
.send({ value: ethValue })

ethToTokenSwapOutput

ParameterTypeDescription
msg.valueuint256Maximum ETH sold
tokens_boughtuint256Amount of ERC20 tokens bought
deadlineuint256Transaction deadline
Returns
uint256Amount of ETH sold

Smart Contract

@payable
ethToTokenSwapOutput(
tokens_bought: uint256,
deadline: uint256
): uint256

Web3

exchangeContract.methods.ethToTokenSwapOutput(tokens_bought, deadline).send({ value: ethValue })

ethToTokenTransferOutput

ParameterTypeDescription
msg.valueuint256Maximum ETH sold
tokens_boughtuint256Amount of ERC20 tokens bought
deadlineuint256Transaction deadline
recipientaddressAddress that receives ERC20 tokens
Returns
uint256Amount of ETH sold

Smart Contract

@payable
ethToTokenTransferOutput(
tokens_bought: uint256,
deadline: uint256,
recipient: address
): uint256

Web3

exchangeContract.methods
.ethToTokenTransferOutput(tokens_bought, deadline, (recipient: String))
.send({ value: ethValue })

tokenToEthSwapInput

ParameterTypeDescription
tokens_solduint256Amount of ERC20 tokens sold
min_ethuint256Minimum ETH bought
deadlineuint256Transaction deadline
Returns
uint256Amount of ETH bought

Smart Contract

tokenToEthSwapInput(
tokens_sold: uint256,
min_eth: uint256,
deadline: uint256
): uint256

Web3

exchangeContract.methods.tokenToEthSwapInput(tokens_sold, min_eth, deadline).send()

tokenToEthTransferInput

ParameterTypeDescription
tokens_solduint256Amount of ERC20 tokens sold
min_ethuint256Minimum ETH bought
deadlineuint256Transaction deadline
recipientaddressAddress that receives ETH
Returns
uint256Amount of ETH bought

Smart Contract

tokenToEthTransferInput(
tokens_sold: uint256,
min_eth: uint256,
deadline: uint256,
recipient: address
): uint256

Web3

exchangeContract.methods.tokenToEthTransferInput(tokens_sold, min_eth, deadline, recipient).send()

tokenToEthSwapOutput

ParameterTypeDescription
eth_boughtuint256Amount of ETH bought
max_tokensuint256Maximum ERC20 tokens sold
deadlineuint256Transaction deadline
Returns
uint256Amount of ERC20 tokens sold

Smart Contract

tokenToEthSwapOutput(
eth_bought: uint256,
max_tokens: uint256,
deadline: uint256
): uint256

Web3

exchangeContract.methods.tokenToEthSwapOutput(eth_bought, max_tokens, (deadline: Integer)).send()

tokenToEthTransferOutput

ParameterTypeDescription
eth_boughtuint256Amount of ETH bought
max_tokensuint256Maximum ERC20 tokens sold
deadlineuint256Transaction deadline
recipientaddressAddress that receives ETH
Returns
uint256Amount of ERC20 tokens sold

Smart Contract

tokenToEthTransferOutput(
eth_bought: uint256,
max_tokens: uint256,
deadline: uint256,
recipient: address
): uint256

Web3

exchangeContract.methods
.tokenToEthTransferOutput(eth_bought, max_tokens, (deadline: Integer), (recipient: String))
.send()

tokenToTokenSwapInput

ParameterTypeDescription
tokens_solduint256Amount of input ERC20 tokens sold
min_tokens_boughtuint256Minimum output ERC20 tokens bought
min_eth_boughtuint256Minimum ETH bought as intermediary
deadlineuint256Transaction deadline
token_addraddressAddress of output ERC20 token
Returns
uint256Amount of output ERC20 tokens bought

Smart Contract

tokenToTokenSwapInput(
tokens_sold: uint256,
min_tokens_bought: uint256,
min_eth_bought: uint256,
deadline: uint256,
token_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToTokenSwapInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, token_addr)
.send()

tokenToTokenTransferInput

ParameterTypeDescription
tokens_solduint256Amount of input ERC20 tokens sold
min_tokens_boughtuint256Minimum output ERC20 tokens bought
min_eth_boughtuint256Minimum ETH bought as intermediary
deadlineuint256Transaction deadline
recipientaddressAddress that receives output ERC20 tokens
token_addraddressAddress of output ERC20 token
Returns
uint256Amount of output ERC20 tokens bought

Smart Contract

tokenToTokenTransferInput(
tokens_sold: uint256,
min_tokens_bought: uint256,
min_eth_bought: uint256,
deadline: uint256,
recipient: address
token_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToTokenTransferInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, recipient, token_addr)
.send()

tokenToTokenSwapOutput

ParameterTypeDescription
tokens_boughtuint256Amount of output ERC20 tokens bought
max_tokens_solduint256Maximum input ERC20 tokens bought
max_eth_solduint256Maximum ETH bought as intermediary
deadlineuint256Transaction deadline
token_addraddressAddress of output ERC20 token
Returns
uint256Amount of input ERC20 tokens sold

Smart Contract

tokenToTokenSwapOutput(
tokens_bought: uint256,
max_tokens_sold: uint256,
max_eth_sold: uint256,
deadline: uint256,
token_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToTokenSwapOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, token_addr)
.send()

tokenToTokenTransferOutput

ParameterTypeDescription
tokens_boughtuint256Amount of output ERC20 tokens bought
max_tokens_solduint256Maximum input ERC20 tokens bought
max_eth_solduint256Maximum ETH bought as intermediary
deadlineuint256Transaction deadline
recipientaddressAddress that receives output ERC20 tokens
token_addraddressAddress of output ERC20 token
Returns
uint256Amount of input ERC20 tokens sold

Smart Contract

tokenToTokenTransferOutput(
tokens_bought: uint256,
max_tokens_sold: uint256,
max_eth_sold: uint256,
deadline: uint256,
recipient: address,
token_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToTokenTransferOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, recipient, token_addr)
.send()

tokenToExchangeSwapInput

ParameterTypeDescription
tokens_solduint256Amount of input ERC20 tokens sold
min_tokens_boughtuint256Minimum output ERC20 tokens bought
min_eth_boughtuint256Minimum ETH bought as intermediary
deadlineuint256Transaction deadline
exchange_addraddressAddress of output ERC20 token exchange
Returns
uint256Amount of output ERC20 tokens bought

Smart Contract

tokenToTokenSwapInput(
tokens_sold: uint256,
min_tokens_bought: uint256,
min_eth_bought: uint256,
deadline: uint256,
exchange_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToTokenSwapInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, exchange_addr)
.send()

tokenToExchangeTransferInput

ParameterTypeDescription
tokens_solduint256Amount of input ERC20 tokens sold
min_tokens_boughtuint256Minimum output ERC20 tokens bought
min_eth_boughtuint256Minimum ETH bought as intermediary
deadlineuint256Transaction deadline
recipientaddressAddress that receives output ERC20 tokens
exchange_addraddressAddress of output ERC20 token exchange
Returns
uint256Amount of output ERC20 tokens bought

Smart Contract

tokenToExchangeTransferInput(
tokens_sold: uint256,
min_tokens_bought: uint256,
min_eth_bought: uint256,
deadline: uint256,
recipient: address
exchange_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToExchangeTransferInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, recipient, exchange_addr)
.send()

tokenToExchangeSwapOutput

ParameterTypeDescription
tokens_boughtuint256Amount of output ERC20 tokens bought
max_tokens_solduint256Maximum input ERC20 tokens bought
max_eth_solduint256Maximum ETH bought as intermediary
deadlineuint256Transaction deadline
exchange_addraddressAddress of output ERC20 token exchange
Returns
uint256Amount of input ERC20 tokens sold

Smart Contract

tokenToExchangeSwapOutput(
tokens_bought: uint256,
max_tokens_sold: uint256,
max_eth_sold: uint256,
deadline: uint256,
exchange_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToExchangeSwapOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, exchange_addr)
.send()

tokenToExchangeTransferOutput

ParameterTypeDescription
tokens_boughtuint256Amount of output ERC20 tokens bought
max_tokens_solduint256Maximum input ERC20 tokens bought
max_eth_solduint256Maximum ETH bought as intermediary
deadlineuint256Transaction deadline
recipientaddressAddress that receives output ERC20 tokens
exchange_addraddressAddress of output ERC20 token exchange
Returns
uint256Amount of input ERC20 tokens sold

Smart Contract

tokenToExchangeTransferOutput(
tokens_bought: uint256,
max_tokens_sold: uint256,
max_eth_sold: uint256,
deadline: uint256,
recipient: address,
exchange_addr: address
): uint256

Web3

exchangeContract.methods
.tokenToExchangeTransferOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, recipient, exchange_addr)
.send()

getEthToTokenInputPrice

ParameterTypeDescription
eth_solduint256Amount of ETH sold
Returns
uint256Amount of ERC20 tokens that can be bought

Smart Contract

@constant
getEthToTokenInputPrice(eth_sold: uint256): uint256

Web3

exchangeContract.methods.getEthToTokenInputPrice(eth_sold).call()

getEthToTokenOutputPrice

ParameterTypeDescription
tokens_boughtuint256Amount of ERC20 tokens bought
Returns
uint256Amount of ETH that must be sold

Smart Contract

@constant
getEthToTokenOutputPrice(tokens_bought: uint256): uint256

Web3

exchangeContract.methods.getEthToTokenOutputPrice(tokens_bought).call()

getTokenToEthInputPrice

ParameterTypeDescription
tokens_solduint256Amount of ERC20 tokens sold
Returns
uint256Amount of ETH that can be bought

Smart Contract

@constant
getTokenToEthInputPrice(tokens_sold: uint256): uint256

Web3

exchangeContract.methods.getTokenToEthInputPrice(tokens_sold).call()

getTokenToEthOutputPrice

ParameterTypeDescription
eth_boughtuint256Amount of ETH bought
Returns
uint256Amount of ERC20 tokens that must be sold

Smart Contract

@constant
getTokenToEthOutputPrice(eth_bought: uint256): uint256

Web3

exchangeContract.methods.getTokenToEthOutputPrice(eth_bought).call()

tokenAddress

Returns
addressAddress of ERC20 token sold on exchange

Smart Contract

@constant
tokenAddress(): address

Web3

exchangeContract.methods.tokenAddress().call()

factoryAddress

Returns
addressAddress of factory that created exchange

Smart Contract

@constant
factoryAddress(): address

Web3

exchangeContract.methods.factoryAddress().call()

name

Returns
bytes32Name of liquidity token

Smart Contract

# all exchange contracts have the same name
@constant
name(): bytes32 // Uniswap V1

Web3

exchangeContract.methods.tokenAddress().call()

symbol

Returns
bytes32Symbol of liquidity token

Smart Contract

# all exchange contracts have the same symbol
@constant
symbol(): bytes32 // UNI-V1

Web3

exchangeContract.methods.tokenAddress().call()

decimals

Returns
uint256Decimals of liquidity token

Smart Contract

# all exchange contracts have the same decimals
@constant
decimals(): uint256 // 18

Web3

exchangeContract.methods.decimals().call()

balanceOf

ParameterTypeDescription
_owneraddressEthereum address
Returns
uint256Liquidity token balance of address

Smart Contract

@constant
balanceOf(_owner: address): uint256

Web3

exchangeContract.methods.balanceOf(_owner).call()

transfer

ParameterTypeDescription
_toaddressRecipient address
_valueuint256Amount transferred
Returns
boolTrue if successful. Reverts or false on failure

Smart Contract

transfer(
_to: address,
_value : uint256
): bool

Web3

exchangeContract.methods.transfer(_to, _value).send()

transferFrom

ParameterTypeDescription
_fromaddressSender address
_toaddressRecipient address
_valueuint256Amount transferred
Returns
boolTrue if successful. Reverts or false on failure

Smart Contract

transferFrom(
_from: address,
_to: address,
_value : uint256
): bool

Web3

exchangeContract.methods.transferFrom(_from, _to, _value).send()

approve

ParameterTypeDescription
_spenderaddressAddress of approved spender
_valueuint256Spender allowance
Returns
boolTrue if successful. Reverts or false on failure

Smart Contract

approve(
_spender: address,
_value: uint256
): bool

Web3

exchangeContract.methods.approve(_spender, _value).send()

allowance

ParameterTypeDescription
_owneraddressAddress of liquidity token owner
_spenderuint256Address of approved spender
Returns
uint256Spender allowance

Smart Contract

allowance(
_owner: address,
_spender: address
): uint256

Web3

exchangeContract.methods.allowance(_owner, _spender).call()