Skip to content

Commit

Permalink
Added view 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 a580b81 commit d6adea3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions batcher/batcher.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,9 @@ let does_batch_need_liquidity
[@view]
let get_valid_swap (pair,storage:string * storage): valid_swap_reduced = get_valid_swap_reduced pair storage

[@view]
let get_pair_name ((to,from),_storage:(string * string) * storage): string = find_lexicographical_pair_name to from

[@view]
let get_batches_needing_liquidity ((),storage: unit * storage) : batch list=
let collect_batches (acc, (_s, i) : batch list * (string * nat)) : batch list =
Expand Down
39 changes: 39 additions & 0 deletions batcher/michelson/batcher-ghostnet.tz
Original file line number Diff line number Diff line change
Expand Up @@ -4776,6 +4776,45 @@
SWAP ;
ITER { CDR ; PUSH nat 0 ; SWAP ; COMPARE ; GT ; OR } ;
OR } } } ;
view "get_valid_swap"
string
(pair (pair %swap (string %from) (string %to))
(address %oracle_address)
(string %oracle_asset_name)
(nat %oracle_precision)
(bool %is_disabled_for_deposits))
{ UNPAIR ;
SWAP ;
CDR ;
CDR ;
CAR ;
UNIT ;
VIEW "get_valid_swaps"
(map string
(pair (pair %swap (string %from) (string %to))
(address %oracle_address)
(string %oracle_asset_name)
(nat %oracle_precision)
(bool %is_disabled_for_deposits))) ;
IF_NONE { PUSH nat 165 ; FAILWITH } {} ;
PUSH nat 0 ;
DUP 2 ;
SIZE ;
COMPARE ;
EQ ;
IF { DROP 2 ; PUSH nat 165 ; FAILWITH }
{ SWAP ; GET ; IF_NONE { PUSH nat 117 ; FAILWITH } {} } } ;
view "get_pair_name"
(pair string string)
string
{ CAR ;
UNPAIR ;
DUP 2 ;
DUP 2 ;
COMPARE ;
GT ;
IF { SWAP ; PUSH string "-" ; CONCAT ; SWAP ; CONCAT }
{ PUSH string "-" ; CONCAT ; SWAP ; CONCAT } } ;
view "get_batches_needing_liquidity"
unit
(list (pair (nat %batch_number)
Expand Down

0 comments on commit d6adea3

Please sign in to comment.