Math action reference
This page is generated from the plugin registry. Do not edit it by hand.
Aggregation and arithmetic operations across array data or multiple upstream node outputs.
For guidance and examples see the Math guide.
Set actionType in a node’s config to the action type shown under each heading. See the workflow definition page for the node format.
| Action | Action type |
|---|---|
| Aggregate | math/aggregate |
| Compare With Tolerance | math/compare-tolerance |
| Treasury Runway | math/treasury-runway |
| Format Number | math/format-number |
| Multi-Source Consensus Tolerance | math/consensus-tolerance |
Aggregate
Action type: math/aggregate. Connection: not required.
Perform aggregation operations (sum, count, average, median, min, max, product) on numeric values from upstream nodes or arrays, with optional post-aggregation arithmetic.
Inputs
| Field | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|
operation | string | Yes | sum | sum, count, average, median, min, max, product | Operation. |
inputMode | string | Yes | explicit | explicit, array | Input Mode. |
explicitValues | string | No | Values. Shown when inputMode is explicit. | ||
arrayInput | string | No | Array Data. Shown when inputMode is array. | ||
fieldPath | string | No | Field Path. Property to extract from each array item. [{balance: “100”}, {balance: “200”}] → balance [{token: {amount: 50}}] → token.amount [{result: {value: “3”}}] → result.value [1, 2, 3] → leave empty. Shown when inputMode is array. | ||
postOperation | string | No | none | none, add, subtract, multiply, divide, modulo, power, abs, round, round-decimals, floor, ceil | Operation. |
postOperand | string | No | Operand. Shown when postOperation is one of add, subtract, multiply, divide, modulo, power. | ||
postDecimalPlaces | number | No | min 0 | Decimal Places. Shown when postOperation is round-decimals. | |
zeroDivisorBehaviour | string | No | fail | fail, null-result | Zero Divisor. What happens when the operand is zero. Failing stops the run; a null result lets a Condition node branch on divisionByZero. Shown when postOperation is one of divide, modulo. |
Outputs
| Output | Description |
|---|---|
success | Whether the aggregation succeeded |
result | The aggregation result as a string (exact on the fixed-point path), or null when divide or modulo had a zero operand and the Zero Divisor field is set to return a null result |
resultType | ”bigint” when the result is a whole number computed in fixed point, “number” otherwise |
operation | The operation(s) performed |
inputCount | Number of values that were aggregated |
divisionByZero | true when the divide or modulo post-operation had a zero operand and the Zero Divisor field is set to return a null result; result is then null and the step succeeds so a Condition can branch on it |
error | Error message if aggregation failed |
Compare With Tolerance
Action type: math/compare-tolerance. Connection: not required.
Compare an actual value against an expected value with a percentage or absolute tolerance. BigInt-safe, so RAD and WAD magnitude values compare without float precision loss.
Inputs
| Field | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|
actual | string | Yes | Actual. | ||
expected | string | Yes | Expected. | ||
mode | string | Yes | percent | percent, absolute | Tolerance Mode. |
tolerance | string | Yes | Tolerance. In percent mode this is a percentage, so 0.5 means half a percent. In absolute mode it is in the same units as the values. | ||
precision | number | No | 6 | min 0 | Percent Decimal Places. Decimal places used when formatting percentDifference. |
Outputs
| Output | Description |
|---|---|
success | Whether the comparison ran |
withinTolerance | True when the difference is inside the tolerance |
breached | True when the difference is outside the tolerance - wire this to an alert branch |
direction | above, below or equal, relative to the expected value |
difference | Actual minus expected, as a signed decimal string |
absoluteDifference | The difference without its sign |
percentDifference | Signed percentage difference from expected, or null when expected is zero |
actual | The normalised actual value |
expected | The normalised expected value |
tolerance | The tolerance that was applied |
mode | percent or absolute |
error | Error message if the comparison failed |
Treasury Runway
Action type: math/treasury-runway. Connection: not required.
Calculate reserve-adjusted treasury runway, recovery funding and a machine-readable treasury status using precision-safe arithmetic.
Inputs
| Field | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|
treasuryBalance | string | Yes | Treasury Balance. Current treasury balance. Use the same amount unit and precision for all balance and rate inputs. | ||
incomingRate | string | Yes | Incoming Rate. Amount entering the treasury during each rate period. | ||
outgoingRate | string | Yes | Outgoing Rate. Amount leaving the treasury during each rate period. | ||
protectedReserve | string | Yes | Protected Reserve. Balance reserved from ordinary spending. A balance below this value sets reserveBreached to true. | ||
minimumRunwayDays | string | Yes | Minimum Runway Days. Required minimum runway in days. Reported runway uses up to six decimal places. | ||
ratePeriod | string | Yes | second, minute, hour, day, week, month, year | Rate Period. Fixed period represented by both incoming and outgoing rates. |
Outputs
| Output | Description |
|---|---|
success | Whether the calculation succeeded |
reserveAdjustedBalance | Treasury balance minus protected reserve, preserved as a signed decimal string |
reserveBreached | True when the treasury balance is below the protected reserve |
netBurnRate | Outgoing rate minus incoming rate in the selected rate period |
runwayDays | Remaining runway in days with up to six decimal places, or null when the treasury is not depleting |
requiredRecoveryAmount | Final top-up required to reach minimum runway, rounded upward at the supplied amount precision |
status | Runway status: safe, warning or critical. A safe result can still have reserveBreached set to true. |
ratePeriod | The fixed period used by the incoming and outgoing rates |
error | Error message if the calculation failed |
Format Number
Action type: math/format-number. Connection: not required.
Turn a raw integer or decimal into a readable string - scale down token decimals, group thousands, or shorten to compact K/M/B/T notation with an optional unit.
Inputs
| Field | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|
value | string | Yes | Value. | ||
decimals | number | No | 0 | min 0 | Token Decimals. Divides the value by 10 to this power before formatting. Use 18 for a wei amount, 6 for USDC, 0 for a plain number. |
notation | string | No | compact | compact, plain | Notation. |
precision | number | No | 2 | min 0 | Decimal Places. |
unit | string | No | Unit. Appended after the number, separated by a space. |
Outputs
| Output | Description |
|---|---|
success | Whether formatting succeeded |
formatted | The display string, e.g. “1.23M SKY” |
value | The full scaled value as a decimal string, with no rounding applied |
magnitude | The compact suffix used: K, M, B, T or empty |
notation | compact or plain |
error | Error message if formatting failed |
Multi-Source Consensus Tolerance
Action type: math/consensus-tolerance. Connection: not required.
Evaluate N-way agreement across multiple price feeds or oracle readings (e.g. Chronicle, Chainlink, Pyth). BigInt-safe, checks every pair of sources against the tolerance and reports the median across all sources.
Inputs
| Field | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|
values | string | Yes | Source Values. One value per line, or a JSON array, from multiple oracle/read nodes. Commas inside a value are read as thousands separators, so put each source on its own line. | ||
tolerance | string | Yes | Tolerance. In percent mode, 1.0 means 1% max divergence between any pair of sources. | ||
mode | string | Yes | percent | percent, absolute | Tolerance Mode. |
minSources | number | No | 2 | min 2 | Minimum Sources Required. Fails if fewer than this number of sources are supplied (prevents single-oracle fallback). Two is the floor, so a lower value is treated as 2. |
precision | number | No | 6 | min 0 | Percent Decimal Places. |
Outputs
| Output | Description |
|---|---|
success | Whether the consensus check executed |
inConsensus | True when all sources agree within the specified tolerance |
sourceCount | Number of sources evaluated |
maxDeviation | Largest difference found between any two sources |
maxPercentDeviation | Largest percentage difference between any pair, relative to the larger absolute value of that pair. 0 only when every source agrees exactly |
median | Median across all sources, including any that broke consensus |
values | The source values as they were read, in input order |
tolerance | The tolerance applied |
mode | percent or absolute |
error | Error message if consensus check failed |