Skip to content

fix: test fn rounding#195

Merged
andrewsource147 merged 1 commit into0.2.0_auditfrom
zenith_audit_0.2.0/test_get_max_amount_in_rounding
Mar 2, 2026
Merged

fix: test fn rounding#195
andrewsource147 merged 1 commit into0.2.0_auditfrom
zenith_audit_0.2.0/test_get_max_amount_in_rounding

Conversation

@codewithgun
Copy link
Contributor

@ZhengYuTay
Copy link

/bot review

@metoeraag-bot
Copy link

metoeraag-bot bot commented Feb 27, 2026

Bot Agent progress: /bot review

Progress:

  • Repo checks (4 ok, 1 failed)
  • Context build
  • Codex review (1 pass + first look)
  • Buddy review (agreed after 1/10)
  • Post review

Copy link

@metoeraag-bot metoeraag-bot bot left a comment

Choose a reason for hiding this comment

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

Summary

⚠️ Limited-confidence review: check failed: cargo clippy --workspace --all-targets -- -D warnings.

Reviewed the rounding-direction change in ConcentratedLiquidity (Rounding::Down -> Rounding::Up) for max input delta calculations. I don’t see a clear correctness, security, or reliability regression from this diff alone; the update appears intentional and internally consistent.

Claude (API) review

Rounds: 1 (min=1, max=10).
First look: Codex + Claude (Claude first-look failed; fell back to Codex).
Agreement: yes (no new findings/questions).

Debate transcript

First look comparison

Codex (first look):

Summary:
Reviewed the rounding-direction change in ConcentratedLiquidity (Rounding::Down -> Rounding::Up) for max input delta calculations. I don’t see a clear correctness, security, or reliability regression from this diff alone; the update appears intentional and internally consistent.

Inline comment highlights: (none)

Codex (first look fallback):

Summary:
No actionable correctness, security, or reliability issues identified in this focused diff. The switch from Rounding::Down to Rounding::Up appears intentional and internally consistent for input-side delta calculations.

Inline comment highlights: (none)

Comparison notes:

Review Synthesis

Top 3 differences in emphasis

  1. No real disagreement: Both reviewers agree there are no actionable correctness, security, or reliability issues.
  2. Scope wording: Codex says “from this diff alone,” while Buddy says “in this focused diff” (same conclusion, slightly different framing).
  3. Focus detail: Codex explicitly names ConcentratedLiquidity; Buddy highlights that the change is consistent for input-side delta calculations.

Most important follow-up action

  • Add/verify targeted boundary tests for max input delta under Rounding::Up (edge tick ranges and amounts) to confirm intended economic behavior and guard against regressions.

Round 1

Codex (primary):

Summary:
Reviewed the rounding-direction change in ConcentratedLiquidity (Rounding::Down -> Rounding::Up) for max input delta calculations. I don’t see a clear correctness, security, or reliability regression from this diff alone; the update appears intentional and internally consistent.

Inline comment highlights: (none)

Claude (API):

The primary review correctly identifies the rounding direction change as intentional and internally consistent. The change from Rounding::Down to Rounding::Up for max input delta calculations is the expected conservative direction for input amounts (round up what the user must provide). Both the primary review and the independent first-look converge on the same conclusion. The clippy failures in CI are pre-existing and unrelated to this diff. No additional issues or false positives to flag.

Codex (response):

Agreement reached. No further changes.

Synthesis

Review Synthesis

Top 3 differences in emphasis

  1. No real disagreement: Both reviewers agree there are no actionable correctness, security, or reliability issues.
  2. Scope wording: Codex says “from this diff alone,” while Buddy says “in this focused diff” (same conclusion, slightly different framing).
  3. Focus detail: Codex explicitly names ConcentratedLiquidity; Buddy highlights that the change is consistent for input-side delta calculations.

Most important follow-up action

  • Add/verify targeted boundary tests for max input delta under Rounding::Up (edge tick ranges and amounts) to confirm intended economic behavior and guard against regressions.
Repo checks

Repo Checks

  • LLM checks planner: added package install step before running JS commands.

  • rustup component add --toolchain 1.85.0-x86_64-unknown-linux-gnu clippy: ok

info: downloading component 'clippy'
info: installing component 'clippy'
  • cargo fetch --locked: ok
ownloaded windows_i686_gnu v0.48.0
  Downloaded windows_x86_64_gnu v0.48.0
  Downloaded redox_syscall v0.3.5
  Downloaded smallvec v1.14.0
  Downloaded parking_lot_core v0.9.8
  Downloaded indexmap v2.7.1
  Downloaded windows_i686_msvc v0.48.0
  Downloaded byteorder v1.4.3
  Downloaded solana-instructions-sysvar v2.2.1
  Downloaded solana-program-entrypoint v2.2.1
  Downloaded solana-sysvar v2.2.1
  Downloaded solana-clock v2.2.1
  Downloaded num_enum_derive v0.7.3
  Downloaded itoa v1.0.8
  Downloaded five8_core v0.1.1
  Downloaded alloy-rlp v0.3.11
  Downloaded parity-scale-codec-derive v3.6.12
  Downloaded opaque-debug v0.3.0
  Downloaded cpufeatures v0.2.9
  Downloaded solana-instruction v2.2.1
  Downloaded thiserror-impl v2.0.12
  Downloaded rustc_version v0.4.0
  Downloaded r-efi v5.2.0
  Downloaded solana-program-memory v2.2.1
  Downloaded zerocopy-derive v0.7.35
  Downloaded tinyvec v1.6.0
  Downloaded pest v2.8.0
  Downloaded typenum v1.16.0
  Downloaded arrayvec v0.7.4
  Downloaded equivalent v1.0.0
  Downloaded serde_spanned v0.6.8
  Downloaded toml_edit v0.22.24
  Downloaded autocfg v1.1.0
  Downloaded proptest v1.6.0
  Downloaded bumpalo v3.13.0
  Downloaded log v0.4.26
  Downloaded getrandom v0.2.10
  Downloaded ppv-lite86 v0.2.17
  Downloaded cfg-if v1.0.0
  Downloaded windows-targets v0.48.1
  Downloaded parking_lot v0.12.1
  Downloaded solana-pubkey v2.2.1
  Downloaded thiserror v2.0.12
  Downloaded version_check v0.9.4
  Downloaded either v1.13.0
  Downloaded impl-trait-for-tuples v0.2.2
  Downloaded toml_datetime v0.6.8
  Downloaded memchr v2.7.4
  Downloaded parity-scale-codec v3.6.12
  Downloaded errno v0.3.11
  Downloaded once_cell v1.21.1
  Downloaded bitflags v2.9.0
  Downloaded quote v1.0.36
  Downloaded unicode-ident v1.0.10
  Downloaded syn v2.0.98
  Downloaded ruint v1.14.0
  Downloaded solana-hash v2.2.1
  Downloaded solana-sha256-hasher v2.2.1
  Downloaded crunchy v0.2.2
  Downloaded rustversion v1.0.17
  Downloaded solana-zk-sdk v2.2.3
  • pnpm install --frozen-lockfile: ok
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +192
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 192, reused 68, downloaded 0, added 0
Progress: resolved 192, reused 187, downloaded 4, added 191
Progress: resolved 192, reused 187, downloaded 5, added 192, done

dependencies:
+ @coral-xyz/anchor 0.31.1
+ @coral-xyz/borsh 0.31.1
+ @solana/spl-token 0.4.14
+ @solana/web3.js 1.98.4
+ borsh 2.0.0
+ decimal.js 10.6.0
+ litesvm 0.1.0

devDependencies:
+ @solana/spl-token-metadata 0.1.6
+ @types/bn.js 5.2.0
+ @types/chai 4.3.20
+ @types/mocha 9.1.1
+ chai 4.5.0
+ mocha 9.2.2
+ prettier 2.8.8
+ ts-mocha 10.1.0
+ typescript 5.9.3

╭ Warning ─────────────────────────────────────────────────────────────────────╮
│                                                                              │
│   Ignored build scripts: bigint-buffer@1.1.5, bufferutil@4.0.9,              │
│   utf-8-validate@5.0.10.                                                     │
│   Run "pnpm approve-builds" to pick which dependencies should be allowed     │
│   to run scripts.                                                            │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
Done in 3.3s using pnpm v10.30.3

! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-10.30.3.tgz
  • cargo check --workspace: ok
nterface v2.2.1
    Checking solana-loader-v4-interface v2.2.1
    Checking solana-stable-layout v2.2.1
    Checking solana-loader-v2-interface v2.2.1
    Checking spl-discriminator v0.4.1
    Checking spl-memo v6.0.0
    Checking solana-example-mocks v2.2.1
    Checking spl-associated-token-account-client v2.0.0
    Checking solana-secp256k1-recover v2.2.1
    Checking solana-sysvar v2.2.1
    Checking solana-program v2.2.1
    Checking spl-program-error v0.6.0
    Checking spl-token v7.0.0
   Compiling anchor-derive-serde v0.31.1
   Compiling anchor-attribute-account v0.31.1
   Compiling anchor-attribute-program v0.31.1
   Compiling anchor-derive-accounts v0.31.1
   Compiling anchor-attribute-access-control v0.31.1
   Compiling anchor-attribute-constant v0.31.1
    Checking spl-pod v0.5.1
   Compiling anchor-attribute-event v0.31.1
   Compiling anchor-attribute-error v0.31.1
    Checking spl-token-confidential-transfer-ciphertext-arithmetic v0.2.1
    Checking spl-type-length-value v0.7.0
    Checking spl-token-confidential-transfer-proof-extraction v0.2.1
    Checking spl-token-group-interface v0.5.0
    Checking spl-elgamal-registry v0.1.1
    Checking spl-token-confidential-transfer-proof-generation v0.2.0
    Checking spl-tlv-account-resolution v0.9.0
    Checking spl-token-metadata-interface v0.6.0
    Checking spl-transfer-hook-interface v0.9.0
    Checking spl-token-2022 v6.0.0
    Checking anchor-lang v0.31.1
    Checking jupiter v0.1.0 (https://github.com/MeteoraAg/zap-program?rev=064c58b317b9a85f212c0de72caea286fc72fdb4#064c58b3)
    Checking protocol-zap v0.1.0 (https://github.com/MeteoraAg/zap-program?rev=064c58b317b9a85f212c0de72caea286fc72fdb4#064c58b3)
    Checking spl-associated-token-account v6.0.0
    Checking anchor-spl v0.31.1
    Checking cp-amm v0.2.0 (/data/workdir/MeteoraAg/damm-v2/programs/cp-amm)
    Checking rust-sdk v0.2.0 (/data/workdir/MeteoraAg/damm-v2/rust-sdk)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 51.74s
  • cargo clippy --workspace --all-targets -- -D warnings: failed
rt_comparison
help: replace it with `assert!(..)`
   |
56 -     assert_eq!(fee_mode.fees_on_input, false);
56 +     assert!(!fee_mode.fees_on_input);
   |

error: used `assert_eq!` with a literal bool
  --> programs/cp-amm/src/tests/test_collect_fee_mode.rs:60:5
   |
60 |     assert_eq!(fee_mode.fees_on_token_a, false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
help: replace it with `assert!(..)`
   |
60 -     assert_eq!(fee_mode.fees_on_token_a, false);
60 +     assert!(!fee_mode.fees_on_token_a);
   |

error: importing legacy numeric constants
  --> programs/cp-amm/src/tests/test_liquidity_compounding.rs:18:5
   |
18 | use std::u64;
   |     ^^^^^^^^
   |
   = help: remove this import
   = note: then `u64::<CONST>` will resolve to the respective associated constant
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants

error: manual `RangeInclusive::contains` implementation
  --> programs/cp-amm/src/tests/test_liquidity_compounding.rs:34:9
   |
34 |         sqrt_price >= MIN_SQRT_PRICE && sqrt_price <= MAX_SQRT_PRICE,
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `(MIN_SQRT_PRICE..=MAX_SQRT_PRICE).contains(&sqrt_price)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains

error: casting to the same type is unnecessary (`u16` -> `u16`)
   --> programs/cp-amm/src/params/fee_parameters.rs:167:38
    |
167 |             self.reduction_factor <= MAX_BASIS_POINT as u16,
    |                                      ^^^^^^^^^^^^^^^^^^^^^^ help: try: `MAX_BASIS_POINT`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

error: could not compile `cp-amm` (lib test) due to 182 previous errors

@andrewsource147 andrewsource147 changed the base branch from release_0.2.0 to 0.2.0_audit March 2, 2026 02:11
@andrewsource147 andrewsource147 merged commit f012cb3 into 0.2.0_audit Mar 2, 2026
6 checks passed
@andrewsource147 andrewsource147 deleted the zenith_audit_0.2.0/test_get_max_amount_in_rounding branch March 2, 2026 02:12
andrewsource147 added a commit that referenced this pull request Mar 2, 2026
* fix: consistent zero amount check for get sqrt price (#192)

* fix: function comment (#193)

* fix: function comment

* remove unused comments

---------

Co-authored-by: Andrew Nguyen <cuong.hv.dtvt@gmail.com>

* chore: add documentation on price behavior for clmm and cpmm (#194)

* fix: test fn rounding (#195)

---------

Co-authored-by: kampung-tech <codewithgun@gmail.com>
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.

3 participants