🟠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.
a_constant
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−1 where 2≤n≤4 - number of DEX underlying tokens. You could read more about this constant at Curve whitepaper and an explanation of Curve formulas.
input_tokens
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.
tokens_info
Token Info contains initial data for Token information type - pool underlying token info.
add_poolToken info setting
When you want to initialise pool, you should setup initial reserves, rate and precision_multiplier in correct way:
Let 4
TBC= 2TXZ= 1TEH(from example)
Then calculate LCM of these ratios =4
Token info for TBC
precision_multiplier- 10decimalLP−decimalTBC
rate- 10decimalLP∗10decimalLP−decimalTBC∗(ratioTBC/LCM)
reserves- N∗10decimalTBC∗ratioTBC
Token info for TXZ
precision_multiplier- 10decimalLP−decimalTXZ
rate- 10decimalLP∗10decimalLP−decimalTXZ∗(ratioTXZ/LCM)
reserves- N∗10decimalTXZ∗ratioTXZ
Token info for TEH
precision_multiplier- 10decimalLP−decimalTEH
rate- 10decimalLP∗10decimalLP−decimalTEH∗(ratioTEH/LCM)
reserves- N∗10decimalTEH∗ratioTEH
Then you should receive LPT=10decimalLP∗LCM∗tokensCount LP tokens.
Details of how to calculate values are in this table. (You can copy and play with this sheet)
Last updated
