WritableNativeBalance

Trait WritableNativeBalance 

pub trait WritableNativeBalance: ReadableNativeBalance {
    // Required method
    fn set_balance(&mut self, balance: u64);

    // Provided methods
    fn checked_add_balance(&mut self, balance: u64) -> Result<(), VaultError> { ... }
    fn checked_sub_balance(&mut self, balance: u64) -> Result<(), VaultError> { ... }
    fn saturating_add_balance(&mut self, balance: u64) { ... }
    fn saturating_sub_balance(&mut self, balance: u64) { ... }
}
Expand description

Trait for modifying native balance.

Required Methods§

fn set_balance(&mut self, balance: u64)

Sets the native token balance of the vault.

§Parameters
  • balance - new balance in plancks

Provided Methods§

fn checked_add_balance(&mut self, balance: u64) -> Result<(), VaultError>

Adds to the native token balance with overflow checking.

§Parameters
  • balance - amount to add to the balance
§Errors

Returns VaultError::ArithmeticOverflow if the addition would overflow.

fn checked_sub_balance(&mut self, balance: u64) -> Result<(), VaultError>

Subtracts from the native token balance with underflow checking.

§Parameters
  • balance - amount to subtract from the balance
§Errors

Returns VaultError::ArithmeticUnderflow if the subtraction would underflow.

fn saturating_add_balance(&mut self, balance: u64)

Adds to the native token balance with saturation.

This method never fails. If adding would overflow, the balance is set to the maximum possible value.

§Parameters
  • balance - amount to add to the balance

fn saturating_sub_balance(&mut self, balance: u64)

Subtracts from the native token balance with saturation.

This method never fails. If subtracting would underflow, the balance is set to 0.

§Parameters
  • balance - amount to subtract from the balance

Implementors§

§

impl WritableNativeBalance for delta_base_sdk::vaults::BaseVault

§

impl WritableNativeBalance for delta_base_sdk::vaults::Vault