amm.watchRebalanceSwap
Watches for rebalance swap events on the Fee AMM.
Usage
import { } from './viem.config'
const = .amm.watchRebalanceSwap({
: (, ) => {
.('Amount in:', .amountIn)
.('Amount out:', .amountOut)
.('Swapper:', .swapper)
.('User token:', .userToken)
.('Validator token:', .validatorToken)
},
})
// Later, stop watching
()Return Type
type ReturnType = () => voidReturns a function to unsubscribe from the event.
Parameters
onRebalanceSwap
- Type:
function
declare function onRebalanceSwap(args: Args, log: Log): void
type Args = {
/** Address of the user token */
userToken: Address
/** Address of the validator token */
validatorToken: Address
/** Address of the swapper */
swapper: Address
/** Amount of validator token swapped in */
amountIn: bigint
/** Amount of user token received */
amountOut: bigint
}Callback to invoke when a rebalance swap occurs.
userToken (optional)
- Type:
Address | bigint
Address or ID of the user token to filter events.
validatorToken (optional)
- Type:
Address | bigint
Address or ID of the validator token to filter events.
args (optional)
- Type:
object
type Args = {
/** Filter by user token address */
userToken?: Address | Address[] | null
/** Filter by validator token address */
validatorToken?: Address | Address[] | null
/** Filter by swapper address */
swapper?: Address | Address[] | null
}Filter parameters for the event.
fromBlock (optional)
- Type:
bigint
Block to start listening from.
onError (optional)
- Type:
function
declare function onError(error: Error): voidThe callback to call when an error occurred when trying to get for a new block.
poll (optional)
- Type:
true
Whether to use polling.
pollingInterval (optional)
- Type:
number
Polling frequency (in ms). Defaults to Client's pollingInterval config.