LogoLogo
ston-fi/docs
ston-fi/docs
  • User section
    • About
    • STON.fi Protocol
    • Fees
    • Glossary
    • Procedure for Adding Tokens to the Default List
    • Whitepaper
  • Developer section
    • Architecture
    • SDK
      • DEX v1 guide
        • reference
        • swap
        • provide liquidity
        • refund liquidity
        • burn liquidity tokens
      • DEX v2 guide
        • swap
        • provide liquidity
        • refund liquidity
        • burn liquidity tokens
        • withdraw fee from vault
      • Farm guide
        • stake in farm
        • claim farm rewards
        • unstake from farm
        • destroy farm NFT
      • Transaction sending guide
        • via ton
        • via tonweb
        • via tonconnect
      • v0.5 > v1.0.0 migration guide
      • v0.5 (deprecated)
        • DEX guide
          • swap
          • provide liquidity
          • refund liquidity
          • burn liquidity tokens
        • Farm guide
          • stake in farm
          • claim farm rewards
          • unstake from farm
          • destroy farm NFT
        • Transaction sending guide
          • via ton
          • via tonweb
          • via tonconnect
      • v0.4 > v0.5 migration guide
      • v0.4 (deprecated)
        • perform a swap operation
        • provide liquidity
        • refund liquidity
        • burn liquidity tokens
        • using get methods
        • create a custom router revision
    • API reference v1
      • Router
      • Pool
      • LpAccount
      • LpWallet
    • API reference v2
      • Router
      • Pool
      • LpAccount
      • LpWallet
      • Vault
      • Swap examples
      • LpProvide examples
      • Vault examples
      • Op Codes
    • DEX API
    • OMNISTON
      • Resolvers (How to become a resolver)
      • Swap overview
      • Swap extra
      • Swap grpc
      • React
      • Nodejs
      • Referral fees
    • Quickstart Guides
      • Swap Guide
      • Omniston Guide
  • Help
    • Contact Us
Powered by GitBook
On this page
  • Deposit liquidity (both tokens)
  • Deposit of the first token
  • Deposit of the second token
  • Deposit liquidity (single side provision)
  • Deposit liquidity (with payload)
  • Refund deposited liquidity
  • Liquidity is refunded to lp account
  • Withdraw refunded liquidity
  • Withdraw liquidly
  • Providing already deposited liquidity
Export as PDF
  1. Developer section
  2. API reference v2

LpProvide examples

This section contains example schemes for liquidity provision

PreviousSwap examplesNextVault examples

Last updated 2 months ago

Deposit liquidity (both tokens)

Liquidity provision is done via 2 transactions: deposit of the first token and deposit of the second token.

Deposit of the first token

The amount of the first token sent is stored on a user's lp account awaiting a transaction of the second token.

Deposit of the second token

When the second token is sent, lp account automatically initiates liquidity addition into the pool. As a result, full amounts of deposited tokens are used as new liquidity and the user receives lp tokens.

Notes:

  • the Lp Account contract is deleted on cb_add_liquidity in order to not pay storage fees (each deposit sends state init so it will be redeployed as soon as any new deposit occurs)

  • when depositing initial liquidity 0.000001001 lp tokens will be reserved on pool, the rest of liquidity will be sent to the user

Deposit liquidity (single side provision)

It is possible to deposit liquidity by sending just 1 type of token, the pool will automatically perform a swap and use the resulting amount to mint lp tokens

Deposit liquidity (with payload)

It is possible to specify who will receive lp tokens and to include a payload which will be sent as transfer_notification (e.g. Farm contract)

Refund deposited liquidity

In the event that the issued amount of lp tokens doesn't match the specified minimum value, all deposited liquidity is returned to lp account and can be withdrawn by user.

Liquidity is refunded to lp account

Withdraw refunded liquidity

Withdraw liquidly

Liquidly is withdrawn from a pool by burning lp tokens, a user then receives both pool tokens based on the current exchange rate.

Providing already deposited liquidity

A user can deposit liquidity after it was refunded to lp account without doing a withdraw.