Skip to content

Optimize deltas in unlock callback for BaseCustomAccounting #43

@cairoeth

Description

@cairoeth

🧐 Motivation
Currently, the unlockCallback function in BaseCustomAccounting separates the caller delta and fees accrued into the principal delta, which is then used to take/settle tokens. It can be more efficient if it instead uses the callerDelta for the case when the hook only takes a portion of fees accrued. Using principalDelta requires three transactions, versus two with callerDelta.

With this change, we can also calculate principal delta once in the add/removeLiquidity functions instead of twice (currently calculated both in unlockCallback and add/removeLiquidity)

📝 Details
If the hook takes a portion of fees accrued, this may affect how the tokens are taken/settled. Any modification to these deltas may need to also be reflected in add/removeLiquidity for the slippage checks which are based on the deltas returned by the pool manager.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions