Skip to content

Commit 1d634dd

Browse files
authored
Release/0.15.0 (#3)
- Configuration synchronization - Remove migration ix - Add Pyth EMA price type - Add fixed price type
1 parent c065d3a commit 1d634dd

22 files changed

+364
-342
lines changed

Cargo.lock

+11-58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configs/mainnet/hubble.json

+77-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
},
1919
"3": {
2020
"label": "SRM/USD",
21-
"oracle_mapping": "3NBReDRTLKMQEKiLD5tGcx4kXbTf88b7f2xLS9UuGjym",
22-
"oracle_type": "Pyth"
21+
"oracle_type": "FixedPrice",
22+
"fixed_price": 0.000001
2323
},
2424
"4": {
2525
"label": "RAY/USD",
@@ -196,8 +196,8 @@
196196
},
197197
"55": {
198198
"label": "EMA SRM/USD",
199-
"oracle_mapping": "3NBReDRTLKMQEKiLD5tGcx4kXbTf88b7f2xLS9UuGjym",
200-
"oracle_type": "PythEMA"
199+
"oracle_type": "FixedPrice",
200+
"fixed_price": 0.000001
201201
},
202202
"56": {
203203
"label": "EMA RAY/USD",
@@ -371,8 +371,8 @@
371371
},
372372
"86": {
373373
"label": "MOBILE/HNT",
374-
"oracle_mapping": "7bEjAXVd6ug8T8kbYKxCuoDHZzYK4CTAW9WVPVGLz2or",
375-
"oracle_type": "SwitchboardV2",
374+
"oracle_mapping": "45zpzzpZquaVv4BAdXfzNbuba7DAXV32d1sTrUh5wcnW",
375+
"oracle_type": "OrcaWhirlpoolBtoA",
376376
"twap_enabled": true,
377377
"max_age": 200
378378
},
@@ -2267,5 +2267,76 @@
22672267
"oracle_type": "PythPullBased",
22682268
"ref_price": 1,
22692269
"max_age": 175
2270+
},
2271+
"401": {
2272+
"label": "Pyth Pull INF/USD",
2273+
"oracle_mapping": "Ceg5oePJv1a6RR541qKeQaTepvERA3i8SvyueX9tT8Sq",
2274+
"oracle_type": "PythPullBased",
2275+
"twap_enabled": true,
2276+
"max_age": 200
2277+
},
2278+
"402": {
2279+
"label": "TWAP Pyth Pull INF/USD",
2280+
"oracle_type": "ScopeTwap",
2281+
"twap_source": 401,
2282+
"max_age": 220
2283+
},
2284+
"403": {
2285+
"label": "Orca TREMP/SOL",
2286+
"oracle_mapping": "DbyEjKTHE76qgb8niQ4zDCoaU4CK7Si9PJkD6Ckjtugo",
2287+
"oracle_type": "OrcaWhirlpoolBtoA",
2288+
"twap_enabled": true,
2289+
"max_age": 100
2290+
},
2291+
"404": {
2292+
"label": "TWAP Orca TREMP/SOL",
2293+
"oracle_type": "ScopeTwap",
2294+
"twap_source": 403,
2295+
"max_age": 120
2296+
},
2297+
"405": {
2298+
"label": "Orca MICHI/SOL",
2299+
"oracle_mapping": "CATK9eqtn8Qwv95JF6JS4xdC4AYRFqPiuswG7fwsnVN1",
2300+
"oracle_type": "OrcaWhirlpoolBtoA",
2301+
"twap_enabled": true,
2302+
"max_age": 100
2303+
},
2304+
"406": {
2305+
"label": "TWAP Orca MICHI/SOL",
2306+
"oracle_type": "ScopeTwap",
2307+
"twap_source": 405,
2308+
"max_age": 120
2309+
},
2310+
"407": {
2311+
"label": "Orca MANEKI/SOL",
2312+
"oracle_mapping": "J3XD1CgkMaTQMJqyTFyxHUExSuMiBfVWHGzGEBLsefDY",
2313+
"oracle_type": "OrcaWhirlpoolBtoA",
2314+
"twap_enabled": true,
2315+
"max_age": 100
2316+
},
2317+
"408": {
2318+
"label": "TWAP Orca MANEKI/SOL",
2319+
"oracle_type": "ScopeTwap",
2320+
"twap_source": 407,
2321+
"max_age": 120
2322+
},
2323+
"409": {
2324+
"label": "Orca BOME/SOL",
2325+
"oracle_mapping": "DfUcPcAYUE5Vqi7wirnSkAVJdAKu4d6JC3o5roTVBz5N",
2326+
"oracle_type": "OrcaWhirlpoolBtoA",
2327+
"twap_enabled": true,
2328+
"max_age": 100
2329+
},
2330+
"410": {
2331+
"label": "TWAP Orca BOME/SOL",
2332+
"oracle_type": "ScopeTwap",
2333+
"twap_source": 409,
2334+
"max_age": 120
2335+
},
2336+
"411": {
2337+
"label": "Stake rate INF/SOL",
2338+
"oracle_mapping": "2EVUajXzWab9sAUA9AuHwkQmr2y6bGZvcztQEE7p7Q9Y",
2339+
"oracle_type": "SwitchboardV2",
2340+
"max_age": 58500
22702341
}
22712342
}

programs/scope/src/errors.rs

+3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ pub enum ScopeError {
9393

9494
#[msg("Cannot resize the account we only allow it to grow in size")]
9595
CannotResizeAccount,
96+
97+
#[msg("The provided fixed price is invalid")]
98+
FixedPriceInvalid,
9699
}
97100

98101
impl<T> From<TryFromPrimitiveError<T>> for ScopeError

programs/scope/src/handlers/handler_extend_mapping.rs

-62
This file was deleted.

programs/scope/src/handlers/handler_initialize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct Initialize<'info> {
2727

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

3333
pub fn process(ctx: Context<Initialize>, _: String) -> Result<()> {

programs/scope/src/handlers/handler_refresh_prices.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use solana_program::{
99
},
1010
};
1111

12-
use crate::utils::zero_copy_deserialize;
13-
use crate::OracleMappingsCore;
12+
use crate::utils::{price_impl::check_ref_price_difference, zero_copy_deserialize};
13+
use crate::OracleMappings;
1414
use crate::{
1515
oracles::{get_price, OracleType},
1616
ScopeError,
@@ -39,8 +39,7 @@ pub fn refresh_price_list<'info>(
3939
) -> Result<()> {
4040
check_execution_ctx(&ctx.accounts.instruction_sysvar_account_info)?;
4141

42-
let oracle_mappings =
43-
&zero_copy_deserialize::<OracleMappingsCore>(&ctx.accounts.oracle_mappings)?;
42+
let oracle_mappings = &zero_copy_deserialize::<OracleMappings>(&ctx.accounts.oracle_mappings)?;
4443
let mut oracle_twaps = ctx.accounts.oracle_twaps.load_mut()?;
4544

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

126125
let mut oracle_prices = ctx.accounts.oracle_prices.load_mut()?;
126+
127+
// check that the price is close enough to the ref price is there is a ref price
128+
if oracle_mappings.ref_price[token_idx] != u16::MAX {
129+
let ref_price =
130+
oracle_prices.prices[usize::from(oracle_mappings.ref_price[token_idx])].price;
131+
check_ref_price_difference(price.price, ref_price)?;
132+
}
127133
let to_update = oracle_prices
128134
.prices
129135
.get_mut(token_idx)

0 commit comments

Comments
 (0)