lightcone 0.5.2

Rust SDK for the Lightcone Protocol — unified native + WASM client
Documentation
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
//! Account structures and deserialization for Lightcone Pinocchio.
//!
//! This module contains all on-chain account structures with their exact
//! byte layouts matching the program.

use solana_pubkey::Pubkey;

use crate::program::constants::{
    EXCHANGE_DISCRIMINATOR, EXCHANGE_SIZE, GLOBAL_DEPOSIT_TOKEN_DISCRIMINATOR,
    GLOBAL_DEPOSIT_TOKEN_SIZE, MARKET_DISCRIMINATOR, MARKET_SIZE, ORDERBOOK_DISCRIMINATOR,
    ORDERBOOK_SIZE, ORDER_STATUS_DISCRIMINATOR, ORDER_STATUS_SIZE, POSITION_DISCRIMINATOR,
    POSITION_SIZE, USER_NONCE_DISCRIMINATOR, USER_NONCE_SIZE,
};
use crate::program::error::{SdkError, SdkResult};
use crate::program::types::MarketStatus;

/// Helper to extract a fixed-size array from a slice
#[inline]
fn read_bytes<const N: usize>(data: &[u8], offset: usize) -> [u8; N] {
    let mut arr = [0u8; N];
    arr.copy_from_slice(&data[offset..offset + N]);
    arr
}

/// Helper to read a Pubkey from data
#[inline]
fn read_pubkey(data: &[u8], offset: usize) -> Pubkey {
    Pubkey::new_from_array(read_bytes::<32>(data, offset))
}

/// Helper to read a u64 from data (little-endian)
#[inline]
fn read_u64(data: &[u8], offset: usize) -> u64 {
    u64::from_le_bytes(read_bytes::<8>(data, offset))
}

// ============================================================================
// Exchange Account (88 bytes)
// ============================================================================

/// Exchange account - singleton state for the exchange
///
/// Layout:
/// - [0..8]   discriminator (8 bytes)
/// - [8..40]  authority (32 bytes)
/// - [40..72] operator (32 bytes)
/// - [72..80] market_count (8 bytes)
/// - [80]     paused (1 byte)
/// - [81]     bump (1 byte)
/// - [82..84] deposit_token_count (2 bytes)
/// - [84..88] _padding (4 bytes)
#[derive(Debug, Clone)]
pub struct Exchange {
    /// Account discriminator
    pub discriminator: [u8; 8],
    /// Exchange authority (can pause, set operator, create markets)
    pub authority: Pubkey,
    /// Operator (can match orders)
    pub operator: Pubkey,
    /// Number of markets created
    pub market_count: u64,
    /// Whether the exchange is paused
    pub paused: bool,
    /// PDA bump seed
    pub bump: u8,
    /// Number of whitelisted deposit tokens
    pub deposit_token_count: u16,
}

impl Exchange {
    /// Account size in bytes
    pub const LEN: usize = EXCHANGE_SIZE;

    /// Deserialize from account data
    pub fn deserialize(data: &[u8]) -> SdkResult<Self> {
        if data.len() < Self::LEN {
            return Err(SdkError::InvalidDataLength {
                expected: Self::LEN,
                actual: data.len(),
            });
        }

        let discriminator = read_bytes::<8>(data, 0);
        if discriminator != EXCHANGE_DISCRIMINATOR {
            return Err(SdkError::InvalidDiscriminator {
                expected: hex::encode(EXCHANGE_DISCRIMINATOR),
                actual: hex::encode(discriminator),
            });
        }

        Ok(Self {
            discriminator,
            authority: read_pubkey(data, 8),
            operator: read_pubkey(data, 40),
            market_count: read_u64(data, 72),
            paused: data[80] != 0,
            bump: data[81],
            deposit_token_count: u16::from_le_bytes(read_bytes::<2>(data, 82)),
        })
    }

    /// Check if account data has the exchange discriminator
    pub fn is_exchange_account(data: &[u8]) -> bool {
        data.len() >= 8 && data[0..8] == EXCHANGE_DISCRIMINATOR
    }
}

// ============================================================================
// Market Account (120 bytes)
// ============================================================================

/// Market account - represents a market
///
/// Layout:
/// - [0..8]     discriminator (8 bytes)
/// - [8..16]   market_id (8 bytes)
/// - [16]       num_outcomes (1 byte)
/// - [17]       status (1 byte)
/// - [18]       winning_outcome (1 byte)
/// - [19]       has_winning_outcome (1 byte)
/// - [20]       bump (1 byte)
/// - [21..24]   _padding (3 bytes)
/// - [24..56]   oracle (32 bytes)
/// - [56..88]   question_id (32 bytes)
/// - [88..120]  condition_id (32 bytes)
#[derive(Debug, Clone)]
pub struct Market {
    /// Account discriminator
    pub discriminator: [u8; 8],
    /// Unique market ID
    pub market_id: u64,
    /// Number of possible outcomes (2-6)
    pub num_outcomes: u8,
    /// Current market status
    pub status: MarketStatus,
    /// Winning outcome index (255 if not resolved)
    pub winning_outcome: u8,
    /// Whether a winning outcome has been set
    pub has_winning_outcome: bool,
    /// PDA bump seed
    pub bump: u8,
    /// Oracle pubkey that can settle this market
    pub oracle: Pubkey,
    /// Question ID (32 bytes)
    pub question_id: [u8; 32],
    /// Condition ID derived from oracle + question_id + num_outcomes
    pub condition_id: [u8; 32],
}

impl Market {
    /// Account size in bytes
    pub const LEN: usize = MARKET_SIZE;

    /// Deserialize from account data
    pub fn deserialize(data: &[u8]) -> SdkResult<Self> {
        if data.len() < Self::LEN {
            return Err(SdkError::InvalidDataLength {
                expected: Self::LEN,
                actual: data.len(),
            });
        }

        let discriminator = read_bytes::<8>(data, 0);
        if discriminator != MARKET_DISCRIMINATOR {
            return Err(SdkError::InvalidDiscriminator {
                expected: hex::encode(MARKET_DISCRIMINATOR),
                actual: hex::encode(discriminator),
            });
        }

        Ok(Self {
            discriminator,
            market_id: read_u64(data, 8),
            num_outcomes: data[16],
            status: MarketStatus::try_from(data[17])?,
            winning_outcome: data[18],
            has_winning_outcome: data[19] != 0,
            bump: data[20],
            oracle: read_pubkey(data, 24),
            question_id: read_bytes::<32>(data, 56),
            condition_id: read_bytes::<32>(data, 88),
        })
    }

    /// Check if account data has the market discriminator
    pub fn is_market_account(data: &[u8]) -> bool {
        data.len() >= 8 && data[0..8] == MARKET_DISCRIMINATOR
    }
}

// ============================================================================
// Position Account (80 bytes)
// ============================================================================

/// Position account - user's custody account for a market
///
/// Layout:
/// - [0..8]   discriminator (8 bytes)
/// - [8..40]  owner (32 bytes)
/// - [40..72] market (32 bytes)
/// - [72]     bump (1 byte)
/// - [73..80] _padding (7 bytes)
#[derive(Debug, Clone)]
pub struct Position {
    /// Account discriminator
    pub discriminator: [u8; 8],
    /// Owner of this position
    pub owner: Pubkey,
    /// Market this position is for
    pub market: Pubkey,
    /// PDA bump seed
    pub bump: u8,
}

impl Position {
    /// Account size in bytes
    pub const LEN: usize = POSITION_SIZE;

    /// Deserialize from account data
    pub fn deserialize(data: &[u8]) -> SdkResult<Self> {
        if data.len() < Self::LEN {
            return Err(SdkError::InvalidDataLength {
                expected: Self::LEN,
                actual: data.len(),
            });
        }

        let discriminator = read_bytes::<8>(data, 0);
        if discriminator != POSITION_DISCRIMINATOR {
            return Err(SdkError::InvalidDiscriminator {
                expected: hex::encode(POSITION_DISCRIMINATOR),
                actual: hex::encode(discriminator),
            });
        }

        Ok(Self {
            discriminator,
            owner: read_pubkey(data, 8),
            market: read_pubkey(data, 40),
            bump: data[72],
        })
    }

    /// Check if account data has the position discriminator
    pub fn is_position_account(data: &[u8]) -> bool {
        data.len() >= 8 && data[0..8] == POSITION_DISCRIMINATOR
    }
}

// ============================================================================
// OrderStatus Account (24 bytes)
// ============================================================================

/// Order status account - tracks partial fills and cancellations
///
/// Layout:
/// - [0..8]   discriminator (8 bytes)
/// - [8..16]  remaining (8 bytes)
/// - [16]     is_cancelled (1 byte)
/// - [17..24] _padding (7 bytes)
#[derive(Debug, Clone)]
pub struct OrderStatus {
    /// Account discriminator
    pub discriminator: [u8; 8],
    /// Remaining amount_in to be filled
    pub remaining: u64,
    /// Whether the order has been cancelled
    pub is_cancelled: bool,
}

impl OrderStatus {
    /// Account size in bytes
    pub const LEN: usize = ORDER_STATUS_SIZE;

    /// Deserialize from account data
    pub fn deserialize(data: &[u8]) -> SdkResult<Self> {
        if data.len() < Self::LEN {
            return Err(SdkError::InvalidDataLength {
                expected: Self::LEN,
                actual: data.len(),
            });
        }

        let discriminator = read_bytes::<8>(data, 0);
        if discriminator != ORDER_STATUS_DISCRIMINATOR {
            return Err(SdkError::InvalidDiscriminator {
                expected: hex::encode(ORDER_STATUS_DISCRIMINATOR),
                actual: hex::encode(discriminator),
            });
        }

        Ok(Self {
            discriminator,
            remaining: read_u64(data, 8),
            is_cancelled: data[16] != 0,
        })
    }

    /// Check if account data has the order status discriminator
    pub fn is_order_status_account(data: &[u8]) -> bool {
        data.len() >= 8 && data[0..8] == ORDER_STATUS_DISCRIMINATOR
    }
}

// ============================================================================
// UserNonce Account (16 bytes)
// ============================================================================

/// User nonce account - tracks user's current nonce for mass cancellation
///
/// Layout:
/// - [0..8]  discriminator (8 bytes)
/// - [8..16] nonce (8 bytes)
#[derive(Debug, Clone)]
pub struct UserNonce {
    /// Account discriminator
    pub discriminator: [u8; 8],
    /// Current nonce value
    pub nonce: u64,
}

impl UserNonce {
    /// Account size in bytes
    pub const LEN: usize = USER_NONCE_SIZE;

    /// Deserialize from account data
    pub fn deserialize(data: &[u8]) -> SdkResult<Self> {
        if data.len() < Self::LEN {
            return Err(SdkError::InvalidDataLength {
                expected: Self::LEN,
                actual: data.len(),
            });
        }

        let discriminator = read_bytes::<8>(data, 0);
        if discriminator != USER_NONCE_DISCRIMINATOR {
            return Err(SdkError::InvalidDiscriminator {
                expected: hex::encode(USER_NONCE_DISCRIMINATOR),
                actual: hex::encode(discriminator),
            });
        }

        Ok(Self {
            discriminator,
            nonce: read_u64(data, 8),
        })
    }

    /// Check if account data has the user nonce discriminator
    pub fn is_user_nonce_account(data: &[u8]) -> bool {
        data.len() >= 8 && data[0..8] == USER_NONCE_DISCRIMINATOR
    }
}

// ============================================================================
// Orderbook Account (144 bytes)
// ============================================================================

/// Orderbook account - on-chain orderbook with lookup table
///
/// Layout:
/// - [0..8]     discriminator (8 bytes)
/// - [8..40]    market (32 bytes)
/// - [40..72]   mint_a (32 bytes)
/// - [72..104]  mint_b (32 bytes)
/// - [104..136] lookup_table (32 bytes)
/// - [136]      base_index (1 byte)
/// - [137]      bump (1 byte)
/// - [138..144] _padding (6 bytes)
#[derive(Debug, Clone)]
pub struct Orderbook {
    /// Account discriminator
    pub discriminator: [u8; 8],
    /// Market this orderbook is for
    pub market: Pubkey,
    /// Mint A
    pub mint_a: Pubkey,
    /// Mint B
    pub mint_b: Pubkey,
    /// Address lookup table
    pub lookup_table: Pubkey,
    /// Which mint is the base asset (0 = mint_a, 1 = mint_b)
    pub base_index: u8,
    /// PDA bump seed
    pub bump: u8,
}

impl Orderbook {
    /// Account size in bytes
    pub const LEN: usize = ORDERBOOK_SIZE;

    /// Deserialize from account data
    pub fn deserialize(data: &[u8]) -> SdkResult<Self> {
        if data.len() < Self::LEN {
            return Err(SdkError::InvalidDataLength {
                expected: Self::LEN,
                actual: data.len(),
            });
        }

        let discriminator = read_bytes::<8>(data, 0);
        if discriminator != ORDERBOOK_DISCRIMINATOR {
            return Err(SdkError::InvalidDiscriminator {
                expected: hex::encode(ORDERBOOK_DISCRIMINATOR),
                actual: hex::encode(discriminator),
            });
        }

        Ok(Self {
            discriminator,
            market: read_pubkey(data, 8),
            mint_a: read_pubkey(data, 40),
            mint_b: read_pubkey(data, 72),
            lookup_table: read_pubkey(data, 104),
            base_index: data[136],
            bump: data[137],
        })
    }

    /// Check if account data has the orderbook discriminator
    pub fn is_orderbook_account(data: &[u8]) -> bool {
        data.len() >= 8 && data[0..8] == ORDERBOOK_DISCRIMINATOR
    }
}

// ============================================================================
// GlobalDepositToken Account (48 bytes)
// ============================================================================

/// GlobalDepositToken account - whitelist entry for global deposits
///
/// Layout:
/// - [0..8]   discriminator (8 bytes)
/// - [8..40]  mint (32 bytes)
/// - [40]     active (1 byte)
/// - [41]     bump (1 byte)
/// - [42..44] index (2 bytes)
/// - [44..48] _padding (4 bytes)
#[derive(Debug, Clone)]
pub struct GlobalDepositToken {
    /// Account discriminator
    pub discriminator: [u8; 8],
    /// The whitelisted token mint
    pub mint: Pubkey,
    /// Whether this deposit token is currently active
    pub active: bool,
    /// PDA bump seed
    pub bump: u8,
    /// Sequential index assigned at whitelist time
    pub index: u16,
}

impl GlobalDepositToken {
    /// Account size in bytes
    pub const LEN: usize = GLOBAL_DEPOSIT_TOKEN_SIZE;

    /// Deserialize from account data
    pub fn deserialize(data: &[u8]) -> SdkResult<Self> {
        if data.len() < Self::LEN {
            return Err(SdkError::InvalidDataLength {
                expected: Self::LEN,
                actual: data.len(),
            });
        }

        let discriminator = read_bytes::<8>(data, 0);
        if discriminator != GLOBAL_DEPOSIT_TOKEN_DISCRIMINATOR {
            return Err(SdkError::InvalidDiscriminator {
                expected: hex::encode(GLOBAL_DEPOSIT_TOKEN_DISCRIMINATOR),
                actual: hex::encode(discriminator),
            });
        }

        Ok(Self {
            discriminator,
            mint: read_pubkey(data, 8),
            active: data[40] != 0,
            bump: data[41],
            index: u16::from_le_bytes(read_bytes::<2>(data, 42)),
        })
    }

    /// Check if account data has the global deposit token discriminator
    pub fn is_global_deposit_token_account(data: &[u8]) -> bool {
        data.len() >= 8 && data[0..8] == GLOBAL_DEPOSIT_TOKEN_DISCRIMINATOR
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_exchange_deserialization() {
        let mut data = vec![0u8; EXCHANGE_SIZE];
        data[0..8].copy_from_slice(&EXCHANGE_DISCRIMINATOR);
        // authority at offset 8
        data[8..40].copy_from_slice(&[1u8; 32]);
        // operator at offset 40
        data[40..72].copy_from_slice(&[2u8; 32]);
        // market_count at offset 72
        data[72..80].copy_from_slice(&5u64.to_le_bytes());
        // paused at offset 80
        data[80] = 0;
        // bump at offset 81
        data[81] = 255;

        let exchange = Exchange::deserialize(&data).unwrap();
        assert_eq!(exchange.market_count, 5);
        assert!(!exchange.paused);
        assert_eq!(exchange.bump, 255);
        assert_eq!(exchange.deposit_token_count, 0);
    }

    #[test]
    fn test_market_deserialization() {
        let mut data = vec![0u8; MARKET_SIZE];
        data[0..8].copy_from_slice(&MARKET_DISCRIMINATOR);
        // market_id at offset 8
        data[8..16].copy_from_slice(&42u64.to_le_bytes());
        // num_outcomes at offset 16
        data[16] = 3;
        // status at offset 17
        data[17] = 1; // Active
                      // winning_outcome at offset 18
        data[18] = 255;
        // has_winning_outcome at offset 19
        data[19] = 0;
        // bump at offset 20
        data[20] = 254;

        let market = Market::deserialize(&data).unwrap();
        assert_eq!(market.market_id, 42);
        assert_eq!(market.num_outcomes, 3);
        assert_eq!(market.status, MarketStatus::Active);
        assert_eq!(market.winning_outcome, 255);
        assert!(!market.has_winning_outcome);
    }

    #[test]
    fn test_position_deserialization() {
        let mut data = vec![0u8; POSITION_SIZE];
        data[0..8].copy_from_slice(&POSITION_DISCRIMINATOR);
        // owner at offset 8
        data[8..40].copy_from_slice(&[1u8; 32]);
        // market at offset 40
        data[40..72].copy_from_slice(&[2u8; 32]);
        // bump at offset 72
        data[72] = 253;

        let position = Position::deserialize(&data).unwrap();
        assert_eq!(position.bump, 253);
    }

    #[test]
    fn test_order_status_deserialization() {
        let mut data = vec![0u8; ORDER_STATUS_SIZE];
        data[0..8].copy_from_slice(&ORDER_STATUS_DISCRIMINATOR);
        // remaining at offset 8
        data[8..16].copy_from_slice(&1000u64.to_le_bytes());
        // is_cancelled at offset 16
        data[16] = 0;

        let order_status = OrderStatus::deserialize(&data).unwrap();
        assert_eq!(order_status.remaining, 1000);
        assert!(!order_status.is_cancelled);
    }

    #[test]
    fn test_user_nonce_deserialization() {
        let mut data = vec![0u8; USER_NONCE_SIZE];
        data[0..8].copy_from_slice(&USER_NONCE_DISCRIMINATOR);
        // nonce at offset 8
        data[8..16].copy_from_slice(&99u64.to_le_bytes());

        let user_nonce = UserNonce::deserialize(&data).unwrap();
        assert_eq!(user_nonce.nonce, 99);
    }

    #[test]
    fn test_orderbook_deserialization() {
        let mut data = vec![0u8; ORDERBOOK_SIZE];
        data[0..8].copy_from_slice(&ORDERBOOK_DISCRIMINATOR);
        // market at offset 8
        data[8..40].copy_from_slice(&[1u8; 32]);
        // mint_a at offset 40
        data[40..72].copy_from_slice(&[2u8; 32]);
        // mint_b at offset 72
        data[72..104].copy_from_slice(&[3u8; 32]);
        // lookup_table at offset 104
        data[104..136].copy_from_slice(&[4u8; 32]);
        // base_index at offset 136
        data[136] = 1;
        // bump at offset 137
        data[137] = 252;

        let orderbook = Orderbook::deserialize(&data).unwrap();
        assert_eq!(orderbook.market, Pubkey::new_from_array([1u8; 32]));
        assert_eq!(orderbook.mint_a, Pubkey::new_from_array([2u8; 32]));
        assert_eq!(orderbook.mint_b, Pubkey::new_from_array([3u8; 32]));
        assert_eq!(orderbook.lookup_table, Pubkey::new_from_array([4u8; 32]));
        assert_eq!(orderbook.base_index, 1);
        assert_eq!(orderbook.bump, 252);
    }

    #[test]
    fn test_orderbook_is_orderbook_account() {
        let mut data = vec![0u8; ORDERBOOK_SIZE];
        data[0..8].copy_from_slice(&ORDERBOOK_DISCRIMINATOR);
        assert!(Orderbook::is_orderbook_account(&data));

        let bad_data = vec![0u8; ORDERBOOK_SIZE];
        assert!(!Orderbook::is_orderbook_account(&bad_data));
    }

    #[test]
    fn test_global_deposit_token_deserialization() {
        let mut data = vec![0u8; GLOBAL_DEPOSIT_TOKEN_SIZE];
        data[0..8].copy_from_slice(&GLOBAL_DEPOSIT_TOKEN_DISCRIMINATOR);
        data[8..40].copy_from_slice(&[5u8; 32]);
        data[40] = 1;
        data[41] = 251;

        let gdt = GlobalDepositToken::deserialize(&data).unwrap();
        assert_eq!(gdt.mint, Pubkey::new_from_array([5u8; 32]));
        assert!(gdt.active);
        assert_eq!(gdt.bump, 251);
        assert_eq!(gdt.index, 0);
    }

    #[test]
    fn test_global_deposit_token_inactive() {
        let mut data = vec![0u8; GLOBAL_DEPOSIT_TOKEN_SIZE];
        data[0..8].copy_from_slice(&GLOBAL_DEPOSIT_TOKEN_DISCRIMINATOR);
        data[40] = 0;

        let gdt = GlobalDepositToken::deserialize(&data).unwrap();
        assert!(!gdt.active);
    }

    #[test]
    fn test_global_deposit_token_is_account() {
        let mut data = vec![0u8; GLOBAL_DEPOSIT_TOKEN_SIZE];
        data[0..8].copy_from_slice(&GLOBAL_DEPOSIT_TOKEN_DISCRIMINATOR);
        assert!(GlobalDepositToken::is_global_deposit_token_account(&data));

        let bad_data = vec![0u8; GLOBAL_DEPOSIT_TOKEN_SIZE];
        assert!(!GlobalDepositToken::is_global_deposit_token_account(
            &bad_data
        ));
    }
}