Skip to content

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

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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