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:
Initia L1 to Rollups Minitswap Flow
In this scenario, a user wants to efficiently bridge their tokens on the Initia L1 to a rollup and ends up with the token for that rollup.
And while bridging from Initia L1 to a rollup is instantaneous, users may occasionally be able to obtain a more favorable rate by utilizing Minitswap as part of the bridging process as shown below.
Rollup to Initia L1 Minitswap Flow
When bridging from a rollup to Initia L1, the user is currently holding tokens on a rollup and would like to bridge it back to tokens on the Initia L1.
In this scenario, utilizing Minitswap will enable them to bridging their INIT back to the Initia L1 instantaneously without waiting for the challenge period to expire.
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.
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
Peg Keeper Swaps
The Peg Keeper Swap is a mechanism designed to keep the exchange rate between and close to 1:1. This ensures that users always receive the best swap rates.
When users move their INIT tokens from a rollup back to Initia L1 using Minitswap, they are essentially selling their tokens for tokens. As more users do this, the supply of increases relative to , which raises the price of future rollup -> Initia L1 swaps.
To address this, the Peg Keeper Swap executes a ( -> ) swap to balance the effect. When a user makes a swap, Minitswap checks the Fully Recovered Ratio against the current pool ratio. If the current ratio exceeds the Fully Recovered Ratio, a Peg Keeper Swap is triggered to restore balance.
When run, the Peg Keeper swap follows the following procedure:
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.swap_amount_to_reach_fr
.swap_amount_to_reach_fr > max_recover_amount
max_recover_amount
.swap_amount_to_reach_fr
Note that the Peg Keeper Swap check is done
Internal Rebalancing
As more Peg Keeper Swaps are performed, the balance of the Peg Keeper gradually decreases. To replenish its balance, the system has an internal rebalancing procedure that converts the Peg Keeper’s back into using IBC and OP Bridge.
The rebalancing process follows these steps:
This process, combined with the Direct Swap, ensures that the Peg Keeper’s balance is replenished, allowing it to continue performing Peg Keeper Swaps.
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:
Initia L1 to Rollups Minitswap Flow
In this scenario, a user wants to efficiently bridge their tokens on the Initia L1 to a rollup and ends up with the token for that rollup.
And while bridging from Initia L1 to a rollup is instantaneous, users may occasionally be able to obtain a more favorable rate by utilizing Minitswap as part of the bridging process as shown below.
Rollup to Initia L1 Minitswap Flow
When bridging from a rollup to Initia L1, the user is currently holding tokens on a rollup and would like to bridge it back to tokens on the Initia L1.
In this scenario, utilizing Minitswap will enable them to bridging their INIT back to the Initia L1 instantaneously without waiting for the challenge period to expire.
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.
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
Peg Keeper Swaps
The Peg Keeper Swap is a mechanism designed to keep the exchange rate between and close to 1:1. This ensures that users always receive the best swap rates.
When users move their INIT tokens from a rollup back to Initia L1 using Minitswap, they are essentially selling their tokens for tokens. As more users do this, the supply of increases relative to , which raises the price of future rollup -> Initia L1 swaps.
To address this, the Peg Keeper Swap executes a ( -> ) swap to balance the effect. When a user makes a swap, Minitswap checks the Fully Recovered Ratio against the current pool ratio. If the current ratio exceeds the Fully Recovered Ratio, a Peg Keeper Swap is triggered to restore balance.
When run, the Peg Keeper swap follows the following procedure:
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.swap_amount_to_reach_fr
.swap_amount_to_reach_fr > max_recover_amount
max_recover_amount
.swap_amount_to_reach_fr
Note that the Peg Keeper Swap check is done
Internal Rebalancing
As more Peg Keeper Swaps are performed, the balance of the Peg Keeper gradually decreases. To replenish its balance, the system has an internal rebalancing procedure that converts the Peg Keeper’s back into using IBC and OP Bridge.
The rebalancing process follows these steps:
This process, combined with the Direct Swap, ensures that the Peg Keeper’s balance is replenished, allowing it to continue performing Peg Keeper Swaps.