Skip to content

Bug in custom accounting docs #1101

@kadenzipfel

Description

@kadenzipfel

In this section of the custom accounting docs, we note that the fee is to be taken in the unspecified currency, also noting that in the exact output case that should be the input token. However, in the code example, we always use the output amount to compute the fee amount:

bool outputIsToken0 = params.zeroForOne ? false : true;

int256 outputAmount = outputIsToken0 ? delta.amount0() : delta.amount1();
if (outputAmount <= 0) {
    return (BaseHook.afterSwap.selector, 0);
}

uint256 feeAmount = (uint256(outputAmount) * HOOK_FEE_PERCENTAGE) / FEE_DENOMINATOR;

This means we incorrectly compute the feeAmount for exact output swaps

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