FlatQube
ā–¶ļø AppšŸ”© SourcesšŸ’¬ CommunityšŸ”’ Audit
  • Welcome to FlatQube
  • šŸ‘Øā€šŸ’»Use
    • Getting started
      • How it works
      • Roles
      • How to connect a wallet
      • Glossary
      • Everscale
      • How to get EVER
    • Swap
      • Interface
        • Basic swap
      • How to
        • Make a basic swap
        • Use limit trading
        • Configure slippage tolerance
        • Use cross-exchange
      • Concepts
        • Limit orders
        • Slippage tolerance
        • Fees
        • Price impact
        • Cross-exchange
    • Tokens
      • Interface
        • All tokens
        • Token page
          • Price
          • TVL
          • Trading volume
          • Pairs
          • Transactions
          • Open in explorer
      • How to
        • Upgrade token(s)
        • Add custom token
      • Concepts
        • Tokens we use
        • EVER and wEVER
        • Token lists
    • Pools
      • Interface
        • All pools
        • Pool page
      • How to
        • Connect DEX account
        • Add liquidity (Get LP tokens) / Withdraw liquidity
        • Create a new pool
        • Calculate the amount of LP tokens
      • Pool economics
    • Farming
      • New farming
        • Interface
          • Farming pools
          • Farming page (user)
            • Farming performance and deposits
            • Statistics
            • Farming speed and vesting
            • Transactions
          • Farm page (administrator)
        • How to
          • Claim reward
          • Deposit/Withdraw farm tokens
          • Get a boost
          • Create and manage your farming pool
      • Old farming
        • Interface
          • Farming pools
          • Farm page (user)
            • Farming perfomance and balances
            • Statistics
            • Farming speed
            • Farm information
            • Transactions
          • Farm page (administrator)
        • How to
          • Claim reward
          • Deposit farm tokens
          • Withdraw farm tokens
          • See farming performance
          • Find my transactions
      • Concepts
        • Yield farming
        • Reward distribution
        • Vesting
        • Farming token
        • Boosted farming
        • Pool share
    • DAO
      • Interface
        • DAO page
        • DAO balance
        • Epoch
      • How to
        • Lock tokens
        • Vote in Epoch
        • Get a boost
        • Become a candidate
      • Concept
        • DAO
        • veQUBE
        • Epoch
        • Boosted farming
        • FAQ
    • Token builder
      • Interface
        • Explorer
        • Token page
      • How to
        • Create new token
        • Mint tokens
        • Burn tokens
        • Transfer ownership
  • āš’ļøIntegrate
    • Open API
      • FlatQube DEX Indexer
        • CMC API
        • Currencies API
        • Pairs API
        • Transactions API
      • FlatQube Farming Indexer
        • Farming pools API
        • Transactions API
        • Graphics API
    • Smart contracts
      • DexAccount
      • DexPair
      • DexPlatform
      • DexRoot
      • DexVault
      • DexVaultLpTokenPending
      • EverToTip3
      • EverWeverToTip3
      • Tip3ToEver
      • TokenFactory
  • ā†—ļøSee also
    • EVER Wallet
    • Octus Bridge
    • Platform products
    • Broxus Github
Powered by GitBook
On this page
  • Initial supply
  • Subsequent supplies

Was this helpful?

  1. Use
  2. Pools
  3. How to

Calculate the amount of LP tokens

Learn how LP tokens are minted against the provided liquidity

Initial supply

When you create a new liquidity pool and deposit liquidity in it, you get the initial amount of LP tokens used as a benchmark for all consequent supplies. Let's look at an example to understand the initial minting process better.

Imagine you are creating a pool of 1,000,000 APPLE and 200 CUCUMBER tokens, which have the following precision (number of digital places after the comma):

  • APPLE - 6 digits (0.000 000)

  • CUCUMBER - 12 digits (0.000 000 000 000)

As Everscale smart contracts operate in integer numbers, they perceive the number of tokens as one big number joining together the integer part and the fraction up to the precision. In other words, 1 APPLE is saved as 1,000,000 in the smart contract, whereas 1 CUCUMBER token is 1,000,000,000,000.

So in our example, 1,000,000 APPLE tokens turn into 1,000,000,000,000 in smart contract memory, and 200 CUCUMBERs into 200,000,000,000,000.

Next, the contract takes the biggest number of those two (i.e., 200,000,000,000,000) and divides it by LP-token precision (9 digits) to issue LP tokens. It means that at the end of the pool creation, you will get 200,000 FLATQUBE-LP-APPLE-CUCUMBER tokens.

Subsequent supplies

All subsequent supplies operate on the proportion of newly provided liquidity compared to (a) the current liquidity level in the pool and (b) the total supply of LP tokens.

Let's imagine we decided to add 200,000 APPLE and 40 CUCUMBER tokens.

In such a case, the contract will calculate the amount of LP tokens to mint following this formula:

LPissue=LPcurrentƗmax(SupplyLeftnewSupplyLeftold,SupplyRightnewSupplyRightold)LP_{issue}=LP_{current} Ɨ max(\frac{SupplyLeft_{new}}{SupplyLeft_{old}},\frac{SupplyRight_{new}}{SupplyRight_{old}})LPissue​=LPcurrent​×max(SupplyLeftold​SupplyLeftnew​​,SupplyRightold​SupplyRightnew​​)

So in our case, it will be:

LPissue=200,000Ɨmax(200,000,000,0001,000,000,000,000,40,000,000,000,000200,000,000,000,000)=50,000LP_{issue}=200,000\times max\big(\frac{200,000,000,000}{1,000,000,000,000},\frac{40,000,000,000,000}{200,000,000,000,000}\big)=50,000LPissue​=200,000Ɨmax(1,000,000,000,000200,000,000,000​,200,000,000,000,00040,000,000,000,000​)=50,000

The total LP-token supply in our example will result in:

LPnew=LPold+LPissue=200,000+50,000=250,000LP_{new}=LP_{old}+LP_{issue}=200,000+50,000=250,000LPnew​=LPold​+LPissue​=200,000+50,000=250,000

Please note that the balance between tokens in the pool will change after each swap. So you will need to provide a different number of pool tokens to get the same number of LP-tokens.

PreviousCreate a new poolNextPool economics

Last updated 2 years ago

Was this helpful?

šŸ‘Øā€šŸ’»