Custom Formulas

Custom formulas let you perform calculations on event values before filtering or displaying them.

When to Use Formulas

Common use cases:

  • Calculating APY from secondly or daily rates

  • Computing percentages

  • Formatting timestamps

  • Custom calculations

Formula Syntax

Basic operations:

  • + Addition

  • - Subtraction

  • * Multiplication

  • / Division

  • () Parentheses for order of operations

Available functions:

  • pow Raises a number to the power of another number.

  • sqrt Returns the square root of a number.

  • abs Returns the absolute (non-negative) value of a number.

  • exp Returns e raised to the power of the input value (eˣ).

  • min Returns the smallest value from a set of numbers.

  • max Returns the largest value from a set of numbers.

  • floor Rounds a number down to the nearest integer.

  • ceil Rounds a number up to the nearest integer.

  • round Rounds a number to the nearest integer.

Example formulas:

Using Formulas in Conditions

Choose the event field and select "Custom Formula" as the operator

Example:

If the event returns the value as the continuously-compounded rate (log rate), we can use the following formula to convert it to annual rate:

Using Formulas in Display

If the event returns the value as the continuously-compounded rate (log rate), we can use the following formula to convert it to annual rate:

Example:

💡 Tip: Use formulas to make notifications readable. Raw blockchain values are hard to parse at a glance.

Last updated