Skip to content

feat(amm): add admin authority and UpdateConfig instruction#151

Merged
0x-r4bbit merged 1 commit into
mainfrom
feat/amm-update-config
Jun 19, 2026
Merged

feat(amm): add admin authority and UpdateConfig instruction#151
0x-r4bbit merged 1 commit into
mainfrom
feat/amm-update-config

Conversation

@0x-r4bbit

Copy link
Copy Markdown
Collaborator

Add an admin authority to the AMM config so configuration can be changed after initialization. AmmConfig gains an authority field, set by Initialize, and a new UpdateConfig instruction lets that admin change config values.

UpdateConfig is access-controlled: the authority account must equal the stored config.authority and be passed authorized (signed). Both fields are optional — token_program_id updates the chained-call token program, and new_authority transfers admin control to a different account. Without this gate any caller could repoint the AMM at a malicious token program.

Add an admin authority to the AMM config so configuration can be changed
after initialization. AmmConfig gains an `authority` field, set by
Initialize, and a new UpdateConfig instruction lets that admin change
config values.

UpdateConfig is access-controlled: the authority account must equal the
stored config.authority and be passed authorized (signed). Both fields are
optional — token_program_id updates the chained-call token program, and
new_authority transfers admin control to a different account. Without this
gate any caller could repoint the AMM at a malicious token program.
@0x-r4bbit 0x-r4bbit requested review from 3esmit and gravityblast June 18, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an admin authority to the AMM’s singleton config account and introduces a new UpdateConfig instruction so the token program ID and/or admin authority can be changed after initialization, with signature-based access control.

Changes:

  • Extend AmmConfig with an authority: AccountId field and update Initialize to set it.
  • Add UpdateConfig instruction + program implementation that only allows the configured authority (signed) to mutate config fields.
  • Update guest method handlers, IDL artifacts, and integration/unit tests to cover the new config layout and access control behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
programs/integration_tests/tests/amm.rs Adds admin key/id helpers and new integration tests covering UpdateConfig behavior and authority handoff.
programs/amm/src/update_config.rs Implements update_config handler with authority checks; adds unit tests for happy path and failure cases.
programs/amm/src/tests.rs Updates AMM test scaffolding to include the new authority field in config data.
programs/amm/src/lib.rs Exposes the new update_config module.
programs/amm/src/initialize.rs Extends initialize to store authority in config; updates tests accordingly.
programs/amm/methods/guest/src/bin/amm.rs Updates the guest instruction interface for Initialize and adds guest handler for UpdateConfig.
programs/amm/core/src/lib.rs Updates the core instruction enum and AmmConfig struct to include authority; documents UpdateConfig.
artifacts/amm-idl.json Updates IDL to include the new initialize arg and new update_config instruction + updated config type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread programs/amm/core/src/lib.rs
Comment thread programs/amm/src/initialize.rs
@0x-r4bbit 0x-r4bbit merged commit 1d9e3dc into main Jun 19, 2026
12 of 13 checks passed
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.

3 participants