Problem
reader::get_claimable_funding_amount (contracts/reader/src/lib.rs:536-586) has zero test coverage anywhere in the repository:
grep -rn "get_claimable_funding_amount" --include="*.rs" . | grep -v reader/src/lib.rs
# no output
The function computes claimable funding for both long and short collateral token sides by diffing the position's stored long_claim_fnd_per_size/short_claim_fnd_per_size trackers against the latest funding_amount_per_size_key value, scaling by mul_div_wide, and then subtracting the position's own funding_fee_amount (from get_position_fees) from whichever side matches the position's actual collateral token. This is genuinely intricate arithmetic — two independent per-token computations merged with a conditional subtraction — none of which is exercised by any test.
Why it matters
This is the query a UI would call to show a trader how much funding they can claim. A sign error in the claimable_per_size subtraction, or applying the funding_fee_amount deduction to the wrong side (long vs short) when position.collateral_token doesn't match either token exactly, would silently misreport claimable funding with no test to catch it.
Suggested fix
Add a test with known funding accrual on both sides of a market, call get_claimable_funding_amount for both a long-collateral and a short-collateral position, and assert the returned FundingAmountResult matches independently-computed expected values.
Problem
reader::get_claimable_funding_amount(contracts/reader/src/lib.rs:536-586) has zero test coverage anywhere in the repository:The function computes claimable funding for both long and short collateral token sides by diffing the position's stored
long_claim_fnd_per_size/short_claim_fnd_per_sizetrackers against the latestfunding_amount_per_size_keyvalue, scaling bymul_div_wide, and then subtracting the position's ownfunding_fee_amount(fromget_position_fees) from whichever side matches the position's actual collateral token. This is genuinely intricate arithmetic — two independent per-token computations merged with a conditional subtraction — none of which is exercised by any test.Why it matters
This is the query a UI would call to show a trader how much funding they can claim. A sign error in the
claimable_per_sizesubtraction, or applying thefunding_fee_amountdeduction to the wrong side (long vs short) whenposition.collateral_tokendoesn't match either token exactly, would silently misreport claimable funding with no test to catch it.Suggested fix
Add a test with known funding accrual on both sides of a market, call
get_claimable_funding_amountfor both a long-collateral and a short-collateral position, and assert the returnedFundingAmountResultmatches independently-computed expected values.