Skip to content

Commit

Permalink
fix reentrancy check
Browse files Browse the repository at this point in the history
  • Loading branch information
KStasi committed Jun 22, 2021
1 parent a8ba7c2 commit d4ffb6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
21 changes: 11 additions & 10 deletions contracts/partials/ITTDex.ligo
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ type transfer_params is list (transfer_param)
type update_operator_params is list (update_operator_param)

type token_action is
| ITransfer of transfer_params
| IBalance_of of balance_params
| IUpdate_operators of update_operator_params
| ITransfer of transfer_params (* transfer asset from one account to another *)
| IBalance_of of balance_params (* returns the balance of the account *)
| IUpdate_operators of update_operator_params (* updates the token operators *)

type return is list (operation) * dex_storage
type dex_func is (dex_action * dex_storage * address) -> return
Expand All @@ -139,19 +139,20 @@ type set_dex_function_params is record [
index : nat; (* the key in functions map *)
]

(* full list of dex entrypoints *)
type full_action is
| Use of use_params
| Transfer of transfer_params
| Balance_of of balance_params
| Update_operators of update_operator_params
| Get_reserves of get_reserves_params
| Close of unit
| Transfer of transfer_params (* transfer asset from one account to another *)
| Balance_of of balance_params (* returns the balance of the account *)
| Update_operators of update_operator_params (* updates the token operators *)
| Get_reserves of get_reserves_params (* returns the underlying token reserves *)
| Close of unit (* entrypoint to prevent reentrancy *)
| SetDexFunction of set_dex_function_params (* sets the dex specific function. Is used before the whole system is launched *)
| SetTokenFunction of set_token_function_params (* sets the FA function, is used before the whole system is launched *)

(* real dex storage *)
type full_dex_storage is record
storage : dex_storage;
storage : dex_storage; (* real dex storage *)
metadata : big_map(string, bytes); (* metadata storage according to TZIP-016 *)
dex_lambdas : big_map(nat, dex_func); (* map with exchange-related functions code *)
token_lambdas : big_map(nat, token_func); (* map with token-related functions code *)
Expand All @@ -161,5 +162,5 @@ type full_return is list (operation) * full_dex_storage

const fee_rate : nat = 333n; (* exchange fee rate distributed among the liquidity providers *)

const token_func_count : nat = 2n;
const token_func_count : nat = 2n; (* number of token-related functions *)

8 changes: 4 additions & 4 deletions contracts/partials/TTDex.ligo
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ block {
| None -> (failwith("Dex/function-not-set") : return)
end;
s.storage := res.1;
res.0 := Tezos.transaction(
unit,
0mutez,
get_close_entrypoint(this)) # res.0;
} with (res.0, s)

(* Route token-specific action
Expand All @@ -49,10 +53,6 @@ block {
| None -> (failwith("Dex/function-not-set") : return)
end;
s.storage := res.1;
res.0 := Tezos.transaction(
unit,
0mutez,
get_close_entrypoint(this)) # res.0;
} with (res.0, s)

[@inline] function close (const s : full_dex_storage) : full_dex_storage is
Expand Down

0 comments on commit d4ffb6c

Please sign in to comment.