Class LiquidityManager<T>

Manages liquidity for tokens, with generic flexibility.

Remarks

It does not implement overflow and underflow checks for operations.

Type Parameters

  • T

    The type used for liquidity amount.

Hierarchy

  • LiquidityManager

Constructors

Methods

  • Burns liquidity from a user's balance and updates the total supply.

    Throws

    if the user's balance is insufficient.

    Parameters

    • user: Address

      The user's address.

    • amount: T

      Amount to burn.

    Returns void

  • Burns liquidity from an owner using the allowance mechanism.

    Throws

    if the spender's allowance is insufficient.

    Parameters

    • owner: Address

      Owner's address.

    • spender: Address

      Spender's address.

    • amount: T

      Amount of liquidity to burn.

    Returns void

  • Fetches the allowed amount a spender can use from an owner's funds.

    Remarks

    If the spender has no allowance in the storage, 0 is returned.

    Returns

    The spender's allowance, or 0 if none is found.

    Parameters

    Returns T

  • Retrieves the balance for a specified user address.

    Returns

    User's balance, or 0 if no balance is found.

    Parameters

    • user: Address

      The user's address.

    Returns T

  • Fetches the total supply of the token.

    Remarks

    By default, the total supply is 0.

    Returns

    The total token supply.

    Returns T

  • Mints liquidity to a user's balance and updates the total supply.

    Remarks

    If the receiver has no balance in the storage, a new one is created. mint also updates the total supply of the token.

    Parameters

    • user: Address

      The user's address.

    • amount: T

      Amount to mint.

    Returns void

  • Removes the allowance of a spender to use the liquidity of an owner from the storage.

    Remarks

    If the spender has no allowance in the storage, the function does nothing.

    Throws

    if the spender has a non-null allowance.

    Parameters

    • owner: Address

      The address of the owner.

    • spender: Address

      The address of the spender.

    Returns void

  • Eliminates a user's balance from the storage. No action if the balance doesn't exist.

    Throws

    if the user has a non-zero balance.

    Parameters

    • user: Address

      The user's address.

    Returns void

  • Transfers an amount of liquidity from one user to another.

    Remarks

    If the receiver has no balance in the storage, a new one is created.

    Throws

    if the sender's balance is insufficient.

    Parameters

    • from: Address

      Sender's address.

    • to: Address

      Receiver's address.

    • amount: T

      Amount of liquidity to transfer.

    Returns void

  • Transfers liquidity using the allowance mechanism.

    Throws

    if the spender's allowance is insufficient.

    Parameters

    • owner: Address

      Owner's address.

    • spender: Address

      Spender's address.

    • to: Address

      Receiver's address.

    • amount: T

      Amount of liquidity to transfer.

    Returns void

  • Updates the allowance set for a spender by an owner.

    Remarks

    If the spender has no allowance in the storage, a new allowance is created.

    Throws

    if attempting to decrease allowance below available amount.

    Parameters

    • owner: Address

      Owner's address.

    • spender: Address

      Spender's address.

    • deltaAmount: T

      Amount to adjust the allowance by.

    • increase: bool

      Whether to increase (true) or decrease (false) the allowance.

    Returns void

Generated using TypeDoc