Skip to content

feat(test): add fee AMM tests for liquidity operations#265

Merged
fgimenez merged 2 commits intomainfrom
fgimenez/fee-amm-tests
Sep 19, 2025
Merged

feat(test): add fee AMM tests for liquidity operations#265
fgimenez merged 2 commits intomainfrom
fgimenez/fee-amm-tests

Conversation

@fgimenez
Copy link
Copy Markdown
Member

ported from reference implementation https://github.com/tempoxyz/specs/blob/fee-manager/test/StableAMM.t.sol

still not ported:

  • fee swap tests (3 tests)
  • rebalance swap tests (2 tests)
  • fuzz/property tests (6 tests)

@fgimenez fgimenez requested a review from 0xKitsune September 18, 2025 10:10
@fgimenez fgimenez force-pushed the fgimenez/fee-amm-tests branch from 35a13c1 to 7bbe8a5 Compare September 18, 2025 10:10
Comment thread crates/node/tests/it/tip_fee_amm.rs Outdated
@fgimenez fgimenez force-pushed the fgimenez/fee-amm-tests branch from 1a60def to e0935ce Compare September 19, 2025 16:41
@fgimenez fgimenez changed the title feat(test): add fee AMM tests for pool and liquidity operations feat(test): add fee AMM tests for liquidity operations Sep 19, 2025

// Calculate expected liquidity (sqrt(amount0 * amount1) - MIN_LIQUIDITY)
// Since amounts are equal, sqrt(amount0 * amount1) = amount0 = amount1
// But we use the formula: (amount0 * amount1) / sqrt(2) - MIN_LIQUIDITY
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: looks like this comment is incorrect, we are using uint!(2_U256) instead of sqrt(2).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops good catch

Comment on lines +563 to +570
assert!(
user_balance0_after > user_balance0_before,
"Should receive userToken"
);
assert!(
user_balance1_after > user_balance1_before,
"Should receive validatorToken"
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt about asserting actual values here since we know the balance before and expected amounts?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep makes sense

@fgimenez fgimenez merged commit f6165ea into main Sep 19, 2025
15 checks passed
@fgimenez fgimenez deleted the fgimenez/fee-amm-tests branch September 19, 2025 17:07
fgimenez added a commit that referenced this pull request Sep 19, 2025
fgimenez added a commit that referenced this pull request Sep 19, 2025
fgimenez added a commit that referenced this pull request Sep 22, 2025
…rence (#279)

ported from reference implementation
https://github.com/tempoxyz/specs/blob/fee-manager/test/StableAMM.t.sol

ref #265

the tests are defined as unit tests bc the covered functionality is not
exposed externally. also, some tests that hit overflow are ignored, same
as in solidity
legion2002 pushed a commit that referenced this pull request Oct 9, 2025
* feat(test): add fee AMM tests for pool and liquidity operations

* consolidate pool creation tests into a single one
legion2002 pushed a commit that referenced this pull request Oct 9, 2025
legion2002 pushed a commit that referenced this pull request Oct 9, 2025
…rence (#279)

ported from reference implementation
https://github.com/tempoxyz/specs/blob/fee-manager/test/StableAMM.t.sol

ref #265

the tests are defined as unit tests bc the covered functionality is not
exposed externally. also, some tests that hit overflow are ignored, same
as in solidity
unbalancedparentheses pushed a commit to unbalancedparentheses/tempo that referenced this pull request Feb 23, 2026
…oxyz#265)

* feat(test): add fee AMM tests for pool and liquidity operations

* consolidate pool creation tests into a single one
unbalancedparentheses pushed a commit to unbalancedparentheses/tempo that referenced this pull request Feb 23, 2026
unbalancedparentheses pushed a commit to unbalancedparentheses/tempo that referenced this pull request Feb 23, 2026
…rence (tempoxyz#279)

ported from reference implementation
https://github.com/tempoxyz/specs/blob/fee-manager/test/StableAMM.t.sol

ref tempoxyz#265

the tests are defined as unit tests bc the covered functionality is not
exposed externally. also, some tests that hit overflow are ignored, same
as in solidity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants