From 5e06b9c719b7357043474e9ed51abe1f019fad53 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Mon, 16 Jan 2017 22:35:43 +0100 Subject: [PATCH] Michelson (docs): fixed reservoir example. --- src/proto/bootstrap/docs/language.md | 40 ++++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/proto/bootstrap/docs/language.md b/src/proto/bootstrap/docs/language.md index 93eca450e..4046c59f6 100644 --- a/src/proto/bootstrap/docs/language.md +++ b/src/proto/bootstrap/docs/language.md @@ -1400,21 +1400,33 @@ writen as pair timestamp tez pair (contract unit unit) (contract unit unit) -its code is +The complete source `reservoir.tz` is: - DUP ; CDAAR # T - NOW - COMPARE ; LE - IF { DUP ; CDADR # N - BALANCE - COMPARE ; LE - IF { } # nothing to do - { DUP ; CDDDR # B - BALANCE ; UNIT ; TRANSFER_TOKENS ; DROP } } - { DUP ; CDDAR ; # A - BALANCE ; - UNIT ; TRANSFER_TOKENS ; DROP } - CDR ; UNIT ; PAIR + parameter timestamp ; + storage + pair + (pair timestamp tez) # T N + (pair (contract unit unit) (contract unit unit)) ; # A B + return unit ; + code + { DUP ; CDAAR ; # T + NOW ; + COMPARE ; LE ; + IF { DUP ; CDADR ; # N + BALANCE ; + COMPARE ; LE ; + IF { CDR ; UNIT ; PAIR } + { DUP ; CDDDR ; # B + BALANCE ; UNIT ; + DIIIP { CDR } ; + TRANSFER_TOKENS ; + PAIR } } + { DUP ; CDDAR ; # A + BALANCE ; + UNIT ; + DIIIP { CDR } ; + TRANSFER_TOKENS ; + PAIR } } ### Reservoir contract (variant with broker and status)