Skip to content

Diff to the kyber swap contract swapMath in calcReturnedAmount function #7

@WagZol

Description

@WagZol

Error:

In the kyber swap elastic contract at the calcReturnedAmount function, if the isToken0 = false then the second element of the addition(the result will be the returned amount) is floored, but in the sdk implementation the mulDivRoundingUp used instead of mulDiv

Proof

Part of original SwapMath.lib of Kyber swap elastic pool contract:
Screenshot_2023-03-22_14-56-44

Implementation of the 'calcReturnedAmount' of the SDK:

JSBI.multiply(FullMath.mulDivRoundingUp(liquidity, Q96, sqrtRatioCurrentX96), JSBI.BigInt(-1))

@viet-nv could you please check it?

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