Goals
- Manipulation Resistance: The architecture of the rollup and related systems themselves already has safeguards in place to prevent various forms of manipulation from malicious actors. The Minitswap DEX is further designed to ensure that, in unforeseen events, any subsequent damages are minimized.
- Capital Efficiency: As the number of rollups continue to increase, naively, the same number of DEX pairs must also exists. This results in liquidity fragmentation, high slippage and volatility, and subpar user experience.
Design
Minitswap itself is designed as a virtual pool DEX between and the various tokens for each of the rollups. The exchange rates on each swap are determined by the StableSwap formula. To achieve the above goals, two main improvements are made to the base StableSwap pool design:- Rate Limiting: To protect against manipulation, the net amount of IbcOpINIT tokens that can be swapped back into INIT tokens is limited. This means that even if a malicious actor manages to acquire or create a large amount of IbcOpINIT tokens on their rollup, the number of tokens that can be swapped back into regular INIT tokens remains restricted.
- Single INIT Token Pool: To minimize liquidity fragmentation, there is a single INIT token pool that can be paired with multiple IbcOpINIT token pools, instead of having separate INIT token pools for each rollups.
Swap Mechanisms
Initia L1 to Rollups

Initia L1 to Rollups Minitswap Flow
- Initiate Swap on Minitswap DEX: The user sends a transaction to the Minitswap DEX to swap their tokens into tokens.
- Simulate Swap: The DEX simulates swapping the user’s tokens into tokens.
- Compare Swap and Direct Bridging: The DEX compares the simulated amount of tokens with the amount the user would receive if they bridged directly through the OP Bridge.
- Perform Optimal Action
- If the amount of tokens from the swap is greater, the DEX performs the swap. The output tokens are then bridged to the destination L2 through IBC.
- If the direct bridging through the OP bridge provides a better amount, the DEX initiates a direct transfer to the destination rollup for the user using the OP bridge.
- Minitswap Swap Process
- Calculate Received: Minitswap calculates how much the user will receive based on the current Virtual Pool state, updating the state in the process.
- Fee Deduction: Minitswap deducts a fee based on a predefined value and an additional fee from any extra that the user receives.
- Peg Keeper Swap Check: Once the user’s swap action and fee calculation are complete, Minitswap checks if a Peg Keeper Swap should be performed based on the latest Virtual Pool state.
- Internal Rebalancing Check: After completing the Peg Keeper Swap, Minitswap checks if Internal Rebalancing is possible based on the Peg Keeper’s balance. If balancing is possible, it is initiated.
- Final Outcome: In both cases, once the OP Bridge or IBC transfer is complete, the user receives the most amount of tokens in their wallet on the destination rollup possible.
Rollup to Initia L1

Rollup to Initia L1 Minitswap Flow
- Transfer to Initia L1 via IBC: The user begins by transferring their tokens on the rollup back to Initia L1 using IBC. As a result, they receive tokens on the Initia L1.
- Swap on Minitswap DEX: Once the IBC transfer is complete and the user has tokens on Initia L1, they initiate a swap transaction on the Minitswap DEX to convert their tokens into tokens.
- Minitswap Swap Process
- Peg Keeper Swap Check: Minitswap first checks if a Peg Keeper Swap can be performed. If this is possible, the swap is executed directly through the Peg Keeper.
- Calculate Received: If the Peg Keeper Swap is not applicable, Minitswap calculates the amount of the user will receive based on the updated state of the Virtual Pool.
- Fee Deduction: Minitswap deducts a predefined fee amount from the transaction.
- Internal Rebalancing Check: After completing the user’s swap transaction, Minitswap checks if Internal Rebalancing is possible based on the Peg Keeper’s balance. If balancing is possible, it is executed to maintain market stability.
- Final Outcome: If the swap is successful, the user receives tokens in their wallet on Initia L1.
Direct Swap
In addition to the standard directional swap explained above, Minitswap also offers a unique Direct Swap option. As more Peg Keeper Swaps are performed, the Peg Keeper’s balance decreases. The Direct Swap aims to incentivize users to help replenish the Peg Keeper’s token balance, which gets depleted over time. This serves as an additional method of replenishing the Peg Keeper’s balance alongside the Internal Rebalancing. The Direct Swap allows any user to directly exchange their tokens for the Peg Keeper’s tokens. This exchange occurs at the average price at which the Peg Keeper has purchased tokens, which could sometimes be lower than the price obtained through the traditional swap process. Initially, the Direct Swap might not seem attractive due to the Target Ratio being close to 0.5. However, as the Peg Keeper’s balance of OP-bridged tokens increases, the Direct Swap option becomes more appealing to users.Swap Logic
Parameters
- Max Ratio: The Max Ratio, , is a Initia L1 governance-controlled parameter that dictates the maximum pool ratio between IbcOpINIT and regular INIT
- Fully Recovered Ratio: The Fully Recovered Ratio, then uses the Max Ratio and the Flexibility to calculate the final target IbcOpINIT:INIT ratio for the pool. The ratio is calculated as follows
Mechanisms
Peg Keeper Swaps

Peg Keeper Swaps
- Calculate the current and the
max_recover_amount
, which defines the maximum size of the Peg Keeper Swap that can be performed in this swap. This is to prevent a huge Peg Keeper Swap from happening. - Check if another Peg Keeper Swap has been run in the same block. Continue if no swaps have been run.
- Calculate the amount the Peg Keeper needs to reach . Let’s call this
swap_amount_to_reach_fr
. - Check if
swap_amount_to_reach_fr > max_recover_amount
- If true, swap only
max_recover_amount
. - If false, swap
swap_amount_to_reach_fr
- If true, swap only
- before a L2 -> L1 swap to make sure the user gets the best rate possible
- after a L1 -> L2 swap to make sure the user’s swap rate doesn’t get affected by the Peg Keeper Swap
Internal Rebalancing

Internal Rebalancing
- Bridge the Peg Keeper’s back to the rollup using IBC, converting it into .
- Use the OP Bridge to convert back into .