Quipuswap
  • introduction
    • What is QuipuSwap?
    • Participants
    • QuipuSwap subprojects
      • QuipuSwap Farms
      • Quipuswap Stable DEX
      • Token to Token Swaps
      • Governance (text-only)
  • Get Started
    • Install Wallet
    • How to get TEZ
    • How to find my tokens
    • Connect wallet
    • FAQ
  • Dex Guides
    • Overview
    • Types of the exchange (Token/TEZ, Token/Token)
    • How to use the DEX
      • Trade
      • How to add liquidity to an existing liquidity pool
      • How to create a new liquidity pool
      • How to remove liquidity
      • How to vote for a baker
      • How to ban/veto a baker
  • Tezos Tokens
    • What is a Token?
    • What is the difference between FA1.2 and FA2 standards?
    • QUIPU Tokenomics
  • Smart Contracts
    • Dex token edition
      • Overview
      • Dex
      • Exceptions
    • QuipuSwap stable swap DEX
      • ๐Ÿ› ๏ธDeveloper module
        • ๐Ÿ“„Storage & action types
        • ๐Ÿ”ตDeveloper setter entrypoints
          • set_dev_address
          • set_dev_fee
      • ๐Ÿ Standalone DEX
        • ๐Ÿ“„Storage and types overview
        • ๐ŸŸกInitialization
          • set_admin_function
          • set_dev_function
          • set_dex_function
          • set_token_function
        • ๐ŸŸ Add new dex
          • add_pool
        • ๐Ÿ”ตDEX methods
          • invest
          • swap
          • ๐Ÿ“คDivesting
            • divest
            • divest_imbalanced
            • divest_one_coin
          • ๐Ÿค‘DEX rewards
            • claim_referral
            • stake
        • ๐Ÿ› ๏ธDeveloper methods
          • claim_developer
          • Dev module entrypoints
        • ๐Ÿ›‘Admin methods
          • add_rem_managers
          • ramp_A
          • set_admin
          • set_fees
          • stop_ramp_A
      • ๐ŸญFactory
        • ๐Ÿ“„Storage and types overview
        • ๐ŸŸกInitial setup
          • set_init_function
          • set_dev_function
          • DEX compiled codebase setup
            • set_admin_function
            • set_dex_function
            • set_token_function
        • ๐ŸŸ Initialize new DEX flow
          • add_pool
          • start_dex
        • ๐Ÿ’ฑDeployed from factory DEX
          • ๐Ÿ“„Storage and types overview
          • ๐ŸŸกInitialization
            • copy_dex_function
            • freeze
          • ๐Ÿ”ตDEX methods
          • ๐Ÿ› ๏ธClaim developer rewards
          • ๐Ÿ›‘Admin methods
        • ๐Ÿ›‘Developer methods
          • claim_rewards
          • ๐Ÿง‘โ€๐Ÿ’ปFactory management
            • ๐ŸŸขFactory params
              • set_burn_rate
              • set_price
              • set_whitelist
            • ๐Ÿ”ตDev module entrypoints
    • Dex 2.0
      • โ‰๏ธErrors overview
      • ๐ŸฅBakerRegistry contract
        • Storage and types overview
        • Entrypoints overview
          • validate
          • register
      • โš™๏ธFlashSwapsProxy contract
        • Storage and types overview
        • Entrypoints overview
          • default
      • ๐ŸงบBucket contract
        • Storage and types overview
        • Entrypoints overview
          • fill
          • pour_out
          • pour_over
          • withdraw_rewards
          • ban_baker
          • vote
          • default
        • On-chain views overview
          • is_banned_baker
          • get_tez_balance
          • get_user_candidate
      • โš–๏ธAuction contract
        • Storage and types overview
        • Entrypoints overview
          • Auction entrypoints
            • receive_fee
            • launch_auction
            • place_bid
            • claim
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_baker
            • set_fees
            • set_auction_duration
            • set_min_bid
            • update_whitelist
            • withdraw_dev_fee
            • withdraw_public_fee
            • burn_bid_fee
      • ๐ŸฆDexCore contract
        • Storage and types overview
        • Entrypoints overview
          • DEX entrypoints
            • launch_exchange
            • invest_liquidity
            • divest_liquidity
            • swap
            • withdraw_profit
            • claim_interface_fee
            • claim_interface_tez_fee
            • withdraw_auction_fee
            • vote
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_flash_swaps_proxy
            • set_auction
            • add_managers
            • set_fees
            • set_collecting_period
            • update_token_metadata
            • ban
          • Permits' entrypoints
            • permit
            • set_expiry
          • FA2 entrypoints
            • transfer
            • update_operators
            • balance_of
          • Callbacks
            • launch_callback
            • flash_swap_callback
            • close
        • On-chain views overview
          • check_is_banned_baker
          • get_reserves
          • get_total_supply
          • get_swap_min_res
          • get_toks_per_share
          • get_cumulative_prices
          • get_collecting_period
    • Trusted contracts
    • Farming
      • Referral system overview
      • Fees overview
      • Rewards precision overview
      • BakerRegistry contract
        • Storage and types overview
        • Entrypoints overview
          • validate
          • register
      • Burner contract
        • Storage and types overview
        • Entrypoints overview
          • default
          • burn_callback
      • ProxyMinter contract
        • Storage and types overview
        • Entrypoints overview
          • Admin entrypoints
            • add_minter
            • withdraw_tokens
            • set_admin
            • confirm_admin
          • Minter entrypoint
            • mint_tokens
      • QFarm contract
        • Storage and types overview
        • Entrypoints overview
          • Farming entrypoints
            • deposit
            • withdraw
            • harvest
          • FA2 entrypoints
            • transfer
            • update_operators
            • balance_of
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_fees
            • set_reward_per_second
            • set_burner
            • set_proxy_minter
            • set_baker_registry
            • set_is_v1_lp
            • ban_bakers
            • add_new_farm
            • pause_farms
            • burn_tez_rewards
            • withdraw_farm_depo
            • update_token_metadata
          • Other entrypoints
            • burn_farm_rewards
            • default
      • TFarm contract
        • Storage and types overview
        • Entrypoints overview
          • Farming entrypoints
            • deposit
            • withdraw
            • harvest
          • FA2 entrypoints
            • transfer
            • update_operators
            • balance_of
          • Admin entrypoints
            • set_admin
            • confirm_admin
            • set_fees
            • set_reward_per_second
            • set_burner
            • set_baker_registry
            • set_is_v1_lp
            • ban_bakers
            • add_new_farm
            • pause_farms
            • burn_tez_rewards
            • claim_farm_rewards
            • withdraw_farm_depo
            • update_token_metadata
          • Other entrypoints
            • default
  • Brand and Logos
Powered by GitBook
On this page
  • Call parameters
  • Usage
  • Errors
  1. Smart Contracts
  2. Dex 2.0
  3. DexCore contract
  4. Entrypoints overview
  5. DEX entrypoints

invest_liquidity

Previouslaunch_exchangeNextdivest_liquidity

Last updated 2 years ago

An entrypoint for liquidity investment in the specific liquidity pool (pair). Also it for the users' bakers in case of liquidity investment to TOK/TEZ pools.

Call parameters

type token_id_t         is nat

type invest_liquidity_t is [@layout:comb] record [
  pair_id                 : token_id_t;
  token_a_in              : nat;
  token_b_in              : nat;
  shares                  : nat;
  shares_receiver         : address;
  candidate               : key_hash;
  deadline                : timestamp;
]
Field
Type
Description

pair_id

token_id_t (nat)

Identifier of the liquidity pool (pair)

token_a_in

nat

Max amount of token A allowed to be spent

token_b_in

nat

Max amount of token B allowed to be spent

shares

nat

Amount of LP tokens to be acquired

shares_receiver

address

Receiver of LP tokens

candidate

key_hash

Baker for voting (is used only in time of investment to TOK/TEZ exchanges)

deadline

timestamp

The time until which the transaction remains valid and will not be rejected

Usage

Note: you need to pass positive TEZ/mutez amount to the send() method in case of FA1.2/TEZ or FA2/TEZ liquidity investment (see example below).

const dexCoreAddress = "KT1...";
const parmas = {
    pair_id: 0,
    token_a_in: 100,
    token_b_in: 100,
    shares: 100,
    shares_receiver: "tz1.../KT1...",
    candidate: "tz1...",
    deadline: String(Date.parse((await tezos.rpc.getBlockHeader()).timestamp) / 1000 + 100),
};
const dexCore = await tezos.contract.at(dexCoreAddress);
const operation = await dexCore.methodsObject.invest_liquidity(parmas).send({ amount: parmas.token_b_in, mutez: true });

await operation.confirmation();

Pass candidate: "tz1ZZZZZZZZZZZZZZZZZZZZZZZZZZZZNkiRg"in case of TOK/TOK exchange

Errors

  • 108 - pair (pool) with the specified token_id not listed.

  • 109 - pair doesn't have a liquidity.

  • 110 - zero amount of LP tokens (shares) expected.

  • 111 - low token A amount in.

  • 112 - low token B amount in.

  • 136 - reentrancy.

  • 141 - wrong amount of TEZ tokens were attached to transaction.

  • 144 - action outdated (the time until which the transaction remained valid was passed).

  • 412 - non payable entrypoint (can't accept TEZ tokens during call of an entrypoint). Only in case of investment to TOK/TOK liquidity pools (pairs).

Also don't forget to add the contract as the operator for your FA2 tokens or make an approve for spending of FA1.2 tokens in time of liquidity investment.

๐Ÿฆ
votes
DexCore