Skip to content

fix(ts-client): pick last-chunk shrink mode by chunk count - #319

Open
ara-stock wants to merge 1 commit into
MeteoraAg:mainfrom
ara-stock:fix/311-chunk-shrink-mode
Open

ara-stock wants to merge 1 commit into
MeteoraAg:mainfrom
ara-stock:fix/311-chunk-shrink-mode

Conversation

@ara-stock

Copy link
Copy Markdown

Fixes #311.

In chunkDepositWithRebalanceEndpoint, the parallel shrink mode of each chunk compared the loop index with chunkBinRange.length - 1. chunkBinRange is the helper function, so .length is its parameter count (3), not the number of chunks in chunkedBinRange. The last chunk only got NoShrinkLeft when there were exactly 3 chunks.

Shrink modes per chunk count, before and after (chunkBinRange declared with the same 3 parameters):

chunks before after
1 NoShrinkRight NoShrinkRight
2 NoShrinkRight, NoShrinkBoth NoShrinkRight, NoShrinkLeft
3 NoShrinkRight, NoShrinkBoth, NoShrinkLeft (unchanged)
4 NoShrinkRight, NoShrinkBoth, NoShrinkLeft, NoShrinkBoth NoShrinkRight, NoShrinkBoth, NoShrinkBoth, NoShrinkLeft
5 ..., NoShrinkLeft, NoShrinkBoth, NoShrinkBoth ..., NoShrinkBoth, NoShrinkBoth, NoShrinkLeft

With 4+ chunks, chunk 3 used NoShrinkLeft and could trim the still-empty right side that chunks 4 and 5 are meant to fill (the issue shows this with simulateTransaction).

Change: one identifier (chunkBinRange → chunkedBinRange) plus a CHANGELOG entry under Unreleased / Fixed. I did not add a test: the branch sits inside the async endpoint builder, and covering it would need either a pool fixture or pulling the selection out into a helper. Happy to do the latter if you prefer.

Disclosure: I used an AI assistant (Claude) to help prepare this change. I checked the line, the parameter count of chunkBinRange, and the table above myself.

🤖 Generated with Claude Code

chunkDepositWithRebalanceEndpoint compared the loop index with
chunkBinRange.length - 1, i.e. the parameter count of the chunkBinRange
function (3) minus one, instead of the number of chunks. With 2, 4 or
more chunks the last chunk did not get NoShrinkLeft.

Fixes MeteoraAg#311

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

chunkDepositWithRebalanceEndpoint: shrinkMode is compared to chunkBinRange.length (function arity) instead of chunkedBinRange.length

1 participant