#[repr(C)]pub struct Referral {
pub authority: Pubkey,
pub total_referred: u64,
pub total_sol_earned: u64,
pub total_oil_earned: u64,
pub pending_sol: u64,
pub pending_oil: u64,
}Expand description
Referral account tracks a referrer’s stats and pending rewards.
Anyone can create a Referral account to become a referrer. When a new miner signs up with their referral link, 0.5% of that miner’s claimed rewards (both SOL and OIL) are credited to the referrer’s pending balance.
Fields§
The authority (wallet) of this referrer.
total_referred: u64Total number of miners referred by this referrer.
total_sol_earned: u64Total SOL earned from referrals (lifetime, for stats).
total_oil_earned: u64Total OIL earned from referrals (lifetime, for stats).
pending_sol: u64Pending SOL rewards to claim.
pending_oil: u64Pending OIL rewards to claim.
Implementations§
Source§impl Referral
impl Referral
Sourcepub fn claim_sol(&mut self) -> u64
pub fn claim_sol(&mut self) -> u64
Claims pending SOL rewards. Returns the amount of SOL that can be claimed and resets pending_sol to 0.
Sourcepub fn claim_oil(&mut self) -> u64
pub fn claim_oil(&mut self) -> u64
Claims pending OIL rewards. Returns the amount of OIL that can be claimed and resets pending_oil to 0.
Sourcepub fn credit_sol_referral(&mut self, total_amount: u64) -> u64
pub fn credit_sol_referral(&mut self, total_amount: u64) -> u64
Calculates and credits SOL referral bonus (1.0% of total amount). Returns the referral amount that should be transferred to this referral account.
This function handles:
- Calculating 1.0% referral bonus
- Crediting pending_sol
- Updating total_sol_earned
Sourcepub fn credit_oil_referral(&mut self, total_amount: u64) -> u64
pub fn credit_oil_referral(&mut self, total_amount: u64) -> u64
Calculates and credits OIL referral bonus (1.0% of total amount). Returns the referral amount that should be transferred to this referral account.
This function handles:
- Calculating 1.0% referral bonus
- Crediting pending_oil
- Updating total_oil_earned
Trait Implementations§
Source§impl AccountValidation for Referral
impl AccountValidation for Referral
fn assert<F>(&self, condition: F) -> Result<&Self, ProgramError>
fn assert_err<F>( &self, condition: F, err: ProgramError, ) -> Result<&Self, ProgramError>
fn assert_msg<F>(&self, condition: F, msg: &str) -> Result<&Self, ProgramError>
fn assert_mut<F>(&mut self, condition: F) -> Result<&mut Self, ProgramError>
fn assert_mut_err<F>( &mut self, condition: F, err: ProgramError, ) -> Result<&mut Self, ProgramError>
fn assert_mut_msg<F>( &mut self, condition: F, msg: &str, ) -> Result<&mut Self, ProgramError>
Source§impl<'de> Deserialize<'de> for Referral
impl<'de> Deserialize<'de> for Referral
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Discriminator for Referral
impl Discriminator for Referral
fn discriminator() -> u8
impl Copy for Referral
impl Pod for Referral
impl StructuralPartialEq for Referral
Auto Trait Implementations§
impl Freeze for Referral
impl RefUnwindSafe for Referral
impl Send for Referral
impl Sync for Referral
impl Unpin for Referral
impl UnwindSafe for Referral
Blanket Implementations§
Source§impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
fn try_from_bytes(data: &[u8]) -> Result<&T, ProgramError>
fn try_from_bytes_mut(data: &mut [u8]) -> Result<&mut T, ProgramError>
Source§impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
fn try_header_from_bytes(data: &[u8]) -> Result<(&T, &[u8]), ProgramError>
fn try_header_from_bytes_mut( data: &mut [u8], ) -> Result<(&mut T, &mut [u8]), ProgramError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more