Contains the logic for calculating how much should be taken from the user in exchange for what they want to obtain. 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

    • outputValue: any

      the value of the asset the user wants to get

    • inputReserve: any

      the value in the liquidity pool of the asset being spent

    • 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 outputValue

    Returns bigint

    inputValue - the value of input required to purchase output