Skip to content

Commit

Permalink
Release/0.15.0 (#3)
Browse files Browse the repository at this point in the history
- Configuration synchronization
- Remove migration ix
- Add Pyth EMA price type
- Add fixed price type
  • Loading branch information
oeble authored Sep 24, 2024
1 parent c065d3a commit 1d634dd
Show file tree
Hide file tree
Showing 22 changed files with 364 additions and 342 deletions.
69 changes: 11 additions & 58 deletions Cargo.lock

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

83 changes: 77 additions & 6 deletions configs/mainnet/hubble.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
},
"3": {
"label": "SRM/USD",
"oracle_mapping": "3NBReDRTLKMQEKiLD5tGcx4kXbTf88b7f2xLS9UuGjym",
"oracle_type": "Pyth"
"oracle_type": "FixedPrice",
"fixed_price": 0.000001
},
"4": {
"label": "RAY/USD",
Expand Down Expand Up @@ -196,8 +196,8 @@
},
"55": {
"label": "EMA SRM/USD",
"oracle_mapping": "3NBReDRTLKMQEKiLD5tGcx4kXbTf88b7f2xLS9UuGjym",
"oracle_type": "PythEMA"
"oracle_type": "FixedPrice",
"fixed_price": 0.000001
},
"56": {
"label": "EMA RAY/USD",
Expand Down Expand Up @@ -371,8 +371,8 @@
},
"86": {
"label": "MOBILE/HNT",
"oracle_mapping": "7bEjAXVd6ug8T8kbYKxCuoDHZzYK4CTAW9WVPVGLz2or",
"oracle_type": "SwitchboardV2",
"oracle_mapping": "45zpzzpZquaVv4BAdXfzNbuba7DAXV32d1sTrUh5wcnW",
"oracle_type": "OrcaWhirlpoolBtoA",
"twap_enabled": true,
"max_age": 200
},
Expand Down Expand Up @@ -2267,5 +2267,76 @@
"oracle_type": "PythPullBased",
"ref_price": 1,
"max_age": 175
},
"401": {
"label": "Pyth Pull INF/USD",
"oracle_mapping": "Ceg5oePJv1a6RR541qKeQaTepvERA3i8SvyueX9tT8Sq",
"oracle_type": "PythPullBased",
"twap_enabled": true,
"max_age": 200
},
"402": {
"label": "TWAP Pyth Pull INF/USD",
"oracle_type": "ScopeTwap",
"twap_source": 401,
"max_age": 220
},
"403": {
"label": "Orca TREMP/SOL",
"oracle_mapping": "DbyEjKTHE76qgb8niQ4zDCoaU4CK7Si9PJkD6Ckjtugo",
"oracle_type": "OrcaWhirlpoolBtoA",
"twap_enabled": true,
"max_age": 100
},
"404": {
"label": "TWAP Orca TREMP/SOL",
"oracle_type": "ScopeTwap",
"twap_source": 403,
"max_age": 120
},
"405": {
"label": "Orca MICHI/SOL",
"oracle_mapping": "CATK9eqtn8Qwv95JF6JS4xdC4AYRFqPiuswG7fwsnVN1",
"oracle_type": "OrcaWhirlpoolBtoA",
"twap_enabled": true,
"max_age": 100
},
"406": {
"label": "TWAP Orca MICHI/SOL",
"oracle_type": "ScopeTwap",
"twap_source": 405,
"max_age": 120
},
"407": {
"label": "Orca MANEKI/SOL",
"oracle_mapping": "J3XD1CgkMaTQMJqyTFyxHUExSuMiBfVWHGzGEBLsefDY",
"oracle_type": "OrcaWhirlpoolBtoA",
"twap_enabled": true,
"max_age": 100
},
"408": {
"label": "TWAP Orca MANEKI/SOL",
"oracle_type": "ScopeTwap",
"twap_source": 407,
"max_age": 120
},
"409": {
"label": "Orca BOME/SOL",
"oracle_mapping": "DfUcPcAYUE5Vqi7wirnSkAVJdAKu4d6JC3o5roTVBz5N",
"oracle_type": "OrcaWhirlpoolBtoA",
"twap_enabled": true,
"max_age": 100
},
"410": {
"label": "TWAP Orca BOME/SOL",
"oracle_type": "ScopeTwap",
"twap_source": 409,
"max_age": 120
},
"411": {
"label": "Stake rate INF/SOL",
"oracle_mapping": "2EVUajXzWab9sAUA9AuHwkQmr2y6bGZvcztQEE7p7Q9Y",
"oracle_type": "SwitchboardV2",
"max_age": 58500
}
}
3 changes: 3 additions & 0 deletions programs/scope/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ pub enum ScopeError {

#[msg("Cannot resize the account we only allow it to grow in size")]
CannotResizeAccount,

#[msg("The provided fixed price is invalid")]
FixedPriceInvalid,
}

impl<T> From<TryFromPrimitiveError<T>> for ScopeError
Expand Down
62 changes: 0 additions & 62 deletions programs/scope/src/handlers/handler_extend_mapping.rs

This file was deleted.

2 changes: 1 addition & 1 deletion programs/scope/src/handlers/handler_initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Initialize<'info> {

// Account is pre-reserved/paid outside the program
#[account(zero)]
pub oracle_mappings: AccountLoader<'info, crate::OracleMappingsOld>,
pub oracle_mappings: AccountLoader<'info, crate::OracleMappings>,
}

pub fn process(ctx: Context<Initialize>, _: String) -> Result<()> {
Expand Down
14 changes: 10 additions & 4 deletions programs/scope/src/handlers/handler_refresh_prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use solana_program::{
},
};

use crate::utils::zero_copy_deserialize;
use crate::OracleMappingsCore;
use crate::utils::{price_impl::check_ref_price_difference, zero_copy_deserialize};
use crate::OracleMappings;
use crate::{
oracles::{get_price, OracleType},
ScopeError,
Expand Down Expand Up @@ -39,8 +39,7 @@ pub fn refresh_price_list<'info>(
) -> Result<()> {
check_execution_ctx(&ctx.accounts.instruction_sysvar_account_info)?;

let oracle_mappings =
&zero_copy_deserialize::<OracleMappingsCore>(&ctx.accounts.oracle_mappings)?;
let oracle_mappings = &zero_copy_deserialize::<OracleMappings>(&ctx.accounts.oracle_mappings)?;
let mut oracle_twaps = ctx.accounts.oracle_twaps.load_mut()?;

// No token to refresh
Expand Down Expand Up @@ -124,6 +123,13 @@ pub fn refresh_price_list<'info>(
// from the price feed that is currently updated

let mut oracle_prices = ctx.accounts.oracle_prices.load_mut()?;

// check that the price is close enough to the ref price is there is a ref price
if oracle_mappings.ref_price[token_idx] != u16::MAX {
let ref_price =
oracle_prices.prices[usize::from(oracle_mappings.ref_price[token_idx])].price;
check_ref_price_difference(price.price, ref_price)?;
}
let to_update = oracle_prices
.prices
.get_mut(token_idx)
Expand Down
Loading

0 comments on commit 1d634dd

Please sign in to comment.