1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::{error::ErrorCode, state::MarketState, CloseMarket};
use anchor_lang::prelude::*;
impl<'info> CloseMarket<'info> {
pub fn process(&mut self) -> Result<()> {
let market = &mut self.market;
let clock = &self.clock;
if market.end_date.is_some() {
return Err(ErrorCode::MarketDurationIsNotUnlimited.into());
}
if market.start_date > clock.unix_timestamp as u64 {
return Err(ErrorCode::MarketIsNotStarted.into());
}
market.state = MarketState::Ended;
Ok(())
}
}