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

SetSharePriceOracle for turbo sweth #220

Merged
merged 5 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sommelier_steward"
version = "3.4.1"
version = "3.4.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
14 changes: 14 additions & 0 deletions proto/cellar_v2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ message CellarV2_5 {
IncreaseShareSupplyCap increase_share_supply_cap = 16;
// Represents function `decreaseShareSupplyCap(uint192)
DecreaseShareSupplyCap decrease_share_supply_cap = 17;
// Represents function `setSharePriceOracle(uint256, address)
SetSharePriceOracle set_share_price_oracle = 18;
}
}

Expand Down Expand Up @@ -612,6 +614,18 @@ message CellarV2_5 {
message DecreaseShareSupplyCap {
string new_cap = 1;
}

/*
* Allows strategist to set the share price oracle contract
*
* Represents function `setSharePriceOracle(uint256, address)`
*/
message SetSharePriceOracle {
// The oracle registry ID
string registry_id = 1;
// The oracle contract address
string oracle = 2;
}
}

// Represents a call to adaptor an. The cellar must be authorized to call the target adaptor.
Expand Down
2 changes: 1 addition & 1 deletion steward/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "steward"
authors = []
version = "3.4.1"
version = "3.4.2"
edition = "2018"

[dependencies]
Expand Down
1 change: 1 addition & 0 deletions steward/src/cellars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub const CELLAR_RYSNX: &str = "cbf2250f33c4161e18d4a2fa47464520af5216b5";
pub const CELLAR_RYUNI: &str = "6a6af5393dc23d7e3db28d28ef422db7c40932b6";
pub const CELLAR_RYUSD: &str = "97e6e0a40a3d02f12d1cec30ebfbae04e37c119e";
pub const CELLAR_RYBTC: &str = "0274a704a6d9129f90a62ddc6f6024b33ecdad36";
pub const CELLAR_TURBO_SWETH: &str = "d33dad974b938744dac81fe00ac67cb5aa13958e";

// deprecated adaptors

Expand Down
34 changes: 32 additions & 2 deletions steward/src/cellars/cellar_v2_5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use crate::{
};

use super::{
check_blocked_adaptor, check_blocked_position, log_cellar_call, validate_new_adaptor,
validate_new_position, V2_5_PERMISSIONS,
check_blocked_adaptor, check_blocked_position, log_cellar_call, normalize_address,
validate_new_adaptor, validate_new_position, CELLAR_TURBO_SWETH, V2_5_PERMISSIONS,
};

const CELLAR_NAME: &str = "CellarV2.5";
Expand Down Expand Up @@ -260,6 +260,36 @@ pub fn get_encoded_function(call: FunctionCall, cellar_id: String) -> Result<Vec

Ok(CellarV2_5Calls::DecreaseShareSupplyCap(call).encode())
}
Function::SetSharePriceOracle(params) => {
let cellar_id_normalized = normalize_address(cellar_id.clone());
let oracle_in = normalize_address(params.oracle.clone());
let allowed_oracles = [
normalize_address("0x72249f0199EACf6230DEF33A31e80CF76de78f67".to_string()),
EricBolten marked this conversation as resolved.
Show resolved Hide resolved
normalize_address("0xC47278B65443cE71CF47E8455BB343F2DB11B70e".to_string()),
];
let allowed_registry_ids = [U256::from(3), U256::from(5)];
let registry_id_in = string_to_u256(params.registry_id.clone())?;
if !cellar_id_normalized.eq(CELLAR_TURBO_SWETH)
|| !allowed_oracles.contains(&oracle_in)
|| !allowed_registry_ids.contains(&registry_id_in)
EricBolten marked this conversation as resolved.
Show resolved Hide resolved
{
return Err(ErrorKind::SPCallError
.context("unauthorized oracle update".to_string())
.into());
}

log_cellar_call(
CELLAR_NAME,
&SetSharePriceOracleCall::function_name(),
&cellar_id,
);
let call = SetSharePriceOracleCall {
registry_id: string_to_u256(params.registry_id)?,
share_price_oracle: sp_call_parse_address(params.oracle)?,
};

Ok(CellarV2_5Calls::SetSharePriceOracle(call).encode())
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion steward_abi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "steward_abi"
version = "3.4.1"
version = "3.4.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
Loading
Loading