initializePair- this function is called when the Bath House initializes this contract. This function creates new Bath Tokens if they do not exist for the given Bath Pair instance and points the Pair to an existing quote Bath Token if it already exists.
executeStrategy- this is the core function of BathPair.sol. In version zero of Rubicon Pools, it allows a strategist to place a pairs trade (ask and bid) with the underlying bathToken liquidity that is managed by this Pair. This function is the entry point for strategists to market make and leverage user liquidity.
getMaxOrderSize- this function returns the largest order size for a bid or an ask that a strategist can place with user funds. Moreover, this function ensures that relative order sizing and dynamic inventory management are enforced.
strategistBootyClaim- this function is called by strategists to automatically return earned yield to them that may have been earned with successful market-making. The key calculation for claiming yield is (Quantity of order fills as a result of this strategist) / (Total quantity of order fills for the given asset) * (Underlying amount of yield).
executeStrategy. Please see them below in the order in which they occur throughout the execution of the function call.
onlyApprovedStrategy- the target strategy of this function call must be approved by the Bath House.
enforceReserveRatio- this modifier ensures that the
reserveRatiofor each of the underlying liquidity pools (asset and quote bathTokens) is observed before and after function execution.
getMaxOrderSize- this function is used here to ensure that the numerator (what is being used from the liquidity pools) of the bid and ask adhere to the pairs dynamic inventory management constraints.
enforceSpread- this function ensures that (a) there is a spread on the orders submitted for a pairs trade and (b) that the pairs trade has an ask/bid price that is on the correct half of the order book (ask/bid is a valid ask/bid >/< midpoint price of the order book). A price oracle will be implemented in future versions to further ensure that midpoint of the order book is respected as a valid point of reference.
IPairsTrade(targetStrategy).execute- the strategy is then called and a pairs trade is placed. See PairsTrade.sol.
cancelPartialFills- this crucial function parses through the outstanding orders for this pair in the order book and (a) cancels any orders whose counterparts (the bid to an ask) of the pairs trade have been filled. This represents a yield event in which a pair's trade was partially filled. (b) Any orders that have exceeded the
timeDelayfor this pair are canceled to ensure no liquidity is locked in old orders.
rebalancePair- this simple function sends any filled orders that send ERC-20 assets to a Bath Token's sister pool (Asset <-> Quote) back to the correct liquidity pool so yield can be realized.