DogukanGun / SolanaBond

1 stars 0 forks source link

use u64 inside investor data account #6

Closed AlphaGergedan closed 1 week ago

AlphaGergedan commented 1 week ago

We use f32 for the values stored in the investor data account:

#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct Investor {
    pub identifier: Pubkey,             // Investor address
    pub amount: f32,                    // Total amount invested
    pub net_profit: f32,                // Total net profit, cannot be negative
}

Shouldn't we use u64 for these to represent the num. of lamports in solana? @DogukanGun

DogukanGun commented 1 week ago

We should store as u64. Decimals will represent the real value but as I remember we represent the amount of a token without decimal.

You can check this

@AlphaGergedan

AlphaGergedan commented 1 week ago

So 1e9 lamports equals 1 SOL?. One lamport is the smallest unit in solana right, so we can store lamports (the smallest unit in solana)?.

DogukanGun commented 1 week ago

Yes but we are gonna work with spl tokens so u32 or u64 are better. If we worked with native token than then lamport is logical. @AlphaGergedan