PMM DEX & Swap
Last updated
Last updated
PMM, the Proactive Market Maker algorithm, originates from the DODO protocol. Compared to traditional AMMs, PMM allows users to deposit and withdraw assets unilaterally, which aligns well with our full-chain single token pool. By building PMM on top of the full-chain single token pool, users will experience lower slippage, and market makers will incur lower impermanent losses.
Marginal Price
The marginal price is the instantaneous price at the current state, representing how many quote tokens can be bought with one base token. It indicates the total deposit of base tokens by the market maker and the total deposit of quote tokens by the market maker. \(B\) represents the total quantity of base tokens in the current asset pool, and \(Q\) represents the total quantity of quote tokens in the current asset pool. It is provided by an oracle as a market price and is a parameter within the range of 0 to 1.
$$P=\begin{cases}i(1-k+k\frac{B_0^2}{B^2}),B<B_0\\\frac{i}{(1-k+k*\frac{Q_0^2}{Q^2})},Q<Q_0\end{cases}$$
From the marginal price formula, when \(k\) is 0, the marginal price is always equal to the market price provided by the oracle, resulting in no slippage and high capital utilization. When \(k\) is 1, it degenerates into a traditional AMM, where both assets must be deposited and withdrawn simultaneously according to the current price ratio, leading to high slippage and low capital utilization. When the quantities of base and quote tokens in the pool deviate from equilibrium, the current price may be higher or lower than the external price, prompting arbitrageurs to arbitrage and bring \(B\) and \(Q\) back to their target quantities. It's worth noting that when the system is in an imbalanced state, changes in the oracle's price can result in profit or loss. For instance, when there's a shortage of base tokens and the oracle price of base tokens rises, the surplus quote tokens are worth less than the value needed to return to equilibrium, resulting in losses for market makers. Therefore, for base tokens and quote tokens with significant marginal price fluctuations, a larger \(k\) should be set to reduce the risk of market maker losses.
Average Price
By integrating the marginal price according to the following formula, the average price \(P\) can be obtained. Through the average price \(P\), the number of tokens that traders need to pay when buying or selling a certain quantity of base tokens and quote tokens can be determined.
Regression Target
The sum \(S\) is the regression target. By substituting \(S\) into the average price formula and solving the resulting system of two linear equations, the regression target can be obtained.
When market makers deposit base tokens, the price \(b\) rises, and the increase is greater. Therefore, once market makers deposit funds, all market makers of base tokens will profit. The protocol will provide deposit rewards to market makers. The rewards are mainly paid by traders who cause the system to deviate from the equilibrium state. Quote tokens follow the same rules. Conversely, when market makers withdraw, all market makers will incur losses. Therefore, withdrawals require a certain fee. The fee is equal to the total losses incurred by market makers due to this withdrawal and is distributed to market makers who have not yet withdrawn.
Overall, the Sun Network's new type of DEX application utilizes the PMM algorithm, allowing users to deposit assets on any public chain for one-sided market making. At the same time, flexible parameter configurations can result in lower slippage, reduced impermanent losses, and a better user experience.
SunSwap enables one-click cross-chain swaps by aggregating liquidity from various public chains. By effectively combining DEXs and token bridges from different public chains, SunSwap finds the optimal route to provide users with a superior swapping experience. Initially, SunSwap will support Ethereum-based EVM chains, utilizing Stargate and Wormhole token bridges to facilitate one-click swaps across different public chains. Leveraging DEX applications built using the PMM algorithm, the majority of cross-chain swaps can be completed within the protocol, effectively utilizing the advantages of the PMM algorithm to offer users lower slippage and lower gas fees.
The following outlines the lifecycle steps of an example cross-chain swap:
Trader requests a quote to sell ETH on Ethereum (source chain) and buy ARB on Arbitrum (target chain).
Market maker provides the trader with a signed quote.
Trader submits the transaction with the signed quote on Ethereum.
Smart contract of the liquidity pool on the source chain performs security checks, transfers funds from the trader's wallet to the pool, sends the payload, and calls the gateway smart contract on the source chain.
Once the transaction on the source chain is successful, the gateway smart contract triggers an event.
Validators use the event to verify the transaction and submit the proof and payload to the gateway endpoint on the target chain.
The relay then submits the payload to the target chain and transfers ARB to the trader's wallet on the target chain.
As described above, the steps do not rely on external bridges nor require users to custody their assets on the source chain to mint bridged assets on the target chain. Users can swap any asset by utilizing signature-based pricing and quotation quotes.