Exchange of Reserves
When a trade is performed through a Virtual Pool, assets sold by the trader are placed into the reserves of the Active Pool.
To ensure continuous operation of the reserve-based virtual pool system, and limit the risk for LPs, it is required that the reserves of the participating pools be periodically reduced in size or emptied and replaced with the pools' respective native tokens. VirtuSwap elegantly achieves this goal by allowing the pools to exchange reserve assets with other pools in the system.
The reserve exchange routine is periodically initiated by the system to perform this. For each one of the reserve tokens (Source Token) held by a each pool (Source Pool) in the system, the routine looks for a Target Pool that complies with the following criteria:
The Source Token is a native token of the Target Pool;
The Target Pool holds a nonzero amount of reserves in one of the Source Pool's native tokens.
If such target pool is found, the exchange of reserves is performed according to the exchange rate in virtual pools constructed separately by each one of the two exchanging pools. For example, if the WETH-USDC pool is currently holding MATIC as reserve, the WETH-MATIC pool holding USDC in reserve is a good candidate for exchange of reserves. In this case, the MATIC-USDC price will be determined by a virtual pool constructed from WETH-USDC and WETH-MATIC pools.
The exchange of reserves between two pools is done using a fixed rate, without an AMM curve and thus does not incur any price impact losses and does not introduce any additional imbalance into the system.
By periodically performing the Reserve Exchange routine, the level of reserves in pools is kept low, enabling trading through virtual pools and reducing the risk incurred to LPs by holding non-native tokens in the pools.
The matching between Source Pools and Target Pools is performed off-chain, while the execution of the actual exchange is done on-chain.
See vExchangeReserves
contract for more technical details.
Liquidation of reserves
In certain rare cases, it may occur that the reserves in one or more VirtuSwap pools get filled up, and cannot be exchanged for a prolonged period of time. For example, if everyone on the market is selling a particular asset and nobody is buying it, that asset may clog the reserves of one or more pools in VirtuSwap DEX and thus prevent them from accepting more reserves and construct virtual pools.
In this case, the Admin or the EmergencyAdmin wallet designated by the DAO can step in and exchange the reserves with the pool at a discount, unclogging the reserves and allowing the pools to operate normally.
Last updated