Skip to content

Commit 715a55b

Browse files
committed
Fix ema deserialize
1 parent ac2718d commit 715a55b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

program/rust/src/log.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,26 @@ pub fn pre_log(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResu
8888

8989
pub fn post_log(c_ret_val: u64, accounts: &[AccountInfo]) -> ProgramResult {
9090
if c_ret_val == SUCCESSFULLY_UPDATED_AGGREGATE {
91-
let start: usize = PRICE_T_AGGREGATE_OFFSET
91+
let aggregate_price_start: usize = PRICE_T_AGGREGATE_OFFSET
9292
.try_into()
9393
.map_err(|_| OracleError::Generic)?;
9494
// We trust that the C oracle has properly checked this account
9595
let aggregate_price_info: pc_price_info = pc_price_info::try_from_slice(
9696
&accounts
9797
.get(1)
9898
.ok_or(OracleError::Generic)?
99-
.try_borrow_data()?[start..(start + size_of::<pc_price_info>())],
99+
.try_borrow_data()?[aggregate_price_start..(aggregate_price_start + size_of::<pc_price_info>())],
100100
)?;
101101

102+
let ema_start: usize = PRICE_T_EMA_OFFSET
103+
.try_into()
104+
.map_err(|_| OracleError::Generic)?;
105+
102106
let ema_info: pc_ema = pc_ema::try_from_slice(
103107
&accounts
104108
.get(1)
105109
.ok_or(OracleError::Generic)?
106-
.try_borrow_data()?[start..(start + size_of::<pc_ema>())],
110+
.try_borrow_data()?[ema_start..(ema_start + size_of::<pc_ema>())],
107111
)?;
108112

109113
let clock = Clock::get()?;

0 commit comments

Comments
 (0)