Skip to main content

gmsol_utils/
lib.rs

1#![cfg_attr(docsrs, feature(doc_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 users.
58pub mod user;
59
60/// Definitions related to instructions.
61#[cfg(feature = "instruction")]
62pub mod instruction;
63
64/// Utils for security-txt.
65#[cfg(feature = "security-txt")]
66pub mod security_txt;
67
68/// Convert a string to a seed.
69pub fn to_seed(key: &str) -> [u8; 32] {
70    use anchor_lang::solana_program::hash::hash;
71    hash(key.as_bytes()).to_bytes()
72}
73
74/// General-purpose errors.
75#[anchor_lang::error_code]
76pub enum GeneralError {
77    /// Already Exist.
78    #[msg("Already exist")]
79    AlreadyExist,
80    /// Exceed length limit.
81    #[msg("Exceed max length limit")]
82    ExceedMaxLengthLimit,
83}
84
85pub use self::{init_space::InitSpace, price::Price};
86pub use bitmaps;
87pub use paste;
88pub use static_assertions;
89
90#[cfg(feature = "security-txt")]
91pub use solana_security_txt;