Skip to content

Commit

Permalink
Use the swap tokens to get pair name
Browse files Browse the repository at this point in the history
  • Loading branch information
glottologist committed Nov 20, 2023
1 parent 2ffcf6c commit 48e7adc
Show file tree
Hide file tree
Showing 6 changed files with 539 additions and 511 deletions.
2 changes: 2 additions & 0 deletions batcher-ui/src/components/batcher/Exchange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ const Exchange = () => {
tolerance,
};

console.info("SWAP PARAMS", swap_params);

if (selectedToken.standard === 'FA1.2 token') {
if (!swap.from.token.address) {
dispatch(
Expand Down
4 changes: 3 additions & 1 deletion batcher/batcher.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ let get_valid_swap_reduced
(pair_name: string)
(storage : storage) : valid_swap_reduced =
let valid_swaps = TokenManagerUtils.get_valid_swaps storage.tokenmanager in
if (Map.size valid_swaps) = 0n then failwith unable_to_get_swaps_from_token_manager else
match Map.find_opt pair_name valid_swaps with
| Some vswp -> vswp
| None -> failwith swap_does_not_exist
Expand Down Expand Up @@ -957,6 +958,7 @@ let cancel
let token_one, token_two = pair in
let pair_name = find_lexicographical_pair_name token_one token_two in
let valid_swaps = TokenManagerUtils.get_valid_swaps storage.tokenmanager in
if (Map.size valid_swaps) = 0n then failwith unable_to_get_swaps_from_token_manager else
match Map.find_opt pair_name valid_swaps with
| None -> failwith swap_does_not_exist
| Some vswpr -> let valid_tokens = TokenManagerUtils.get_valid_tokens storage.tokenmanager in
Expand Down Expand Up @@ -1004,7 +1006,7 @@ let enforce_correct_side
let deposit (external_order: external_swap_order) (storage : storage) : result =
let pair = pair_of_external_swap external_order in
let current_time = Tezos.get_now () in
let pair_name = get_rate_name_from_pair pair in
let pair_name = find_lexicographical_pair_name external_order.swap.to.name external_order.swap.from.token.name in
let valid_swap = get_valid_swap_reduced pair_name storage in
if valid_swap.is_disabled_for_deposits then failwith swap_is_disabled_for_deposits else
let () = enforce_correct_side external_order valid_swap in
Expand Down
1 change: 1 addition & 0 deletions batcher/errors.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@
[@inline] let unable_to_get_balance_of_entrypoint_from_fa2_token : nat = 171n
[@inline] let unable_to_get_balance_response_fa12_entrypoint_from_vault : nat = 172n
[@inline] let unable_to_get_get_balance_entrypoint_from_fa12_token : nat = 173n
[@inline] let valid_swaps_map_is_empty = 174n
Loading

0 comments on commit 48e7adc

Please sign in to comment.