From e1426eb2137d20f0d8f1c699f3a5d2e335e1fa93 Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Sun, 5 Oct 2025 13:09:48 -0700 Subject: [PATCH 1/4] feat: Add getUserPositionInPool External View Function Natspec Comments --- src/onchain/TestAMMContract.sol | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/onchain/TestAMMContract.sol b/src/onchain/TestAMMContract.sol index 286ac53..c1d3d00 100644 --- a/src/onchain/TestAMMContract.sol +++ b/src/onchain/TestAMMContract.sol @@ -453,6 +453,29 @@ contract Test_AMMContract is Ownable { return marketIdToPool[marketId]; } + /** + * @notice Retrieves user's liquidity position information for a specific market + * @dev Returns position data in a format compatible with the main AMM contract. + * Some fields are simplified or fixed values for testing compatibility. + * + * @param _user Address of the liquidity provider to query + * @param _marketId Market identifier for the position + * + * @return operator Address that can operate on the position (this contract) + * @return token0 Address of the first token in the pair (tokenA) + * @return token1 Address of the second token in the pair (tokenB) + * @return fee Fee tier of the pool (fixed at 3000 for 0.3%) + * @return liquidity Amount of liquidity the user has in this pool + * @return tickLower Lower tick bound (fixed at 0 for simplified version) + * @return tickUpper Upper tick bound (fixed at 0 for simplified version) + * @return tokensOwed0 Amount of tokenA fees owed (0 in simplified version) + * @return tokensOwed1 Amount of tokenB fees owed (0 in simplified version) + * @return amount0 Estimated amount of tokenA in the position + * @return amount1 Estimated amount of tokenB in the position + * + * @custom:compatibility Returns data in same format as main contract for interface compatibility + * @custom:simplified Some fields are fixed values since this version doesn't use tick-based liquidity + */ function getUserPositionInPool(address _user, bytes32 _marketId) external view From c6d91a22657f5f961e086c534c4d2684e0e06cd2 Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Mon, 6 Oct 2025 10:41:07 -0700 Subject: [PATCH 2/4] feat: Add getAllPools External View Function --- src/onchain/TestAMMContract.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/onchain/TestAMMContract.sol b/src/onchain/TestAMMContract.sol index c1d3d00..423b835 100644 --- a/src/onchain/TestAMMContract.sol +++ b/src/onchain/TestAMMContract.sol @@ -510,4 +510,8 @@ contract Test_AMMContract is Ownable { userLiq / 2 // amount1 - simplified estimation ); } + + function getAllPools() external view returns (PoolData[] memory) { + return pools; + } } From 48bd86e073b28e352429ba1d4707ba0f31230fcf Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Mon, 6 Oct 2025 10:41:23 -0700 Subject: [PATCH 3/4] feat: Add getAllPools External View Function Natspec Comments --- src/onchain/TestAMMContract.sol | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/onchain/TestAMMContract.sol b/src/onchain/TestAMMContract.sol index 423b835..0974df5 100644 --- a/src/onchain/TestAMMContract.sol +++ b/src/onchain/TestAMMContract.sol @@ -511,6 +511,15 @@ contract Test_AMMContract is Ownable { ); } + /** + * @notice Retrieves all pools created by this contract + * @dev Returns the complete array of PoolData structs for analytics and enumeration + * + * @return Array of PoolData structs representing all managed pools + * + * @custom:analytics Useful for building dashboards and analyzing pool performance + * @custom:enumeration Provides way to iterate through all pools when mapping keys unknown + */ function getAllPools() external view returns (PoolData[] memory) { return pools; } From 552aea7a19805fd32cc165903410bb574170e6b9 Mon Sep 17 00:00:00 2001 From: tyranis0x01 Date: Mon, 6 Oct 2025 10:41:37 -0700 Subject: [PATCH 4/4] feat: forge fmt --- src/onchain/TestAMMContract.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onchain/TestAMMContract.sol b/src/onchain/TestAMMContract.sol index 0974df5..05a8bdf 100644 --- a/src/onchain/TestAMMContract.sol +++ b/src/onchain/TestAMMContract.sol @@ -469,7 +469,7 @@ contract Test_AMMContract is Ownable { * @return tickLower Lower tick bound (fixed at 0 for simplified version) * @return tickUpper Upper tick bound (fixed at 0 for simplified version) * @return tokensOwed0 Amount of tokenA fees owed (0 in simplified version) - * @return tokensOwed1 Amount of tokenB fees owed (0 in simplified version) + * @return tokensOwed1 Amount of tokenB fees owed (0 in simplified version) * @return amount0 Estimated amount of tokenA in the position * @return amount1 Estimated amount of tokenB in the position *