Sentio Docs
Ask or search…
⌃K

Decoding from custom ABIs

Sentio already have a list of builtin ABIs. However, you would still need to provide your own ABI so sentio can generate type safe methods for you to write elegant processor code.
Here we use Uniswap example to demonstrate how to do this. Assuming we want to monitor DAI/USDC uniswap pool. You could use sentio addto fetch the ABI automatically (we got it from etherscan).
If your ABI is not available from etherscan, you could manually copy the json data and put it into your directory abi/eth
Then you run
yarn sentio build
It will generate all the types under src/types
Then you can write functions using modern IDEs like IntelliJ or VScode, it will show auto-complete on the method OnEventSwap (which correspond to the event in the contract).
UniswapProcessor.bind({address: '0x5777d92f208679db4b9778590fa3cab3ac9e2168'})
.onEventSwap(
async function (event: SwapEvent, ctx: UniswapContext) {
ctx.meter.Gauge('dai_usdc_amount0').record(Math.abs(Number(event.args.amount0.toBigInt())))
ctx.meter.Gauge('dai_usdc_amount1').record(Math.abs(Number(event.args.amount1.toBigInt())))
}
)