get_toks_per_share

This on-chain view returns amount of token A and token B for the specified amount of LP tokens in a specific liquidity pool (pair). Also can return a list of responses for a list of requests.

Call parameters

type token_id_t         is nat

type toks_per_shr_req_t is [@layout:comb] record [
  pair_id                 : token_id_t;
  shares_amt              : nat;
]

list(toks_per_shr_req_t)
Field
Type
Description

pair_id

token_id_t (nat)

Pair ID for which you need to get tokens amount per shares

shares_amt

nat

Amount of shares to get info about tokens

Return type

type token_id_t         is nat

type toks_per_shr_t     is [@layout:comb] record [
  token_a_amt             : nat;
  token_b_amt             : nat;
]

type toks_per_shr_req_t is [@layout:comb] record [
  pair_id                 : token_id_t;
  shares_amt              : nat;
]

type toks_per_shr_res_t is [@layout:comb] record [
  request                 : toks_per_shr_req_t;
  tokens_per_share        : toks_per_shr_t;
]

list(toks_per_shr_res_t)

toks_per_shr_req_t

Field
Type
Description

pair_id

token_id_t (nat)

Pair ID for which you need to get tokens amount per shares

shares_amt

nat

Amount of shares to get info about tokens

toks_per_shr_t

Field
Type
Description

token_a_amt

nat

Amount of tokens A per shares

token_b_amt

nat

Amount of tokens B per shares

toks_per_shr_res_t

Field
Type
Description

request

Tokens per shares request

tokens_per_share

Tokens per shares response

Usage

const dexCoreAddress = "KT1...";
const params = [
    {
        pair_id: 1,
        shares_amt: 100,
    },
    ...
];
const viewCaller = "tz1...";
const dexCore = await tezos.contract.at(dexCoreAddress);
const tokensPerShares = await dexCore.contract.contractViews.get_toks_per_share(params).executeView({ viewCaller: viewCaller });

Errors

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

  • 109 - pair doesn't have a liquidity.

Last updated