Structure

The following is an example of a usecase rule to send an alert when withdrawal fee of a liquidity pool is above 50%:

function process({ judger, event, utils, dataSource }) {
  const func = judger.getCallFunction();
  if (func === "setWithdrawalFee") {
    const fee = judger.getCallParameter("_newWithdrawalFee");
    return {
      isAlert: fee > 50,
      message: `WithdrawalFee is set to ${fee}. ${JSON.stringify(event)}`
    }
  }
}

Input

The input is a destructured object with following keys:

judger

The judger module contains a function that is specifically designed to retrieve details of an event. The function can vary depending on the type of event as defined in the target configuration.

See https://gitlab.com/inspexco/frontend/gitbook/-/blob/gitbook/usecase-rules/broken-reference/README.md for more information.

event

The judger module contains a function that is specifically designed to retrieve details of an event. The function can vary depending on the type of event.

See https://gitlab.com/inspexco/frontend/gitbook/-/blob/gitbook/usecase-rules/broken-reference/README.md for more information.

utils

The utils module from ethers.js provides a collection of utility functions that offer common functionality and helper methods for working with Ethereum and blockchain-related tasks.

dataSource (in development)

A data source is an external information not present in current events, but is useful in determining whether the event should be alerted or not.

Only data sources explicitly chosen to be injected in the usecase rule can be called.

Each data source has different specification.

See https://gitlab.com/inspexco/frontend/gitbook/-/blob/gitbook/usecase-rules/broken-reference/README.md for more information.

Output

The input is an object with following keys:

isAlert

boolean Should be true if the event should be alerted. false otherwise.

Default: false

message

string The message that will return as a result message when simulation judger.

Default: ""

Last updated