Contains the logic for calculating how much should be given back to the user in exchange for what they sent in. Reused in several different places, including to check whether an offer is valid, getting the current price for an asset on user request, and to do the actual reallocation after an offer has been made.

  • Parameters

    • inputValue: any

      the value of the asset sent in to be swapped

    • inputReserve: any

      the value in the liquidity pool of the kind of asset sent in

    • outputReserve: any

      the value in the liquidity pool of the kind of asset to be sent out

    • OptionalfeeBasisPoints: bigint = ...

      the fee taken in basis points. The default is 0.3% or 30 basis points. The fee is taken from inputValue

    Returns bigint

    outputValue - the current price, in value form