Interest Protocol
  • 👋Welcome to Interest Protocol
  • Overview
    • Sui💧
      • Contracts
        • Memez
        • Libs 📚
      • Suicoins
        • Swap
        • Dollar-Cost Averaging (DCA)
        • Airdrop
          • Suiplay Airdrop
        • Incinerator
        • Send
        • Merger
        • Suicoins Terminal
      • Memez.gg
        • Coins on Memez.GG
        • Memez.Fun
          • SDK
            • Pump API
            • Interfaces
          • Configuration
          • Migrators
          • Bonding Curve
          • Fees
      • IPX Coin Standard
    • Movement
      • Interest Protocol Decentralized Exchange (DEX)
        • Key Features
        • Core Innovations
      • sr-AMM
      • Token
        • Tokenomics
        • Utility
      • GTM
    • Audits
    • Security
    • Deprecated
      • Coin X Oracle 🔮
        • Pyth Network
        • Switchboard
      • Sui Tears 💧
        • Airdrop
          • Airdrop
          • Airdrop Utils
          • Linear Vesting Airdrop
        • Capabilities
          • Access Control
          • Owner
          • Quest
          • Timelock
        • Collections
          • Bitmap
          • Coin Decimals
        • DeFi
          • Oracle
          • Farm
          • Fund
          • Linear Vesting Wallet
          • Linear Clawback Vesting Wallet
          • Vesting
        • Governance
          • DAO
          • DAO Admin
          • DAO Treasury
        • Utils
          • ASCII
          • Comparator
          • Merkle Proof
          • Vectors
        • Math
          • Fixed Point 64
          • Fixed Point Roll
          • Fixed Point Wad
          • Int
          • Math64
          • Math128
          • Math256
      • CLAMM🐚
        • Hooks
      • Whitepapers
  • Glossary
Powered by GitBook
On this page
  • Structs
  • Account
  • Interface
  • empty
  • underlying
  • shares
  • to_shares
  • to_underlying
  • sub_shares
  • add_underlying
  • sub_underlying
  • add_profit

Was this helpful?

Export as PDF
  1. Overview
  2. Deprecated
  3. Sui Tears 💧
  4. DeFi

Fund

It is a utility struct to easily know how many shares to issue/burn based on an underlying amount.

Structs

Account

struct Fund has store, copy, drop {
    shares: u128,
    underlying: u128
 }
  • shares - The amount of shares issued based on the underlying amount.

  • underlying - The amount of assets in the fund.

Interface

empty

Creates an empty Fund.

public fun empty(): Fund
  • @return Fund.

underlying

Returns the amount of underlying in the self.

public fun underlying(self: &Fund): u64
  • @param self: A Fund.

  • @return u64. The amount of underlying.

shares

Returns the amount of shares in the self.

public fun shares(self: &Fund): u64
  • @param self: A Fund.

  • @return u64. The amount of shares.

to_shares

Returns the number of shares the self would issue if more underlying was deposited in it.

public fun to_shares(self: &Fund, underlying: u64, round_up: bool): u64
  • @param self: A Fund.

  • @param underlying: The amount of underlying that the caller intends to add to the self.

  • @param round_up: If true we would round up the returned value.

  • @return u64. The amount of shares the fund would issue.

to_underlying

Returns the number of shares the self would issue if more underlying was deposited in it.

public fun to_underlying(rebase: &Fund, shares: u64, round_up: bool): u64
  • @param self: A Fund.

  • @param shares: The amount of shares that the caller intends to burn.

  • @param round_up: If true we would round up the returned value.

  • @return u64. The amount underlying the fund would release.

sub_shares

This function reduces the amount of underlying and shares in the fund.

public fun sub_shares(self: &mut Fund, shares: u64, round_up: bool): u64
  • @param self: A Fund.

  • @param shares: The amount of shares that the caller intends to burn.

  • @param round_up: If true we would round up the returned value.

  • @return u64. The amount underlying the shares were worth.

add_underlying

Adds underlying to the self and returns the additional shares issued. This function increases the amount of underlying and shares in the fund.

public fun add_underlying(rebase: &mut Fund, underlying: u64, round_up: bool): u64
  • @param self: A Fund.

  • @param underlying: The amount of underlying to deposit in the self.

  • @param round_up: If true we would round up the returned value.

  • @return u64. The amount of shares the fund issued.

sub_underlying

Removes underlying from the self and returns the burned shares. This function reduces the amount of underlying and shares in the fund.

public fun sub_underlying(rebase: &mut Fund, underlying: u64, round_up: bool): u64
  • @param self: A Fund.

  • @param underlying: The amount of underlying to remove from the self.

  • @param round_up: If true we would round up the returned value.

  • @return u64. The amount of shares the fund burned.

add_profit

Adds profits to the underlying. This is to add profits to the fund.

public fun add_profit(rebase: &mut Fund, profit: u64)
  • @param self: A Fund.

  • @param profit: The amount of underlying to add as profit to self.underlying.

PreviousFarmNextLinear Vesting Wallet

Last updated 1 year ago

Was this helpful?