Skip to content

Commit

Permalink
Pool: cleaned status code
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspluna committed Dec 15, 2023
1 parent 9de293c commit 6556498
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 92 deletions.
8 changes: 6 additions & 2 deletions pool/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl Pool for PoolContract {

fn update_status(e: Env) -> u32 {
storage::extend_instance(&e);
let new_status = pool::execute_update_pool_status(&e, 11); //status input is not used here
let new_status = pool::execute_update_pool_status(&e);

e.events()
.publish((Symbol::new(&e, "set_status"),), new_status);
Expand All @@ -319,7 +319,11 @@ impl Pool for PoolContract {

fn set_status(e: Env, pool_status: u32) {
storage::extend_instance(&e);
pool::execute_update_pool_status(&e, pool_status);
let admin = storage::get_admin(&e);
admin.require_auth();
pool::execute_set_pool_status(&e, pool_status);
e.events()
.publish((Symbol::new(&e, "set_status"), admin), pool_status);
}

/********* Emission Functions **********/
Expand Down
1 change: 1 addition & 0 deletions pool/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub enum PoolError {
NegativeAmount = 4,
InvalidPoolInitArgs = 5,
InvalidReserveMetadata = 6,
StatusNotAllowed = 8,
// Pool State Errors (10-19)
InvalidHf = 10,
InvalidPoolStatus = 11,
Expand Down
4 changes: 3 additions & 1 deletion pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ mod user;
pub use user::{Positions, User};

mod status;
pub use status::{calc_pool_backstop_threshold, execute_update_pool_status};
pub use status::{
calc_pool_backstop_threshold, execute_set_pool_status, execute_update_pool_status,
};
14 changes: 7 additions & 7 deletions pool/src/pool/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ mod tests {
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_200_000_000,
status: 3,
status: 2,
};
e.as_contract(&pool, || {
storage::set_pool_config(&e, &pool_config);
Expand All @@ -286,7 +286,7 @@ mod tests {
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_200_000_000,
status: 0,
status: 1,
};
e.as_contract(&pool, || {
storage::set_pool_config(&e, &pool_config);
Expand All @@ -306,7 +306,7 @@ mod tests {
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_200_000_000,
status: 3,
status: 2,
};
e.as_contract(&pool, || {
storage::set_pool_config(&e, &pool_config);
Expand All @@ -325,7 +325,7 @@ mod tests {
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_200_000_000,
status: 0,
status: 1,
};
e.as_contract(&pool, || {
storage::set_pool_config(&e, &pool_config);
Expand All @@ -345,7 +345,7 @@ mod tests {
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_200_000_000,
status: 5,
status: 4,
};
e.as_contract(&pool, || {
storage::set_pool_config(&e, &pool_config);
Expand All @@ -365,7 +365,7 @@ mod tests {
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_200_000_000,
status: 5,
status: 4,
};
e.as_contract(&pool, || {
storage::set_pool_config(&e, &pool_config);
Expand All @@ -384,7 +384,7 @@ mod tests {
let pool_config = PoolConfig {
oracle,
bstop_rate: 0_200_000_000,
status: 2,
status: 4,
};
e.as_contract(&pool, || {
storage::set_pool_config(&e, &pool_config);
Expand Down
Loading

0 comments on commit 6556498

Please sign in to comment.