Dex
Last updated
Last updated
The contract is responsible for launching new exchange pairs and serves as the automatic market maker engine. The contract manages pools for FA1.2/FA1.2, FA2/FA2 and FA2/FA1.2 tokens. The only instance of the pool for the same pair exists.
The contract fully implements the entrypoints of the FA2 standard according to TZIP-12. The other exchange-specific entrypoints are described in the doc.
Setup the new exchange or relaunch the exchange after all the liquidity was drained. amount_a_in
and amount_b_in
of tokens must be approved. Initial liquidity should be non-zero. All the storage parameters are reset to default values. The sender receives shares equal to a minimum of amount_a_in
and amount_b_in
. Tokens types must be provided in ascending order.
token_a_type
tokens_type
The type of the first token
token_b_type
tokens_type
The type of the second token
token_a_in
nat
Amount of the first token to be invested
token_b_in
nat
Amount of the second token to be invested
Swaps the token to another token. a_to_b
type is used to exchange token_a
to token_b
. b_to_a
performs the opposite swap from token_b_address
to token_a_address
. The token_a
and token_b
are the corresponding tokens of pair_id
pool. The amount_in
of the token will be charged from the user. If the received amount is smaller than min_amount_out
then the transaction is reverted. Tokens types must be provided in ascending order. Deadlines should be in the future.
swaps
list of swap_slice_type
Swaps to perform; each swap consist of pair_id
of the pool and swap_type
to be executed; all the exchanges should be sequential.
amount_in
nat
Amount of the token to swap
min_amount_out
nat
The minimal amount of the token to receive
receiver
address
Receiver's address
deadline
timestamp
Time until the operation is valid
Adds more liquidity to the exchange. token_a_in
and token_b_in
must be approved. Initial liquidity should be non-zero. The sender spends token_a_in
and token_b_in
at most otherwise, the transaction fails. Tokens types must be provided in ascending order. Deadlines should be in the future.
pair_id
nat
Pair identifier
shares
nat
Amount of LP tokens to mint
token_a_in
nat
Max amount of the first token to invest
token_b_in
nat
Max amount of the second token to invest
deadline
timestamp
Time until the operation is valid
Burns shares
and sends tokens to the owner; operation is reverted if the amount of appropriate divested tokens is smaller than min_token_a_out
or min_token_b_out
. Tokens types must be provided in ascending order. Deadlines should be in the future.
pair_id
nat
Pair identifier
min_token_a_out
nat
Minimal amount of the first token to receive
min_token_b_out
nat
Minimal amount of the second token to receive
shares
nat
The amount of the shares to burn
deadline
timestamp
Time until the operation is valid
Is used after all the exchange calls to prevent reentrancy. It can only be called by the exchange itself.
Returns the amount of tokens reserves. No arguments are needed.