Skip to content
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

Emit events on A change #35

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions amm/contracts/stable_pool/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,17 @@ pub mod stable_pool {
}

#[ink(event)]
pub struct AmpCoefChanged {
pub new_amp_coef: u128,
pub struct AmpCoefChange {
pub initial_amp_coef: u128,
pub future_amp_coef: u128,
pub initial_time: u64,
pub future_time: u64,
}

#[ink(event)]
pub struct AmpCoefChangeStop {
pub amp_coef: u128,
pub time: u64,
}

#[ink(event)]
Expand Down Expand Up @@ -808,17 +817,27 @@ pub mod stable_pool {
future_time_ts: u64,
) -> Result<(), StablePoolError> {
self.ensure_owner()?;
let inital_amp_coef = self.amp_coef()?;
self.pool
.amp_coef
.ramp_amp_coef(future_amp_coef, future_time_ts)?;

self.env().emit_event(AmpCoefChange {
initial_amp_coef,
future_amp_coef,
initial_time: self.env().block_timestamp(),
future_time: future_time_ts,
});
Ok(())
}

#[ink(message)]
fn stop_ramp_amp_coef(&mut self) -> Result<(), StablePoolError> {
self.ensure_owner()?;
self.pool.amp_coef.stop_ramp_amp_coef()?;
self.env().emit_event(AmpCoefChangeStop {
amp_coef: self.amp_coef()?,
time: self.env().block_timestamp(),
});
Ok(())
}

Expand Down
Loading