From Michelson to LiquidityΒΆ
Here is a table of how Michelson instructions translate to Liquidity:
ADDRESS
:Contract.untype c
AMOUNT
:Current.amount()
ABS
:match%nat x with Plus n -> | Minus n -> n
ADD
:x + y
AND
:x land y
orx && y
orx & y
BALANCE
:Current.balance()
BLAKE2B
:Crypto.blake2b bytes
CAR
:x.(0)
CDR
:x.(1)
CAST
: not availableCHECK_SIGNATURE
:Crypto.check key sig bytes
COMPARE
:compare x y
CONCAT
:String.concat list
orbytes.concat list
CONS
:x :: y
CONTRACT
CREATE_ACCOUNT
:Account.create
CREATE_CONTRACT
DIP
: automatic stack managementDROP
: automatic stack managementDUP
: automatic stack managementEDIV
:x / y
EMPTY_BIG_MAP
:BigMap []
EMPTY_MAP
:Map []
EMPTY_SET
:Set []
EQ
:x = y
EXEC
:x |> f
orf x
orf @@ x
FAILWITH
:Current.failwith
GE
:x >= y
GET
:Map.find key map
GT
:x > y
HASH_KEY
:Crypto.hash_key k
IF
:if COND_EXPR then EXPR_IF_TRUE else EXPR_IF_FALSE
IF_CONS
:match list with [] -> EXPR | head :: tail -> EXPR
IF_LEFT
:match variant with Left x -> EXPR | Right x -> EXPR
IF_NONE
:match option with None -> EXPR | Some x -> EXPR
IMPLICIT_ACCOUNT
:Account.default
INT
:int x
ISNAT
:is_nat x
ormatch%int x with Plus x -> ... | Minus y -> ...
ITER
:List.iter
,Set.iter
,Map.iter
,List.fold
,Map.fold
LAMBDA
:fun x -> ...
LE
:x <= y
LEFT
:Left x
LOOP
:Loop.loop (fun x -> ...; (cond, x')) x0
LOOP_LEFT
:Loop.left (fun (x, acc) -> (Left x/Right res, acc)) x0 acc
LSL
:x lsl y
orx << y
LSR
:x lsr y
orx >> y
LT
:x < y
MAP
:List.map
,Map.map
,List.map_fold
,Map.map_fold
MEM
:Set.mem ele set
,Map.mem key map
MUL
:x * y
NEG
:~- x
NEQ
:x <> y
NIL
:( [] : int list)
NONE
:(None : int option)
NOT
:not x
NOW
:Current.time ()
OR
:x lor y
, orx || y
, orx or y
PACK
:Bytes.pack x
PAIR
:( x, y )
PUSH
,DIP
,DROP
,DIG
,DUG
,SWAP
: automatic stack managementRENAME
: automatic annotations managementRIGHT
:Right x
SENDER
:Current.sender()
SIZE
:List.size list
,String.size
,Bytes.size
,Set.size
SELF %e
:[%handle Self.e]
SET_DELEGATE
:Contract.set_delegate (Some keyhash)
SHA256
:Crypto.sha256 bytes
SHA512
:Crypto.sha512 bytes
SLICE
:String.sub pos len string
orBytes.sub
SOME
:Some x
SOURCE
:Current.source()
STEPS_TO_QUOTA
:Current.gas()
(deprecated, works for decompilation only)SUB
:x - y
TRANSFER_TOKENS
:Contract.call contract amount param
UNIT
:()
UNPACK
:(unpack bytes : int list option)
UPDATE
:Set.update key true set
orMap.update key (Some val) map
XOR
:x lxor y