fix: withdrawing_dead_liquidity_reward & dead_liquidity_reward no longer carry forward#217
Conversation
|
/bot review |
|
Bot Agent progress:
Progress:
|
There was a problem hiding this comment.
Verdict
Comment
Review coverage
Findings: P0:0 P1:0 P2:1 P3:0
Lower-confidence concerns: 1
Reviewed by: OMP-native GPT openai-codex/gpt-5.5 + Opus anthropic/claude-opus-4-8 + arbiter openai-codex/gpt-5.5
Coverage lanes: Correctness, System integration, State machine, Regression tests, Repo checks
Risk focus: state-machine paths changed; tests changed
Evidence: repo-grounded (reviewers verified findings against the checkout)
Summary
Posted 1 validated inline finding(s) after final filtering.
Findings
- [P2]
tests/deadLiquidityReward.test.ts:249carryForward loop reuses one pool PDA; second iteration runs on stale state (via Opus)
Potential concerns (lower confidence)
- [P3]
tests/deadLiquidityReward.test.ts:273Mid-campaign withdraw asserts only balance increase, not that only the dead share was returned
Repo checks
Repo Checks
- rustup component add --toolchain 1.93.0-x86_64-unknown-linux-gnu clippy: ok
info: component clippy is up to date
- cargo fetch --locked: ok
.6.8
Downloaded windows-targets v0.48.1
Downloaded serde_spanned v0.6.8
Downloaded base64 v0.21.4
Downloaded anyhow v1.0.97
Downloaded tinyvec v1.6.0
Downloaded toml_edit v0.25.10+spec-1.1.0
Downloaded toml_edit v0.22.24
Downloaded aho-corasick v1.0.2
Downloaded unicode-segmentation v1.10.1
Downloaded cc v1.2.59
Downloaded winnow v0.7.4
Downloaded proptest v1.6.0
Downloaded pest v2.8.0
Downloaded bumpalo v3.13.0
Downloaded r-efi v5.2.0
Downloaded typenum v1.16.0
Downloaded either v1.13.0
Downloaded parity-scale-codec-derive v3.6.12
Downloaded once_cell v1.21.1
Downloaded bitflags v2.9.0
Downloaded windows_aarch64_gnullvm v0.48.0
Downloaded windows_x86_64_gnullvm v0.48.0
Downloaded redox_syscall v0.3.5
Downloaded parking_lot v0.12.1
Downloaded alloy-rlp v0.3.11
Downloaded impl-trait-for-tuples v0.2.2
Downloaded arrayvec v0.7.4
Downloaded equivalent v1.0.0
Downloaded solana-hash v4.2.0
Downloaded sha2 v0.10.8
Downloaded version_check v0.9.4
Downloaded rustversion v1.0.17
Downloaded ppv-lite86 v0.2.17
Downloaded ruint v1.14.0
Downloaded solana-fee-calculator v3.1.0
Downloaded serde_bytes v0.11.15
Downloaded windows_aarch64_msvc v0.48.0
Downloaded opaque-debug v0.3.0
Downloaded itoa v1.0.8
Downloaded ryu v1.0.14
Downloaded windows_i686_msvc v0.48.0
Downloaded windows_i686_gnu v0.48.0
Downloaded windows_x86_64_gnu v0.48.0
Downloaded libc v0.2.171
Downloaded windows_x86_64_msvc v0.48.0
Downloaded keccak v0.1.4
Downloaded solana-instruction v3.3.0
Downloaded solana-signature v3.3.0
Downloaded solana-instruction-error v2.2.0
Downloaded solana-transaction-error v3.1.0
Downloaded parking_lot_core v0.9.8
Downloaded cpufeatures v0.2.9
Downloaded byteorder v1.4.3
Downloaded autocfg v1.1.0
Downloaded unicode-ident v1.0.10
Downloaded lock_api v0.4.10
Downloaded five8_core v0.1.1
Downloaded rustc_version v0.4.0
Downloaded errno v0.3.11
Downloaded getrandom v0.2.10
- bun install --frozen-lockfile: ok
bun install v1.3.14 (0d9b296a)
+ @anchor-lang/borsh@1.0.0
+ @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
+ @anchor-lang/core@1.0.0
+ @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
192 packages installed [864.00ms]
- cargo check --workspace: ok
e for more info)
warning: use of deprecated function `anchor_lang::deprecated_account_info_usage`: Use `UncheckedAccount` instead of `AccountInfo` for safer unchecked accounts.
--> programs/cp-amm/src/instructions/ix_split_position.rs:97:1
|
97 | #[event_cpi]
| ^^^^^^^^^^^^
|
= note: this warning originates in the attribute macro `event_cpi` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: use of deprecated function `anchor_lang::deprecated_account_info_usage`: Use `UncheckedAccount` instead of `AccountInfo` for safer unchecked accounts.
--> programs/cp-amm/src/instructions/ix_lock_inner_position.rs:11:1
|
11 | #[event_cpi]
| ^^^^^^^^^^^^
|
= note: this warning originates in the attribute macro `event_cpi` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: use of deprecated function `anchor_lang::deprecated_account_info_usage`: Use `UncheckedAccount` instead of `AccountInfo` for safer unchecked accounts.
--> programs/cp-amm/src/instructions/ix_update_delegate_permission.rs:16:1
|
16 | #[event_cpi]
| ^^^^^^^^^^^^
|
= note: this warning originates in the attribute macro `event_cpi` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: use of deprecated function `cp_amm::claim_protocol_fee`: Use claim_protocol_fee2 through protocol_fee program instead
--> programs/cp-amm/src/lib.rs:189:12
|
189 | pub fn claim_protocol_fee(
| ^^^^^^^^^^^^^^^^^^
warning: use of deprecated function `cp_amm::zap_protocol_fee`: Use claim_protocol_fee2 through protocol_fee program instead
--> programs/cp-amm/src/lib.rs:202:12
|
202 | pub fn zap_protocol_fee(ctx: Context<ZapProtocolFee>, max_amount: u64) -> Result<()> {
| ^^^^^^^^^^^^^^^^
warning: `cp-amm` (lib) generated 32 warnings
Checking rust-sdk v0.2.2 (/data/workdir/2962945/MeteoraAg/damm-v2/rust-sdk)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 24.80s
- cargo clippy --workspace --all-targets -- -D warnings: failed
ed `assert_eq!` with a literal bool
--> programs/cp-amm/src/tests/test_safe_math.rs:34:5
|
34 | assert_eq!(100u128.safe_shl(128).is_err(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#bool_assert_comparison
help: replace it with `assert!(..)`
|
34 - assert_eq!(100u128.safe_shl(128).is_err(), true);
34 + assert!(100u128.safe_shl(128).is_err());
|
error: used `assert_eq!` with a literal bool
--> programs/cp-amm/src/tests/test_safe_math.rs:40:5
|
40 | assert_eq!(100u128.safe_shr(1).is_ok(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#bool_assert_comparison
help: replace it with `assert!(..)`
|
40 - assert_eq!(100u128.safe_shr(1).is_ok(), true);
40 + assert!(100u128.safe_shr(1).is_ok());
|
error: used `assert_eq!` with a literal bool
--> programs/cp-amm/src/tests/test_safe_math.rs:41:5
|
41 | assert_eq!(200u128.safe_shr(129).is_err(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#bool_assert_comparison
help: replace it with `assert!(..)`
|
41 - assert_eq!(200u128.safe_shr(129).is_err(), true);
41 + assert!(200u128.safe_shr(129).is_err());
|
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/rust-1.93.0/index.html#unnecessary_cast
error: could not compile `cp-amm` (lib test) due to 244 previous errors
- bun run lint: failed
Checking formatting...
$ prettier */*.js "*/**/*{.js,.ts}" --check
[warn] tests/compoundingLiquidity.test.ts
[warn] tests/helpers/accounts.ts
[warn] tests/helpers/idl/alpha_vault.ts
[warn] tests/helpers/rateLimiterUtils.ts
[warn] tests/helpers/transferHook/idl/transfer_hook.ts
[warn] tests/zapProtocolFees.test.ts
[warn] Code style issues found in 6 files. Forgot to run Prettier?
error: script "lint" exited with code 1
- bun run test: failed
$ bun run build-local && ANCHOR_WALLET=keys/local/admin-bossj3JvwiNK7pvjr149DqdtJxf2gdygbcmEPTkb2F1.json bunx ts-mocha -p ./tsconfig.json -t 1000000 tests/*.test.ts
$ anchor build --ignore-keys -- --features local
/usr/bin/bash: line 1: anchor: command not found
error: script "build-local" exited with code 127
error: script "test" exited with code 127
- bun run build-local: failed
$ anchor build --ignore-keys -- --features local
/usr/bin/bash: line 1: anchor: command not found
error: script "build-local" exited with code 127
|
/bot review |
|
Bot Agent progress:
Progress:
|
There was a problem hiding this comment.
Verdict
Approve
Review coverage
Findings: P0:0 P1:0 P2:0 P3:0
Reviewed by: OMP-native GPT openai-codex/gpt-5.5 + Opus anthropic/claude-opus-4-8 + arbiter openai-codex/gpt-5.5
Coverage lanes: Correctness, System integration, State machine, Regression tests, Repo checks
Risk focus: state-machine paths changed; tests changed
Evidence: repo-grounded (reviewers verified findings against the checkout)
Summary
Approved. Checked correctness, system-integration, state-machine, and regression-test lanes against the PR head checkout. Verified the new withdraw_dead_liquidity_reward entrypoint, reward-accounting methods, fund_reward gating, sibling withdraw behavior, helper wiring, and direct usages/tests. cargo check --workspace passed. clippy/Prettier failures are in unrelated files; TS tests could not run because anchor is not installed. No patch-anchored blocking defects found.
OMP-native GPT + Opus review
gpt:ok 227525ms
opus:ok 346574ms
arbiter:ok 40257ms
Synthesis
OMP final arbiter used openai-codex/gpt-5.5; 0 final finding(s).
Repo checks
Repo Checks
- rustup component add --toolchain 1.93.0-x86_64-unknown-linux-gnu clippy: ok
info: component clippy is up to date
- cargo fetch --locked: ok
- bun install --frozen-lockfile: ok
bun install v1.3.14 (0d9b296a)
+ @anchor-lang/borsh@1.0.0
+ @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
+ @anchor-lang/core@1.0.0
+ @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
192 packages installed [961.00ms]
- cargo check --workspace: ok
e for more info)
warning: use of deprecated function `anchor_lang::deprecated_account_info_usage`: Use `UncheckedAccount` instead of `AccountInfo` for safer unchecked accounts.
--> programs/cp-amm/src/instructions/ix_split_position.rs:97:1
|
97 | #[event_cpi]
| ^^^^^^^^^^^^
|
= note: this warning originates in the attribute macro `event_cpi` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: use of deprecated function `anchor_lang::deprecated_account_info_usage`: Use `UncheckedAccount` instead of `AccountInfo` for safer unchecked accounts.
--> programs/cp-amm/src/instructions/ix_lock_inner_position.rs:11:1
|
11 | #[event_cpi]
| ^^^^^^^^^^^^
|
= note: this warning originates in the attribute macro `event_cpi` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: use of deprecated function `anchor_lang::deprecated_account_info_usage`: Use `UncheckedAccount` instead of `AccountInfo` for safer unchecked accounts.
--> programs/cp-amm/src/instructions/ix_update_delegate_permission.rs:16:1
|
16 | #[event_cpi]
| ^^^^^^^^^^^^
|
= note: this warning originates in the attribute macro `event_cpi` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: use of deprecated function `cp_amm::claim_protocol_fee`: Use claim_protocol_fee2 through protocol_fee program instead
--> programs/cp-amm/src/lib.rs:189:12
|
189 | pub fn claim_protocol_fee(
| ^^^^^^^^^^^^^^^^^^
warning: use of deprecated function `cp_amm::zap_protocol_fee`: Use claim_protocol_fee2 through protocol_fee program instead
--> programs/cp-amm/src/lib.rs:202:12
|
202 | pub fn zap_protocol_fee(ctx: Context<ZapProtocolFee>, max_amount: u64) -> Result<()> {
| ^^^^^^^^^^^^^^^^
warning: `cp-amm` (lib) generated 32 warnings
Checking rust-sdk v0.2.2 (/data/workdir/2962945/MeteoraAg/damm-v2/rust-sdk)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 27.75s
- cargo clippy --workspace --all-targets -- -D warnings: failed
ed `assert_eq!` with a literal bool
--> programs/cp-amm/src/tests/test_safe_math.rs:34:5
|
34 | assert_eq!(100u128.safe_shl(128).is_err(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#bool_assert_comparison
help: replace it with `assert!(..)`
|
34 - assert_eq!(100u128.safe_shl(128).is_err(), true);
34 + assert!(100u128.safe_shl(128).is_err());
|
error: used `assert_eq!` with a literal bool
--> programs/cp-amm/src/tests/test_safe_math.rs:40:5
|
40 | assert_eq!(100u128.safe_shr(1).is_ok(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#bool_assert_comparison
help: replace it with `assert!(..)`
|
40 - assert_eq!(100u128.safe_shr(1).is_ok(), true);
40 + assert!(100u128.safe_shr(1).is_ok());
|
error: used `assert_eq!` with a literal bool
--> programs/cp-amm/src/tests/test_safe_math.rs:41:5
|
41 | assert_eq!(200u128.safe_shr(129).is_err(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#bool_assert_comparison
help: replace it with `assert!(..)`
|
41 - assert_eq!(200u128.safe_shr(129).is_err(), true);
41 + assert!(200u128.safe_shr(129).is_err());
|
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/rust-1.93.0/index.html#unnecessary_cast
error: could not compile `cp-amm` (lib test) due to 244 previous errors
- bun run lint: failed
Checking formatting...
$ prettier */*.js "*/**/*{.js,.ts}" --check
[warn] tests/compoundingLiquidity.test.ts
[warn] tests/helpers/accounts.ts
[warn] tests/helpers/idl/alpha_vault.ts
[warn] tests/helpers/rateLimiterUtils.ts
[warn] tests/helpers/transferHook/idl/transfer_hook.ts
[warn] tests/zapProtocolFees.test.ts
[warn] Code style issues found in 6 files. Forgot to run Prettier?
error: script "lint" exited with code 1
- bun run test: failed
$ bun run build-local && ANCHOR_WALLET=keys/local/admin-bossj3JvwiNK7pvjr149DqdtJxf2gdygbcmEPTkb2F1.json bunx ts-mocha -p ./tsconfig.json -t 1000000 tests/*.test.ts
$ anchor build --ignore-keys -- --features local
/usr/bin/bash: line 1: anchor: command not found
error: script "build-local" exited with code 127
error: script "test" exited with code 127
- bun run build-local: failed
$ anchor build --ignore-keys -- --features local
/usr/bin/bash: line 1: anchor: command not found
error: script "build-local" exited with code 127
|
/bot review |
|
Bot Agent progress:
Progress:
|
There was a problem hiding this comment.
Verdict
Approve
Review coverage
Findings: P0:0 P1:0 P2:0 P3:1
Reviewed by: OMP-native GPT openai-codex/gpt-5.5 + Opus anthropic/claude-opus-4-8 + arbiter openai-codex/gpt-5.5
Coverage lanes: Correctness, System integration, State machine, Regression tests, Repo checks
Risk focus: state-machine paths changed; tests changed
Evidence: repo-grounded (reviewers verified findings against the checkout)
Summary
No P0/P1/P2 correctness issue found in the changed reward flow. Keep the P3 coverage finding: the source supports mid-campaign withdraw/re-fund behavior, while existing positive tests only exercise the relevant paths after reward end, leaving the headline active-campaign behavior without direct regression coverage.
Findings
- [P3]
tests/deadLiquidityReward.test.ts:197Add active-campaign coverage for the new reward flow (via GPT+Opus)
OMP-native GPT + Opus review
gpt:ok 172129ms
opus:ok 353211ms
gpt_critique:ok 84802ms
opus_critique:ok 175240ms
arbiter:ok 45950ms
Synthesis
OMP final arbiter used openai-codex/gpt-5.5; 1 final finding(s).
|
/bot review |
|
Bot Agent progress:
Progress:
|
There was a problem hiding this comment.
Verdict
Approve
Review coverage
Findings: P0:0 P1:0 P2:1 P3:0
Reviewed by: OMP-native GPT openai-codex/gpt-5.5 + Opus anthropic/claude-opus-4-8 + arbiter openai-codex/gpt-5.5
Coverage lanes: Correctness, System integration, State machine, Regression tests, Repo checks
Risk focus: state-machine paths changed; tests changed
Evidence: repo-grounded (reviewers verified findings against the checkout)
Summary
No P0/P1 production correctness issue verified. One P2 regression-test gap remains: the changed carryForward=true path is not covered when pending dead-liquidity reward exists, so a future regression could re-include dead_liquidity_reward in the carry-forward total without the current test failing.
Findings
- [P2]
tests/deadLiquidityReward.test.ts:258Exercise carryForward=true for dead-liquidity regression (via GPT+Opus)
OMP-native GPT + Opus review
gpt:ok 230560ms
opus:ok 399064ms
gpt_critique:ok 77855ms
opus_critique:ok 163331ms
arbiter:ok 22482ms
Synthesis
OMP final arbiter used openai-codex/gpt-5.5; 1 final finding(s).
| )?; | ||
| } | ||
|
|
||
| emit_cpi!(EvtWithdrawDeadLiquidityReward { |
There was a problem hiding this comment.
it should be inside block if dead_liquidity_reward > 0
* bump version * Feat/nft delegate support (#211) * feat: nft delegate support * fix: remove `.only` in test * feat: negative test cases * fix: clean up is_position_authority * fix: permissions for delegate action * feat: refactor and fix test * fix: use assert! * feat: revoke perm test * refactor: tests * feat: prevent transfer and burn * docs: update * fix: invalid permission * refactor: minor * docs: update changelog * fix: tests * feat: reduce permission space usage * feat: rename account owner -> signer * feat: toOwner perms * feat: combine lock position perms and remove split position perms * feat: use derive-variant-count instead of hardcoding * fix: tests * docs: comma and rearrange * fix: address comments * fix: compounding fee dead liquidity reward accounting (#212) * fix: compounding fee dead liquidity reward accounting * feat: carry forward dead liquidity reward * fix: precision * docs: update changelog * fix: saturate and document * fix: use wrapping to keep dead_liquidity_reward_checkpoint from overflowing * fix: Reward Delegate Can Clear Rewards Without Transfer (#213) * feat: update EvtUpdateDelegatePermission to include delegate (#216) * fix: Incomplete Delegate Endpoint List (#214) * fix: withdrawing_dead_liquidity_reward & dead_liquidity_reward no longer carry forward (#217) * fix: add new ix to reduce breaking changes * fix: test * fix: remove unnecessary fund reward restriction * fix: tests * fix: based on comments * fix: typo (#218)
fund_rewardon compounding pool mid campaign againfund_rewardwill not carry forwarddead_liquidity_reward