Skip to content

Commit 445bcdf

Browse files
committed
doc: compressible config
1 parent 5a398a6 commit 445bcdf

3 files changed

Lines changed: 43 additions & 4 deletions

File tree

sdk-libs/ctoken-sdk/src/ctoken/close.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl CloseCTokenAccount {
7373
/// # let account: AccountInfo = todo!();
7474
/// # let destination: AccountInfo = todo!();
7575
/// # let owner: AccountInfo = todo!();
76+
/// // Use ctoken::RENT_SPONSOR or ctoken::rent_sponsor_pda() to get the protocol rent sponsor.
7677
/// # let rent_sponsor: AccountInfo = todo!();
7778
/// CloseCTokenAccountCpi {
7879
/// token_program,

sdk-libs/ctoken-sdk/src/ctoken/compressible.rs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,30 @@ use solana_pubkey::Pubkey;
66

77
use crate::ctoken::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR};
88

9+
/// Parameters for creating compressible ctoken accounts.
10+
///
11+
/// Compressible accounts have sponsored rent and can be compressed to compressed
12+
/// token accounts when their lamports balance is insufficient.
13+
///
14+
/// Default values are:
15+
/// - 24 hours rent
16+
/// - lamports for 3 hours rent (paid on transfer when account rent is insufficient to cover the next 2 epochs)
17+
/// - Protocol rent sponsor
18+
/// - TokenDataVersion::ShaFlat token data hashing (only sha is supported for compressible accounts)
19+
///
20+
/// # Example
21+
/// ```rust
22+
/// use light_ctoken_sdk::ctoken::CompressibleParams;
23+
///
24+
/// let params = CompressibleParams::new();
25+
/// ```
926
#[derive(Debug, Clone)]
1027
pub struct CompressibleParams {
1128
pub token_account_version: TokenDataVersion,
1229
pub pre_pay_num_epochs: u8,
30+
/// Number of lamports transferred on a write operation (eg transfer) when account rent is insufficient to cover the next 2 rent-epochs.
31+
/// Default: 766 lamports for 3 hours rent.
32+
/// These lamports keep the ctoken account perpetually funded when used.
1333
pub lamports_per_write: Option<u32>,
1434
pub compress_to_account_pubkey: Option<CompressToPubkey>,
1535
pub compressible_config: Pubkey,
@@ -31,9 +51,10 @@ impl Default for CompressibleParams {
3151

3252
impl CompressibleParams {
3353
/// Creates a new `CompressibleParams` with default values.
34-
///
35-
/// Use builder methods to customize:
36-
/// - [`compress_to_pubkey`](Self::compress_to_pubkey) - set the destination for compression
54+
/// - 24 hours rent
55+
/// - 3 hours top up (paid on transfer when account rent is insufficient to cover the next 2 epochs)
56+
/// - Protocol rent sponsor
57+
/// - TokenDataVersion::ShaFlat token data hashing (only sha is supported for compressible accounts)
3758
pub fn new() -> Self {
3859
Self::default()
3960
}
@@ -45,7 +66,23 @@ impl CompressibleParams {
4566
}
4667
}
4768

48-
/// Account infos for compressible token accounts in CPI operations.
69+
/// Parameters for creating compressible ctoken accounts via CPI.
70+
///
71+
/// # Example
72+
/// ```rust,no_run
73+
/// # use light_ctoken_sdk::ctoken::CompressibleParamsCpi;
74+
/// # use solana_account_info::AccountInfo;
75+
/// // Use ctoken::COMPRESSIBLE_CONFIG_V1 or ctoken::config_pda() to get the protocol config.
76+
/// // Use ctoken::RENT_SPONSOR or ctoken::rent_sponsor_pda() to get the protocol rent sponsor.
77+
/// # let compressible_config: AccountInfo = todo!();
78+
/// # let rent_sponsor: AccountInfo = todo!();
79+
/// # let system_program: AccountInfo = todo!();
80+
/// let params = CompressibleParamsCpi::new(
81+
/// compressible_config,
82+
/// rent_sponsor,
83+
/// system_program,
84+
/// );
85+
/// ```
4986
pub struct CompressibleParamsCpi<'info> {
5087
pub compressible_config: AccountInfo<'info>,
5188
pub rent_sponsor: AccountInfo<'info>,

sdk-libs/ctoken-sdk/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//! - rent is 388 lamports per rent epoch (1.5 hours).
1313
//! - once the account's lamports balance is insufficient, it is compressed to a compressed token account.
1414
//! - compressed tokens can be decompressed to a cToken account.
15+
//! - configurable lamports per write (eg transfer) keep the cToken account perpetually funded when used. So you don't have to worry about funding rent.
1516
//!
1617
//! ## Compressed Token Accounts
1718
//! - are on Solana mainnet.

0 commit comments

Comments
 (0)