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
  • Decimals
  • CoinDecimals
  • Interface
  • new
  • contains
  • decimals
  • scalar
  • add

Was this helpful?

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

Coin Decimals

It stores information about Coins' decimals to allow protocols to fetch them. The idea is to pass a single argument CoinDecimals to functions that require several sui::coin::CoinMetadata objects.

Structs

Decimals

struct Decimals has store {
    decimals: u8, 
    scalar: u64
}
  • decimals - decimals of a sui::coin

  • scalar - The scalar of a sui::coin's decimals. It is calculated by 10^decimals. E.g. sui::sui has a scalar of 1_000_000_000 or 1e9.

CoinDecimals

struct CoinDecimals has key, store {
    id: UID
}

The Decimals struct is saved in CoinDecimals using dynamic fields.

Interface

new

It creates a new CoinDecimals.

public fun new(ctx: &mut TxContext): CoinDecimals
  • @return CoinDecimals.

contains

Checks if a coin with type CoinType has been added to self.

public fun contains<CoinType>(self: &CoinDecimals): bool
  • @param self A {CoinDecimals} object.

  • @return bool. True if the coin's decimals and scalar are in the self.

decimals

Returns the decimals of a coin with the type CoinType.

public fun decimals<CoinType>(self: &CoinDecimals): u8
  • @param self A CoinDecimals object.

  • @return u8. The decimals of the coin.

Aborts

  • CoinType has not been added to the self.

scalar

Returns the decimals scalar of a coin with type CoinType.

 public fun scalar<CoinType>(self: &CoinDecimals): u64
  • @param self A {CoinDecimals} object.

  • @return u64. The decimal's scalar. It is calculated by 10^decimals.

Aborts

  • CoinType has not been added to the self.

add

Adds the decimals and decimal scalar of a coin with type CoinType to self.

public fun add<CoinType>(self: &mut CoinDecimals, coin_metadata: &CoinMetadata<CoinType>)
  • @param self A CoinDecimals object.

  • @return coin_metadata The sui::coin::CoinMetadata of a coin with type CoinType.

PreviousBitmapNextDeFi

Last updated 1 year ago

Was this helpful?