Variables with CacheTask
Storing variables with CacheTask
You can store data in the task-runner's variable cache by using a CacheTask. This is a useful tool when you have a task that is complex, or requires the use of a lot of dynamically computed numbers.
CacheTask
The following is an example of a CacheTask specifying multiple variables, building off of one another.
This large task does quite a number of things. It does the following:
It calls an EVM contract and parses some hex using a JsonParseTask, then creates a new variable called
FAIR_VALUE_HEX
that stores a JSON value.It parses that hex into a new variable,
FAIR_VALUE
It creates a low value to be used in subsequent jobs by using a
MultiplyTask
and setting 0.95 *FAIR_VALUE
toFAIR_VALUE_LOW
It creates a high value to be used in subsequent jobs by using the same method to set 1.05 *
FAIR_VALUE
toFAIR_VALUE_HIGH
In subsequent jobs one can reference the values locked in these variables.
Math Tasks
Variables are easily combined with math-related tasks, AddTask
, MultiplyTask
, SubtractTask
, and DivideTask
are some really common ones. These tasks will run agains whatever number is in the current_value of the task-runner context.
They can also be combined with ValueTask
to pull a variable into the current_value position.
For example:
Inside of Math Tasks you can specify one of the following fields:
Last updated