gmsol_utils/
lib.rs

1#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2
3/// Utils for price representation.
4pub mod price;
5
6/// Fixed-size zero copy map.
7pub mod fixed_map;
8
9/// Definition for [`InitSpace`].
10pub mod init_space;
11
12/// Zero-copy flags.
13pub mod flags;
14
15/// Fixed str.
16pub mod fixed_str;
17
18/// Pubkey utils.
19pub mod pubkey;
20
21/// Oracle utils.
22pub mod oracle;
23
24/// Definitions related to market.
25pub mod market;
26
27/// Definitions related to token config.
28pub mod token_config;
29
30/// Utils for dynamic access to an array of zero copy types.
31pub mod dynamic_access;
32
33/// Definitions related to action.
34pub mod action;
35
36/// A `slice::chunk_by` implementation, copied from `std`.
37pub mod chunk_by;
38
39/// Swap parameters.
40pub mod swap;
41
42/// Definitions related to order.
43pub mod order;
44
45/// Definitions related to GLV.
46pub mod glv;
47
48/// Definitions related to global configurations.
49pub mod config;
50
51/// Utils for GT.
52pub mod gt;
53
54/// Definitions related to roles.
55pub mod role;
56
57/// Definitions related to instructions.
58#[cfg(feature = "instruction")]
59pub mod instruction;
60
61/// Convert a string to a seed.
62pub fn to_seed(key: &str) -> [u8; 32] {
63    use anchor_lang::solana_program::hash::hash;
64    hash(key.as_bytes()).to_bytes()
65}
66
67pub use self::{init_space::InitSpace, price::Price};
68pub use bitmaps;
69pub use paste;
70pub use static_assertions;
71
72/// General-purpose errors.
73#[anchor_lang::error_code]
74pub enum GeneralError {
75    /// Already Exist.
76    #[msg("Already exist")]
77    AlreadyExist,
78    /// Exceed length limit.
79    #[msg("Exceed max length limit")]
80    ExceedMaxLengthLimit,
81}