1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use anchor_lang::prelude::*;
use anchor_lang::solana_program::program_pack::Pack;
use std::ops::Deref;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SwapInfo(stable_swap_client::state::SwapInfo);
impl SwapInfo {
pub const LEN: usize = stable_swap_client::state::SwapInfo::LEN;
pub fn minimum_rent_exempt_balance() -> Result<u64> {
Ok(Rent::get()?.minimum_balance(Self::LEN))
}
}
impl Owner for SwapInfo {
fn owner() -> Pubkey {
crate::ID
}
}
impl Deref for SwapInfo {
type Target = stable_swap_client::state::SwapInfo;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl anchor_lang::AccountSerialize for SwapInfo {
fn try_serialize<W: std::io::Write>(&self, _writer: &mut W) -> Result<()> {
Ok(())
}
}
impl anchor_lang::AccountDeserialize for SwapInfo {
fn try_deserialize(buf: &mut &[u8]) -> Result<Self> {
SwapInfo::try_deserialize_unchecked(buf)
}
fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self> {
Ok(stable_swap_client::state::SwapInfo::unpack(buf).map(SwapInfo)?)
}
}