Ubeswap
Search…
Moola Router
The Moola Router automatically wraps and/or unwraps cUSD/cEUR/CELO into mcUSD/mcEUR/mCELO. It allows users to have an identical user experience to the traditional router while allowing for significantly less slippage when trading Moola assets.
We built the Moola Router in order to maximize the liquidity within Celo's early DeFi ecosystem. We want to ensure that there are always enough tokens for users to borrow, as being able to borrow allows long-term Celo holders to participate in DeFi farming without selling.
There is one deployed contract: MoolaRouter, which implements the swapExactTokensForTokens and swapTokensForExactTokens functions. A MoolaRouter user will specify the trading path, and if the first two or last two tokens of the path are "Moola duals", i.e. the tokens can be converted to/from each other via deposit or withdrawal, then the trade will route via the Moola LendingPool contract.

Architecture

The swap functions perform the following steps:
    1.
    Record all balances on the router.
    2.
    Construct a "Swap Plan" to figure out which parts of the path will use Moola to route
    3.
    If the Swap Plan determined that part of the route should go to the UbeswapRouter, approve the UbeswapRouter for the amount desired
    4.
    Transfer the input tokens from the sender
    5.
    If there is a Moola route for the first two tokens, withdraw or deposit.
    6.
    If the UbeswapRouter has a path, perform the swap.
    7.
    If there is a Moola route for the last two tokens, withdraw or deposit.
    8.
    Check to see that the output balances are equal to the input balances, other than the final output token. Unless the output token is equivalent to a token in the path, or the token is the input token.
    9.
    Transfer the output tokens to the _to address.

Contract Owner

There is a contract owner on the Moola Router that can withdraw any stuck tokens. This is currently set to the "Operator" address but will be transitioned to the Executive Timelock if there are no issues.
Last modified 5mo ago