-
Notifications
You must be signed in to change notification settings - Fork 2
[LST-343] StartRebalance and EndRebalance instructions #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Johnnycus
merged 36 commits into
master
from
lst-343-inf1-jiminy-reimpl-startrebalance-and-endrebalance
Nov 7, 2025
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
83a6135
StartRebalance and EndRebalance ixs jiminy implementation
Johnnycus cb1efa4
cargo fmt
Johnnycus b5dc901
fix warning
Johnnycus 836ea0b
remove system_program from end_rebalance and use SYS_PROG_ID const
Johnnycus 46989c4
use csba to parse start_rebalance args
Johnnycus fccbb75
remove redundant validation checks
Johnnycus 1d48e33
combine two verify_pks in start_rebalnce ix into one array based call
Johnnycus 681eef8
realloc after assign and transfer in start_rebalance ix
Johnnycus b648c0f
move get_token_account_amount to a util file
Johnnycus df2154d
simplify verify_end_rebalance_exists fn
Johnnycus 8a78892
use jiminy-sysvar-instructions to verify endrebalance exists after st…
Johnnycus 7f72308
cargo fmt
Johnnycus 06f836c
use .close() at the end of end_rebalance ix
Johnnycus 85ecfda
simplify verify_end_rebalance_exists()
Johnnycus d67faf0
write tests for startrebalance and endrebalance instructions
Johnnycus 335d545
ci
Johnnycus 009637a
ci
Johnnycus 6635954
use iinpt instead of dst and imports when possible
Johnnycus d718a5b
Merge branch 'master' into lst-343-inf1-jiminy-reimpl-startrebalance-…
Johnnycus d065bbe
read pool state using pool_state_checked()
Johnnycus aa34443
refactor start_rebalance test fns and arguments
Johnnycus 5eec945
remove start/end err to programerr mapping
Johnnycus 6c48dc2
review fixes
Johnnycus 2aaa4e3
create rebalance_transaction test that tests rebalance ixs chain
Johnnycus 93a95f2
reorg rebalance ixs and tests
Johnnycus 23fafda
assert lamports are balanced properly
Johnnycus 3b99c0c
Merge branch 'master' into lst-343-inf1-jiminy-reimpl-startrebalance-…
Johnnycus 7e2661f
reduce clutter
Johnnycus bd20f20
better tests for rebalance chain
Johnnycus f8db979
Merge branch 'master' into lst-343-inf1-jiminy-reimpl-startrebalance-…
Johnnycus ddb899f
Merge branch 'master' into lst-343-inf1-jiminy-reimpl-startrebalance-…
Johnnycus 12afd90
cleanup pdasigners for rebalance record and fix endrebalanceixdata use
Johnnycus 15cc924
remove isolated start/end rebalance tests
Johnnycus 4335c4c
add already rebalancing and unauthorized auth rebalance test cases
Johnnycus c5befa5
cleanup
Johnnycus e56a402
restore _POOL_STATE_ALIGN_CHECK
Johnnycus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| use core::mem::size_of; | ||
|
|
||
| use crate::internal_utils::{impl_cast_from_acc_data, impl_cast_to_acc_data}; | ||
|
|
||
| #[repr(C)] | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
| pub struct RebalanceRecord { | ||
| pub old_total_sol_value: u64, | ||
| pub inp_lst_index: u32, | ||
| pub padding: [u8; 4], | ||
| } | ||
| impl_cast_from_acc_data!(RebalanceRecord); | ||
| impl_cast_to_acc_data!(RebalanceRecord); | ||
|
|
||
| #[repr(C)] | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
| pub struct RebalanceRecordPacked { | ||
| old_total_sol_value: [u8; 8], | ||
| inp_lst_index: [u8; 4], | ||
| padding: [u8; 4], | ||
| } | ||
| impl_cast_from_acc_data!(RebalanceRecordPacked, packed); | ||
| impl_cast_to_acc_data!(RebalanceRecordPacked, packed); | ||
|
|
||
| impl RebalanceRecordPacked { | ||
| #[inline] | ||
| pub const fn into_rebalance_record(self) -> RebalanceRecord { | ||
| let Self { | ||
| old_total_sol_value, | ||
| inp_lst_index, | ||
| padding, | ||
| } = self; | ||
| RebalanceRecord { | ||
| old_total_sol_value: u64::from_le_bytes(old_total_sol_value), | ||
| inp_lst_index: u32::from_le_bytes(inp_lst_index), | ||
| padding, | ||
| } | ||
| } | ||
|
|
||
| /// # Safety | ||
| /// - `self` must be pointing to mem that has same align as `RebalanceRecord`. | ||
| /// This is true onchain for a RebalanceRecord account since account data | ||
| /// is always 8-byte aligned onchain. | ||
| #[inline] | ||
| pub const unsafe fn as_rebalance_record(&self) -> &RebalanceRecord { | ||
| &*(self as *const Self).cast() | ||
| } | ||
| } | ||
|
|
||
| impl From<RebalanceRecordPacked> for RebalanceRecord { | ||
| #[inline] | ||
| fn from(value: RebalanceRecordPacked) -> Self { | ||
| value.into_rebalance_record() | ||
| } | ||
| } | ||
|
|
||
| const _ASSERT_PACKED_UNPACKED_SIZES_EQ: () = | ||
| assert!(size_of::<RebalanceRecord>() == size_of::<RebalanceRecordPacked>()); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.