[contract] fund settlement with non-delegated lamports #77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently when one tries to fund the Settlement with a stake account containing the larger amount of non-delegated lamports (bigger to funded amount + stake account rent) then the instruction fails.
It's because the stake program
split
instruction places all non-delegate lamports into the origin stake account and the rest is moved into a split. If the amount of non-delegated lamports is so many that the original stake account won't be a valid delegated stake account (a valid stake account needs to have delegated to a minimum of 1 SOL, at least per expected feature gate) then it ends failing.I do propose a PR to fix the issue of funding Settlements with non-delegated lamports (when more of them available in a stake account).
But I'm not fully happy with the current result. I realized I needed to combine manual withdrawal with split and delegate to get the wanted behaviour. The fund settlement instruction started to be even more complicated than before, and I failed to make it somehow more readable.
Any input is appreciated.
(and I assume the task not being of the highest priority)