Skip to content

Commit

Permalink
comments added
Browse files Browse the repository at this point in the history
  • Loading branch information
KStasi committed Jun 22, 2021
1 parent d4ffb6c commit 6261cef
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
55 changes: 29 additions & 26 deletions contracts/partials/ITTDex.ligo
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ type pair_info is record [
]

type tokens_info is record [
token_a_address : address;
token_b_address : address;
token_a_id : nat;
token_b_id : nat;
token_a_type : token_type;
token_b_type : token_type;
token_a_address : address; (* token A address *)
token_b_address : address; (* token B address *)
token_a_id : nat; (* token A identifier *)
token_b_id : nat; (* token B identifier *)
token_a_type : token_type; (* token A standard *)
token_b_type : token_type; (* token B standard *)
]

type token_pair is bytes
Expand All @@ -48,33 +48,36 @@ type dex_storage is record [
pairs : big_map(nat, pair_info); (* account info per address *)
ledger : big_map((address * nat), account_info); (* account info per address *)
]
type swap_type is Buy | Sell
(* operation type *)
type swap_type is
| Sell (* exchange token A to token B *)
| Buy (* exchange token B to token A *)

type swap_slice_type is record [
pair : tokens_info;
operation : swap_type;
pair : tokens_info; (* exchange pair info *)
operation : swap_type; (* exchange operation *)
]

type swap_side is record [
pool : nat;
token : address;
id : nat;
standard : token_type;
pool : nat; (* pair identifier*)
token : address; (* token address*)
id : nat; (* token aidentifier *)
standard : token_type; (* token standard *)
]

type swap_data is record [
to_ : swap_side;
from_ : swap_side;
to_ : swap_side; (* info about sold asset *)
from_ : swap_side; (* info about bought asset *)
]

type internal_swap_type is record [
s : dex_storage;
amount_in : nat;
token_address_in : address;
token_id_in : nat;
operation : option(operation);
sender : address;
receiver : address;
s : dex_storage; (* storage state *)
amount_in : nat; (* amount of tokens to be sold *)
token_address_in : address; (* address of sold token *)
token_id_in : nat; (* identifier of sold token *)
operation : option(operation); (* exchange operation type *)
sender : address; (* address of the sender *)
receiver : address; (* address of the receiver *)
]

(* Entrypoint arguments *)
Expand All @@ -90,15 +93,15 @@ type token_to_token_route_params is
type invest_liquidity_params is
[@layout:comb]
record [
pair : tokens_info;
pair : tokens_info; (* exchange pair info *)
token_a_in : nat; (* min amount of tokens A invested *)
token_b_in : nat; (* min amount of tokens B invested *)
]

type divest_liquidity_params is
[@layout:comb]
record [
pair : tokens_info;
pair : tokens_info; (* exchange pair info *)
min_token_a_out : nat; (* min amount of tokens A received to accept the divestment *)
min_token_b_out : nat; (* min amount of tokens B received to accept the divestment *)
shares : nat; (* amount of shares to be burnt *)
Expand All @@ -112,8 +115,8 @@ type dex_action is

type use_params is dex_action
type get_reserves_params is record [
receiver : contract(nat * nat);
token_id : nat;
receiver : contract(nat * nat); (* response receiver *)
pair_id : nat; (* pair identifier *)
]

(* Main function parameter types specific for FA2 standard*)
Expand Down
2 changes: 1 addition & 1 deletion contracts/partials/TTDex.ligo
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ block {
const params : get_reserves_params;
const s : full_dex_storage) : full_return is
block {
const pair : pair_info = case s.storage.pairs[params.token_id] of
const pair : pair_info = case s.storage.pairs[params.pair_id] of
None -> record [
token_a_pool = 0n;
token_b_pool = 0n;
Expand Down

0 comments on commit 6261cef

Please sign in to comment.