mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-26 22:51:14 +00:00
fix(amm)!: restrict UpdateConfig to authority transfer only
UpdateConfig let the admin rewrite token_program_id and twap_oracle_program_id in place. Both are immutable deployment parameters — twap_oracle_program_id derives the current-tick PDA and every price-observation/price account PDA, and token_program_id is the program the AMM issues its vault transfers to — so changing either after any pool exists would orphan every derived account and vault. A genuine change requires redeploying the AMM, never an in-place edit. - Instruction::UpdateConfig now carries a single required field, new_authority; the two program-id fields are removed. - update_config assigns the new authority directly (no Option/if-let); PDA + admin + signature preconditions unchanged. - Guest handler and IDL updated to match. - Drop the integration test that mutated token_program_id (it exercised the vulnerability); keep reject-non-admin and authority-handoff, and assert program ids survive a transfer. BREAKING CHANGE: the UpdateConfig instruction ABI changed — the token_program_id and twap_oracle_program_id fields are removed and new_authority is now required (was Option). Any client constructing UpdateConfig must be updated. The instruction enum change also alters the program ImageID: redeploy and update every ImageID-derived value (deployed program ids, client/config files, PDA-derived addresses, AMM/ATA program-id inputs) before submitting
This commit is contained in:
@@ -47,7 +47,9 @@ mod amm {
|
||||
Ok(spel_framework::SpelOutput::execute(post_states, vec![]))
|
||||
}
|
||||
|
||||
/// Updates the AMM Program's configuration. Only the configured admin authority may call this.
|
||||
/// Transfers the AMM Program's admin authority. Only the configured admin authority may call
|
||||
/// this. The Token Program and TWAP oracle program IDs are immutable deployment parameters and
|
||||
/// cannot be changed here.
|
||||
///
|
||||
/// Expected accounts:
|
||||
/// 1. `config` — initialized AMM config account.
|
||||
@@ -59,15 +61,11 @@ mod amm {
|
||||
config: AccountWithMetadata,
|
||||
#[account(signer)]
|
||||
authority: AccountWithMetadata,
|
||||
token_program_id: Option<ProgramId>,
|
||||
twap_oracle_program_id: Option<ProgramId>,
|
||||
new_authority: Option<AccountId>,
|
||||
new_authority: AccountId,
|
||||
) -> SpelResult {
|
||||
let post_states = amm_program::update_config::update_config(
|
||||
config,
|
||||
authority,
|
||||
token_program_id,
|
||||
twap_oracle_program_id,
|
||||
new_authority,
|
||||
ctx.self_program_id,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user