Skip to Content

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.

ActionAction type
Aggregatemath/aggregate
Compare With Tolerancemath/compare-tolerance
Treasury Runwaymath/treasury-runway
Format Numbermath/format-number
Multi-Source Consensus Tolerancemath/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

FieldTypeRequiredDefaultAllowed valuesDescription
operationstringYessumsum, count, average, median, min, max, productOperation.
inputModestringYesexplicitexplicit, arrayInput Mode.
explicitValuesstringNoValues. Shown when inputMode is explicit.
arrayInputstringNoArray Data. Shown when inputMode is array.
fieldPathstringNoField 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.
postOperationstringNononenone, add, subtract, multiply, divide, modulo, power, abs, round, round-decimals, floor, ceilOperation.
postOperandstringNoOperand. Shown when postOperation is one of add, subtract, multiply, divide, modulo, power.
postDecimalPlacesnumberNomin 0Decimal Places. Shown when postOperation is round-decimals.
zeroDivisorBehaviourstringNofailfail, null-resultZero 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

OutputDescription
successWhether the aggregation succeeded
resultThe 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
operationThe operation(s) performed
inputCountNumber of values that were aggregated
divisionByZerotrue 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
errorError 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

FieldTypeRequiredDefaultAllowed valuesDescription
actualstringYesActual.
expectedstringYesExpected.
modestringYespercentpercent, absoluteTolerance Mode.
tolerancestringYesTolerance. 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.
precisionnumberNo6min 0Percent Decimal Places. Decimal places used when formatting percentDifference.

Outputs

OutputDescription
successWhether the comparison ran
withinToleranceTrue when the difference is inside the tolerance
breachedTrue when the difference is outside the tolerance - wire this to an alert branch
directionabove, below or equal, relative to the expected value
differenceActual minus expected, as a signed decimal string
absoluteDifferenceThe difference without its sign
percentDifferenceSigned percentage difference from expected, or null when expected is zero
actualThe normalised actual value
expectedThe normalised expected value
toleranceThe tolerance that was applied
modepercent or absolute
errorError 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

FieldTypeRequiredDefaultAllowed valuesDescription
treasuryBalancestringYesTreasury Balance. Current treasury balance. Use the same amount unit and precision for all balance and rate inputs.
incomingRatestringYesIncoming Rate. Amount entering the treasury during each rate period.
outgoingRatestringYesOutgoing Rate. Amount leaving the treasury during each rate period.
protectedReservestringYesProtected Reserve. Balance reserved from ordinary spending. A balance below this value sets reserveBreached to true.
minimumRunwayDaysstringYesMinimum Runway Days. Required minimum runway in days. Reported runway uses up to six decimal places.
ratePeriodstringYessecond, minute, hour, day, week, month, yearRate Period. Fixed period represented by both incoming and outgoing rates.

Outputs

OutputDescription
successWhether the calculation succeeded
reserveAdjustedBalanceTreasury balance minus protected reserve, preserved as a signed decimal string
reserveBreachedTrue when the treasury balance is below the protected reserve
netBurnRateOutgoing rate minus incoming rate in the selected rate period
runwayDaysRemaining runway in days with up to six decimal places, or null when the treasury is not depleting
requiredRecoveryAmountFinal top-up required to reach minimum runway, rounded upward at the supplied amount precision
statusRunway status: safe, warning or critical. A safe result can still have reserveBreached set to true.
ratePeriodThe fixed period used by the incoming and outgoing rates
errorError 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

FieldTypeRequiredDefaultAllowed valuesDescription
valuestringYesValue.
decimalsnumberNo0min 0Token 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.
notationstringNocompactcompact, plainNotation.
precisionnumberNo2min 0Decimal Places.
unitstringNoUnit. Appended after the number, separated by a space.

Outputs

OutputDescription
successWhether formatting succeeded
formattedThe display string, e.g. “1.23M SKY”
valueThe full scaled value as a decimal string, with no rounding applied
magnitudeThe compact suffix used: K, M, B, T or empty
notationcompact or plain
errorError 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

FieldTypeRequiredDefaultAllowed valuesDescription
valuesstringYesSource 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.
tolerancestringYesTolerance. In percent mode, 1.0 means 1% max divergence between any pair of sources.
modestringYespercentpercent, absoluteTolerance Mode.
minSourcesnumberNo2min 2Minimum 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.
precisionnumberNo6min 0Percent Decimal Places.

Outputs

OutputDescription
successWhether the consensus check executed
inConsensusTrue when all sources agree within the specified tolerance
sourceCountNumber of sources evaluated
maxDeviationLargest difference found between any two sources
maxPercentDeviationLargest percentage difference between any pair, relative to the larger absolute value of that pair. 0 only when every source agrees exactly
medianMedian across all sources, including any that broke consensus
valuesThe source values as they were read, in input order
toleranceThe tolerance applied
modepercent or absolute
errorError message if consensus check failed