Tokens
Tokens are an important part of the simulation. This field allows you to
configure tokens that have to instantiated in the simulator, without adding them
here there it won't be available to use within the simulation at all. But if you
do add them here you can use environment.get_client().get_chain().get_token()
to retreive a class for the token (EVMToken
).
This class has several functions available.
mint(address: str, amount: float)
transfer(from_address: str, to_address: str, amount: float)
approve(wallet: str, spender: str, amount: float)
get_balance(address: string)
get_token_quantity_as_decimal(quantity: int)
These functions will all be available for that token.
Please only use ERC20 tokens, other tokens are not supported. The easiest way to find the address for a token is to use an explorer of your choice and find the token there. It will have the address listed somewhere on that page or in the URL.
It is also possible to add native tokens, the difference here is that instead of
using the ERC20 contract functions on the provided address it will use the
native token to perform actions. Certain actions are not supported (approve
).
To do this make sure to set the isNative
field to true
and add a
nativeLabel
field with a string for the name of this native token. The label
has exists because sometimes you might want to run simulations on multiple
projects at the same time that use different addresses for native token mapping.
The reason for this field is that certain projects have a seperate field for the
native token that runs on the chain they're using. For example bancor
uses the
address 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
in their contracts which
means Native ETH
. Sometimes when performing a function you will need to use
these addresses to call contracts. This should also work on layer 2 chains,
Polygon for example this will map to functions that call MATIC balances and
transfers etc.
Please note that when using Wrapped ETH (or any other wrapped native token) you should NOT set it to native since this is an ERC20 token.
Format
name | type |
---|---|
type | array of { label: string, address: string } |
required | true |
Example
nativeTokens:
- label: "bancor"
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
Format
name | type |
---|---|
type | array of string |
required | true |
Example
tokens:
- name: "DAI"
address: "0x6B175474E89094C44Da98b954EedeAC495271d0F"
isNative: false
- name: "BNT"
address: "0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C"
isNative: false
- name: "ETH"
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
isNative: true
nativeLabel: "bancor"