Closed ALPAC-4 closed 1 week ago
The pull request introduces enhancements to the initia_std::dex
and minitia_std::dex
modules, focusing on liquidity provision and simulation. New public functions, get_provide_simulation
and get_single_asset_provide_simulation
, have been added to facilitate liquidity return estimations. Existing functions have been refined for clarity, with improved error handling and formatting. Helper functions for calculating liquidity returns were introduced, and several function signatures were modified for better readability. Overall, the changes aim to improve the functionality and maintainability of the modules.
File Path | Change Summary |
---|---|
precompile/modules/initia_stdlib/sources/dex.move |
Added functions for liquidity provision simulation and refined existing functions for clarity and error handling. |
precompile/modules/minitia_stdlib/sources/dex.move |
Introduced liquidity provision simulation functions and improved formatting of assertions and function signatures. |
sequenceDiagram
participant User
participant DexModule
participant LiquidityPool
User->>DexModule: get_provide_simulation(pair, coin_a_amount_in, coin_b_amount_in)
DexModule->>LiquidityPool: Calculate expected returns
LiquidityPool-->>DexModule: Return expected return amounts
DexModule-->>User: Provide simulation results
User->>DexModule: get_single_asset_provide_simulation(pair, offer_asset_metadata, amount_in)
DexModule->>LiquidityPool: Calculate expected returns for single asset
LiquidityPool-->>DexModule: Return expected return amount
DexModule-->>User: Provide single asset simulation results
🐇 In the land of liquidity, we hop and play,
With new simulations brightening our day.
Functions added, clarity gained,
In the dex we trust, our returns are sustained.
So let’s leap with joy, for code has improved,
A bountiful future, our paths now grooved! 🌼
precompile/modules/initia_stdlib/sources/dex.move (5)
`372-383`: **LGTM!** The new `get_provide_simulation` function looks good. It provides a useful feature to simulate the provision of liquidity for a pair of coins. --- `386-398`: **LGTM!** The new `get_single_asset_provide_simulation` function looks good. It provides a useful feature to simulate the provision of liquidity for a single asset. --- Line range hint `413-416`: **LGTM!** The modification to the `pool_info` function to return the coin weights along with the pool amounts and swap fee rate looks good. It provides more useful information about the pool state. --- Line range hint `1148-1218`: **LGTM!** The minor changes to the `swap` function, adding trailing commas to the error codes, are fine. They improve consistency without affecting the functionality. --- `683-686`: **LGTM!** The modification to the `unpack_pair_response` function to return the `Weights` and `BigDecimal` values along with the coin and liquidity token addresses looks good. It provides more useful information when unpacking the `PairResponse` struct.precompile/modules/minitia_stdlib/sources/dex.move (8)
Line range hint `256-268`: **Formatting changes look good.** The code changes are related to formatting: - The error code is moved to a new line. - A trailing comma is added after the error code. The logic and functionality remain the same. --- Line range hint `290-307`: **Formatting changes look good.** The code changes are related to formatting: - The error code is moved to a new line. - A trailing comma is added after the error code. The logic and functionality remain the same. --- Line range hint `322-335`: **Formatting changes look good.** The code changes are related to formatting: - The `offer_amount` argument is moved to a new line. - A trailing comma is added after the `offer_amount` argument. The logic and functionality remain the same. --- Line range hint `335-352`: **Formatting changes look good.** The code changes are related to formatting: - The error code is moved to a new line. - A trailing comma is added after the error code. The logic and functionality remain the same. --- `367-369`: **Formatting changes look good.** The code changes are related to formatting: - The `return_amount` argument is moved to a new line. - A trailing comma is added after the `return_amount` argument. The logic and functionality remain the same. --- `371-398`: **New simulation functions look good.** The new functions provide simulations for liquidity provision: - `get_provide_simulation` simulates the liquidity return amount for providing liquidity with both coin types. - `get_single_asset_provide_simulation` simulates the liquidity return amount for providing liquidity with a single coin type. The functions use existing helper functions to calculate the liquidity return amounts. --- Line range hint `444-463`: **Formatting changes look good.** The code changes are related to formatting: - The error code is moved to a new line. - A trailing comma is added after the error code. The logic and functionality remain the same. --- Line range hint `491-519`: **Formatting changes look good.** The code changes are related to formatting: - The error code is moved to a new line. - A trailing comma is added after the error code. The logic and functionality remain the same.
Add provide liquidity simulation query
Summary by CodeRabbit