Tokens
Last updated
Last updated
Get a token object through the getToken(tokenSymbol)
function on the tokenService.
The list of tokens that can be passed into getToken()
are: SAI, MKR, WETH, PETH, ETH.
This list can also be obtained with tokenService.getTokens()
. This function returns a string representation of the token symbol, e.g. 'SAI', which can also be passed into getToken
.
When the Multi-Collateral Dai plugin is in use, getToken('DAI')
will return a token object for Dai.
Most of the methods below can be called on any token object. deposit
and withdraw
are for WETH only, and join
and exit
are for PETH only.
Params:
tokenOwner
- address of token owner
spender
- address of token spender
Returns: promise (resolves to token allowance)
allowance
returns a representing the token allowance.
Params: none
Returns: promise (resolves balance of current account)
Params: address to check
Returns: promise (resolves balance of address)
Params: none
Returns: promise (resolves total supply of token)
Params:
spender - address of token spender
amount - amount of token to allow
approve
approves the spending address to spend up to amount
of msg.sender
's tokens.
Params: address of token spender
approveUnlimited
approves the spending address to spend the maximum amount of msg.sender
's tokens.
Params:
to - address to send to
amount - amount of token to send
transfer
transfers amount
of token to to
address.
Params:
from - address to send tokens from
to - address to send to
amount - amount of token to send
transferFrom()
transfers amount
of token from from
address to to
address. Transaction will fail if msg.sender
does not have allowance to transfer the amount of tokens from
the from address.
Params: amount of Eth to deposit
deposit
converts amount
of Eth to amount
of Weth.
Params: amount of Weth to withdraw
withdraw
converts amount
of Weth to amount
of Eth.
Params: amount of Weth to join
Params: amount of Peth to exit
balance
returns a representing the token balance of the current account
balanceOf
returns a representing the token balance of the supplied account.
totalSupply
returns a representing the total token supply
Returns: promise (resolves to once mined)
Returns: promise (resolves to once mined)
Returns: promise (resolves to once mined)
Returns: promise (resolves to once mined)
Returns: promise (resolves to once mined)
Returns: promise (resolves to once mined)
Returns: promise (resolves to once mined)
join
converts amount
of Weth to Peth, at the .
Returns: promise (resolves to once mined)
withdraw
converts amount
of Peth to Weth, at the .