Add new dex
This page describes creation of new DEX pool.
These contract methods are called only by admin of that contract.
Creation of pool consist of some parameters for seeting up DEX config.


Constant A used for manipulating with swap function. As larger the value of A, as more the function tends to be constant sum invariant. This constant is stored inside the contact as
Astorage=Aβˆ—nnβˆ’1A_{storage} = A * n^{n-1}
2≀n≀42 \le n \le 4
- number of DEX underlying tokens. You could read more about this constant at Curve whitepaper and an explanation of Curve formulas.
Understanding StableSwap (Curve)
An explanation of Curve formulas


This param is a set of FA12/FA2 tokens that would be traded on DEX. Set type in Tezos contract is the sorted list of unique values, so you must keep in mind that for setting up tokens_info and when calling DEX.


Token Info contains initial data for Token information type - pool underlying token info.

Token info setting

When you want to initialise pool, you should setup initial reserves, rate and precision_multiplier in correct way:
Let 4 TBC = 2 TXZ = 1 TEH (from example)
Then calculate
of these ratios
=4= 4
Token info for TBC
precision_multiplier -
10decimalLPβˆ’decimalTBC10^{decimal_{LP} - decimal_{TBC}}
rate -
10decimalLPβˆ—10decimalLPβˆ’decimalTBCβˆ—(ratioTBC/LCM)10^{decimal_{LP}} * 10^{decimal_{LP} - decimal_{TBC}} * (ratio_{TBC}/LCM)
reserves -
Nβˆ—10decimalTBCβˆ—ratioTBCN * 10^{decimal_{TBC}} * ratio_{TBC}
Token info for TXZ
precision_multiplier -
10decimalLPβˆ’decimalTXZ10^{decimal_{LP} - decimal_{TXZ}}
rate -
10decimalLPβˆ—10decimalLPβˆ’decimalTXZβˆ—(ratioTXZ/LCM)10^{decimal_{LP}} * 10^{decimal_{LP} - decimal_{TXZ}} * (ratio_{TXZ}/LCM)
reserves -
Nβˆ—10decimalTXZβˆ—ratioTXZN * 10^{decimal_{TXZ}} * ratio_{TXZ}
Token info for TEH
precision_multiplier -
10decimalLPβˆ’decimalTEH10^{decimal_{LP} - decimal_{TEH}}
rate -
10decimalLPβˆ—10decimalLPβˆ’decimalTEHβˆ—(ratioTEH/LCM)10^{decimal_{LP}} * 10^{decimal_{LP} - decimal_{TEH}} * (ratio_{TEH}/LCM)
reserves -
Nβˆ—10decimalTEHβˆ—ratioTEHN * 10^{decimal_{TEH}} * ratio_{TEH}
Then you should receive
LPT=10decimalLPβˆ—LCMβˆ—tokensCountLPT = 10^{decimal_{LP}} * LCM * tokensCount
LP tokens.
Details of how to calculate values are in this table. (You can copy and play with this sheet)
Stable exchange with switching of amount of tokens
Copy link