Events are available as callback functions in the PoodlApp config object. Each event will provide you with a set of outputs that can then be used in custom functions.
Note that events are fired locally, async functions are therefore not required.
onAccountChange
This event is triggered every time users connect or disconnect their wallet as well as switching between accounts.
This event is triggered every time users succesfully swap a token through the widget
It gives back a json object - quote
The quote object represent the aggregator quote used to submit the transaction and therefore it includes all the information related to that transaction.
/*
* available args
* quote: aggregatorQuote
*/
quote : {
from: string, //address of the user
chainId: number, // chain where the transaction took place
buyTokenAddress: string, // address of the token to be bought
sellTokenAddress: string, // address of the token to be sold
sellAmount: number, // amount sold
buyAmount: string, // amount bought
}
This is particularly useful for tracking or analytics purposes:
// Database
onSuccessSwap: quote => {
//{code to push to database(quote)}
}
// Google analytics
// {define Google analytics event}
onSuccessSwap: quote => {
//{Google analytics event(quote)}
}