Contract

Struct Contract 

Source
#[repr(C)]
pub struct Contract {
Show 30 fields pub magic: u64, pub version: u8, pub created_at: u64, pub amount_withdrawn: u64, pub canceled_at: u64, pub end_time: u64, pub last_withdrawn_at: u64, pub sender: Pubkey, pub sender_tokens: Pubkey, pub recipient: Pubkey, pub recipient_tokens: Pubkey, pub mint: Pubkey, pub escrow_tokens: Pubkey, pub streamflow_treasury: Pubkey, pub streamflow_treasury_tokens: Pubkey, pub streamflow_fee_total: u64, pub streamflow_fee_withdrawn: u64, pub streamflow_fee_percent: f32, pub partner: Pubkey, pub partner_tokens: Pubkey, pub partner_fee_total: u64, pub partner_fee_withdrawn: u64, pub partner_fee_percent: f32, pub ix: CreateParams, pub ix_padding: Vec<u8>, pub closed: bool, pub current_pause_start: u64, pub pause_cumulative: u64, pub last_rate_change_time: u64, pub funds_unlocked_at_last_rate_change: u64,
}
Expand description

Struct that represents Stream Contract stored on chain, this account DOES NOT have a discriminator.

May be read like so

let stream_metadata: Contract = match try_from_slice_unchecked(&stream_data) {
    Ok(v) => v,
    Err(_) => return err!(ErrorCode::InvalidStreamMetadata),
};

Fields§

§magic: u64

Magic bytes

§version: u8

Version of the program

§created_at: u64

Timestamp when stream was created

§amount_withdrawn: u64

Amount of funds withdrawn

§canceled_at: u64

Timestamp when stream was canceled (if canceled)

§end_time: u64

Timestamp at which stream can be safely canceled by a 3rd party (Stream is either fully vested or there isn’t enough capital to keep it active)

§last_withdrawn_at: u64

Timestamp of the last withdrawal

§sender: Pubkey

Pubkey of the stream initializer

§sender_tokens: Pubkey

Pubkey of the stream initializer’s token account

§recipient: Pubkey

Pubkey of the stream recipient

§recipient_tokens: Pubkey

Pubkey of the stream recipient’s token account

§mint: Pubkey

Pubkey of the token mint

§escrow_tokens: Pubkey

Escrow account holding the locked tokens for recipient

§streamflow_treasury: Pubkey

Streamflow treasury authority

§streamflow_treasury_tokens: Pubkey

Escrow account holding the locked tokens for Streamflow (fee account)

§streamflow_fee_total: u64

The total fee amount for streamflow

§streamflow_fee_withdrawn: u64

The withdrawn fee amount for streamflow

§streamflow_fee_percent: f32

Fee percentage for Streamflow

§partner: Pubkey

Streamflow partner authority

§partner_tokens: Pubkey

Escrow account holding the locked tokens for Streamflow partner (fee account)

§partner_fee_total: u64

The total fee amount for the partner

§partner_fee_withdrawn: u64

The withdrawn fee amount for the partner

§partner_fee_percent: f32

Fee percentage for partner

§ix: CreateParams

The stream instruction

§ix_padding: Vec<u8>

Padding for ix: CreateParams to allow for future upgrades.

§closed: bool

Stream is closed

§current_pause_start: u64

time of the current pause. 0 signifies unpaused state

§pause_cumulative: u64

total time the contract was paused for

§last_rate_change_time: u64

timestamp of last rate change for this stream. Rate can be changed with update instruction

§funds_unlocked_at_last_rate_change: u64

Accumulated unlocked tokens before last rate change (excluding cliff_amount)

Implementations§

Source§

impl Contract

Source

pub fn start_time(&self) -> u64

Source

pub fn effective_start_time(&self) -> u64

Source

pub fn pause_time(&self, now: u64) -> u64

Source

pub fn vested_available(&self, now: u64) -> u64

amount available that is vested (excluding cliff)

Source

pub fn available_to_claim(&self, now: u64, fee_percentage: f32) -> u64

Source

pub fn cliff_available(&self, now: u64) -> u64

Trait Implementations§

Source§

impl BorshDeserialize for Contract

Source§

fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for Contract

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for Contract

Source§

fn clone(&self) -> Contract

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Contract

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V