Skip to main content
Version: 1.3.2

Imports

Importing code into the simulation can be usefull to generalise certain actions, you could make one file that contains certain actions and how they should be performed. These actions can be called through the agent or environment code files.

Currently we only support one way of importing; using a seperate file that contains a single Python class. This file will be made available for you to instantiate through whichever file you would like the same way as the contracts are made available, through the client. It is up to you to instantiate the class if necessary and make it available to the area where you would like to call the functions.

Format

nametype
namestring
sourcestring
typestring, currently always set to sdk_class

Example

imports:
- name: "bancor"
source: "file://./imports/bancor.py"
type: "sdk_class"

Example of using class

The bancor sdk class specified here:

class BancorModule():
def __init__(self) -> None:
pass

def test(self):
return "BancorModule test"

See the example environmentInitialization.py.

from almanak.simulations.environment import EnvironmentWrapper
from almanak.simulations.metriccollector import MetricCollectorWrapper


def environment_initialization(_environment: EnvironmentWrapper, _metric_collector: MetricCollectorWrapper):
determine_swapping_fee(_environment)
print(_environment.get_client().bancor().test())


# pyright: reportUndefinedVariable=false
environment_initialization(a, metric_collector)