Skip to main content

LiquidStakingPool

Struct LiquidStakingPool 

Source
pub struct LiquidStakingPool { /* private fields */ }
Expand description

Liquid staking pool manager

Manages the stTNZO liquid staking derivative for Tenzro Network.

Implementations§

Source§

impl LiquidStakingPool

Source

pub fn new(config: LiquidStakingConfig) -> Result<Self>

Create a new liquid staking pool

Source

pub fn with_storage( config: LiquidStakingConfig, storage: Arc<dyn KvStore>, ) -> Result<Self>

Create a liquid staking pool with persistent backing in CF_TOKENS. Hydrates config, aggregate totals, per-holder balances, validator delegations, and pending withdrawal requests on construction.

Source

pub fn update_config(&self, new_config: LiquidStakingConfig) -> Result<()>

Update the config (governance-driven). Validates and persists.

Source

pub fn exchange_rate(&self) -> u128

Get the current exchange rate: TNZO per stTNZO.

exchange_rate = total_underlying_wei / total_sttnzo_supply

Returns the rate as a fixed-point number with 18 decimals. A rate of 1_000_000_000_000_000_000 (10^18) means 1:1.

Source

pub fn deposit(&self, depositor: Address, tnzo_amount: u128) -> Result<u128>

Deposit TNZO and receive stTNZO.

The amount of stTNZO minted is calculated from the current exchange rate: sttnzo_amount = tnzo_amount * 10^18 / exchange_rate

Source

pub fn request_withdrawal( &self, requester: Address, sttnzo_amount: u128, ) -> Result<WithdrawalRequest>

Request withdrawal: burn stTNZO and start unbonding.

The TNZO amount is calculated from the current exchange rate at request time. User must wait the unbonding period before claiming.

Source

pub fn claim_withdrawal(&self, request_id: &str) -> Result<(Address, u128)>

Claim a completed withdrawal after the unbonding period.

Returns the TNZO amount to transfer to the user.

Source

pub fn distribute_rewards( &self, reward_amount: u128, ) -> Result<RewardDistribution>

Distribute staking rewards to the pool.

This is called by the reward distributor when staking rewards are earned. The rewards increase the exchange rate (underlying TNZO goes up, stTNZO supply stays the same).

Source

pub fn balance_of(&self, address: &Address) -> u128

Get stTNZO balance for an address

Source

pub fn tnzo_value(&self, sttnzo_amount: u128) -> u128

Get the TNZO value of a stTNZO amount at the current exchange rate

Source

pub fn stats(&self) -> LiquidStakingStats

Get pool statistics

Source

pub fn add_validator(&self, validator: Address, amount: u128)

Add a validator delegation

Source

pub fn validator_delegations(&self) -> Vec<(Address, u128)>

Get all validator delegations

Source

pub fn transfer(&self, from: &Address, to: &Address, amount: u128) -> Result<()>

Transfer stTNZO between addresses

Source

pub fn pending_withdrawals_for( &self, holder: &Address, ) -> Vec<WithdrawalRequest>

List all pending (unclaimed) withdrawal requests for a holder.

Source

pub fn get_withdrawal(&self, request_id: &str) -> Option<WithdrawalRequest>

Look up a single withdrawal request by ID.

Source

pub fn config(&self) -> LiquidStakingConfig

Read a snapshot of the current liquid staking config.

Trait Implementations§

Source§

impl Debug for LiquidStakingPool

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for LiquidStakingPool

Source§

fn default() -> Self

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more