Data Sources

Data source is an external source of information that is useful in defining usecase rules. There are some cases where information received from the event alone is not enough to determine whether it should be alerted. A great usecase to use data sources is to check if a wallet is found in a government's sanction list.

async process({ event, dataSource }) {
  const sanctionList = dataSource.get("sanction-list");
  const isInSanctionList = sanctionList.check(event.data.from);

  return {
    isAlert: isInSanctionList
  }
}

This usecase rule will alert if the transaction is initiated from an address found in sanction lists.

Accessing data sources in usecase rules

process() function injects dataSource parameter so that it can be called. In order to get specific type of data source, call dataSource.get("<data-source-type>") to access the data source. As in above example, dataSource.get("sanction-list") will provide sanction list methods.

async process({ dataSource }) {
  const cexDataSource = dataSource.get("cex");
  const price = cexDataSource.getTokenPrice("BTCUSDT")

  return {
    isAlert: price > 25000
  }
}

Each data source has different methods that can be called. Please consult the API Documentation for more information.

Last updated