From ed2541b1d29ad60e9538bef6c0c5c33957e410b7 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 24 Nov 2020 12:34:16 -0500 Subject: [PATCH 01/62] liquidity baking: initial commit --- .../lib_client/operation_result.ml | 2 + .../lib_delegate/client_baking_forge.ml | 41 +- .../lib_delegate/client_baking_forge.mli | 1 + src/proto_alpha/lib_delegate/client_daemon.ml | 3 +- .../lib_delegate/client_daemon.mli | 1 + .../lib_delegate/delegate_commands.ml | 16 +- src/proto_alpha/lib_parameters/cpmm.json | 2218 +++++++++++++++++ .../lib_parameters/default_parameters.ml | 88 +- src/proto_alpha/lib_parameters/dune | 4 +- .../lib_parameters/michelson_v1_macros.ml | 1542 ++++++++++++ .../lib_parameters/michelson_v1_macros.mli | 86 + .../lib_parameters/michelson_v1_parser.ml | 101 + .../lib_parameters/michelson_v1_parser.mli | 53 + src/proto_alpha/lib_protocol/TEZOS_PROTOCOL | 2 +- src/proto_alpha/lib_protocol/alpha_context.ml | 17 + .../lib_protocol/alpha_context.mli | 11 + src/proto_alpha/lib_protocol/apply.ml | 21 + src/proto_alpha/lib_protocol/baking.mli | 2 + .../lib_protocol/bootstrap_storage.ml | 38 +- .../lib_protocol/constants_repr.ml | 38 +- .../lib_protocol/constants_storage.ml | 8 + src/proto_alpha/lib_protocol/dune.inc | 25 +- src/proto_alpha/lib_protocol/init_storage.ml | 1 + .../lib_protocol/parameters_repr.ml | 21 +- .../lib_protocol/parameters_repr.mli | 3 +- src/proto_alpha/lib_protocol/raw_context.ml | 7 + src/proto_alpha/lib_protocol/raw_context.mli | 4 + src/proto_alpha/lib_protocol/roll_storage.ml | 10 + src/proto_alpha/lib_protocol/roll_storage.mli | 2 + src/proto_alpha/lib_protocol/storage.ml | 7 + src/proto_alpha/lib_protocol/storage.mli | 3 + .../lib_protocol/test/contracts/cpmm.tz | 1420 +++++++++++ 32 files changed, 5744 insertions(+), 52 deletions(-) create mode 100644 src/proto_alpha/lib_parameters/cpmm.json create mode 100644 src/proto_alpha/lib_parameters/michelson_v1_macros.ml create mode 100644 src/proto_alpha/lib_parameters/michelson_v1_macros.mli create mode 100644 src/proto_alpha/lib_parameters/michelson_v1_parser.ml create mode 100644 src/proto_alpha/lib_parameters/michelson_v1_parser.mli create mode 100644 src/proto_alpha/lib_protocol/test/contracts/cpmm.tz diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 80370e7c9d6f..b71dd260784c 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -159,6 +159,8 @@ let pp_balance_updates ppf = function Format.asprintf "fees(%a,%a)" pp_baker pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" pp_baker pkh Cycle.pp l + | Misc c -> + Format.asprintf "miscellaneous(%a)" Contract.pp c in let balance = match origin with diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index 2a3cba4ac8a4..c287d7b1bbb9 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -606,7 +606,8 @@ let error_of_op (result : error Preapply_result.t) op = let filter_and_apply_operations cctxt state ~chain ~block block_info ~priority ?protocol_data - ((operations : packed_operation list list), overflowing_operations) = + ((operations : packed_operation list list), overflowing_operations) + ~liquidity_baker_escape_flag = (* Retrieve the minimal valid time for when the block can be baked with 0 endorsements *) Delegate_services.Minimal_valid_time.get cctxt (chain, block) priority 0 >>=? fun min_valid_timestamp -> @@ -724,6 +725,19 @@ let filter_and_apply_operations cctxt state ~chain ~block block_info ~priority >>= fun (manager_inc, anonymous) -> filter_valid_operations manager_inc (managers @ overflowing_operations) >>= fun (inc, managers) -> + let inc = + { + inc with + state = + { + inc.state with + ctxt = + Protocol.Alpha_context.set_liquidity_baker_escape_flag + inc.state.ctxt + liquidity_baker_escape_flag; + }; + } + in finalize_construction inc >>=? fun _ -> let quota : Environment.Updater.quota list = Main.validation_passes in @@ -938,6 +952,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ~protocol_data bi (operations, overflowing_ops) + ~liquidity_baker_escape_flag:false >>=? fun ( final_context, (validation_result, _), operations, @@ -1172,7 +1187,8 @@ let fetch_operations (cctxt : #Protocol_client_context.full) ~chain with consistent operations that went through the client-side validation *) let build_block cctxt ~user_activated_upgrades state seed_nonce_hash - ((slot_timestamp, (bi, priority, delegate)) as slot) = + ((slot_timestamp, (bi, priority, delegate)) as slot) + ~liquidity_baker_escape_flag = let chain = `Hash bi.Client_baking_blocks.chain_id in let block = `Hash (bi.hash, 0) in Alpha_services.Helpers.current_level cctxt ~offset:1l (chain, block) @@ -1249,6 +1265,7 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash ~protocol_data bi (operations, overflowing_ops) + ~liquidity_baker_escape_flag >>= function | Error errs -> lwt_log_error @@ -1356,7 +1373,7 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash so. All the necessary information is available in the [state.best_slot]. *) let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades - ~chain state = + ~chain state ~liquidity_baker_escape_flag = ( match state.best_slot with | None -> assert false (* unreachable *) @@ -1365,7 +1382,13 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades >>=? fun slot -> let seed_nonce = generate_seed_nonce () in let seed_nonce_hash = Nonce.hash seed_nonce in - build_block cctxt ~user_activated_upgrades state seed_nonce_hash slot + build_block + cctxt + ~user_activated_upgrades + state + seed_nonce_hash + slot + ~liquidity_baker_escape_flag >>=? function | Some (head, priority, shell_header, operations, delegate, seed_nonce_hash) -> ( @@ -1589,7 +1612,8 @@ let reveal_potential_nonces (cctxt : #Client_context.full) constants ~chain the [delegates] *) let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?max_priority ~chain ~context_path delegates block_stream = + ?max_priority ~chain ~context_path delegates block_stream + ~liquidity_baker_escape_flag = let state_maker bi = Alpha_services.Constants.all cctxt (chain, `Head 0) >>=? fun constants -> @@ -1639,7 +1663,12 @@ let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades timeout ) in let timeout_k cctxt state () = - bake cctxt ~user_activated_upgrades ~chain state + bake + cctxt + ~user_activated_upgrades + ~chain + state + ~liquidity_baker_escape_flag >>= function | Error err -> if state.retry_counter = 0 then ( diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.mli b/src/proto_alpha/lib_delegate/client_baking_forge.mli index 508e06a270e7..793ed049e513 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.mli +++ b/src/proto_alpha/lib_delegate/client_baking_forge.mli @@ -103,4 +103,5 @@ val create : context_path:string -> public_key_hash list -> Client_baking_blocks.block_info tzresult Lwt_stream.t -> + liquidity_baker_escape_flag:bool -> unit tzresult Lwt.t diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index ba9385171187..e67f52a4fb45 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -94,7 +94,7 @@ end module Baker = struct let run (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~chain ~context_path ~keep_alive delegates = + ~chain ~context_path ~keep_alive ~liquidity_baker_escape_flag delegates = let process () = Config_services.user_activated_upgrades cctxt >>=? fun user_activated_upgrades -> @@ -116,6 +116,7 @@ module Baker = struct ~context_path delegates block_stream + ~liquidity_baker_escape_flag in Client_confirmations.wait_for_bootstrapped ~retry:(retry cctxt ~delay:1. ~factor:1.5 ~tries:5) diff --git a/src/proto_alpha/lib_delegate/client_daemon.mli b/src/proto_alpha/lib_delegate/client_daemon.mli index 410e71670ec9..86b5f1684fc4 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.mli +++ b/src/proto_alpha/lib_delegate/client_daemon.mli @@ -46,6 +46,7 @@ module Baker : sig chain:Chain_services.chain -> context_path:string -> keep_alive:bool -> + liquidity_baker_escape_flag:bool -> public_key_hash list -> unit tzresult Lwt.t end diff --git a/src/proto_alpha/lib_delegate/delegate_commands.ml b/src/proto_alpha/lib_delegate/delegate_commands.ml index f7bcf06e678c..8219f8e258ee 100644 --- a/src/proto_alpha/lib_delegate/delegate_commands.ml +++ b/src/proto_alpha/lib_delegate/delegate_commands.ml @@ -236,6 +236,13 @@ let delegate_commands () = block_hashes >>= fun () -> return_unit)) ] +let liquidity_baker_escape_flag = + Clic.switch + ~doc:"Vote to stop the liquidity baker subsidy." + ~short:'F' + ~long:"liquidity-baker-escape-flag" + () + let baker_commands () = let open Clic in let group = @@ -247,13 +254,14 @@ let baker_commands () = [ command ~group ~desc:"Launch the baker daemon." - (args6 + (args7 pidfile_arg max_priority_arg minimal_fees_arg minimal_nanotez_per_gas_unit_arg minimal_nanotez_per_byte_arg - keep_alive_arg) + keep_alive_arg + liquidity_baker_escape_flag) ( prefixes ["run"; "with"; "local"; "node"] @@ param ~name:"context_path" @@ -265,7 +273,8 @@ let baker_commands () = minimal_fees, minimal_nanotez_per_gas_unit, minimal_nanotez_per_byte, - keep_alive ) + keep_alive, + liquidity_baker_escape_flag ) node_path delegates cctxt -> @@ -284,6 +293,7 @@ let baker_commands () = ?max_priority ~context_path:(Filename.concat node_path "context") ~keep_alive + ~liquidity_baker_escape_flag (List.map snd delegates)) ] let endorser_commands () = diff --git a/src/proto_alpha/lib_parameters/cpmm.json b/src/proto_alpha/lib_parameters/cpmm.json new file mode 100644 index 000000000000..642bcd43298d --- /dev/null +++ b/src/proto_alpha/lib_parameters/cpmm.json @@ -0,0 +1,2218 @@ +[ { "prim": "parameter", + "args": + [ { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, + { "prim": "timestamp" } ] } ], + "annots": [ "%addLiquidity" ] }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, { "prim": "nat" } ] } ], + "annots": [ "%approve" ] } ] }, + { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "mutez" }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, + { "prim": "timestamp" } ] } ] } ], + "annots": [ "%removeLiquidity" ] }, + { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "address" } ] }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, + { "prim": "pair", + "args": + [ { "prim": "mutez" }, + { "prim": "timestamp" } ] } ] } ], + "annots": [ "%tokenToXtz" ] } ] } ] }, + { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "key_hash", + "annots": [ "%updateTokenPool" ] }, + { "prim": "nat", + "annots": [ "%updateTokenPoolInternal" ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, { "prim": "timestamp" } ] } ], + "annots": [ "%xtzToToken" ] } ] } ] } ] }, + { "prim": "storage", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "big_map", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "map", + "args": + [ { "prim": "address" }, { "prim": "nat" } ], + "annots": [ "%allowances" ] }, + { "prim": "nat", "annots": [ "%balance" ] } ] } ], + "annots": [ "%accounts" ] }, + { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "nat", "annots": [ "%lqt_total" ] }, + { "prim": "bool", + "annots": [ "%self_is_updating_token_pool" ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", "annots": [ "%token_pool" ] }, + { "prim": "mutez", "annots": [ "%xtz_pool" ] } ] } ], + "annots": [ "%s" ] } ] } ] }, + { "prim": "code", + "args": + [ [ { "prim": "EMPTY_MAP", + "args": [ { "prim": "address" }, { "prim": "nat" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "address" }, + { "string": "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" } ] }, + { "prim": "LAMBDA", + "args": + [ { "prim": "mutez" }, { "prim": "nat" }, + [ { "prim": "PUSH", + "args": [ { "prim": "mutez" }, { "int": "1" } ] }, + { "prim": "SWAP" }, { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "LAMBDA", + "args": + [ { "prim": "nat" }, { "prim": "mutez" }, + [ { "prim": "PUSH", + "args": [ { "prim": "mutez" }, { "int": "1" } ] }, + { "prim": "SWAP" }, { "prim": "MUL" } ] ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "4" } ] }, + { "prim": "LAMBDA", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "map", + "args": [ { "prim": "address" }, { "prim": "nat" } ] }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "big_map", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "map", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] }, + { "prim": "nat" } ] } ] } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "map", + "args": [ { "prim": "address" }, { "prim": "nat" } ] }, + { "prim": "nat" } ] }, + [ { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "CDR" }, { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "PAIR" } ], + [ { "prim": "SWAP" }, { "prim": "DROP" } ] ] } ] ] }, + { "prim": "SWAP" }, { "prim": "APPLY" }, + { "prim": "DIG", "args": [ { "int": "5" } ] }, { "prim": "DUP" }, + { "prim": "CDR" }, { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "self_is_updating_token_pool must be false" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, { "prim": "NOW" }, + { "prim": "COMPARE" }, { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The current time must be less than the deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "max_tokens_deposited must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The amount of XTZ sent to the contract to be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "min_lqt_minted must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CAR" }, { "prim": "COMPARE" }, + { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": "DIG", + "args": [ { "int": "7" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "7" } ] }, + { "prim": "SWAP" }, + { "prim": "EXEC" }, + { "prim": "AMOUNT" }, + { "prim": "DIG", + "args": [ { "int": "7" } ] }, + { "prim": "SWAP" }, + { "prim": "EXEC" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "7" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": + [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "CAR" } ], + [ { "prim": "PUSH", + "args": + [ { "prim": + "nat" }, + { "int": "1" } ] }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "ADD" } ] ] } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, + { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "tokens_deposited must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "max_tokens_deposited must be greater than or equal to tokens_deposited." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "6" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "lqt_minted must be greater than min_lqt_minted." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, + { "prim": "EXEC" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "ADD" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "6" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "6" } ] }, + { "prim": "SWAP" }, + { "prim": "SOME" }, + { "prim": "SWAP" }, + { "prim": "UPDATE" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "ADD" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "ADD" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "AMOUNT" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "ADD" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "SWAP" }, + { "prim": "NIL", + "args": + [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, + { "prim": "PAIR" } ], + [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1000000" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The initial liquidity amount must be greater than or equal to zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "AMOUNT" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "ADD" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "SWAP" }, + { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, + { "prim": "SOME" }, + { "prim": "SWAP" }, + { "prim": "UPDATE" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "AMOUNT" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "ADD" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "SWAP" }, + { "prim": "NIL", + "args": + [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, + { "prim": "PAIR" } ] ] } ], + [ { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "self_is_updating_token_pool must be false" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "amount must be zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "SENDER" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "DUP" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "6" } ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] } ], [] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "COMPARE" }, { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "SWAP" }, + { "prim": "SOME" }, + { "prim": "SWAP" }, + { "prim": "UPDATE" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, + { "prim": "SOME" }, + { "prim": "SENDER" }, + { "prim": "UPDATE" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" } ], + [ { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "current_allowance must equal account.allowances[spender]." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "CDR" }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } ] ] } ], + [ { "prim": "DIG", "args": [ { "int": "6" } ] }, + { "prim": "DROP" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "self_is_updating_token_pool must be false" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, { "prim": "NOW" }, + { "prim": "COMPARE" }, { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The current time must be less than the deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "amount must be zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "min_xtz_withdrawn must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "min_tokens_withdrawn must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "lqt_burned must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "7" } ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The owner does not have any liquidity in this contract." } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "7" } ] }, + { "prim": "SENDER" }, + { "prim": "COMPARE" }, + { "prim": "NEQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "SENDER" }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "The sender does not have an allowance from the give owner in this contract." } ] }, + { "prim": + "FAILWITH" } ], + [ { "prim": "DIG", + "args": + [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DUP" }, + { "prim": "DIG", + "args": + [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": + [ { "int": "6" } ] }, + { "prim": "COMPARE" }, + { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": + "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "lqt_burned cannot be greater than the sender's allowance." } ] }, + { "prim": + "FAILWITH" } ], + [] ] } ] ] } ], + [ { "prim": "SWAP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "PAIR" } ] ] }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "lqt_burned cannot be greater than the owner's balance." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "11" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "6" } ] }, + { "prim": "MUL" }, { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "9" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The amount of xtz withdrawn must be greater than or equal to min_xtz_withdrawn." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "7" } ] }, + { "prim": "MUL" }, { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The amount of tokens withdrawn must be greater than or equal to min_tokens_withdrawn." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "7" } ] }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "8" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "9" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "6" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "SUB" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [ { "prim": "ABS" } ], + [ { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "account.balance - lqt_burned resulted in a negative number." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "6" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "7" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "8" } ] }, + { "prim": "SWAP" }, { "prim": "SOME" }, + { "prim": "SWAP" }, { "prim": "UPDATE" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CAR" }, { "prim": "SUB" }, + { "prim": "DROP" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "SUB" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [ { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "ABS" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" } ], + [ { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "storage.s.token_pool - tokens_withdrawn resulted in a negative number." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "SENDER" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "7" } ] }, + { "prim": "COMPARE" }, { "prim": "NEQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "SUB" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, + { "int": "0" } ] }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [ { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": + [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": + [ { "int": "5" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": + [ { "int": "6" } ] }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": + [ { "int": "7" } ] }, + { "prim": "SWAP" }, + { "prim": "EXEC" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": + [ { "int": "2" } ] }, + { "prim": "ABS" }, + { "prim": "SOME" }, + { "prim": "SENDER" }, + { "prim": "UPDATE" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": + [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": + [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": + [ { "int": "2" } ] }, + { "prim": "DIG", + "args": + [ { "int": "5" } ] }, + { "prim": "SWAP" }, + { "prim": "SOME" }, + { "prim": "SWAP" }, + { "prim": "UPDATE" }, + { "prim": "PAIR" } ], + [ { "prim": "DROP" }, + { "prim": "DIG", + "args": + [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": + [ { "int": "4" } ] }, + { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "sender_allowance - lqt_burned resulted in a negative number" } ] }, + { "prim": "FAILWITH" } ] ] } ], + [ { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DROP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "SUB" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CONTRACT", + "args": [ { "prim": "unit" } ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_contract" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "UNIT" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "PAIR" }, { "prim": "SELF" }, + { "prim": "ADDRESS" }, { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, { "prim": "PAIR" } ], + [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "self_is_updating_token_pool must be false" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "NOW" }, { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The current time must be less than the deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "amount must be zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "tokens_sold must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "min_xtz_bought must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "xtz_pool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "token_pool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "999" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "MUL" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "1000" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "MUL" }, + { "prim": "ADD" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "8" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "999" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "MUL" }, { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "6" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "xtz_bought must be greater than or equal to min_xtz_bought." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "ADD" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "SUB" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CONTRACT", + "args": [ { "prim": "unit" } ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_contract" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "UNIT" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "SELF" }, { "prim": "ADDRESS" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ], + [ { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", "args": [ { "int": "4" } ] }, + { "prim": "DROP" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "IMPLICIT_ACCOUNT" }, + { "prim": "ADDRESS" }, + { "prim": "SENDER" }, + { "prim": "COMPARE" }, { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "SELF", + "annots": + [ "%updateTokenPoolInternal" ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "contract", + "args": + [ { "prim": "nat" } ] } ] } ], + "annots": [ "%getBalance" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "bool" }, + { "prim": "True" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "NIL", + "args": + [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, + { "prim": "PAIR" } ], + [ { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "UnsafeUpdateTokenPool" } ] }, + { "prim": "FAILWITH" } ] ] } ], + [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "SENDER" }, + { "prim": "COMPARE" }, { "prim": "NEQ" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, { "prim": "NOT" }, + { "prim": "OR" }, + { "prim": "IF", + "args": + [ [ { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "This entrypoint may only be called by dexter itself via getBalance of tokenAddress." } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "bool" }, + { "prim": "False" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" } ] ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } ] ] } ], + [ { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "self_is_updating_token_pool must be false" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "NOW" }, { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The current time must be less than the deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "AMOUNT" }, { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "amount must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "4" } ] }, + { "prim": "COMPARE" }, { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "min_tokens_bought must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "xtz_pool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "token_pool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "DIG", "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "AMOUNT" }, + { "prim": "DIG", "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "999" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "MUL" }, + { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "1000" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "MUL" }, { "prim": "ADD" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "999" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "MUL" }, { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "tokens_bought must be greater than or equal to min_tokens_bought." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "SUB" }, + { "prim": "PUSH", + "args": [ { "prim": "int" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "SWAP" }, + { "prim": "ABS" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "PAIR" } ], + [ { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "token_pool - tokens_bought is negative." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "AMOUNT" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "ADD" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DIG", "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, { "prim": "SELF" }, + { "prim": "ADDRESS" }, { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, { "prim": "SWAP" }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ] ] } ] + diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 88537b786d65..abe7da4841de 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -56,6 +56,12 @@ let constants_mainnet = min_proposal_quorum = 5_00l; initial_endorsers = 24; delay_per_missing_endorsement = Period.of_seconds_exn 8L; + liquidity_baker_origination_nonce = + (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) + Contract_repr.initial_origination_nonce Operation_hash.zero; + (* now + six months *) + (* MUST BE ADJUSTED PRIOR TO INJECTION !!! *) + liquidity_baker_sunset = Int32.add 1292070l 262800l; } let constants_sandbox = @@ -71,6 +77,7 @@ let constants_sandbox = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; + liquidity_baker_sunset = 64l; } let constants_test = @@ -85,14 +92,16 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; + liquidity_baker_sunset = 64l; } let bootstrap_accounts_strings = [ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"; "edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9"; "edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV"; - "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU"; - "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" ] + "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" ] + +(* "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" ] *) let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L @@ -109,6 +118,78 @@ let bootstrap_accounts = }) bootstrap_accounts_strings +let bootstrap_contracts_strings = + [ ( None, + 4_000_000_000_000L, + (* 20% of outstanding tez *) + "cpmm.json", + "4000000000000", + Contract_repr.initial_origination_nonce Operation_hash.zero ) ] + +(* let parse source = + * Michelson_v1_parser.parse_toplevel ?check:(Some true) source + * |> Tezos_micheline.Micheline_parser.no_parsing_error + * |> function + * | Error _ -> + * assert false + * | Ok parsing_result -> + * parsing_result.Michelson_v1_parser.expanded *) + +let parse_storage source = + Michelson_v1_parser.parse_expression ?check:(Some true) source + |> Tezos_micheline.Micheline_parser.no_parsing_error + |> function + | Error _ -> + assert false + | Ok parsing_result -> + parsing_result.Michelson_v1_parser.expanded + +exception Failed of string + +let fail_awakener = ref None + +let fail x = + Printf.ksprintf + (fun message -> + ( match !fail_awakener with + | None -> + () + | Some awakener -> + fail_awakener := None ; + Lwt.wakeup_later_exn awakener (Failed message) ) ; + raise (Failed message)) + x + +let parse_file file = + let with_open_in file read_f = + let chan = open_in file in + try + let value = read_f chan in + close_in chan ; value + with x -> close_in chan ; raise x + in + try with_open_in file (fun chan -> Ezjsonm.from_channel chan) + with Ezjsonm.Parse_error (_, message) -> + fail "%s: invalid JSON: %s" file message + +let bootstrap_contracts = + List.map + (fun (d, a, sc, st, n) -> + let amount = Tez_repr.of_mutez_exn a in + let code = parse_file sc in + let script = + Script_repr. + { + code = + Script_repr.lazy_expr + (Data_encoding.Json.destruct Script_repr.expr_encoding code); + storage = Script_repr.lazy_expr (parse_storage st); + } + in + Parameters_repr. + {delegate = d; amount; script; origination_nonce = Some n}) + bootstrap_contracts_strings + (* TODO this could be generated from OCaml together with the faucet for now these are hardcoded values in the tests *) let commitments = @@ -138,7 +219,8 @@ let make_bootstrap_account (pkh, pk, amount) = Parameters.{public_key_hash = pkh; public_key = Some pk; amount} let parameters_of_constants ?(bootstrap_accounts = bootstrap_accounts) - ?(bootstrap_contracts = []) ?(with_commitments = false) constants = + ?(bootstrap_contracts = bootstrap_contracts) ?(with_commitments = false) + constants = let commitments = if with_commitments then commitments else [] in Parameters. { diff --git a/src/proto_alpha/lib_parameters/dune b/src/proto_alpha/lib_parameters/dune index 590563d8068d..a33342f225e8 100644 --- a/src/proto_alpha/lib_parameters/dune +++ b/src/proto_alpha/lib_parameters/dune @@ -4,9 +4,11 @@ (modules :standard \ gen) (libraries tezos-base tezos-protocol-environment - tezos-protocol-alpha) + tezos-protocol-alpha + tezos-micheline) (flags (:standard -open Tezos_base__TzPervasives -open Tezos_protocol_alpha + -open Tezos_micheline -linkall)) ) diff --git a/src/proto_alpha/lib_parameters/michelson_v1_macros.ml b/src/proto_alpha/lib_parameters/michelson_v1_macros.ml new file mode 100644 index 000000000000..a2e1bb897b08 --- /dev/null +++ b/src/proto_alpha/lib_parameters/michelson_v1_macros.ml @@ -0,0 +1,1542 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2019 Nomadic Labs *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Tezos_micheline +open Micheline +module IntMap = Map.Make (Compare.Int) + +type 'l node = ('l, string) Micheline.node + +type error += Unexpected_macro_annotation of string + +type error += Sequence_expected of string + +type error += Invalid_arity of string * int * int + +let rec check_letters str i j f = + i > j || (f str.[i] && check_letters str (i + 1) j f) + +let expand_caddadr original = + match original with + | Prim (loc, str, args, annot) -> + let len = String.length str in + if + len > 3 + && str.[0] = 'C' + && str.[len - 1] = 'R' + && check_letters str 1 (len - 2) (function + | 'A' | 'D' -> + true + | _ -> + false) + then + ( match args with + | [] -> + ok () + | _ :: _ -> + error (Invalid_arity (str, List.length args, 0)) ) + >>? fun () -> + let path_annot = + List.filter (function "@%" | "@%%" -> true | _ -> false) annot + in + let rec parse i acc = + if i = 0 then Seq (loc, acc) + else + let annot = if i = len - 2 then annot else path_annot in + match str.[i] with + | 'A' -> + parse (i - 1) (Prim (loc, "CAR", [], annot) :: acc) + | 'D' -> + parse (i - 1) (Prim (loc, "CDR", [], annot) :: acc) + | _ -> + assert false + in + ok (Some (parse (len - 2) [])) + else ok None + | _ -> + ok None + +let expand_carn original = + match original with + | Prim (loc, "CAR", [Int (loc2, n)], annot) -> + ok + (Some + (Seq + ( loc, + [ Prim + ( loc, + "GET", + [Int (loc2, Z.(of_int 1 + (n * of_int 2)))], + annot ) ] ))) + | _ -> + ok None + +let expand_cdrn original = + match original with + | Prim (loc, "CDR", [Int (loc2, n)], annot) -> + ok + (Some + (Seq + (loc, [Prim (loc, "GET", [Int (loc2, Z.(n * of_int 2))], annot)]))) + | _ -> + ok None + +let extract_field_annots annot = + List.partition + (fun a -> + match a.[0] with + | '%' -> + true + | _ -> + false + | exception Invalid_argument _ -> + false) + annot + +let expand_set_caddadr original = + match original with + | Prim (loc, str, args, annot) -> + let len = String.length str in + if + len >= 7 + && String.sub str 0 5 = "SET_C" + && str.[len - 1] = 'R' + && check_letters str 5 (len - 2) (function + | 'A' | 'D' -> + true + | _ -> + false) + then + ( match args with + | [] -> + ok () + | _ :: _ -> + error (Invalid_arity (str, List.length args, 0)) ) + >>? fun () -> + ( match extract_field_annots annot with + | ([], annot) -> + ok (None, annot) + | ([f], annot) -> + ok (Some f, annot) + | (_, _) -> + error (Unexpected_macro_annotation str) ) + >>? fun (field_annot, annot) -> + let rec parse i acc = + if i = 4 then acc + else + let annot = if i = 5 then annot else [] in + match str.[i] with + | 'A' -> + let acc = + Seq + ( loc, + [ Prim (loc, "DUP", [], []); + Prim + ( loc, + "DIP", + [Seq (loc, [Prim (loc, "CAR", [], ["@%%"]); acc])], + [] ); + Prim (loc, "CDR", [], ["@%%"]); + Prim (loc, "SWAP", [], []); + Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) + in + parse (i - 1) acc + | 'D' -> + let acc = + Seq + ( loc, + [ Prim (loc, "DUP", [], []); + Prim + ( loc, + "DIP", + [Seq (loc, [Prim (loc, "CDR", [], ["@%%"]); acc])], + [] ); + Prim (loc, "CAR", [], ["@%%"]); + Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) + in + parse (i - 1) acc + | _ -> + assert false + in + match str.[len - 2] with + | 'A' -> + let access_check = + match field_annot with + | None -> + [] + | Some f -> + [ Prim (loc, "DUP", [], []); + Prim (loc, "CAR", [], [f]); + Prim (loc, "DROP", [], []) ] + in + let encoding = + [Prim (loc, "CDR", [], ["@%%"]); Prim (loc, "SWAP", [], [])] + in + let pair = + [ Prim + ( loc, + "PAIR", + [], + [Option.value field_annot ~default:"%"; "%@"] ) ] + in + let init = Seq (loc, access_check @ encoding @ pair) in + ok (Some (parse (len - 3) init)) + | 'D' -> + let access_check = + match field_annot with + | None -> + [] + | Some f -> + [ Prim (loc, "DUP", [], []); + Prim (loc, "CDR", [], [f]); + Prim (loc, "DROP", [], []) ] + in + let encoding = [Prim (loc, "CAR", [], ["@%%"])] in + let pair = + [ Prim + ( loc, + "PAIR", + [], + ["%@"; Option.value field_annot ~default:"%"] ) ] + in + let init = Seq (loc, access_check @ encoding @ pair) in + ok (Some (parse (len - 3) init)) + | _ -> + assert false + else ok None + | _ -> + ok None + +let expand_map_caddadr original = + match original with + | Prim (loc, str, args, annot) -> + let len = String.length str in + if + len >= 7 + && String.sub str 0 5 = "MAP_C" + && str.[len - 1] = 'R' + && check_letters str 5 (len - 2) (function + | 'A' | 'D' -> + true + | _ -> + false) + then + ( match args with + | [(Seq _ as code)] -> + ok code + | [_] -> + error (Sequence_expected str) + | [] | _ :: _ :: _ -> + error (Invalid_arity (str, List.length args, 1)) ) + >>? fun code -> + ( match extract_field_annots annot with + | ([], annot) -> + ok (None, annot) + | ([f], annot) -> + ok (Some f, annot) + | (_, _) -> + error (Unexpected_macro_annotation str) ) + >>? fun (field_annot, annot) -> + let rec parse i acc = + if i = 4 then acc + else + let annot = if i = 5 then annot else [] in + match str.[i] with + | 'A' -> + let acc = + Seq + ( loc, + [ Prim (loc, "DUP", [], []); + Prim + ( loc, + "DIP", + [Seq (loc, [Prim (loc, "CAR", [], ["@%%"]); acc])], + [] ); + Prim (loc, "CDR", [], ["@%%"]); + Prim (loc, "SWAP", [], []); + Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) + in + parse (i - 1) acc + | 'D' -> + let acc = + Seq + ( loc, + [ Prim (loc, "DUP", [], []); + Prim + ( loc, + "DIP", + [Seq (loc, [Prim (loc, "CDR", [], ["@%%"]); acc])], + [] ); + Prim (loc, "CAR", [], ["@%%"]); + Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) + in + parse (i - 1) acc + | _ -> + assert false + in + let cr_annot = + match field_annot with + | None -> + [] + | Some f -> + ["@" ^ String.sub f 1 (String.length f - 1)] + in + match str.[len - 2] with + | 'A' -> + let init = + Seq + ( loc, + [ Prim (loc, "DUP", [], []); + Prim (loc, "CDR", [], ["@%%"]); + Prim + ( loc, + "DIP", + [Seq (loc, [Prim (loc, "CAR", [], cr_annot); code])], + [] ); + Prim (loc, "SWAP", [], []); + Prim + ( loc, + "PAIR", + [], + [Option.value field_annot ~default:"%"; "%@"] ) ] ) + in + ok (Some (parse (len - 3) init)) + | 'D' -> + let init = + Seq + ( loc, + [ Prim (loc, "DUP", [], []); + Prim (loc, "CDR", [], cr_annot); + code; + Prim (loc, "SWAP", [], []); + Prim (loc, "CAR", [], ["@%%"]); + Prim + ( loc, + "PAIR", + [], + ["%@"; Option.value field_annot ~default:"%"] ) ] ) + in + ok (Some (parse (len - 3) init)) + | _ -> + assert false + else ok None + | _ -> + ok None + +exception Not_a_roman + +let decimal_of_roman roman = + (* http://rosettacode.org/wiki/Roman_numerals/Decode#OCaml *) + let arabic = ref 0 in + let lastval = ref 0 in + for i = String.length roman - 1 downto 0 do + let n = + match roman.[i] with + | 'M' -> + 1000 + | 'D' -> + 500 + | 'C' -> + 100 + | 'L' -> + 50 + | 'X' -> + 10 + | 'V' -> + 5 + | 'I' -> + 1 + | _ -> + raise_notrace Not_a_roman + in + if Compare.Int.(n < !lastval) then arabic := !arabic - n + else arabic := !arabic + n ; + lastval := n + done ; + !arabic + +let dip ~loc ?(annot = []) depth instr = + assert (depth >= 0) ; + if depth = 1 then Prim (loc, "DIP", [instr], annot) + else Prim (loc, "DIP", [Int (loc, Z.of_int depth); instr], annot) + +let expand_deprecated_dxiiivp original = + (* transparently expands deprecated macro [DI...IP] to instruction [DIP n] *) + match original with + | Prim (loc, str, args, annot) -> + let len = String.length str in + if len > 3 && str.[0] = 'D' && str.[len - 1] = 'P' then + try + let depth = decimal_of_roman (String.sub str 1 (len - 2)) in + match args with + | [(Seq (_, _) as arg)] -> + ok @@ Some (dip ~loc ~annot depth arg) + | [_] -> + error (Sequence_expected str) + | [] | _ :: _ :: _ -> + error (Invalid_arity (str, List.length args, 1)) + with Not_a_roman -> ok None + else ok None + | _ -> + ok None + +exception Not_a_pair + +type pair_item = A | I | P of int * pair_item * pair_item + +let parse_pair_substr str ~len start = + let rec parse ?left i = + if i = len - 1 then raise_notrace Not_a_pair + else if str.[i] = 'P' then + let (next_i, l) = parse ~left:true (i + 1) in + let (next_i, r) = parse ~left:false next_i in + (next_i, P (i, l, r)) + else if str.[i] = 'A' && left = Some true then (i + 1, A) + else if str.[i] = 'I' && left <> Some true then (i + 1, I) + else raise_notrace Not_a_pair + in + let (last, ast) = parse start in + if last <> len - 1 then raise_notrace Not_a_pair else ast + +let unparse_pair_item ast = + let rec unparse ast acc = + match ast with + | P (_, l, r) -> + unparse r (unparse l ("P" :: acc)) + | A -> + "A" :: acc + | I -> + "I" :: acc + in + List.rev ("R" :: unparse ast []) |> String.concat "" + +let pappaiir_annots_pos ast annot = + let rec find_annots_pos p_pos ast annots acc = + match (ast, annots) with + | (_, []) -> + (annots, acc) + | (P (i, left, right), _) -> + let (annots, acc) = find_annots_pos i left annots acc in + find_annots_pos i right annots acc + | (A, a :: annots) -> + let pos = + match IntMap.find p_pos acc with + | None -> + ([a], []) + | Some (_, cdr) -> + ([a], cdr) + in + (annots, IntMap.add p_pos pos acc) + | (I, a :: annots) -> + let pos = + match IntMap.find p_pos acc with + | None -> + ([], [a]) + | Some (car, _) -> + (car, [a]) + in + (annots, IntMap.add p_pos pos acc) + in + snd (find_annots_pos 0 ast annot IntMap.empty) + +let expand_pappaiir original = + match original with + | Prim (loc, str, args, annot) -> + let len = String.length str in + if + len > 4 + && str.[0] = 'P' + && str.[len - 1] = 'R' + && check_letters str 1 (len - 2) (function + | 'P' | 'A' | 'I' -> + true + | _ -> + false) + then + try + let (field_annots, annot) = extract_field_annots annot in + let ast = parse_pair_substr str ~len 0 in + let field_annots_pos = pappaiir_annots_pos ast field_annots in + let rec parse p (depth, acc) = + match p with + | P (i, left, right) -> + let annot = + match (i, IntMap.find i field_annots_pos) with + | (0, None) -> + annot + | (_, None) -> + [] + | (0, Some ([], cdr_annot)) -> + ("%" :: cdr_annot) @ annot + | (_, Some ([], cdr_annot)) -> + "%" :: cdr_annot + | (0, Some (car_annot, cdr_annot)) -> + car_annot @ cdr_annot @ annot + | (_, Some (car_annot, cdr_annot)) -> + car_annot @ cdr_annot + in + let acc = + if depth = 0 then Prim (loc, "PAIR", [], annot) :: acc + else + dip ~loc depth (Seq (loc, [Prim (loc, "PAIR", [], annot)])) + :: acc + in + (depth, acc) |> parse left |> parse right + | A | I -> + (depth + 1, acc) + in + let (_, expanded) = parse ast (0, []) in + ( match args with + | [] -> + ok () + | _ :: _ -> + error (Invalid_arity (str, List.length args, 0)) ) + >>? fun () -> ok (Some (Seq (loc, expanded))) + with Not_a_pair -> ok None + else ok None + | _ -> + ok None + +let expand_unpappaiir original = + match original with + | Prim (loc, str, args, _annot) -> + let len = String.length str in + if + len > 6 + && String.sub str 0 3 = "UNP" + && str.[len - 1] = 'R' + && check_letters str 3 (len - 2) (function + | 'P' | 'A' | 'I' -> + true + | _ -> + false) + then + try + let unpair = Prim (loc, "UNPAIR", [], []) in + let ast = parse_pair_substr str ~len 2 in + let rec parse p (depth, acc) = + match p with + | P (_i, left, right) -> + let acc = + if depth = 0 then unpair :: acc + else dip ~loc depth (Seq (loc, [unpair])) :: acc + in + (depth, acc) |> parse left |> parse right + | A | I -> + (depth + 1, acc) + in + let (_, rev_expanded) = parse ast (0, []) in + let expanded = Seq (loc, List.rev rev_expanded) in + ( match args with + | [] -> + ok () + | _ :: _ -> + error (Invalid_arity (str, List.length args, 0)) ) + >>? fun () -> ok (Some expanded) + with Not_a_pair -> ok None + else ok None + | _ -> + ok None + +exception Not_a_dup + +let expand_deprecated_duuuuup original = + (* transparently expands deprecated macro [DU...UP] to [{ DUP n }] *) + match original with + | Prim (loc, str, args, annot) -> + let len = String.length str in + if + len > 3 + && str.[0] = 'D' + && str.[len - 1] = 'P' + && check_letters str 1 (len - 2) (( = ) 'U') + then + ( match args with + | [] -> + ok () + | _ :: _ -> + error (Invalid_arity (str, List.length args, 0)) ) + >>? fun () -> + try + let rec parse i = + if i = 1 then + Prim (loc, "DUP", [Int (loc, Z.of_int (len - 2))], annot) + else if str.[i] = 'U' then parse (i - 1) + else raise_notrace Not_a_dup + in + ok (Some (parse (len - 2))) + with Not_a_dup -> ok None + else ok None + | _ -> + ok None + +let expand_compare original = + let cmp loc is annot = + let is = + match List.rev_map (fun i -> Prim (loc, i, [], [])) is with + | Prim (loc, i, args, _) :: r -> + List.rev (Prim (loc, i, args, annot) :: r) + | is -> + List.rev is + in + ok (Some (Seq (loc, is))) + in + let ifcmp loc is l r annot = + let is = + List.map (fun i -> Prim (loc, i, [], [])) is + @ [Prim (loc, "IF", [l; r], annot)] + in + ok (Some (Seq (loc, is))) + in + match original with + | Prim (loc, "CMPEQ", [], annot) -> + cmp loc ["COMPARE"; "EQ"] annot + | Prim (loc, "CMPNEQ", [], annot) -> + cmp loc ["COMPARE"; "NEQ"] annot + | Prim (loc, "CMPLT", [], annot) -> + cmp loc ["COMPARE"; "LT"] annot + | Prim (loc, "CMPGT", [], annot) -> + cmp loc ["COMPARE"; "GT"] annot + | Prim (loc, "CMPLE", [], annot) -> + cmp loc ["COMPARE"; "LE"] annot + | Prim (loc, "CMPGE", [], annot) -> + cmp loc ["COMPARE"; "GE"] annot + | Prim + ( _, + (("CMPEQ" | "CMPNEQ" | "CMPLT" | "CMPGT" | "CMPLE" | "CMPGE") as str), + args, + [] ) -> + error (Invalid_arity (str, List.length args, 0)) + | Prim (loc, "IFCMPEQ", [l; r], annot) -> + ifcmp loc ["COMPARE"; "EQ"] l r annot + | Prim (loc, "IFCMPNEQ", [l; r], annot) -> + ifcmp loc ["COMPARE"; "NEQ"] l r annot + | Prim (loc, "IFCMPLT", [l; r], annot) -> + ifcmp loc ["COMPARE"; "LT"] l r annot + | Prim (loc, "IFCMPGT", [l; r], annot) -> + ifcmp loc ["COMPARE"; "GT"] l r annot + | Prim (loc, "IFCMPLE", [l; r], annot) -> + ifcmp loc ["COMPARE"; "LE"] l r annot + | Prim (loc, "IFCMPGE", [l; r], annot) -> + ifcmp loc ["COMPARE"; "GE"] l r annot + | Prim (loc, "IFEQ", [l; r], annot) -> + ifcmp loc ["EQ"] l r annot + | Prim (loc, "IFNEQ", [l; r], annot) -> + ifcmp loc ["NEQ"] l r annot + | Prim (loc, "IFLT", [l; r], annot) -> + ifcmp loc ["LT"] l r annot + | Prim (loc, "IFGT", [l; r], annot) -> + ifcmp loc ["GT"] l r annot + | Prim (loc, "IFLE", [l; r], annot) -> + ifcmp loc ["LE"] l r annot + | Prim (loc, "IFGE", [l; r], annot) -> + ifcmp loc ["GE"] l r annot + | Prim + ( _, + ( ( "IFCMPEQ" + | "IFCMPNEQ" + | "IFCMPLT" + | "IFCMPGT" + | "IFCMPLE" + | "IFCMPGE" + | "IFEQ" + | "IFNEQ" + | "IFLT" + | "IFGT" + | "IFLE" + | "IFGE" ) as str ), + args, + [] ) -> + error (Invalid_arity (str, List.length args, 2)) + | Prim + ( _, + ( ( "IFCMPEQ" + | "IFCMPNEQ" + | "IFCMPLT" + | "IFCMPGT" + | "IFCMPLE" + | "IFCMPGE" + | "IFEQ" + | "IFNEQ" + | "IFLT" + | "IFGT" + | "IFLE" + | "IFGE" ) as str ), + [], + _ :: _ ) -> + error (Unexpected_macro_annotation str) + | _ -> + ok None + +let expand_asserts original = + let may_rename loc = function + | [] -> + Seq (loc, []) + | annot -> + Seq (loc, [Prim (loc, "RENAME", [], annot)]) + in + let fail_false ?(annot = []) loc = + [may_rename loc annot; Seq (loc, [Prim (loc, "FAIL", [], [])])] + in + let fail_true ?(annot = []) loc = + [Seq (loc, [Prim (loc, "FAIL", [], [])]); may_rename loc annot] + in + match original with + | Prim (loc, "ASSERT", [], []) -> + ok @@ Some (Seq (loc, [Prim (loc, "IF", fail_false loc, [])])) + | Prim (loc, "ASSERT_NONE", [], []) -> + ok @@ Some (Seq (loc, [Prim (loc, "IF_NONE", fail_false loc, [])])) + | Prim (loc, "ASSERT_SOME", [], annot) -> + ok @@ Some (Seq (loc, [Prim (loc, "IF_NONE", fail_true ~annot loc, [])])) + | Prim (loc, "ASSERT_LEFT", [], annot) -> + ok + @@ Some (Seq (loc, [Prim (loc, "IF_LEFT", fail_false ~annot loc, [])])) + | Prim (loc, "ASSERT_RIGHT", [], annot) -> + ok @@ Some (Seq (loc, [Prim (loc, "IF_LEFT", fail_true ~annot loc, [])])) + | Prim + ( _, + ( ( "ASSERT" + | "ASSERT_NONE" + | "ASSERT_SOME" + | "ASSERT_LEFT" + | "ASSERT_RIGHT" ) as str ), + args, + [] ) -> + error (Invalid_arity (str, List.length args, 0)) + | Prim (_, (("ASSERT" | "ASSERT_NONE") as str), [], _ :: _) -> + error (Unexpected_macro_annotation str) + | Prim (loc, s, args, annot) + when String.(length s > 7 && equal (sub s 0 7) "ASSERT_") -> ( + ( match args with + | [] -> + ok () + | _ :: _ -> + error (Invalid_arity (s, List.length args, 0)) ) + >>? fun () -> + ( match annot with + | _ :: _ -> + error (Unexpected_macro_annotation s) + | [] -> + ok () ) + >>? fun () -> + let remaining = String.(sub s 7 (length s - 7)) in + let remaining_prim = Prim (loc, remaining, [], []) in + match remaining with + | "EQ" | "NEQ" | "LT" | "LE" | "GE" | "GT" -> + ok + @@ Some + (Seq + (loc, [remaining_prim; Prim (loc, "IF", fail_false loc, [])])) + | _ -> ( + expand_compare remaining_prim + >|? function + | None -> + None + | Some seq -> + Some (Seq (loc, [seq; Prim (loc, "IF", fail_false loc, [])])) ) ) + | _ -> + ok None + +let expand_if_some = function + | Prim (loc, "IF_SOME", [right; left], annot) -> + ok @@ Some (Seq (loc, [Prim (loc, "IF_NONE", [left; right], annot)])) + | Prim (_, "IF_SOME", args, _annot) -> + error (Invalid_arity ("IF_SOME", List.length args, 2)) + | _ -> + ok @@ None + +let expand_if_right = function + | Prim (loc, "IF_RIGHT", [right; left], annot) -> + ok @@ Some (Seq (loc, [Prim (loc, "IF_LEFT", [left; right], annot)])) + | Prim (_, "IF_RIGHT", args, _annot) -> + error (Invalid_arity ("IF_RIGHT", List.length args, 2)) + | _ -> + ok @@ None + +let expand_fail = function + | Prim (loc, "FAIL", [], []) -> + ok + @@ Some + (Seq + ( loc, + [Prim (loc, "UNIT", [], []); Prim (loc, "FAILWITH", [], [])] )) + | _ -> + ok @@ None + +let expand original = + let rec try_expansions = function + | [] -> + ok @@ original + | expander :: expanders -> ( + expander original + >>? function + | None -> try_expansions expanders | Some rewritten -> ok rewritten ) + in + try_expansions + [ expand_carn; + expand_cdrn; + expand_caddadr; + expand_set_caddadr; + expand_map_caddadr; + expand_deprecated_dxiiivp; + (* expand_paaiair ; *) + expand_pappaiir; + (* expand_unpaaiair ; *) + expand_unpappaiir; + expand_deprecated_duuuuup; + expand_compare; + expand_asserts; + expand_if_some; + expand_if_right; + expand_fail ] + +let expand_rec expr = + let rec error_map (expanded, errors) f = function + | [] -> + (List.rev expanded, List.rev errors) + | hd :: tl -> + let (new_expanded, new_errors) = f hd in + error_map + (new_expanded :: expanded, List.rev_append new_errors errors) + f + tl + in + let error_map = error_map ([], []) in + let rec expand_rec expr = + match expand expr with + | Ok expanded -> ( + match expanded with + | Seq (loc, items) -> + let (items, errors) = error_map expand_rec items in + (Seq (loc, items), errors) + | Prim (loc, name, args, annot) -> + let (args, errors) = error_map expand_rec args in + (Prim (loc, name, args, annot), errors) + | (Int _ | String _ | Bytes _) as atom -> + (atom, []) ) + | Error errors -> + (expr, errors) + in + expand_rec expr + +let unexpand_carn_and_cdrn expanded = + match expanded with + | Seq (loc, [Prim (_, "GET", [Int (locn, n)], annot)]) -> + let (half, parity) = Z.ediv_rem n (Z.of_int 2) in + if Z.(parity = zero) then + Some (Prim (loc, "CDR", [Int (locn, half)], annot)) + else Some (Prim (loc, "CAR", [Int (locn, half)], annot)) + | _ -> + None + +let unexpand_caddadr expanded = + let rec rsteps acc = function + | [] -> + Some acc + | Prim (_, "CAR", [], []) :: rest -> + rsteps ("A" :: acc) rest + | Prim (_, "CDR", [], []) :: rest -> + rsteps ("D" :: acc) rest + | _ -> + None + in + match expanded with + | Seq (loc, (Prim (_, "CAR", [], []) :: _ as nodes)) + | Seq (loc, (Prim (_, "CDR", [], []) :: _ as nodes)) -> ( + match rsteps [] nodes with + | Some steps -> + let name = String.concat "" ("C" :: List.rev ("R" :: steps)) in + Some (Prim (loc, name, [], [])) + | None -> + None ) + | _ -> + None + +let unexpand_set_caddadr expanded = + let rec steps acc annots = function + | Seq + ( loc, + [ Prim (_, "CDR", [], _); + Prim (_, "SWAP", [], _); + Prim (_, "PAIR", [], _) ] ) -> + Some (loc, "A" :: acc, annots) + | Seq + ( loc, + [ Prim (_, "DUP", [], []); + Prim (_, "CAR", [], [field_annot]); + Prim (_, "DROP", [], []); + Prim (_, "CDR", [], _); + Prim (_, "SWAP", [], []); + Prim (_, "PAIR", [], _) ] ) -> + Some (loc, "A" :: acc, field_annot :: annots) + | Seq (loc, [Prim (_, "CAR", [], _); Prim (_, "PAIR", [], _)]) -> + Some (loc, "D" :: acc, annots) + | Seq + ( loc, + [ Prim (_, "DUP", [], []); + Prim (_, "CDR", [], [field_annot]); + Prim (_, "DROP", [], []); + Prim (_, "CAR", [], _); + Prim (_, "PAIR", [], _) ] ) -> + Some (loc, "D" :: acc, field_annot :: annots) + | Seq + ( _, + [ Prim (_, "DUP", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CAR", [], _); sub])], []); + Prim (_, "CDR", [], _); + Prim (_, "SWAP", [], []); + Prim (_, "PAIR", [], pair_annots) ] ) -> + let (_, pair_annots) = extract_field_annots pair_annots in + steps ("A" :: acc) (List.rev_append pair_annots annots) sub + | Seq + ( _, + [ Prim (_, "DUP", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], _); sub])], []); + Prim (_, "CAR", [], _); + Prim (_, "PAIR", [], pair_annots) ] ) -> + let (_, pair_annots) = extract_field_annots pair_annots in + steps ("D" :: acc) (List.rev_append pair_annots annots) sub + | _ -> + None + in + match steps [] [] expanded with + | Some (loc, steps, annots) -> + let name = String.concat "" ("SET_C" :: List.rev ("R" :: steps)) in + Some (Prim (loc, name, [], List.rev annots)) + | None -> + None + +let unexpand_map_caddadr expanded = + let rec steps acc annots = function + | Seq + ( loc, + [ Prim (_, "DUP", [], []); + Prim (_, "CDR", [], _); + Prim (_, "SWAP", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CAR", [], []); code])], []); + Prim (_, "PAIR", [], _) ] ) -> + Some (loc, "A" :: acc, annots, code) + | Seq + ( loc, + [ Prim (_, "DUP", [], []); + Prim (_, "CDR", [], _); + Prim (_, "SWAP", [], []); + Prim + ( _, + "DIP", + [Seq (_, [Prim (_, "CAR", [], [field_annot]); code])], + [] ); + Prim (_, "PAIR", [], _) ] ) -> + Some (loc, "A" :: acc, field_annot :: annots, code) + | Seq + ( loc, + [ Prim (_, "DUP", [], []); + Prim (_, "CDR", [], []); + code; + Prim (_, "SWAP", [], []); + Prim (_, "CAR", [], _); + Prim (_, "PAIR", [], _) ] ) -> + Some (loc, "D" :: acc, annots, code) + | Seq + ( loc, + [ Prim (_, "DUP", [], []); + Prim (_, "CDR", [], [field_annot]); + code; + Prim (_, "SWAP", [], []); + Prim (_, "CAR", [], _); + Prim (_, "PAIR", [], _) ] ) -> + Some (loc, "D" :: acc, field_annot :: annots, code) + | Seq + ( _, + [ Prim (_, "DUP", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CAR", [], _); sub])], []); + Prim (_, "CDR", [], _); + Prim (_, "SWAP", [], []); + Prim (_, "PAIR", [], pair_annots) ] ) -> + let (_, pair_annots) = extract_field_annots pair_annots in + steps ("A" :: acc) (List.rev_append pair_annots annots) sub + | Seq + ( _, + [ Prim (_, "DUP", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], []); sub])], []); + Prim (_, "CAR", [], []); + Prim (_, "PAIR", [], pair_annots) ] ) -> + let (_, pair_annots) = extract_field_annots pair_annots in + steps ("D" :: acc) (List.rev_append pair_annots annots) sub + | _ -> + None + in + match steps [] [] expanded with + | Some (loc, steps, annots, code) -> + let name = String.concat "" ("MAP_C" :: List.rev ("R" :: steps)) in + Some (Prim (loc, name, [code], List.rev annots)) + | None -> + None + +let unexpand_deprecated_dxiiivp expanded = + (* transparently turn the old expansion of deprecated [DI...IP] to [DIP n] *) + match expanded with + | Seq + ( loc, + [Prim (_, "DIP", [(Seq (_, [Prim (_, "DIP", [_], [])]) as sub)], [])] + ) -> + let rec count acc = function + | Seq (_, [Prim (_, "DIP", [sub], [])]) -> + count (acc + 1) sub + | sub -> + (acc, sub) + in + let (depth, sub) = count 1 sub in + Some (Prim (loc, "DIP", [Int (loc, Z.of_int depth); sub], [])) + | _ -> + None + +let unexpand_dupn expanded = + match expanded with + | Seq + ( loc, + [ Prim + (_, "DIP", [Int (_, np); Seq (_, [Prim (_, "DUP", [], annot)])], []); + Prim (_, "DIG", [Int (nloc, ng)], []) ] ) + when Z.equal np (Z.pred ng) -> + Some (Prim (loc, "DUP", [Int (nloc, ng)], annot)) + | _ -> + None + +let unexpand_deprecated_duuuuup expanded = + (* transparently turn the old expansion of deprecated [DU...UP] to [DUP n] *) + let rec expand n = function + | Seq (loc, [Prim (nloc, "DUP", [], annot)]) -> + if n = 1 then None + else Some (Prim (loc, "DUP", [Int (nloc, Z.of_int n)], annot)) + | Seq (_, [Prim (_, "DIP", [expanded'], []); Prim (_, "SWAP", [], [])]) -> + expand (n + 1) expanded' + | _ -> + None + in + expand 1 expanded + +let rec normalize_pair_item ?(right = false) = function + | P (i, a, b) -> + P (i, normalize_pair_item a, normalize_pair_item ~right:true b) + | A when right -> + I + | A -> + A + | I -> + I + +let unexpand_pappaiir expanded = + match expanded with + | Seq (_, [Prim (_, "PAIR", [], [])]) -> + Some expanded + | Seq (loc, (_ :: _ as nodes)) -> ( + let rec exec stack nodes = + match (nodes, stack) with + | ([], _) -> + stack + (* support new expansion using [DIP n] *) + | ( Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, + a :: rstack ) + when Z.to_int n > 1 -> + exec + ( a + :: exec + rstack + [ Prim + (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) + ] ) + rest + | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, a :: rstack) + when Z.to_int n = 1 -> + exec (a :: exec rstack sub) rest + | (Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, []) + when Z.to_int n > 1 -> + exec + ( A + :: exec + [] + [ Prim + (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) + ] ) + rest + | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, []) + when Z.to_int n = 1 -> + exec (A :: exec [] sub) rest + (* support old expansion using [DIP] *) + | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, a :: rstack) -> + exec (a :: exec rstack sub) rest + | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, []) -> + exec (A :: exec [] sub) rest + | (Prim (_, "PAIR", [], []) :: rest, a :: b :: rstack) -> + exec (P (0, a, b) :: rstack) rest + | (Prim (_, "PAIR", [], []) :: rest, [a]) -> + exec [P (0, a, I)] rest + | (Prim (_, "PAIR", [], []) :: rest, []) -> + exec [P (0, A, I)] rest + | _ -> + raise_notrace Not_a_pair + in + match exec [] nodes with + | [] -> + None + | res :: _ -> + let res = normalize_pair_item res in + let name = unparse_pair_item res in + Some (Prim (loc, name, [], [])) + | exception Not_a_pair -> + None ) + | _ -> + None + +let unexpand_unpappaiir expanded = + match expanded with + | Seq (loc, (_ :: _ as nodes)) -> ( + let rec exec stack nodes = + match (nodes, stack) with + | ([], _) -> + stack + (* support new expansion using [DIP n] *) + | ( Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, + a :: rstack ) + when Z.to_int n > 1 -> + exec + ( a + :: exec + rstack + [ Prim + (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) + ] ) + rest + | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, a :: rstack) + when Z.to_int n = 1 -> + exec (a :: exec rstack sub) rest + | (Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, []) + when Z.to_int n > 1 -> + exec + ( A + :: exec + [] + [ Prim + (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) + ] ) + rest + | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, []) + when Z.to_int n = 1 -> + exec (A :: exec [] sub) rest + (* support old expansion using [DIP] *) + | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, a :: rstack) -> + exec (a :: exec rstack sub) rest + | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, []) -> + exec (A :: exec [] sub) rest + | ( Seq + ( _, + [ Prim (_, "DUP", [], []); + Prim (_, "CAR", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], [])])], []) ] + ) + :: rest, + a :: b :: rstack ) -> + exec (P (0, a, b) :: rstack) rest + | ( Seq + ( _, + [ Prim (_, "DUP", [], []); + Prim (_, "CAR", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], [])])], []) ] + ) + :: rest, + [a] ) -> + exec [P (0, a, I)] rest + | ( Seq + ( _, + [ Prim (_, "DUP", [], []); + Prim (_, "CAR", [], []); + Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], [])])], []) ] + ) + :: rest, + [] ) -> + exec [P (0, A, I)] rest + | _ -> + raise_notrace Not_a_pair + in + match exec [] (List.rev nodes) with + | [] -> + None + | res :: _ -> + let res = normalize_pair_item res in + let name = "UN" ^ unparse_pair_item res in + Some (Prim (loc, name, [], [])) + | exception Not_a_pair -> + None ) + | _ -> + None + +let unexpand_compare expanded = + match expanded with + | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "EQ", [], annot)]) -> + Some (Prim (loc, "CMPEQ", [], annot)) + | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "NEQ", [], annot)]) -> + Some (Prim (loc, "CMPNEQ", [], annot)) + | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "LT", [], annot)]) -> + Some (Prim (loc, "CMPLT", [], annot)) + | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "GT", [], annot)]) -> + Some (Prim (loc, "CMPGT", [], annot)) + | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "LE", [], annot)]) -> + Some (Prim (loc, "CMPLE", [], annot)) + | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "GE", [], annot)]) -> + Some (Prim (loc, "CMPGE", [], annot)) + | Seq + ( loc, + [ Prim (_, "COMPARE", [], _); + Prim (_, "EQ", [], _); + Prim (_, "IF", args, annot) ] ) -> + Some (Prim (loc, "IFCMPEQ", args, annot)) + | Seq + ( loc, + [ Prim (_, "COMPARE", [], _); + Prim (_, "NEQ", [], _); + Prim (_, "IF", args, annot) ] ) -> + Some (Prim (loc, "IFCMPNEQ", args, annot)) + | Seq + ( loc, + [ Prim (_, "COMPARE", [], _); + Prim (_, "LT", [], _); + Prim (_, "IF", args, annot) ] ) -> + Some (Prim (loc, "IFCMPLT", args, annot)) + | Seq + ( loc, + [ Prim (_, "COMPARE", [], _); + Prim (_, "GT", [], _); + Prim (_, "IF", args, annot) ] ) -> + Some (Prim (loc, "IFCMPGT", args, annot)) + | Seq + ( loc, + [ Prim (_, "COMPARE", [], _); + Prim (_, "LE", [], _); + Prim (_, "IF", args, annot) ] ) -> + Some (Prim (loc, "IFCMPLE", args, annot)) + | Seq + ( loc, + [ Prim (_, "COMPARE", [], _); + Prim (_, "GE", [], _); + Prim (_, "IF", args, annot) ] ) -> + Some (Prim (loc, "IFCMPGE", args, annot)) + | Seq (loc, [Prim (_, "EQ", [], _); Prim (_, "IF", args, annot)]) -> + Some (Prim (loc, "IFEQ", args, annot)) + | Seq (loc, [Prim (_, "NEQ", [], _); Prim (_, "IF", args, annot)]) -> + Some (Prim (loc, "IFNEQ", args, annot)) + | Seq (loc, [Prim (_, "LT", [], _); Prim (_, "IF", args, annot)]) -> + Some (Prim (loc, "IFLT", args, annot)) + | Seq (loc, [Prim (_, "GT", [], _); Prim (_, "IF", args, annot)]) -> + Some (Prim (loc, "IFGT", args, annot)) + | Seq (loc, [Prim (_, "LE", [], _); Prim (_, "IF", args, annot)]) -> + Some (Prim (loc, "IFLE", args, annot)) + | Seq (loc, [Prim (_, "GE", [], _); Prim (_, "IF", args, annot)]) -> + Some (Prim (loc, "IFGE", args, annot)) + | _ -> + None + +let unexpand_asserts expanded = + match expanded with + | Seq + ( loc, + [ Prim + ( _, + "IF", + [ Seq (_, []); + Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT", [], [])) + | Seq + ( loc, + [ Seq (_, [Prim (_, "COMPARE", [], []); Prim (_, comparison, [], [])]); + Prim + ( _, + "IF", + [ Seq (_, []); + Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_CMP" ^ comparison, [], [])) + | Seq + ( loc, + [ Prim (_, comparison, [], []); + Prim + ( _, + "IF", + [ Seq (_, []); + Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_" ^ comparison, [], [])) + | Seq + ( loc, + [ Prim + ( _, + "IF_NONE", + [ Seq (_, [Prim (_, "RENAME", [], annot)]); + Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_NONE", [], annot)) + | Seq + ( loc, + [ Prim + ( _, + "IF_NONE", + [ Seq (_, []); + Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_NONE", [], [])) + | Seq + ( loc, + [ Prim + ( _, + "IF_NONE", + [ Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ); + Seq (_, []) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_SOME", [], [])) + | Seq + ( loc, + [ Prim + ( _, + "IF_NONE", + [ Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ); + Seq (_, [Prim (_, "RENAME", [], annot)]) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_SOME", [], annot)) + | Seq + ( loc, + [ Prim + ( _, + "IF_LEFT", + [ Seq (_, []); + Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_LEFT", [], [])) + | Seq + ( loc, + [ Prim + ( _, + "IF_LEFT", + [ Seq (_, [Prim (_, "RENAME", [], annot)]); + Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_LEFT", [], annot)) + | Seq + ( loc, + [ Prim + ( _, + "IF_LEFT", + [ Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ); + Seq (_, []) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_RIGHT", [], [])) + | Seq + ( loc, + [ Prim + ( _, + "IF_LEFT", + [ Seq + ( _, + [ Seq + ( _, + [ Prim (_, "UNIT", [], []); + Prim (_, "FAILWITH", [], []) ] ) ] ); + Seq (_, [Prim (_, "RENAME", [], annot)]) ], + [] ) ] ) -> + Some (Prim (loc, "ASSERT_RIGHT", [], annot)) + | _ -> + None + +let unexpand_if_some = function + | Seq (loc, [Prim (_, "IF_NONE", [left; right], annot)]) -> + Some (Prim (loc, "IF_SOME", [right; left], annot)) + | _ -> + None + +let unexpand_if_right = function + | Seq (loc, [Prim (_, "IF_LEFT", [left; right], annot)]) -> + Some (Prim (loc, "IF_RIGHT", [right; left], annot)) + | _ -> + None + +let unexpand_fail = function + | Seq (loc, [Prim (_, "UNIT", [], []); Prim (_, "FAILWITH", [], [])]) -> + Some (Prim (loc, "FAIL", [], [])) + | _ -> + None + +let unexpand original = + let try_unexpansions unexpanders = + match + List.fold_left + (fun acc f -> + match acc with + | None -> + f original + | Some rewritten -> + Some rewritten) + None + unexpanders + with + | None -> + original + | Some rewritten -> + rewritten + in + try_unexpansions + [ unexpand_asserts; + unexpand_carn_and_cdrn; + unexpand_caddadr; + unexpand_set_caddadr; + unexpand_map_caddadr; + unexpand_deprecated_dxiiivp; + unexpand_pappaiir; + unexpand_unpappaiir; + unexpand_deprecated_duuuuup; + unexpand_dupn; + unexpand_compare; + unexpand_if_some; + unexpand_if_right; + unexpand_fail ] + +(* + If an argument of Prim is a sequence, we do not want to unexpand + its root in case the source already contains an expanded macro. In + which case unexpansion would remove surrounding braces and generate + ill-formed code. + + For example, DIIP { DIP { DUP }; SWAP } is not unexpandable but + DIIP {{ DIP { DUP }; SWAP }} (note the double braces) is unexpanded + to DIIP { DUUP }. + + unexpand_rec_but_root is the same as unexpand_rec but does not try + to unexpand at root *) + +let rec unexpand_rec expr = unexpand_rec_but_root (unexpand expr) + +and unexpand_rec_but_root = function + | Seq (loc, items) -> + Seq (loc, List.map unexpand_rec items) + | Prim (loc, name, args, annot) -> + Prim (loc, name, List.map unexpand_rec_but_root args, annot) + | (Int _ | String _ | Bytes _) as atom -> + atom + +let () = + let open Data_encoding in + register_error_kind + `Permanent + ~id:"michelson.macros.unexpected_annotation" + ~title:"Unexpected annotation" + ~description: + "A macro had an annotation, but no annotation was permitted on this \ + macro." + ~pp:(fun ppf -> Format.fprintf ppf "Unexpected annotation on macro %s.") + (obj1 (req "macro_name" string)) + (function Unexpected_macro_annotation str -> Some str | _ -> None) + (fun s -> Unexpected_macro_annotation s) ; + register_error_kind + `Permanent + ~id:"michelson.macros.sequence_expected" + ~title:"Macro expects a sequence" + ~description:"An macro expects a sequence, but a sequence was not provided" + ~pp:(fun ppf name -> + Format.fprintf + ppf + "Macro %s expects a sequence, but did not receive one." + name) + (obj1 (req "macro_name" string)) + (function Sequence_expected name -> Some name | _ -> None) + (fun name -> Sequence_expected name) ; + register_error_kind + `Permanent + ~id:"michelson.macros.bas_arity" + ~title:"Wrong number of arguments to macro" + ~description:"A wrong number of arguments was provided to a macro" + ~pp:(fun ppf (name, got, exp) -> + Format.fprintf + ppf + "Macro %s expects %d arguments, was given %d." + name + exp + got) + (obj3 + (req "macro_name" string) + (req "given_number_of_arguments" uint16) + (req "expected_number_of_arguments" uint16)) + (function + | Invalid_arity (name, got, exp) -> Some (name, got, exp) | _ -> None) + (fun (name, got, exp) -> Invalid_arity (name, got, exp)) diff --git a/src/proto_alpha/lib_parameters/michelson_v1_macros.mli b/src/proto_alpha/lib_parameters/michelson_v1_macros.mli new file mode 100644 index 000000000000..352a59b00a9e --- /dev/null +++ b/src/proto_alpha/lib_parameters/michelson_v1_macros.mli @@ -0,0 +1,86 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Tezos_micheline + +type 'l node = ('l, string) Micheline.node + +type error += Unexpected_macro_annotation of string + +type error += Sequence_expected of string + +type error += Invalid_arity of string * int * int + +val expand : 'l node -> 'l node tzresult + +val expand_rec : 'l node -> 'l node * error list + +val expand_caddadr : 'l node -> 'l node option tzresult + +val expand_set_caddadr : 'l node -> 'l node option tzresult + +val expand_map_caddadr : 'l node -> 'l node option tzresult + +val expand_deprecated_dxiiivp : 'l node -> 'l node option tzresult + +val expand_pappaiir : 'l node -> 'l node option tzresult + +val expand_deprecated_duuuuup : 'l node -> 'l node option tzresult + +val expand_compare : 'l node -> 'l node option tzresult + +val expand_asserts : 'l node -> 'l node option tzresult + +val expand_unpappaiir : 'l node -> 'l node option tzresult + +val expand_if_some : 'l node -> 'l node option tzresult + +val expand_if_right : 'l node -> 'l node option tzresult + +val unexpand : 'l node -> 'l node + +val unexpand_rec : 'l node -> 'l node + +val unexpand_caddadr : 'l node -> 'l node option + +val unexpand_set_caddadr : 'l node -> 'l node option + +val unexpand_map_caddadr : 'l node -> 'l node option + +val unexpand_deprecated_dxiiivp : 'l node -> 'l node option + +val unexpand_pappaiir : 'l node -> 'l node option + +val unexpand_deprecated_duuuuup : 'l node -> 'l node option + +val unexpand_compare : 'l node -> 'l node option + +val unexpand_asserts : 'l node -> 'l node option + +val unexpand_unpappaiir : 'l node -> 'l node option + +val unexpand_if_some : 'l node -> 'l node option + +val unexpand_if_right : 'l node -> 'l node option diff --git a/src/proto_alpha/lib_parameters/michelson_v1_parser.ml b/src/proto_alpha/lib_parameters/michelson_v1_parser.ml new file mode 100644 index 000000000000..5a2e5b8d1c16 --- /dev/null +++ b/src/proto_alpha/lib_parameters/michelson_v1_parser.ml @@ -0,0 +1,101 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol +open Tezos_micheline +open Micheline_parser +open Micheline + +type parsed = { + source : string; + unexpanded : string canonical; + expanded : Michelson_v1_primitives.prim canonical; + expansion_table : (int * (Micheline_parser.location * int list)) list; + unexpansion_table : (int * int) list; +} + +(* Unexpanded toplevel expression should be a sequence *) +let expand_all source ast errors = + let (unexpanded, loc_table) = extract_locations ast in + let (expanded, expansion_errors) = + Michelson_v1_macros.expand_rec (root unexpanded) + in + let (expanded, unexpansion_table) = extract_locations expanded in + let expansion_table = + let sorted = + List.sort (fun (_, a) (_, b) -> compare a b) unexpansion_table + in + let grouped = + let rec group = function + | (acc, []) -> + acc + | ([], (u, e) :: r) -> + group ([(e, [u])], r) + | (((pe, us) :: racc as acc), (u, e) :: r) -> + if e = pe then group ((e, u :: us) :: racc, r) + else group ((e, [u]) :: acc, r) + in + group ([], sorted) + in + List.map2 + (fun (l, ploc) (l', elocs) -> + assert (l = l') ; + (l, (ploc, elocs))) + (List.sort compare loc_table) + (List.sort compare grouped) + in + match + Environment.wrap_error (Michelson_v1_primitives.prims_of_strings expanded) + with + | Ok expanded -> + ( {source; unexpanded; expanded; expansion_table; unexpansion_table}, + errors @ expansion_errors ) + | Error errs -> + ( { + source; + unexpanded; + expanded = Micheline.strip_locations (Seq ((), [])); + expansion_table; + unexpansion_table; + }, + errors @ expansion_errors @ errs ) + +let parse_toplevel ?check source = + let (tokens, lexing_errors) = Micheline_parser.tokenize source in + let (asts, parsing_errors) = Micheline_parser.parse_toplevel ?check tokens in + let ast = + let start = min_point asts and stop = max_point asts in + Seq ({start; stop}, asts) + in + expand_all source ast (lexing_errors @ parsing_errors) + +let parse_expression ?check source = + let (tokens, lexing_errors) = Micheline_parser.tokenize source in + let (ast, parsing_errors) = + Micheline_parser.parse_expression ?check tokens + in + expand_all source ast (lexing_errors @ parsing_errors) + +let expand_all ~source ~original = expand_all source original [] diff --git a/src/proto_alpha/lib_parameters/michelson_v1_parser.mli b/src/proto_alpha/lib_parameters/michelson_v1_parser.mli new file mode 100644 index 000000000000..4f55e20943fa --- /dev/null +++ b/src/proto_alpha/lib_parameters/michelson_v1_parser.mli @@ -0,0 +1,53 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol +open Alpha_context +open Tezos_micheline + +(** The result of parsing and expanding a Michelson V1 script or data. *) +type parsed = { + source : string; (** The original source code. *) + unexpanded : string Micheline.canonical; + (** Original expression with macros. *) + expanded : Script.expr; (** Expression with macros fully expanded. *) + expansion_table : (int * (Micheline_parser.location * int list)) list; + (** Associates unexpanded nodes to their parsing locations and + the nodes expanded from it in the expanded expression. *) + unexpansion_table : (int * int) list; + (** Associates an expanded node to its source in the unexpanded + expression. *) +} + +val parse_toplevel : + ?check:bool -> string -> parsed Micheline_parser.parsing_result + +val parse_expression : + ?check:bool -> string -> parsed Micheline_parser.parsing_result + +val expand_all : + source:string -> + original:Micheline_parser.node -> + parsed Micheline_parser.parsing_result diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index 008eaefa29f5..ad1a3ca47fba 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -16,6 +16,7 @@ "Fixed_point_repr", "Saturation_repr", "Gas_limit_repr", + "Contract_repr", "Constants_repr", "Fitness_repr", "Raw_level_repr", @@ -27,7 +28,6 @@ "Script_timestamp_repr", "Michelson_v1_primitives", "Script_repr", - "Contract_repr", "Roll_repr", "Vote_repr", "Block_header_repr", diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index a0e2c784b8df..fd0c30fa0d5e 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -297,3 +297,20 @@ let get_rewards = Raw_context.get_rewards let description = Raw_context.description module Parameters = Parameters_repr + +let get_liquidity_baker_escape_flag = + Raw_context.get_liquidity_baker_escape_flag + +let set_liquidity_baker_escape_flag = + Raw_context.set_liquidity_baker_escape_flag + +let get_liquidity_baker_escape_ema = Storage.Liquidity_baker_escape_ema.get + +let set_liquidity_baker_escape_ema ctxt flag = + Storage.Liquidity_baker_escape_ema.get ctxt + >>=? fun old_ema -> + let new_ema = + Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) + in + Storage.Liquidity_baker_escape_ema.set ctxt new_ema + >|=? fun ctxt -> (ctxt, new_ema) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index ac3cb8fcee90..938e1c6165ff 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1529,6 +1529,8 @@ module Roll : sig val get_change : context -> Signature.Public_key_hash.t -> Tez.t tzresult Lwt.t + + val num_rolls : context -> int tzresult Lwt.t end module Commitment : sig @@ -1638,3 +1640,12 @@ module Parameters : sig val encoding : t Data_encoding.t end + +val get_liquidity_baker_escape_flag : context -> bool + +val set_liquidity_baker_escape_flag : context -> bool -> context + +val get_liquidity_baker_escape_ema : context -> Int32.t tzresult Lwt.t + +val set_liquidity_baker_escape_ema : + context -> bool -> (context * Int32.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 745b239fcf3b..1b99babc4edc 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1595,6 +1595,27 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some nonce_hash -> Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> + set_liquidity_baker_escape_ema ctxt (get_liquidity_baker_escape_flag ctxt) + >>=? fun (ctxt, liquidity_baker_escape_ema) -> + let liquidity_baker = + Contract.originated_contract + (Constants.liquidity_baker_origination_nonce ctxt) + in + let liquidity_baker_reward = + let level = Raw_level.to_int32 (Level.current ctxt).level in + if + Compare.Int32.(level < Constants.liquidity_baker_sunset ctxt) + && Compare.Int32.(liquidity_baker_escape_ema <= 500000l) + then + match Tez.of_mutez 5L with + | None -> + Tez.zero + | Some liquidity_baker_reward -> + liquidity_baker_reward + else Tez.zero + in + Contract.credit ctxt liquidity_baker liquidity_baker_reward + >>=? fun ctxt -> (* end of cycle *) may_snapshot_roll ctxt >>=? fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/baking.mli b/src/proto_alpha/lib_protocol/baking.mli index a6eaee1da518..d292305e26a2 100644 --- a/src/proto_alpha/lib_protocol/baking.mli +++ b/src/proto_alpha/lib_protocol/baking.mli @@ -126,6 +126,8 @@ val check_proof_of_work_stamp : context -> Block_header.t -> unit tzresult and the given block is within the protocol parameters *) val check_fitness_gap : context -> Block_header.t -> unit tzresult +val last_of_a_cycle : context -> Level.t -> bool + val dawn_of_a_new_cycle : context -> Cycle.t option val earlier_predecessor_timestamp : context -> Level.t -> Timestamp.t tzresult diff --git a/src/proto_alpha/lib_protocol/bootstrap_storage.ml b/src/proto_alpha/lib_protocol/bootstrap_storage.ml index 26b59dfd0200..c30d9c67bec8 100644 --- a/src/proto_alpha/lib_protocol/bootstrap_storage.ml +++ b/src/proto_alpha/lib_protocol/bootstrap_storage.ml @@ -40,18 +40,32 @@ let init_account ctxt return ctxt let init_contract ~typecheck ctxt - ({delegate; amount; script} : Parameters_repr.bootstrap_contract) = - Contract_storage.fresh_contract_from_current_nonce ctxt - >>?= fun (ctxt, contract) -> - typecheck ctxt script - >>=? fun (script, ctxt) -> - Contract_storage.raw_originate - ctxt - contract - ~balance:amount - ~prepaid_bootstrap_storage:true - ~script - ~delegate:(Some delegate) + ({delegate; amount; script; origination_nonce} : + Parameters_repr.bootstrap_contract) = + match origination_nonce with + | None -> + Contract_storage.fresh_contract_from_current_nonce ctxt + >>?= fun (ctxt, contract) -> + typecheck ctxt script + >>=? fun (script, ctxt) -> + Contract_storage.raw_originate + ctxt + contract + ~balance:amount + ~prepaid_bootstrap_storage:true + ~script + ~delegate + | Some origination_nonce -> + let contract = Contract_repr.originated_contract origination_nonce in + typecheck ctxt script + >>=? fun (script, ctxt) -> + Contract_storage.raw_originate + ctxt + contract + ~balance:amount + ~prepaid_bootstrap_storage:true + ~script + ~delegate let init ctxt ~typecheck ?ramp_up_cycles ?no_reward_cycles accounts contracts = let nonce = diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index 1697fc966de4..0f40ed6413ee 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -115,6 +115,8 @@ type parametric = { min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; + liquidity_baker_origination_nonce : Contract_repr.origination_nonce; + liquidity_baker_sunset : int32; } let parametric_encoding = @@ -137,9 +139,9 @@ let parametric_encoding = c.origination_size, c.block_security_deposit, c.endorsement_security_deposit, - c.baking_reward_per_endorsement ), - ( c.endorsement_reward, - c.cost_per_byte, + c.baking_reward_per_endorsement, + c.endorsement_reward ), + ( c.cost_per_byte, c.hard_storage_limit_per_operation, 0L, (* At this position in the encoding we used to have a test @@ -151,7 +153,9 @@ let parametric_encoding = c.quorum_max, c.min_proposal_quorum, c.initial_endorsers, - c.delay_per_missing_endorsement ) ) )) + c.delay_per_missing_endorsement, + c.liquidity_baker_origination_nonce, + c.liquidity_baker_sunset ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -168,16 +172,18 @@ let parametric_encoding = origination_size, block_security_deposit, endorsement_security_deposit, - baking_reward_per_endorsement ), - ( endorsement_reward, - cost_per_byte, + baking_reward_per_endorsement, + endorsement_reward ), + ( cost_per_byte, hard_storage_limit_per_operation, _test_chain_duration, quorum_min, quorum_max, min_proposal_quorum, initial_endorsers, - delay_per_missing_endorsement ) ) ) -> + delay_per_missing_endorsement, + liquidity_baker_origination_nonce, + liquidity_baker_sunset ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -204,6 +210,8 @@ let parametric_encoding = min_proposal_quorum; initial_endorsers; delay_per_missing_endorsement; + liquidity_baker_origination_nonce; + liquidity_baker_sunset; }) (merge_objs (obj9 @@ -221,7 +229,7 @@ let parametric_encoding = "hard_gas_limit_per_block" Gas_limit_repr.Arith.z_integral_encoding)) (merge_objs - (obj8 + (obj9 (req "proof_of_work_threshold" int64) (req "tokens_per_roll" Tez_repr.encoding) (req "michelson_maximum_type_size" uint16) @@ -229,9 +237,9 @@ let parametric_encoding = (req "origination_size" int31) (req "block_security_deposit" Tez_repr.encoding) (req "endorsement_security_deposit" Tez_repr.encoding) - (req "baking_reward_per_endorsement" (list Tez_repr.encoding))) - (obj9 - (req "endorsement_reward" (list Tez_repr.encoding)) + (req "baking_reward_per_endorsement" (list Tez_repr.encoding)) + (req "endorsement_reward" (list Tez_repr.encoding))) + (obj10 (req "cost_per_byte" Tez_repr.encoding) (req "hard_storage_limit_per_operation" z) (req "test_chain_duration" int64) @@ -239,7 +247,11 @@ let parametric_encoding = (req "quorum_max" int32) (req "min_proposal_quorum" int32) (req "initial_endorsers" uint16) - (req "delay_per_missing_endorsement" Period_repr.encoding)))) + (req "delay_per_missing_endorsement" Period_repr.encoding) + (req + "liquidity_baker_origination_nonce" + Contract_repr.origination_nonce_encoding) + (req "liquidity_baker_sunset" int32)))) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index 772b11e875bc..aa7ef5bbc9b6 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -123,4 +123,12 @@ let min_proposal_quorum c = let constants = Raw_context.constants c in constants.min_proposal_quorum +let liquidity_baker_origination_nonce c = + let constants = Raw_context.constants c in + constants.liquidity_baker_origination_nonce + +let liquidity_baker_sunset c = + let constants = Raw_context.constants c in + constants.liquidity_baker_sunset + let parametric c = Raw_context.constants c diff --git a/src/proto_alpha/lib_protocol/dune.inc b/src/proto_alpha/lib_protocol/dune.inc index d859045eda8a..ee57405d369c 100644 --- a/src/proto_alpha/lib_protocol/dune.inc +++ b/src/proto_alpha/lib_protocol/dune.inc @@ -32,8 +32,14 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end fixed_point_repr.mli fixed_point_repr.ml saturation_repr.mli saturation_repr.ml gas_limit_repr.mli gas_limit_repr.ml +<<<<<<< HEAD constants_repr.mli constants_repr.ml fitness_repr.mli fitness_repr.ml +======= + contract_repr.mli contract_repr.ml + constants_repr.ml + fitness_repr.ml +>>>>>>> liquidity baking: initial commit raw_level_repr.mli raw_level_repr.ml cycle_repr.mli cycle_repr.ml level_repr.mli level_repr.ml @@ -43,7 +49,6 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end script_timestamp_repr.mli script_timestamp_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml - contract_repr.mli contract_repr.ml roll_repr.mli roll_repr.ml vote_repr.mli vote_repr.ml block_header_repr.mli block_header_repr.ml @@ -119,8 +124,14 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end fixed_point_repr.mli fixed_point_repr.ml saturation_repr.mli saturation_repr.ml gas_limit_repr.mli gas_limit_repr.ml +<<<<<<< HEAD constants_repr.mli constants_repr.ml fitness_repr.mli fitness_repr.ml +======= + contract_repr.mli contract_repr.ml + constants_repr.ml + fitness_repr.ml +>>>>>>> liquidity baking: initial commit raw_level_repr.mli raw_level_repr.ml cycle_repr.mli cycle_repr.ml level_repr.mli level_repr.ml @@ -130,7 +141,6 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end script_timestamp_repr.mli script_timestamp_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml - contract_repr.mli contract_repr.ml roll_repr.mli roll_repr.ml vote_repr.mli vote_repr.ml block_header_repr.mli block_header_repr.ml @@ -206,8 +216,14 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end fixed_point_repr.mli fixed_point_repr.ml saturation_repr.mli saturation_repr.ml gas_limit_repr.mli gas_limit_repr.ml +<<<<<<< HEAD constants_repr.mli constants_repr.ml fitness_repr.mli fitness_repr.ml +======= + contract_repr.mli contract_repr.ml + constants_repr.ml + fitness_repr.ml +>>>>>>> liquidity baking: initial commit raw_level_repr.mli raw_level_repr.ml cycle_repr.mli cycle_repr.ml level_repr.mli level_repr.ml @@ -217,7 +233,6 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end script_timestamp_repr.mli script_timestamp_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml - contract_repr.mli contract_repr.ml roll_repr.mli roll_repr.ml vote_repr.mli vote_repr.ml block_header_repr.mli block_header_repr.ml @@ -313,6 +328,7 @@ include Tezos_raw_protocol_alpha.Main Fixed_point_repr Saturation_repr Gas_limit_repr + Contract_repr Constants_repr Fitness_repr Raw_level_repr @@ -324,7 +340,6 @@ include Tezos_raw_protocol_alpha.Main Script_timestamp_repr Michelson_v1_primitives Script_repr - Contract_repr Roll_repr Vote_repr Block_header_repr @@ -436,6 +451,7 @@ include Tezos_raw_protocol_alpha.Main fixed_point_repr.mli fixed_point_repr.ml saturation_repr.mli saturation_repr.ml gas_limit_repr.mli gas_limit_repr.ml + contract_repr.mli contract_repr.ml constants_repr.mli constants_repr.ml fitness_repr.mli fitness_repr.ml raw_level_repr.mli raw_level_repr.ml @@ -447,7 +463,6 @@ include Tezos_raw_protocol_alpha.Main script_timestamp_repr.mli script_timestamp_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml - contract_repr.mli contract_repr.ml roll_repr.mli roll_repr.ml vote_repr.mli vote_repr.ml block_header_repr.mli block_header_repr.ml diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 6ed181c481e9..34b604210ef1 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -86,6 +86,7 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = ~amount_mutez:100_000_000L >>= fun (ctxt, balance_updates) -> Storage.Pending_migration_balance_updates.init ctxt balance_updates + >>=? fun ctxt -> Storage.Virtual_baker_share.init ctxt Z.zero let prepare ctxt ~level ~predecessor_timestamp ~timestamp ~fitness = Raw_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt diff --git a/src/proto_alpha/lib_protocol/parameters_repr.ml b/src/proto_alpha/lib_protocol/parameters_repr.ml index d5869c641c12..e5c9aae07568 100644 --- a/src/proto_alpha/lib_protocol/parameters_repr.ml +++ b/src/proto_alpha/lib_protocol/parameters_repr.ml @@ -30,9 +30,11 @@ type bootstrap_account = { } type bootstrap_contract = { - delegate : Signature.Public_key_hash.t; + delegate : Signature.Public_key_hash.t option; amount : Tez_repr.t; script : Script_repr.t; + origination_nonce : Contract_repr.origination_nonce option; + (* to test inflationary in sandbox, otherwise should be None *) } type t = { @@ -81,12 +83,19 @@ let bootstrap_account_encoding = let bootstrap_contract_encoding = let open Data_encoding in conv - (fun {delegate; amount; script} -> (delegate, amount, script)) - (fun (delegate, amount, script) -> {delegate; amount; script}) - (obj3 - (req "delegate" Signature.Public_key_hash.encoding) + (fun {delegate; amount; script; origination_nonce} -> + (delegate, amount, script, origination_nonce)) + (fun (delegate, amount, script, origination_nonce) -> + {delegate; amount; script; origination_nonce}) + (obj4 + (req + "delegate" + (Data_encoding.option Signature.Public_key_hash.encoding)) (req "amount" Tez_repr.encoding) - (req "script" Script_repr.encoding)) + (req "script" Script_repr.encoding) + (req + "origination nonce" + (Data_encoding.option Contract_repr.origination_nonce_encoding))) let encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/parameters_repr.mli b/src/proto_alpha/lib_protocol/parameters_repr.mli index 6f8436e719b9..56df3d258471 100644 --- a/src/proto_alpha/lib_protocol/parameters_repr.mli +++ b/src/proto_alpha/lib_protocol/parameters_repr.mli @@ -30,9 +30,10 @@ type bootstrap_account = { } type bootstrap_contract = { - delegate : Signature.Public_key_hash.t; + delegate : Signature.Public_key_hash.t option; amount : Tez_repr.t; script : Script_repr.t; + origination_nonce : Contract_repr.origination_nonce option; } type t = { diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index e28fb8bb8f81..e534a791c4f7 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -99,6 +99,7 @@ type back = { internal_nonce : int; internal_nonces_used : Int_set.t; gas_counter_status : gas_counter_status; + liquidity_baker_escape_flag : bool; } (* @@ -751,6 +752,7 @@ let prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt = internal_nonce = 0; internal_nonces_used = Int_set.empty; gas_counter_status = Unlimited_operation_gas; + liquidity_baker_escape_flag = false; }; } @@ -1003,3 +1005,8 @@ let map_temporary_lazy_storage_ids_s ctxt f = f (temporary_lazy_storage_ids ctxt) >|= fun (ctxt, temporary_lazy_storage_ids) -> update_temporary_lazy_storage_ids ctxt temporary_lazy_storage_ids + +let get_liquidity_baker_escape_flag ctxt = ctxt.liquidity_baker_escape_flag + +let set_liquidity_baker_escape_flag ctxt flag = + {ctxt with liquidity_baker_escape_flag = flag} diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index 50e40c91793d..b946ed420211 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -205,3 +205,7 @@ val map_temporary_lazy_storage_ids_s : t -> (Lazy_storage_kind.Temp_ids.t -> (t * Lazy_storage_kind.Temp_ids.t) Lwt.t) -> t Lwt.t + +val get_liquidity_baker_escape_flag : context -> bool + +val set_liquidity_baker_escape_flag : context -> bool -> context diff --git a/src/proto_alpha/lib_protocol/roll_storage.ml b/src/proto_alpha/lib_protocol/roll_storage.ml index 42fb65627a50..1f1933b5f65b 100644 --- a/src/proto_alpha/lib_protocol/roll_storage.ml +++ b/src/proto_alpha/lib_protocol/roll_storage.ml @@ -576,3 +576,13 @@ let update_tokens_per_roll ctxt new_tokens_per_roll = >>?= fun amount -> if decrease then Delegate.add_amount ctxt pkh amount else Delegate.remove_amount ctxt pkh amount) + +let num_rolls ctxt = + Storage.Delegates.fold + ctxt + (Ok (0, ctxt)) + (fun pkh ctxt_opt -> + ctxt_opt + >>?= fun (accum, ctxt) -> + count_rolls ctxt pkh >>=? fun count -> return (count + accum, ctxt)) + >>=? fun (accum, _ctxt) -> return accum diff --git a/src/proto_alpha/lib_protocol/roll_storage.mli b/src/proto_alpha/lib_protocol/roll_storage.mli index e88cbefe9788..6553c5941198 100644 --- a/src/proto_alpha/lib_protocol/roll_storage.mli +++ b/src/proto_alpha/lib_protocol/roll_storage.mli @@ -262,3 +262,5 @@ val get_contract_delegate : Raw_context.t -> Contract_repr.t -> Signature.Public_key_hash.t option tzresult Lwt.t + +val num_rolls : Raw_context.t -> int tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 6135c28e535a..67ead15c7794 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1227,3 +1227,10 @@ module Pending_migration_balance_updates = let encoding = Receipt_repr.balance_updates_encoding end) + +module Liquidity_baker_escape_ema = + Make_single_data_storage (Registered) (Raw_context) + (struct + let name = ["liquidity_baker_escape_ema"] + end) + (Int32) diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 694161e20bde..ac4a23380666 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -487,3 +487,6 @@ module Pending_migration_balance_updates : Single_data_storage with type value = Receipt_repr.balance_updates and type t := Raw_context.t + +module Liquidity_baker_escape_ema : + Single_data_storage with type t := Raw_context.t and type value = Int32.t diff --git a/src/proto_alpha/lib_protocol/test/contracts/cpmm.tz b/src/proto_alpha/lib_protocol/test/contracts/cpmm.tz new file mode 100644 index 000000000000..07f0ff60eaeb --- /dev/null +++ b/src/proto_alpha/lib_protocol/test/contracts/cpmm.tz @@ -0,0 +1,1420 @@ +{ parameter + (or (or (or (pair %addLiquidity (pair address nat) (pair nat timestamp)) + (pair %approve address (pair nat nat))) + (or (pair %removeLiquidity + (pair address (pair address nat)) + (pair mutez (pair nat timestamp))) + (pair %tokenToXtz (pair address address) (pair nat (pair mutez timestamp))))) + (or (or (key_hash %updateTokenPool) (nat %updateTokenPoolInternal)) + (pair %xtzToToken address (pair nat timestamp)))) ; + storage + (pair (big_map %accounts address (pair (map %allowances address nat) (nat %balance))) + (pair %s + (pair (nat %lqt_total) (bool %self_is_updating_token_pool)) + (pair (nat %token_pool) (mutez %xtz_pool)))) ; + code { EMPTY_MAP address nat ; + PUSH address "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" ; + LAMBDA + mutez + nat + { PUSH mutez 1 ; + SWAP ; + EDIV ; + IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; + CAR } ; + LAMBDA nat mutez { PUSH mutez 1 ; SWAP ; MUL } ; + DIG 3 ; + DUP ; + DUG 4 ; + LAMBDA + (pair (map address nat) (pair address (big_map address (pair (map address nat) nat)))) + (pair (map address nat) nat) + { DUP ; + CDR ; + SWAP ; + CAR ; + SWAP ; + DUP ; + CDR ; + SWAP ; + CAR ; + GET ; + IF_NONE { PUSH nat 0 ; SWAP ; PAIR } { SWAP ; DROP } } ; + SWAP ; + APPLY ; + DIG 5 ; + DUP ; + CDR ; + SWAP ; + CAR ; + IF_LEFT + { IF_LEFT + { DIG 3 ; + DROP ; + IF_LEFT + { DUP ; + DUG 2 ; + CDR ; + CDR ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + PAIR ; + DIG 2 ; + DUP ; + DUG 3 ; + CAR ; + CDR ; + DIG 3 ; + CAR ; + CAR ; + DIG 2 ; + DUP ; + CDR ; + SWAP ; + CAR ; + DIG 4 ; + DUP ; + DUG 5 ; + CDR ; + CAR ; + CDR ; + IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; + SWAP ; + NOW ; + COMPARE ; + LT ; + IF {} + { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; + PUSH nat 0 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GT ; + IF {} + { PUSH string "max_tokens_deposited must be greater than zero." ; FAILWITH } ; + PUSH mutez 0 ; + AMOUNT ; + COMPARE ; + GT ; + IF {} + { PUSH string "The amount of XTZ sent to the contract to be greater than zero." ; + FAILWITH } ; + PUSH nat 0 ; + DIG 3 ; + DUP ; + DUG 4 ; + COMPARE ; + GT ; + IF {} { PUSH string "min_lqt_minted must be greater than zero." ; FAILWITH } ; + PUSH nat 0 ; + DIG 4 ; + DUP ; + DUG 5 ; + CDR ; + CAR ; + CAR ; + COMPARE ; + GT ; + IF { DIG 7 ; + DROP ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CDR ; + CDR ; + DIG 6 ; + DUP ; + DUG 7 ; + SWAP ; + EXEC ; + AMOUNT ; + DIG 7 ; + SWAP ; + EXEC ; + SWAP ; + DUP ; + DUG 2 ; + DIG 6 ; + DUP ; + DUG 7 ; + CDR ; + CDR ; + CAR ; + DIG 2 ; + DUP ; + DUG 3 ; + MUL ; + EDIV ; + IF_NONE + { PUSH string "DIV by 0" ; FAILWITH } + { PUSH nat 0 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + COMPARE ; + EQ ; + IF { CAR } { PUSH nat 1 ; SWAP ; CAR ; ADD } } ; + PUSH nat 0 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GT ; + IF {} + { PUSH string "tokens_deposited must be greater than zero." ; FAILWITH } ; + DUP ; + DIG 4 ; + COMPARE ; + GE ; + IF {} + { PUSH string + "max_tokens_deposited must be greater than or equal to tokens_deposited." ; + FAILWITH } ; + DIG 2 ; + DIG 5 ; + DUP ; + DUG 6 ; + CDR ; + CAR ; + CAR ; + DIG 3 ; + MUL ; + EDIV ; + IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; + CAR ; + DIG 3 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF {} + { PUSH string "lqt_minted must be greater than min_lqt_minted." ; FAILWITH } ; + DIG 3 ; + DUP ; + DUG 4 ; + CAR ; + DIG 3 ; + DUP ; + DUG 4 ; + PAIR ; + DIG 5 ; + SWAP ; + EXEC ; + SWAP ; + DUP ; + DUG 2 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + ADD ; + DIG 5 ; + DUP ; + DUG 6 ; + CDR ; + DIG 6 ; + CAR ; + DIG 2 ; + DIG 3 ; + CAR ; + PAIR ; + DIG 5 ; + DUP ; + DUG 6 ; + SWAP ; + SOME ; + SWAP ; + UPDATE ; + PAIR ; + DUP ; + CDR ; + CDR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + CDR ; + DIG 3 ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CAR ; + CAR ; + ADD ; + PAIR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + DUP ; + CDR ; + CDR ; + CDR ; + DIG 2 ; + DUP ; + DUG 3 ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CDR ; + CAR ; + ADD ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + AMOUNT ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + ADD ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + DIG 3 ; + CONTRACT %transfer (pair address (pair address nat)) ; + IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 3 ; + SELF ; + ADDRESS ; + PAIR ; + DIG 4 ; + PAIR ; + TRANSFER_TOKENS ; + SWAP ; + NIL operation ; + DIG 2 ; + CONS ; + PAIR } + { DIG 2 ; + DROP ; + DIG 3 ; + DROP ; + PUSH mutez 1000000 ; + AMOUNT ; + COMPARE ; + GE ; + IF {} + { PUSH string "The initial liquidity amount must be greater than or equal to zero." ; + FAILWITH } ; + AMOUNT ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CDR ; + CDR ; + ADD ; + DIG 4 ; + SWAP ; + EXEC ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CDR ; + DIG 4 ; + DUP ; + DUG 5 ; + CDR ; + CAR ; + CDR ; + DIG 2 ; + DUP ; + DUG 3 ; + PAIR ; + PAIR ; + DIG 4 ; + CAR ; + DIG 2 ; + DIG 6 ; + PAIR ; + DIG 4 ; + DUP ; + DUG 5 ; + SWAP ; + SOME ; + SWAP ; + UPDATE ; + PAIR ; + DUP ; + CDR ; + CDR ; + CDR ; + DIG 2 ; + DUP ; + DUG 3 ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + AMOUNT ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + ADD ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + DIG 3 ; + CONTRACT %transfer (pair address (pair address nat)) ; + IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 3 ; + SELF ; + ADDRESS ; + PAIR ; + DIG 4 ; + PAIR ; + TRANSFER_TOKENS ; + SWAP ; + NIL operation ; + DIG 2 ; + CONS ; + PAIR } } + { DIG 3 ; + DROP ; + DIG 3 ; + DROP ; + DIG 3 ; + DROP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + DIG 2 ; + CAR ; + DIG 2 ; + DUP ; + CDR ; + SWAP ; + CAR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + CDR ; + IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; + PUSH mutez 0 ; + AMOUNT ; + COMPARE ; + GT ; + IF { PUSH string "amount must be zero." ; FAILWITH } {} ; + SWAP ; + DUP ; + DUG 2 ; + CAR ; + SENDER ; + PAIR ; + DIG 5 ; + SWAP ; + EXEC ; + DUP ; + CAR ; + DUP ; + DIG 5 ; + DUP ; + DUG 6 ; + GET ; + IF_NONE { PUSH nat 0 } {} ; + DIG 3 ; + COMPARE ; + EQ ; + IF { DIG 4 ; + DIG 4 ; + SWAP ; + SOME ; + SWAP ; + UPDATE ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + DIG 3 ; + CAR ; + DIG 3 ; + CDR ; + DIG 3 ; + DUP ; + DUG 4 ; + PAIR ; + SOME ; + SENDER ; + UPDATE ; + PAIR ; + SWAP ; + PAIR } + { SWAP ; + DROP ; + DIG 2 ; + DROP ; + DIG 2 ; + DROP ; + PUSH string "current_allowance must equal account.allowances[spender]." ; + FAILWITH } ; + CDR ; + NIL operation ; + PAIR } } + { DIG 6 ; + DROP ; + IF_LEFT + { DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CDR ; + CAR ; + PAIR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + DIG 2 ; + DUP ; + DUG 3 ; + CAR ; + CDR ; + CDR ; + PAIR ; + DIG 2 ; + DUP ; + DUG 3 ; + CAR ; + CDR ; + CAR ; + DIG 3 ; + CAR ; + CAR ; + DIG 2 ; + DUP ; + CDR ; + SWAP ; + CAR ; + DIG 4 ; + DUP ; + CDR ; + SWAP ; + CAR ; + DUP ; + CDR ; + SWAP ; + CAR ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + CDR ; + IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; + SWAP ; + NOW ; + COMPARE ; + LT ; + IF {} + { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; + PUSH mutez 0 ; + AMOUNT ; + COMPARE ; + GT ; + IF { PUSH string "amount must be zero." ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 4 ; + DUP ; + DUG 5 ; + COMPARE ; + GT ; + IF {} + { PUSH string "min_xtz_withdrawn must be greater than zero." ; FAILWITH } ; + PUSH nat 0 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GT ; + IF {} + { PUSH string "min_tokens_withdrawn must be greater than zero." ; FAILWITH } ; + PUSH nat 0 ; + DIG 3 ; + DUP ; + DUG 4 ; + COMPARE ; + GT ; + IF {} { PUSH string "lqt_burned must be greater than zero." ; FAILWITH } ; + PUSH nat 0 ; + DIG 2 ; + DUP ; + DUG 3 ; + CAR ; + DIG 6 ; + DUP ; + DUG 7 ; + GET ; + IF_NONE + { PUSH string "The owner does not have any liquidity in this contract." ; + FAILWITH } + { DIG 6 ; + DUP ; + DUG 7 ; + SENDER ; + COMPARE ; + NEQ ; + IF { DUP ; + CAR ; + SENDER ; + GET ; + IF_NONE + { PUSH string + "The sender does not have an allowance from the give owner in this contract." ; + FAILWITH } + { DIG 2 ; + DROP ; + DUP ; + DIG 5 ; + DUP ; + DUG 6 ; + COMPARE ; + GT ; + IF { PUSH string "lqt_burned cannot be greater than the sender's allowance." ; + FAILWITH } + {} } } + { SWAP } ; + SWAP ; + CDR ; + PAIR } ; + DUP ; + CAR ; + DIG 4 ; + DUP ; + DUG 5 ; + COMPARE ; + GT ; + IF { PUSH string "lqt_burned cannot be greater than the owner's balance." ; + FAILWITH } + {} ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + CAR ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CDR ; + CDR ; + DIG 11 ; + SWAP ; + EXEC ; + DIG 5 ; + DUP ; + DUG 6 ; + MUL ; + EDIV ; + IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; + CAR ; + DIG 9 ; + SWAP ; + EXEC ; + DIG 5 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF {} + { PUSH string + "The amount of xtz withdrawn must be greater than or equal to min_xtz_withdrawn." ; + FAILWITH } ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CAR ; + CAR ; + DIG 4 ; + DUP ; + DUG 5 ; + CDR ; + CDR ; + CAR ; + DIG 6 ; + DUP ; + DUG 7 ; + MUL ; + EDIV ; + IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; + CAR ; + DIG 3 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF {} + { PUSH string + "The amount of tokens withdrawn must be greater than or equal to min_tokens_withdrawn." ; + FAILWITH } ; + DIG 3 ; + DUP ; + DUG 4 ; + CAR ; + DIG 6 ; + DUP ; + DUG 7 ; + PAIR ; + DIG 8 ; + DUP ; + DUG 9 ; + SWAP ; + EXEC ; + DIG 5 ; + DUP ; + DUG 6 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + SUB ; + PUSH int 0 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF { ABS } + { DROP ; + PUSH string "account.balance - lqt_burned resulted in a negative number." ; + FAILWITH } ; + DIG 5 ; + DUP ; + DUG 6 ; + CDR ; + DIG 6 ; + CAR ; + DIG 2 ; + DIG 3 ; + CAR ; + PAIR ; + DIG 7 ; + DUP ; + DUG 8 ; + SWAP ; + SOME ; + SWAP ; + UPDATE ; + PAIR ; + DIG 4 ; + DUP ; + DUG 5 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + CAR ; + SUB ; + DROP ; + SWAP ; + DUP ; + DUG 2 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + SUB ; + PUSH int 0 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF { SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + SWAP ; + ABS ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR } + { DROP ; + PUSH string + "storage.s.token_pool - tokens_withdrawn resulted in a negative number." ; + FAILWITH } ; + SENDER ; + DIG 6 ; + DUP ; + DUG 7 ; + COMPARE ; + NEQ ; + IF { DIG 4 ; + DIG 4 ; + CDR ; + SUB ; + PUSH int 0 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF { SWAP ; + DUP ; + DUG 2 ; + CAR ; + DIG 5 ; + DUP ; + DUG 6 ; + PAIR ; + DIG 7 ; + SWAP ; + EXEC ; + DUP ; + CDR ; + SWAP ; + CAR ; + DIG 2 ; + ABS ; + SOME ; + SENDER ; + UPDATE ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + DIG 2 ; + CAR ; + DIG 2 ; + DIG 5 ; + SWAP ; + SOME ; + SWAP ; + UPDATE ; + PAIR } + { DROP ; + DIG 3 ; + DROP ; + DIG 4 ; + DROP ; + PUSH string "sender_allowance - lqt_burned resulted in a negative number" ; + FAILWITH } } + { DIG 3 ; DROP ; DIG 3 ; DROP ; DIG 3 ; DROP ; DIG 4 ; DROP } ; + DIG 2 ; + DUP ; + DUG 3 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + SUB ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + DIG 3 ; + DUP ; + DUG 4 ; + CONTRACT unit ; + IF_NONE { PUSH string "bad address for get_contract" ; FAILWITH } {} ; + DIG 3 ; + UNIT ; + TRANSFER_TOKENS ; + DIG 4 ; + CONTRACT %transfer (pair address (pair address nat)) ; + IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 4 ; + DIG 5 ; + PAIR ; + SELF ; + ADDRESS ; + PAIR ; + TRANSFER_TOKENS ; + DIG 2 ; + NIL operation ; + DIG 2 ; + CONS ; + DIG 2 ; + CONS ; + PAIR } + { DIG 2 ; + DROP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + PAIR ; + DIG 2 ; + DUP ; + DUG 3 ; + CAR ; + CDR ; + DIG 3 ; + CAR ; + CAR ; + DIG 2 ; + DUP ; + CDR ; + SWAP ; + CAR ; + DIG 4 ; + DUP ; + CDR ; + SWAP ; + CAR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + CDR ; + IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; + NOW ; + COMPARE ; + LT ; + IF {} + { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; + PUSH mutez 0 ; + AMOUNT ; + COMPARE ; + GT ; + IF { PUSH string "amount must be zero." ; FAILWITH } {} ; + PUSH nat 0 ; + DIG 2 ; + DUP ; + DUG 3 ; + COMPARE ; + GT ; + IF { PUSH string "tokens_sold must be greater than zero." ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 3 ; + DUP ; + DUG 4 ; + COMPARE ; + GT ; + IF { PUSH string "min_xtz_bought must be greater than zero." ; FAILWITH } {} ; + PUSH mutez 0 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + COMPARE ; + EQ ; + IF { PUSH string "xtz_pool must be greater than zero." ; FAILWITH } {} ; + PUSH nat 0 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + COMPARE ; + EQ ; + IF { PUSH string "token_pool must be greater than zero." ; FAILWITH } {} ; + PUSH nat 999 ; + DIG 2 ; + DUP ; + DUG 3 ; + MUL ; + PUSH nat 1000 ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CDR ; + CAR ; + MUL ; + ADD ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + DIG 8 ; + SWAP ; + EXEC ; + PUSH nat 999 ; + DIG 4 ; + DUP ; + DUG 5 ; + MUL ; + MUL ; + EDIV ; + IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; + CAR ; + DIG 6 ; + SWAP ; + EXEC ; + DIG 3 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF {} + { PUSH string "xtz_bought must be greater than or equal to min_xtz_bought." ; + FAILWITH } ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + DIG 3 ; + DUP ; + DUG 4 ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CDR ; + CAR ; + ADD ; + PAIR ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + PAIR ; + DIG 2 ; + CAR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + SUB ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + DIG 4 ; + CONTRACT unit ; + IF_NONE { PUSH string "bad address for get_contract" ; FAILWITH } {} ; + DIG 2 ; + UNIT ; + TRANSFER_TOKENS ; + DIG 4 ; + CONTRACT %transfer (pair address (pair address nat)) ; + IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 4 ; + SELF ; + ADDRESS ; + PAIR ; + DIG 5 ; + PAIR ; + TRANSFER_TOKENS ; + DIG 2 ; + NIL operation ; + DIG 2 ; + CONS ; + DIG 2 ; + CONS ; + PAIR } } } + { DIG 2 ; + DROP ; + DIG 2 ; + DROP ; + DIG 4 ; + DROP ; + IF_LEFT + { DIG 2 ; + DROP ; + IF_LEFT + { IMPLICIT_ACCOUNT ; + ADDRESS ; + SENDER ; + COMPARE ; + EQ ; + IF { SELF %updateTokenPoolInternal ; + DIG 2 ; + CONTRACT %getBalance (pair address (contract nat)) ; + IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 2 ; + SELF ; + ADDRESS ; + PAIR ; + TRANSFER_TOKENS ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + PUSH bool True ; + DIG 3 ; + DUP ; + DUG 4 ; + CDR ; + CAR ; + CAR ; + PAIR ; + PAIR ; + DIG 2 ; + CAR ; + PAIR ; + NIL operation ; + DIG 2 ; + CONS ; + PAIR } + { SWAP ; DROP ; PUSH string "UnsafeUpdateTokenPool" ; FAILWITH } } + { DIG 2 ; + SENDER ; + COMPARE ; + NEQ ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + CDR ; + NOT ; + OR ; + IF { DROP ; + PUSH string + "This entrypoint may only be called by dexter itself via getBalance of tokenAddress." ; + FAILWITH } + { SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + SWAP ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + DUP ; + CDR ; + CDR ; + PUSH bool False ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + CAR ; + PAIR ; + PAIR ; + SWAP ; + CAR ; + PAIR } ; + NIL operation ; + PAIR } } + { DUP ; + DUG 2 ; + CDR ; + CDR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + DIG 2 ; + CAR ; + DIG 2 ; + DUP ; + CDR ; + SWAP ; + CAR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + CDR ; + IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; + NOW ; + COMPARE ; + LT ; + IF {} + { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; + PUSH mutez 0 ; + AMOUNT ; + COMPARE ; + EQ ; + IF { PUSH string "amount must be greater than zero." ; FAILWITH } {} ; + PUSH nat 0 ; + DIG 3 ; + DUP ; + DUG 4 ; + COMPARE ; + EQ ; + IF { PUSH string "min_tokens_bought must be greater than zero." ; FAILWITH } + {} ; + PUSH mutez 0 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + COMPARE ; + EQ ; + IF { PUSH string "xtz_pool must be greater than zero." ; FAILWITH } {} ; + PUSH nat 0 ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + COMPARE ; + EQ ; + IF { PUSH string "token_pool must be greater than zero." ; FAILWITH } {} ; + DUP ; + CDR ; + CDR ; + CDR ; + DIG 4 ; + DUP ; + DUG 5 ; + SWAP ; + EXEC ; + AMOUNT ; + DIG 5 ; + SWAP ; + EXEC ; + PUSH nat 999 ; + SWAP ; + DUP ; + DUG 2 ; + MUL ; + PUSH nat 1000 ; + DIG 3 ; + MUL ; + ADD ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CDR ; + CAR ; + PUSH nat 999 ; + DIG 3 ; + MUL ; + MUL ; + EDIV ; + IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; + CAR ; + DIG 3 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF {} + { PUSH string "tokens_bought must be greater than or equal to min_tokens_bought." ; + FAILWITH } ; + DUP ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CDR ; + CAR ; + SUB ; + PUSH int 0 ; + SWAP ; + DUP ; + DUG 2 ; + COMPARE ; + GE ; + IF { DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CDR ; + CDR ; + SWAP ; + ABS ; + PAIR ; + DIG 2 ; + DUP ; + DUG 3 ; + CDR ; + CAR ; + PAIR ; + DIG 2 ; + CAR ; + PAIR } + { DROP ; PUSH string "token_pool - tokens_bought is negative." ; FAILWITH } ; + AMOUNT ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CDR ; + ADD ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CDR ; + CAR ; + PAIR ; + SWAP ; + DUP ; + DUG 2 ; + CDR ; + CAR ; + PAIR ; + SWAP ; + CAR ; + PAIR ; + DIG 3 ; + CONTRACT %transfer (pair address (pair address nat)) ; + IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; + PUSH mutez 0 ; + DIG 3 ; + DIG 4 ; + PAIR ; + SELF ; + ADDRESS ; + PAIR ; + TRANSFER_TOKENS ; + SWAP ; + NIL operation ; + DIG 2 ; + CONS ; + PAIR } } } } + -- GitLab From eef075b7a05b24c7fc61a5ee7595933ca2365320 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Sun, 10 Jan 2021 19:04:39 -0500 Subject: [PATCH 02/62] use POSIX compliant bash shebang in user_activated_upgrade.sh --- scripts/user_activated_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/user_activated_upgrade.sh b/scripts/user_activated_upgrade.sh index 6c72b1ec3f20..250421dada3a 100755 --- a/scripts/user_activated_upgrade.sh +++ b/scripts/user_activated_upgrade.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /usr/bin/env bash set -e -- GitLab From 78bca6872998f5099188a43b7f709deb7b427dba Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Sun, 10 Jan 2021 20:27:43 -0500 Subject: [PATCH 03/62] liquidity baking: inject test fa1.2 contract in genesis block --- src/proto_alpha/lib_parameters/cpmm.json | 570 ++++++++++-------- .../lib_parameters/default_parameters.ml | 28 +- src/proto_alpha/lib_parameters/fa12.json | 443 ++++++++++++++ 3 files changed, 779 insertions(+), 262 deletions(-) mode change 100644 => 100755 src/proto_alpha/lib_parameters/cpmm.json create mode 100644 src/proto_alpha/lib_parameters/fa12.json diff --git a/src/proto_alpha/lib_parameters/cpmm.json b/src/proto_alpha/lib_parameters/cpmm.json old mode 100644 new mode 100755 index 642bcd43298d..a57511937687 --- a/src/proto_alpha/lib_parameters/cpmm.json +++ b/src/proto_alpha/lib_parameters/cpmm.json @@ -26,7 +26,8 @@ "annots": [ "%approve" ] } ] }, { "prim": "or", "args": - [ { "prim": "pair", + [ { "prim": "unit", "annots": [ "%default" ] }, + { "prim": "pair", "args": [ { "prim": "pair", "args": @@ -42,8 +43,12 @@ "args": [ { "prim": "nat" }, { "prim": "timestamp" } ] } ] } ], - "annots": [ "%removeLiquidity" ] }, - { "prim": "pair", + "annots": [ "%removeLiquidity" ] } ] } ] }, + { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "pair", "args": [ { "prim": "pair", "args": @@ -56,22 +61,21 @@ "args": [ { "prim": "mutez" }, { "prim": "timestamp" } ] } ] } ], - "annots": [ "%tokenToXtz" ] } ] } ] }, - { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "key_hash", - "annots": [ "%updateTokenPool" ] }, - { "prim": "nat", - "annots": [ "%updateTokenPoolInternal" ] } ] }, - { "prim": "pair", + "annots": [ "%tokenToXtz" ] }, + { "prim": "key_hash", + "annots": [ "%updateTokenPool" ] } ] }, + { "prim": "or", "args": - [ { "prim": "address" }, + [ { "prim": "nat", + "annots": [ "%updateTokenPoolInternal" ] }, { "prim": "pair", "args": - [ { "prim": "nat" }, { "prim": "timestamp" } ] } ], - "annots": [ "%xtzToToken" ] } ] } ] } ] }, + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, + { "prim": "timestamp" } ] } ], + "annots": [ "%xtzToToken" ] } ] } ] } ] } ] }, { "prim": "storage", "args": [ { "prim": "pair", @@ -106,7 +110,7 @@ { "prim": "PUSH", "args": [ { "prim": "address" }, - { "string": "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" } ] }, + { "string": "KT1BEqzn5Wx8uJrZNvuS9DVHmLvG9td3fDLi" } ] }, { "prim": "LAMBDA", "args": [ { "prim": "mutez" }, { "prim": "nat" }, @@ -904,7 +908,31 @@ { "prim": "DROP" }, { "prim": "IF_LEFT", "args": - [ [ { "prim": "DUP" }, + [ [ { "prim": "DROP" }, { "prim": "SWAP" }, + { "prim": "DROP" }, { "prim": "SWAP" }, + { "prim": "DROP" }, { "prim": "SWAP" }, + { "prim": "DROP" }, { "prim": "SWAP" }, + { "prim": "DROP" }, { "prim": "AMOUNT" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "ADD" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } ], + [ { "prim": "DUP" }, { "prim": "DUG", "args": [ { "int": "2" } ] }, { "prim": "CDR" }, { "prim": "CDR" }, @@ -1529,10 +1557,16 @@ { "prim": "CONS" }, { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, { "prim": "PAIR" } ], - [ { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, { "prim": "DUP" }, + { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ], + [ { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", "args": [ { "int": "5" } ] }, + { "prim": "DROP" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DUP" }, { "prim": "DUG", "args": [ { "int": "2" } ] }, { "prim": "CDR" }, { "prim": "CDR" }, @@ -1839,20 +1873,14 @@ { "prim": "CONS" }, { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ], - [ { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", "args": [ { "int": "4" } ] }, - { "prim": "DROP" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IMPLICIT_ACCOUNT" }, + { "prim": "CONS" }, { "prim": "PAIR" } ], + [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "IMPLICIT_ACCOUNT" }, { "prim": "ADDRESS" }, { "prim": "SENDER" }, { "prim": "COMPARE" }, { "prim": "EQ" }, @@ -1929,8 +1957,15 @@ [ { "prim": "string" }, { "string": "UnsafeUpdateTokenPool" } ] }, - { "prim": "FAILWITH" } ] ] } ], - [ { "prim": "DIG", + { "prim": "FAILWITH" } ] ] } ] ] } ], + [ { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, { "prim": "SENDER" }, { "prim": "COMPARE" }, { "prim": "NEQ" }, @@ -1992,227 +2027,272 @@ { "prim": "PAIR" } ] ] }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, - { "prim": "PAIR" } ] ] } ], - [ { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "self_is_updating_token_pool must be false" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "NOW" }, { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The current time must be less than the deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "AMOUNT" }, { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", + { "prim": "PAIR" } ], + [ { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "IF", "args": - [ { "prim": "string" }, - { "string": - "amount must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "4" } ] }, - { "prim": "COMPARE" }, { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "min_tokens_bought must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "self_is_updating_token_pool must be false" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "NOW" }, { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", "args": - [ { "prim": "string" }, - { "string": - "xtz_pool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "token_pool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIG", "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "AMOUNT" }, - { "prim": "DIG", "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "999" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "MUL" }, - { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "1000" } ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "MUL" }, { "prim": "ADD" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "999" } ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "MUL" }, { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "tokens_bought must be greater than or equal to min_tokens_bought." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "SUB" }, - { "prim": "PUSH", - "args": [ { "prim": "int" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [ { "prim": "DIG", + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The current time must be less than the deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "amount must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "COMPARE" }, { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "min_tokens_bought must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "xtz_pool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "token_pool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "AMOUNT" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "999" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "MUL" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "1000" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "MUL" }, { "prim": "ADD" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, { "prim": "DUP" }, { "prim": "DUG", "args": [ { "int": "3" } ] }, { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "SWAP" }, - { "prim": "ABS" }, { "prim": "PAIR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "999" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "MUL" }, { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "DIV by 0" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "tokens_bought must be greater than or equal to min_tokens_bought." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "DIG", "args": [ { "int": "2" } ] }, { "prim": "DUP" }, { "prim": "DUG", "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "SUB" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, { "int": "0" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GE" }, + { "prim": "IF", + "args": + [ [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "ABS" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "PAIR" } ], + [ { "prim": "DROP" }, + { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "token_pool - tokens_bought is negative." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "AMOUNT" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "ADD" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "PAIR" }, { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "PAIR" } ], - [ { "prim": "DROP" }, + "args": [ { "int": "3" } ] }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], [] ] }, { "prim": "PUSH", "args": - [ { "prim": "string" }, - { "string": - "token_pool - tokens_bought is negative." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "AMOUNT" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "ADD" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "DIG", "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, { "prim": "SELF" }, - { "prim": "ADDRESS" }, { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, { "prim": "SWAP" }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ] ] } ] + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, { "prim": "SELF" }, + { "prim": "ADDRESS" }, { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "SWAP" }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ] ] } ] ] } ] diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index abe7da4841de..5c6ec8d5be53 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -77,7 +77,7 @@ let constants_sandbox = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baker_sunset = 64l; + liquidity_baker_sunset = 1024l; } let constants_test = @@ -92,16 +92,15 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baker_sunset = 64l; + liquidity_baker_sunset = 1024l; } let bootstrap_accounts_strings = [ "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"; "edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9"; "edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV"; - "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" ] - -(* "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" ] *) + "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU"; + "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" ] let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L @@ -120,20 +119,15 @@ let bootstrap_accounts = let bootstrap_contracts_strings = [ ( None, + 2_000_000_000_000L, + "fa12.json", + "Pair {} 2000000000000", + Contract_repr.initial_origination_nonce Operation_hash.(of_hex_exn (`Hex (String.make (size * 2) '1')))); + ( None, 4_000_000_000_000L, - (* 20% of outstanding tez *) "cpmm.json", - "4000000000000", - Contract_repr.initial_origination_nonce Operation_hash.zero ) ] - -(* let parse source = - * Michelson_v1_parser.parse_toplevel ?check:(Some true) source - * |> Tezos_micheline.Micheline_parser.no_parsing_error - * |> function - * | Error _ -> - * assert false - * | Ok parsing_result -> - * parsing_result.Michelson_v1_parser.expanded *) + "Pair {} (Pair (Pair 4000000000000 False) (Pair 2000000000000 2000000000000))", + Contract_repr.initial_origination_nonce Operation_hash.zero ); ] let parse_storage source = Michelson_v1_parser.parse_expression ?check:(Some true) source diff --git a/src/proto_alpha/lib_parameters/fa12.json b/src/proto_alpha/lib_parameters/fa12.json new file mode 100644 index 000000000000..815c399b2201 --- /dev/null +++ b/src/proto_alpha/lib_parameters/fa12.json @@ -0,0 +1,443 @@ +[ { "prim": "parameter", + "args": + [ { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ "%spender" ] }, + { "prim": "nat", "annots": [ "%value" ] } ], + "annots": [ "%approve" ] }, + { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ "%owner" ] }, + { "prim": "address", + "annots": [ "%spender" ] } ] }, + { "prim": "contract", + "args": [ { "prim": "nat" } ] } ], + "annots": [ "%getAllowance" ] } ] }, + { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address", "annots": [ "%owner" ] }, + { "prim": "contract", + "args": [ { "prim": "nat" } ] } ], + "annots": [ "%getBalance" ] }, + { "prim": "pair", + "args": + [ { "prim": "unit" }, + { "prim": "contract", + "args": [ { "prim": "nat" } ] } ], + "annots": [ "%getTotalSupply" ] } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "address", "annots": [ "%from" ] }, + { "prim": "pair", + "args": + [ { "prim": "address", "annots": [ "%to" ] }, + { "prim": "nat", "annots": [ "%value" ] } ] } ], + "annots": [ "%transfer" ] } ] } ] }, + { "prim": "storage", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "big_map", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "map", + "args": + [ { "prim": "address" }, { "prim": "nat" } ], + "annots": [ "%allowances" ] }, + { "prim": "nat", "annots": [ "%balance" ] } ] } ], + "annots": [ "%ledger" ] }, + { "prim": "nat", "annots": [ "%totalSupply" ] } ] } ] }, + { "prim": "code", + "args": + [ [ { "prim": "NIL", "args": [ { "prim": "operation" } ] }, + { "prim": "LAMBDA", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "big_map", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "map", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] }, + { "prim": "nat" } ] } ] }, + { "prim": "nat" } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "map", + "args": [ { "prim": "address" }, { "prim": "nat" } ] }, + { "prim": "nat" } ] }, + [ { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "SWAP" }, { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "EMPTY_MAP", + "args": + [ { "prim": "address" }, { "prim": "nat" } ] }, + { "prim": "PAIR" } ], [] ] } ] ] }, + { "prim": "LAMBDA", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "map", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] }, + { "prim": "nat" } ] }, + { "prim": "address" } ] }, + { "prim": "pair", + "args": + [ { "prim": "big_map", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "map", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] }, + { "prim": "nat" } ] } ] }, + { "prim": "nat" } ] } ] }, { "prim": "nat" }, + [ { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "DROP" }, + { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "CAR" }, { "prim": "SWAP" }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": [ { "prim": "nat" }, { "int": "0" } ] } ], + [] ] } ] ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, { "prim": "DUP" }, + { "prim": "CDR" }, { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "SENDER" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "PAIR" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "5" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "GT" }, + { "prim": "AND" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "UnsafeAllowanceChange" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "SOME" }, + { "prim": "SWAP" }, { "prim": "UPDATE" }, + { "prim": "PAIR" }, { "prim": "SOME" }, + { "prim": "SENDER" }, { "prim": "UPDATE" }, + { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "PAIR" } ], + [ { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DROP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "PAIR" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ], + [ { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "CAR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "PAIR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "CONS" }, { "prim": "PAIR" } ], + [ { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, { "prim": "CDR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", + "args": [ { "int": "2" } ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ], + [ { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, + { "prim": "DIG", "args": [ { "int": "6" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "7" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "COMPARE" }, { "prim": "LT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "NotEnoughBalance" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SENDER" }, + { "prim": "DIG", "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "5" } ] }, + { "prim": "COMPARE" }, { "prim": "NEQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "3" } ] }, + { "prim": "SENDER" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "3" } ] }, + { "prim": "PAIR" }, { "prim": "PAIR" }, + { "prim": "DIG", "args": [ { "int": "6" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "COMPARE" }, { "prim": "LT" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "NotEnoughAllowance" } ] }, + { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "4" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "SUB" }, { "prim": "ABS" }, + { "prim": "SOME" }, { "prim": "SENDER" }, + { "prim": "UPDATE" }, { "prim": "PAIR" } ], + [ { "prim": "DIG", "args": [ { "int": "5" } ] }, + { "prim": "DROP" } ] ] }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "SUB" }, { "prim": "ABS" }, + { "prim": "SWAP" }, { "prim": "CAR" }, { "prim": "PAIR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DIG", "args": [ { "int": "4" } ] }, + { "prim": "SWAP" }, { "prim": "SOME" }, { "prim": "SWAP" }, + { "prim": "UPDATE" }, { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, + { "prim": "DIG", "args": [ { "int": "4" } ] }, + { "prim": "SWAP" }, { "prim": "EXEC" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "ADD" }, { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "PAIR" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, { "prim": "SOME" }, { "prim": "SWAP" }, + { "prim": "UPDATE" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, { "prim": "PAIR" } ] ] } ] ] } ] + -- GitLab From 7ec5b04b823b2929115b1e2bf6764a14bbfa5040 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Sun, 10 Jan 2021 20:28:34 -0500 Subject: [PATCH 04/62] liquidity baking: call default entrypoint of cpmm to update storage --- src/proto_alpha/lib_protocol/apply.ml | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 1b99babc4edc..f79789cfaae9 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1616,6 +1616,36 @@ let finalize_application ctxt protocol_data delegate ~block_delay in Contract.credit ctxt liquidity_baker liquidity_baker_reward >>=? fun ctxt -> + Contract.get_script ctxt liquidity_baker + >>=? fun (ctxt, script) -> + match script with + | None -> Lwt.return (error (Script_tc_errors.No_such_entrypoint "default") ) + | Some script -> + let step_constants = + let open Script_interpreter in + {source = liquidity_baker; + payer = liquidity_baker; + self = liquidity_baker; + amount = liquidity_baker_reward; + chain_id = Chain_id.zero; } (* TODO: get chain_id *) + in + let parameter = Micheline.strip_locations Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) in + Script_interpreter.execute + ctxt + Optimized + step_constants + ~script + ~parameter + ~entrypoint:"default" + ~internal:true + >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> + let _operations = operations in + Contract.update_script_storage + ctxt + liquidity_baker + storage + lazy_storage_diff + >>=? fun ctxt -> (* end of cycle *) may_snapshot_roll ctxt >>=? fun ctxt -> -- GitLab From c1a6835ed1e4bcb2f75f4cb0c24f15687bc8d6a6 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Sun, 10 Jan 2021 20:28:59 -0500 Subject: [PATCH 05/62] liquidity baking: add protocol stitching --- src/proto_alpha/lib_protocol/init_storage.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 34b604210ef1..b624b3f056fe 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -86,7 +86,7 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = ~amount_mutez:100_000_000L >>= fun (ctxt, balance_updates) -> Storage.Pending_migration_balance_updates.init ctxt balance_updates - >>=? fun ctxt -> Storage.Virtual_baker_share.init ctxt Z.zero + >>=? fun ctxt -> Storage.Liquidity_baker_escape_ema.init ctxt 0l let prepare ctxt ~level ~predecessor_timestamp ~timestamp ~fitness = Raw_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt -- GitLab From ad7580766954f7583945fcd56454e09d9027849a Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Sun, 10 Jan 2021 20:30:13 -0500 Subject: [PATCH 06/62] liquidity baking: increase block_security deposit to 544 --- src/proto_alpha/lib_parameters/default_parameters.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 5c6ec8d5be53..e9d94dbc49aa 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -43,7 +43,7 @@ let constants_mainnet = seed_nonce_revelation_tip = (match Tez.(one /? 8L) with Ok c -> c | Error _ -> assert false); origination_size = 257; - block_security_deposit = Tez.(mul_exn one 512); + block_security_deposit = Tez.(mul_exn one 544); endorsement_security_deposit = Tez.(mul_exn one 64); baking_reward_per_endorsement = Tez.[of_mutez_exn 1_250_000L; of_mutez_exn 187_500L]; -- GitLab From fcc8288a3419a5ae327357628aaa0bed43113e93 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Sun, 10 Jan 2021 20:32:38 -0500 Subject: [PATCH 07/62] liquidity baking: correct reward --- src/proto_alpha/lib_protocol/apply.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index f79789cfaae9..482470245a88 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1607,7 +1607,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay Compare.Int32.(level < Constants.liquidity_baker_sunset ctxt) && Compare.Int32.(liquidity_baker_escape_ema <= 500000l) then - match Tez.of_mutez 5L with + match Tez.of_mutez 5_000_000L with | None -> Tez.zero | Some liquidity_baker_reward -> -- GitLab From ab4962ef56774d525e776d6bebe3a5a84d4aceb8 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 11 Jan 2021 22:51:35 -0500 Subject: [PATCH 08/62] liquidity baking: move escape_flag to protocol_data --- .../lib_delegate/client_baking_forge.ml | 60 ++++++++++--------- .../lib_delegate/client_baking_forge.mli | 4 +- .../lib_delegate/client_baking_lib.ml | 3 +- .../lib_delegate/client_baking_lib.mli | 1 + src/proto_alpha/lib_delegate/client_daemon.ml | 4 +- .../lib_delegate/client_daemon.mli | 2 +- .../lib_delegate/delegate_commands.ml | 27 +++++---- .../lib_protocol/alpha_context.mli | 1 + src/proto_alpha/lib_protocol/apply.ml | 10 +++- .../lib_protocol/block_header_repr.ml | 15 +++-- .../lib_protocol/block_header_repr.mli | 1 + .../lib_protocol/helpers_services.ml | 27 +++++++-- .../lib_protocol/helpers_services.mli | 1 + .../lib_protocol/test/helpers/block.ml | 9 +-- .../lib_protocol/test/helpers/block.mli | 1 + 15 files changed, 101 insertions(+), 65 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index c287d7b1bbb9..6556f2a5951b 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -113,9 +113,9 @@ let generate_seed_nonce () = nonce let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block - delegate_sk shell priority seed_nonce_hash = + delegate_sk shell priority seed_nonce_hash liquidity_baker_escape_flag = Client_baking_pow.mine cctxt chain block shell (fun proof_of_work_nonce -> - {Block_header.priority; seed_nonce_hash; proof_of_work_nonce}) + {Block_header.priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag }) >>=? fun contents -> let unsigned_header = Data_encoding.Binary.to_bytes_exn @@ -130,7 +130,8 @@ let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block ~watermark:(Block_header chain_id) unsigned_header -let forge_faked_protocol_data ~priority ~seed_nonce_hash = +let forge_faked_protocol_data ~priority ~seed_nonce_hash + ~liquidity_baker_escape_flag = Alpha_context.Block_header. { contents = @@ -138,6 +139,7 @@ let forge_faked_protocol_data ~priority ~seed_nonce_hash = priority; seed_nonce_hash; proof_of_work_nonce = Client_baking_pow.empty_proof_of_work_nonce; + liquidity_baker_escape_flag; }; signature = Signature.zero; } @@ -178,7 +180,8 @@ let compute_endorsing_power cctxt ~chain ~block operations = operations let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header - ~priority ~delegate_pkh ~delegate_sk ~level operations = + ~priority ~delegate_pkh ~delegate_sk ~level operations + liquidity_baker_escape_flag = assert_valid_operations_hash shell_header operations >>=? fun () -> let block = `Hash (shell_header.Tezos_base.Block_header.predecessor, 0) in @@ -190,6 +193,7 @@ let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header shell_header priority seed_nonce_hash + liquidity_baker_escape_flag >>=? fun signed_header -> (* Record baked blocks to prevent double baking *) let open Client_baking_highwatermarks in @@ -606,8 +610,7 @@ let error_of_op (result : error Preapply_result.t) op = let filter_and_apply_operations cctxt state ~chain ~block block_info ~priority ?protocol_data - ((operations : packed_operation list list), overflowing_operations) - ~liquidity_baker_escape_flag = + ((operations : packed_operation list list), overflowing_operations) = (* Retrieve the minimal valid time for when the block can be baked with 0 endorsements *) Delegate_services.Minimal_valid_time.get cctxt (chain, block) priority 0 >>=? fun min_valid_timestamp -> @@ -725,19 +728,6 @@ let filter_and_apply_operations cctxt state ~chain ~block block_info ~priority >>= fun (manager_inc, anonymous) -> filter_valid_operations manager_inc (managers @ overflowing_operations) >>= fun (inc, managers) -> - let inc = - { - inc with - state = - { - inc.state with - ctxt = - Protocol.Alpha_context.set_liquidity_baker_escape_flag - inc.state.ctxt - liquidity_baker_escape_flag; - }; - } - in finalize_construction inc >>=? fun _ -> let quota : Environment.Updater.quota list = Main.validation_passes in @@ -783,6 +773,16 @@ let filter_and_apply_operations cctxt state ~chain ~block block_info ~priority state.index block_info >>=? fun inc -> + (* Alpha_services.Forge.set_liquidity_baker_escape_ema + * inc.state.ctxt + * block + * chain + * liquidity_baker_escape_flag + * >>=? fun ctxt -> *) + (* let ctxt = Alpha_context.set_liquidity_baker_escape_flag + * inc.state.ctxt + * liquidity_baker_escape_flag in + * let inc = { inc with state = {inc.state with ctxt } } in *) List.fold_left_es (fun inc op -> add_operation inc op >>=? fun (inc, _receipt) -> return inc) inc @@ -842,8 +842,9 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ?(sort = best_effort) ?(minimal_fees = default_minimal_fees) ?(minimal_nanotez_per_gas_unit = default_minimal_nanotez_per_gas_unit) ?(minimal_nanotez_per_byte = default_minimal_nanotez_per_byte) ?timestamp - ?mempool ?context_path ?seed_nonce_hash ~chain ~priority ~delegate_pkh - ~delegate_sk block = + ?mempool ?context_path ?seed_nonce_hash + ~liquidity_baker_escape_flag + ~chain ~priority ~delegate_pkh ~delegate_sk block = (* making the arguments usable *) unopt_operations cctxt chain mempool operations >>=? fun operations_arg -> @@ -854,7 +855,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) unopt_timestamp ?force timestamp minimal_timestamp >>=? fun timestamp -> (* get basic building blocks *) - let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash in + let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baker_escape_flag in Alpha_services.Constants.all cctxt (chain, block) >>=? fun Constants. { parametric = {hard_gas_limit_per_block; endorsers_per_block; _}; @@ -952,7 +953,6 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ~protocol_data bi (operations, overflowing_ops) - ~liquidity_baker_escape_flag:false >>=? fun ( final_context, (validation_result, _), operations, @@ -1032,6 +1032,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ~delegate_sk ~level operations + liquidity_baker_escape_flag >>= function | Ok hash -> return hash @@ -1050,7 +1051,8 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) let shell_prevalidation (cctxt : #Protocol_client_context.full) ~chain ~block ~timestamp seed_nonce_hash operations ((_, (bi, priority, delegate)) as _slot) = - let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash in + let liquidity_baker_escape_flag = false in + let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baker_escape_flag in Alpha_block_services.Helpers.Preapply.block cctxt ~chain @@ -1254,7 +1256,7 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash slot else let protocol_data = - forge_faked_protocol_data ~priority ~seed_nonce_hash + forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baker_escape_flag in filter_and_apply_operations cctxt @@ -1265,7 +1267,6 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash ~protocol_data bi (operations, overflowing_ops) - ~liquidity_baker_escape_flag >>= function | Error errs -> lwt_log_error @@ -1419,6 +1420,7 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ~delegate_sk ~level operations + liquidity_baker_escape_flag >>= function | Error errs -> lwt_log_error @@ -1611,9 +1613,9 @@ let reveal_potential_nonces (cctxt : #Client_context.full) constants ~chain starts individual baking operations when baking-slots are available to any of the [delegates] *) let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades - ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?max_priority ~chain ~context_path delegates block_stream - ~liquidity_baker_escape_flag = + ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte + ?max_priority ~liquidity_baker_escape_flag + ~chain ~context_path delegates block_stream = let state_maker bi = Alpha_services.Constants.all cctxt (chain, `Head 0) >>=? fun constants -> diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.mli b/src/proto_alpha/lib_delegate/client_baking_forge.mli index 793ed049e513..afa81440bfd3 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.mli +++ b/src/proto_alpha/lib_delegate/client_baking_forge.mli @@ -48,6 +48,7 @@ val inject_block : delegate_sk:Client_keys.sk_uri -> level:Raw_level.t -> Operation.raw list list -> + bool -> Block_hash.t tzresult Lwt.t type error += Failed_to_preapply of Tezos_base.Operation.t * error list @@ -85,6 +86,7 @@ val forge_block : ?mempool:string -> ?context_path:string -> ?seed_nonce_hash:Nonce_hash.t -> + liquidity_baker_escape_flag:bool -> chain:Chain_services.chain -> priority:[`Set of int | `Auto of public_key_hash * int option] -> delegate_pkh:Signature.Public_key_hash.t -> @@ -99,9 +101,9 @@ val create : ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> + liquidity_baker_escape_flag:bool -> chain:Chain_services.chain -> context_path:string -> public_key_hash list -> Client_baking_blocks.block_info tzresult Lwt_stream.t -> - liquidity_baker_escape_flag:bool -> unit tzresult Lwt.t diff --git a/src/proto_alpha/lib_delegate/client_baking_lib.ml b/src/proto_alpha/lib_delegate/client_baking_lib.ml index face4ba87e2c..e2922a73d076 100644 --- a/src/proto_alpha/lib_delegate/client_baking_lib.ml +++ b/src/proto_alpha/lib_delegate/client_baking_lib.ml @@ -29,7 +29,7 @@ open Alpha_context let bake_block (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force ?max_priority ?(minimal_timestamp = false) ?mempool ?context_path ?src_sk - ~chain ~head delegate = + ~liquidity_baker_escape_flag ~chain ~head delegate = ( match src_sk with | None -> Client_keys.get_key cctxt delegate @@ -60,6 +60,7 @@ let bake_block (cctxt : #Protocol_client_context.full) ?minimal_fees ?seed_nonce_hash ?mempool ?context_path + ~liquidity_baker_escape_flag ~chain ~priority:(`Auto (delegate, max_priority)) ~delegate_pkh:delegate diff --git a/src/proto_alpha/lib_delegate/client_baking_lib.mli b/src/proto_alpha/lib_delegate/client_baking_lib.mli index dd8e00bf3565..b28056125df9 100644 --- a/src/proto_alpha/lib_delegate/client_baking_lib.mli +++ b/src/proto_alpha/lib_delegate/client_baking_lib.mli @@ -38,6 +38,7 @@ val bake_block : ?mempool:string -> ?context_path:string -> ?src_sk:Client_keys.sk_uri -> + liquidity_baker_escape_flag:bool -> chain:Chain_services.chain -> head:Block_services.block -> public_key_hash -> diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index e67f52a4fb45..e3d83cc03b71 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -94,7 +94,7 @@ end module Baker = struct let run (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~chain ~context_path ~keep_alive ~liquidity_baker_escape_flag delegates = + ~liquidity_baker_escape_flag ~chain ~context_path ~keep_alive delegates = let process () = Config_services.user_activated_upgrades cctxt >>=? fun user_activated_upgrades -> @@ -112,11 +112,11 @@ module Baker = struct ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority + ~liquidity_baker_escape_flag ~chain ~context_path delegates block_stream - ~liquidity_baker_escape_flag in Client_confirmations.wait_for_bootstrapped ~retry:(retry cctxt ~delay:1. ~factor:1.5 ~tries:5) diff --git a/src/proto_alpha/lib_delegate/client_daemon.mli b/src/proto_alpha/lib_delegate/client_daemon.mli index 86b5f1684fc4..47825a483480 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.mli +++ b/src/proto_alpha/lib_delegate/client_daemon.mli @@ -43,10 +43,10 @@ module Baker : sig ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> + liquidity_baker_escape_flag:bool -> chain:Chain_services.chain -> context_path:string -> keep_alive:bool -> - liquidity_baker_escape_flag:bool -> public_key_hash list -> unit tzresult Lwt.t end diff --git a/src/proto_alpha/lib_delegate/delegate_commands.ml b/src/proto_alpha/lib_delegate/delegate_commands.ml index 8219f8e258ee..9850875db227 100644 --- a/src/proto_alpha/lib_delegate/delegate_commands.ml +++ b/src/proto_alpha/lib_delegate/delegate_commands.ml @@ -86,12 +86,19 @@ let keep_alive_arg = ~long:"keep-alive" () +let liquidity_baker_escape_flag_arg = + Clic.switch + ~doc:"Vote to stop the liquidity baker subsidy." + ~short:'F' + ~long:"liquidity-baker-escape-flag" + () + let delegate_commands () = let open Clic in [ command ~group ~desc:"Forge and inject block using the delegate rights." - (args8 + (args9 max_priority_arg minimal_fees_arg minimal_nanotez_per_gas_unit_arg @@ -99,7 +106,8 @@ let delegate_commands () = force_switch minimal_timestamp_switch mempool_arg - context_path_arg) + context_path_arg + liquidity_baker_escape_flag_arg ) ( prefixes ["bake"; "for"] @@ Client_keys.Public_key_hash.source_param ~name:"baker" @@ -112,7 +120,8 @@ let delegate_commands () = force, minimal_timestamp, mempool, - context_path ) + context_path, + liquidity_baker_escape_flag ) delegate cctxt -> bake_block @@ -125,6 +134,7 @@ let delegate_commands () = ~minimal_timestamp ?mempool ?context_path + ~liquidity_baker_escape_flag ~chain:cctxt#chain ~head:cctxt#block delegate); @@ -236,13 +246,6 @@ let delegate_commands () = block_hashes >>= fun () -> return_unit)) ] -let liquidity_baker_escape_flag = - Clic.switch - ~doc:"Vote to stop the liquidity baker subsidy." - ~short:'F' - ~long:"liquidity-baker-escape-flag" - () - let baker_commands () = let open Clic in let group = @@ -261,7 +264,7 @@ let baker_commands () = minimal_nanotez_per_gas_unit_arg minimal_nanotez_per_byte_arg keep_alive_arg - liquidity_baker_escape_flag) + liquidity_baker_escape_flag_arg) ( prefixes ["run"; "with"; "local"; "node"] @@ param ~name:"context_path" @@ -291,9 +294,9 @@ let baker_commands () = ~minimal_nanotez_per_gas_unit ~minimal_nanotez_per_byte ?max_priority + ~liquidity_baker_escape_flag ~context_path:(Filename.concat node_path "context") ~keep_alive - ~liquidity_baker_escape_flag (List.map snd delegates)) ] let endorser_commands () = diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 938e1c6165ff..bbb5615ad529 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1177,6 +1177,7 @@ module Block_header : sig priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; + liquidity_baker_escape_flag : bool; } type protocol_data = {contents : contents; signature : Signature.t} diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 482470245a88..7354cd62f1b1 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1502,6 +1502,8 @@ let begin_full_construction ctxt pred_timestamp protocol_data = >>=? fun ctxt -> Baking.check_baking_rights ctxt protocol_data pred_timestamp >>=? fun (delegate_pk, block_delay) -> + set_liquidity_baker_escape_ema ctxt protocol_data.liquidity_baker_escape_flag + >>=? fun (ctxt, _liquidity_baker_escape_ema) -> let ctxt = Fitness.increase ctxt in endorsement_rights_of_pred_level ctxt >|=? fun rights -> @@ -1595,17 +1597,19 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some nonce_hash -> Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> - set_liquidity_baker_escape_ema ctxt (get_liquidity_baker_escape_flag ctxt) - >>=? fun (ctxt, liquidity_baker_escape_ema) -> let liquidity_baker = Contract.originated_contract (Constants.liquidity_baker_origination_nonce ctxt) in + get_liquidity_baker_escape_ema ctxt + >>=? fun liquidity_baker_escape_ema -> + (* set_liquidity_baker_escape_ema ctxt (get_liquidity_baker_escape_flag ctxt) + * >>=? fun (ctxt, liquidity_baker_escape_ema) -> *) let liquidity_baker_reward = let level = Raw_level.to_int32 (Level.current ctxt).level in if Compare.Int32.(level < Constants.liquidity_baker_sunset ctxt) - && Compare.Int32.(liquidity_baker_escape_ema <= 500000l) + && Compare.Int32.(liquidity_baker_escape_ema < 5_000l) then match Tez.of_mutez 5_000_000L with | None -> diff --git a/src/proto_alpha/lib_protocol/block_header_repr.ml b/src/proto_alpha/lib_protocol/block_header_repr.ml index faf827278a93..2599e3f5bcdc 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.ml +++ b/src/proto_alpha/lib_protocol/block_header_repr.ml @@ -29,6 +29,7 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; + liquidity_baker_escape_flag : bool; } type protocol_data = {contents : contents; signature : Signature.t} @@ -49,16 +50,17 @@ let contents_encoding = let open Data_encoding in def "block_header.alpha.unsigned_contents" @@ conv - (fun {priority; seed_nonce_hash; proof_of_work_nonce} -> - (priority, proof_of_work_nonce, seed_nonce_hash)) - (fun (priority, proof_of_work_nonce, seed_nonce_hash) -> - {priority; seed_nonce_hash; proof_of_work_nonce}) - (obj3 + (fun {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag} -> + (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baker_escape_flag)) + (fun (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baker_escape_flag) -> + {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag}) + (obj4 (req "priority" uint16) (req "proof_of_work_nonce" (Fixed.bytes Constants_repr.proof_of_work_nonce_size)) - (opt "seed_nonce_hash" Nonce_hash.encoding)) + (opt "seed_nonce_hash" Nonce_hash.encoding) + (req "liquidity_baker_escape_flag" Data_encoding.bool)) let protocol_data_encoding = let open Data_encoding in @@ -108,6 +110,7 @@ let max_header_length = proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '0'; seed_nonce_hash = Some Nonce_hash.zero; + liquidity_baker_escape_flag = false; } in Data_encoding.Binary.length diff --git a/src/proto_alpha/lib_protocol/block_header_repr.mli b/src/proto_alpha/lib_protocol/block_header_repr.mli index 374a0640ea1e..738a8e0c0e55 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.mli +++ b/src/proto_alpha/lib_protocol/block_header_repr.mli @@ -27,6 +27,7 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; + liquidity_baker_escape_flag : bool; } type protocol_data = {contents : contents; signature : Signature.t} diff --git a/src/proto_alpha/lib_protocol/helpers_services.ml b/src/proto_alpha/lib_protocol/helpers_services.ml index 7c7183623415..a958f0fd93a6 100644 --- a/src/proto_alpha/lib_protocol/helpers_services.ml +++ b/src/proto_alpha/lib_protocol/helpers_services.ml @@ -852,15 +852,24 @@ module Forge = struct ~description:"Forge the protocol-specific part of a block header" ~query:RPC_query.empty ~input: - (obj3 + (obj4 (req "priority" uint16) (opt "nonce_hash" Nonce_hash.encoding) (dft "proof_of_work_nonce" (Fixed.bytes Alpha_context.Constants.proof_of_work_nonce_size) - empty_proof_of_work_nonce)) + empty_proof_of_work_nonce) + (req "liquidity_baker_escape_flag" bool)) ~output:(obj1 (req "protocol_data" bytes)) RPC_path.(path / "protocol_data") + + (* let flags = + * RPC_service.post_service + * ~description:"Set block flags" + * ~query:RPC_query.empty + * ~input:bool + * ~output:int32 + * RPC_path.(path / "flags") *) end let register () = @@ -872,11 +881,11 @@ module Forge = struct (shell, proto))) ; register0_noctxt S.protocol_data - (fun () (priority, seed_nonce_hash, proof_of_work_nonce) -> + (fun () (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baker_escape_flag) -> return (Data_encoding.Binary.to_bytes_exn Block_header.contents_encoding - {priority; seed_nonce_hash; proof_of_work_nonce})) + {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag})) module Manager = struct let[@coq_axiom_with_reason "cast on e"] operations ctxt block ~branch @@ -1030,13 +1039,19 @@ module Forge = struct Bytes.make Constants_repr.proof_of_work_nonce_size '\000' let protocol_data ctxt block ~priority ?seed_nonce_hash - ?(proof_of_work_nonce = empty_proof_of_work_nonce) () = + ?(proof_of_work_nonce = empty_proof_of_work_nonce) + ~liquidity_baker_escape_flag () = RPC_context.make_call0 S.protocol_data ctxt block () - (priority, seed_nonce_hash, proof_of_work_nonce) + (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baker_escape_flag) + + (* let set_liquidity_baker_escape_ema ctxt block flag = + * (\* Alpha_context.set_liquidity_baker_escape_ema ctxt flag + * * >>=? fun (ctxt, new_ema) - *\) + * RPC_context.make_call0 S.flags ctxt block () flag *) end module Parse = struct diff --git a/src/proto_alpha/lib_protocol/helpers_services.mli b/src/proto_alpha/lib_protocol/helpers_services.mli index 399a441929bc..55a1bb63253f 100644 --- a/src/proto_alpha/lib_protocol/helpers_services.mli +++ b/src/proto_alpha/lib_protocol/helpers_services.mli @@ -289,6 +289,7 @@ module Forge : sig priority:int -> ?seed_nonce_hash:Nonce_hash.t -> ?proof_of_work_nonce:bytes -> + liquidity_baker_escape_flag:bool -> unit -> bytes shell_tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 6ee67bad2100..3778f1fcdfec 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -145,8 +145,9 @@ module Forge = struct Bytes.create Constants.proof_of_work_nonce_size let make_contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ~priority ~seed_nonce_hash () = - Block_header.{priority; proof_of_work_nonce; seed_nonce_hash} + ?(liquidity_baker_escape_flag = false) + ~priority ~seed_nonce_hash () = + Block_header.{priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baker_escape_flag} let make_shell ~level ~predecessor ~timestamp ~fitness ~operations_hash = Tezos_base.Block_header. @@ -221,8 +222,8 @@ module Forge = struct (* compatibility only, needed by incremental *) let contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ?(priority = 0) ?seed_nonce_hash () = - {Block_header.priority; proof_of_work_nonce; seed_nonce_hash} + ?(priority = 0) ?seed_nonce_hash ?(liquidity_baker_escape_flag = false) () = + {Block_header.priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baker_escape_flag} end (********* Genesis creation *************) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 7d327b3fdf99..f9dd2ac3ff3c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -62,6 +62,7 @@ module Forge : sig ?proof_of_work_nonce:Bytes.t -> ?priority:int -> ?seed_nonce_hash:Nonce_hash.t -> + ?liquidity_baker_escape_flag:bool -> unit -> Block_header.contents -- GitLab From 1aca8d38d566848d1d5af9eb8bb3b22fda4280a1 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 11 Jan 2021 22:52:56 -0500 Subject: [PATCH 09/62] liquidity_baking: increase sunset in test params --- src/proto_alpha/lib_parameters/default_parameters.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index e9d94dbc49aa..40eb9935fbad 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -92,7 +92,7 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baker_sunset = 1024l; + liquidity_baker_sunset = 2058l; } let bootstrap_accounts_strings = -- GitLab From 5b0f064912e12ca7e105cfee9a48de7a8db69453 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 11 Jan 2021 22:55:21 -0500 Subject: [PATCH 10/62] liquidity baking: add unit tests --- src/proto_alpha/lib_protocol/test/main.ml | 3 +- .../test/test_liquidity_baking.ml | 183 ++++++++++++++++++ 2 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml diff --git a/src/proto_alpha/lib_protocol/test/main.ml b/src/proto_alpha/lib_protocol/test/main.ml index 3dfbf30e1f0f..0d23a9efe922 100644 --- a/src/proto_alpha/lib_protocol/test/main.ml +++ b/src/proto_alpha/lib_protocol/test/main.ml @@ -60,5 +60,6 @@ let () = ("script deserialize gas", Test_script_gas.tests); ("failing_noop operation", Test_failing_noop.tests); ("storage description", Test_storage.tests); - ("time", Test_time_repr.tests) ] + ("time", Test_time_repr.tests); + ("liquidity baking", Liquidity_baking.tests); ] |> Lwt_main.run diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml new file mode 100644 index 000000000000..1d6f57b7d408 --- /dev/null +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -0,0 +1,183 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2020 Tocqueville Group, Inc. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Protocol +open Test_tez + +let liquidity_baking_rewards n () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baker = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baker_origination_nonce + in + Context.Contract.balance (B blk) liquidity_baker + >>=? fun old_balance -> + Block.bake_n n blk + >>=? fun blk -> + Assert.balance_was_credited + ~loc:__LOC__ + (B blk) + liquidity_baker + old_balance + (Tez.of_int (5*n)) + >>=? fun () -> return_unit + +let liquidity_baking_sunset () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baker = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baker_origination_nonce + in + let sunset = csts.parametric.liquidity_baker_sunset in + Context.Contract.balance (B blk) liquidity_baker + >>=? fun old_balance -> + Block.bake_n Int32.(to_int (add sunset 100l)) blk + >>=? fun blk -> + Assert.balance_was_credited + ~loc:__LOC__ + (B blk) + liquidity_baker + old_balance + (Tez.of_int Int32.(to_int (mul 5l (sub sunset 1l)))) + >>=? fun () -> return_unit + +let liquidity_baking_escape_hatch_100 () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baker = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baker_origination_nonce + in + let escape_level = 693 in + Context.Contract.balance (B blk) liquidity_baker + >>=? fun old_balance -> + Block.bake_n (escape_level + 100) blk + >>=? fun blk -> + Assert.balance_was_credited + ~loc:__LOC__ + (B blk) + liquidity_baker + old_balance + (Tez.of_int (5*(escape_level - 1))) + >>=? fun () -> return_unit + +let liquidity_baking_escape_hatch_80 () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baker = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baker_origination_nonce + in + let escape_level = 980 in + Context.Contract.balance (B blk) liquidity_baker + >>=? fun old_balance -> + let rec bake_80_percent_escaping blk i = + if i < escape_level + then + Block.bake_n 4 blk (* with escape hatch flag *) + >>=? fun blk -> + Block.bake blk + >>=? fun blk -> + bake_80_percent_escaping blk (i+5) + else return blk + in + bake_80_percent_escaping blk 0 + >>=? fun blk -> + Block.bake_n 100 blk + >>=? fun blk -> + Assert.balance_was_credited + ~loc:__LOC__ + (B blk) + liquidity_baker + old_balance + (Tez.of_int (5*(escape_level - 1))) + >>=? fun () -> return_unit + +let liquidity_baking_escape_hatch_60 () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baker = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baker_origination_nonce + in + let escape_level = 1790 in + Context.Contract.balance (B blk) liquidity_baker + >>=? fun old_balance -> + let rec bake_80_percent_escaping blk i = + if i < escape_level + then + Block.bake_n 3 blk (* with escape hatch flag *) + >>=? fun blk -> + Block.bake_n 2 blk + >>=? fun blk -> + bake_80_percent_escaping blk (i+5) + else return blk + in + bake_80_percent_escaping blk 0 + >>=? fun blk -> + Block.bake_n 100 blk + >>=? fun blk -> + Assert.balance_was_credited + ~loc:__LOC__ + (B blk) + liquidity_baker + old_balance + (Tez.of_int (5*(escape_level - 1))) + >>=? fun () -> return_unit + +let tests = + [ Test.tztest + "test liquidity baking rewards are correct" + `Quick + (liquidity_baking_rewards 64); + Test.tztest + "test liquidity baking shuts off at sunset level" + `Quick + liquidity_baking_sunset; + Test.tztest + "test liquidity baking escape hatch with 100% of bakers flagging" + `Quick + liquidity_baking_escape_hatch_100; + Test.tztest + "test liquidity baking escape hatch with 80% of bakers flagging" + `Quick + liquidity_baking_escape_hatch_80; + Test.tztest + "test liquidity baking escape hatch with 60% of bakers flagging" + `Quick + liquidity_baking_escape_hatch_60; + ] -- GitLab From f69f3d20b72f03d89e5861c97d065b92c9b7a132 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 11 Jan 2021 23:09:46 -0500 Subject: [PATCH 11/62] liquidity baking: s/liquidity_baker/liquidity_baking --- .../lib_delegate/client_baking_forge.ml | 44 +++++++++---------- .../lib_delegate/client_baking_forge.mli | 4 +- .../lib_delegate/client_baking_lib.ml | 4 +- .../lib_delegate/client_baking_lib.mli | 2 +- src/proto_alpha/lib_delegate/client_daemon.ml | 4 +- .../lib_delegate/client_daemon.mli | 2 +- .../lib_delegate/delegate_commands.ml | 14 +++--- .../lib_parameters/default_parameters.ml | 8 ++-- src/proto_alpha/lib_protocol/alpha_context.ml | 16 +++---- .../lib_protocol/alpha_context.mli | 10 ++--- src/proto_alpha/lib_protocol/apply.ml | 40 ++++++++--------- .../lib_protocol/block_header_repr.ml | 14 +++--- .../lib_protocol/block_header_repr.mli | 2 +- .../lib_protocol/constants_repr.ml | 20 ++++----- .../lib_protocol/constants_storage.ml | 8 ++-- .../lib_protocol/helpers_services.ml | 14 +++--- .../lib_protocol/helpers_services.mli | 2 +- src/proto_alpha/lib_protocol/raw_context.ml | 10 ++--- src/proto_alpha/lib_protocol/raw_context.mli | 4 +- src/proto_alpha/lib_protocol/storage.ml | 4 +- src/proto_alpha/lib_protocol/storage.mli | 2 +- .../lib_protocol/test/helpers/block.ml | 8 ++-- .../lib_protocol/test/helpers/block.mli | 2 +- .../test/test_liquidity_baking.ml | 42 +++++++++--------- 24 files changed, 140 insertions(+), 140 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index 6556f2a5951b..4104115b7efa 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -113,9 +113,9 @@ let generate_seed_nonce () = nonce let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block - delegate_sk shell priority seed_nonce_hash liquidity_baker_escape_flag = + delegate_sk shell priority seed_nonce_hash liquidity_baking_escape_flag = Client_baking_pow.mine cctxt chain block shell (fun proof_of_work_nonce -> - {Block_header.priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag }) + {Block_header.priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag }) >>=? fun contents -> let unsigned_header = Data_encoding.Binary.to_bytes_exn @@ -131,7 +131,7 @@ let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block unsigned_header let forge_faked_protocol_data ~priority ~seed_nonce_hash - ~liquidity_baker_escape_flag = + ~liquidity_baking_escape_flag = Alpha_context.Block_header. { contents = @@ -139,7 +139,7 @@ let forge_faked_protocol_data ~priority ~seed_nonce_hash priority; seed_nonce_hash; proof_of_work_nonce = Client_baking_pow.empty_proof_of_work_nonce; - liquidity_baker_escape_flag; + liquidity_baking_escape_flag; }; signature = Signature.zero; } @@ -181,7 +181,7 @@ let compute_endorsing_power cctxt ~chain ~block operations = let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header ~priority ~delegate_pkh ~delegate_sk ~level operations - liquidity_baker_escape_flag = + liquidity_baking_escape_flag = assert_valid_operations_hash shell_header operations >>=? fun () -> let block = `Hash (shell_header.Tezos_base.Block_header.predecessor, 0) in @@ -193,7 +193,7 @@ let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header shell_header priority seed_nonce_hash - liquidity_baker_escape_flag + liquidity_baking_escape_flag >>=? fun signed_header -> (* Record baked blocks to prevent double baking *) let open Client_baking_highwatermarks in @@ -773,15 +773,15 @@ let filter_and_apply_operations cctxt state ~chain ~block block_info ~priority state.index block_info >>=? fun inc -> - (* Alpha_services.Forge.set_liquidity_baker_escape_ema + (* Alpha_services.Forge.set_liquidity_baking_escape_ema * inc.state.ctxt * block * chain - * liquidity_baker_escape_flag + * liquidity_baking_escape_flag * >>=? fun ctxt -> *) - (* let ctxt = Alpha_context.set_liquidity_baker_escape_flag + (* let ctxt = Alpha_context.set_liquidity_baking_escape_flag * inc.state.ctxt - * liquidity_baker_escape_flag in + * liquidity_baking_escape_flag in * let inc = { inc with state = {inc.state with ctxt } } in *) List.fold_left_es (fun inc op -> add_operation inc op >>=? fun (inc, _receipt) -> return inc) @@ -843,7 +843,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ?(minimal_nanotez_per_gas_unit = default_minimal_nanotez_per_gas_unit) ?(minimal_nanotez_per_byte = default_minimal_nanotez_per_byte) ?timestamp ?mempool ?context_path ?seed_nonce_hash - ~liquidity_baker_escape_flag + ~liquidity_baking_escape_flag ~chain ~priority ~delegate_pkh ~delegate_sk block = (* making the arguments usable *) unopt_operations cctxt chain mempool operations @@ -855,7 +855,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) unopt_timestamp ?force timestamp minimal_timestamp >>=? fun timestamp -> (* get basic building blocks *) - let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baker_escape_flag in + let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baking_escape_flag in Alpha_services.Constants.all cctxt (chain, block) >>=? fun Constants. { parametric = {hard_gas_limit_per_block; endorsers_per_block; _}; @@ -1032,7 +1032,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ~delegate_sk ~level operations - liquidity_baker_escape_flag + liquidity_baking_escape_flag >>= function | Ok hash -> return hash @@ -1051,8 +1051,8 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) let shell_prevalidation (cctxt : #Protocol_client_context.full) ~chain ~block ~timestamp seed_nonce_hash operations ((_, (bi, priority, delegate)) as _slot) = - let liquidity_baker_escape_flag = false in - let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baker_escape_flag in + let liquidity_baking_escape_flag = false in + let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baking_escape_flag in Alpha_block_services.Helpers.Preapply.block cctxt ~chain @@ -1190,7 +1190,7 @@ let fetch_operations (cctxt : #Protocol_client_context.full) ~chain validation *) let build_block cctxt ~user_activated_upgrades state seed_nonce_hash ((slot_timestamp, (bi, priority, delegate)) as slot) - ~liquidity_baker_escape_flag = + ~liquidity_baking_escape_flag = let chain = `Hash bi.Client_baking_blocks.chain_id in let block = `Hash (bi.hash, 0) in Alpha_services.Helpers.current_level cctxt ~offset:1l (chain, block) @@ -1256,7 +1256,7 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash slot else let protocol_data = - forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baker_escape_flag + forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baking_escape_flag in filter_and_apply_operations cctxt @@ -1374,7 +1374,7 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash so. All the necessary information is available in the [state.best_slot]. *) let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades - ~chain state ~liquidity_baker_escape_flag = + ~chain state ~liquidity_baking_escape_flag = ( match state.best_slot with | None -> assert false (* unreachable *) @@ -1389,7 +1389,7 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades state seed_nonce_hash slot - ~liquidity_baker_escape_flag + ~liquidity_baking_escape_flag >>=? function | Some (head, priority, shell_header, operations, delegate, seed_nonce_hash) -> ( @@ -1420,7 +1420,7 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ~delegate_sk ~level operations - liquidity_baker_escape_flag + liquidity_baking_escape_flag >>= function | Error errs -> lwt_log_error @@ -1614,7 +1614,7 @@ let reveal_potential_nonces (cctxt : #Client_context.full) constants ~chain the [delegates] *) let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?max_priority ~liquidity_baker_escape_flag + ?max_priority ~liquidity_baking_escape_flag ~chain ~context_path delegates block_stream = let state_maker bi = Alpha_services.Constants.all cctxt (chain, `Head 0) @@ -1670,7 +1670,7 @@ let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ~user_activated_upgrades ~chain state - ~liquidity_baker_escape_flag + ~liquidity_baking_escape_flag >>= function | Error err -> if state.retry_counter = 0 then ( diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.mli b/src/proto_alpha/lib_delegate/client_baking_forge.mli index afa81440bfd3..509935aea1c4 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.mli +++ b/src/proto_alpha/lib_delegate/client_baking_forge.mli @@ -86,7 +86,7 @@ val forge_block : ?mempool:string -> ?context_path:string -> ?seed_nonce_hash:Nonce_hash.t -> - liquidity_baker_escape_flag:bool -> + liquidity_baking_escape_flag:bool -> chain:Chain_services.chain -> priority:[`Set of int | `Auto of public_key_hash * int option] -> delegate_pkh:Signature.Public_key_hash.t -> @@ -101,7 +101,7 @@ val create : ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> - liquidity_baker_escape_flag:bool -> + liquidity_baking_escape_flag:bool -> chain:Chain_services.chain -> context_path:string -> public_key_hash list -> diff --git a/src/proto_alpha/lib_delegate/client_baking_lib.ml b/src/proto_alpha/lib_delegate/client_baking_lib.ml index e2922a73d076..b9a159669523 100644 --- a/src/proto_alpha/lib_delegate/client_baking_lib.ml +++ b/src/proto_alpha/lib_delegate/client_baking_lib.ml @@ -29,7 +29,7 @@ open Alpha_context let bake_block (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force ?max_priority ?(minimal_timestamp = false) ?mempool ?context_path ?src_sk - ~liquidity_baker_escape_flag ~chain ~head delegate = + ~liquidity_baking_escape_flag ~chain ~head delegate = ( match src_sk with | None -> Client_keys.get_key cctxt delegate @@ -60,7 +60,7 @@ let bake_block (cctxt : #Protocol_client_context.full) ?minimal_fees ?seed_nonce_hash ?mempool ?context_path - ~liquidity_baker_escape_flag + ~liquidity_baking_escape_flag ~chain ~priority:(`Auto (delegate, max_priority)) ~delegate_pkh:delegate diff --git a/src/proto_alpha/lib_delegate/client_baking_lib.mli b/src/proto_alpha/lib_delegate/client_baking_lib.mli index b28056125df9..bdde7435e72c 100644 --- a/src/proto_alpha/lib_delegate/client_baking_lib.mli +++ b/src/proto_alpha/lib_delegate/client_baking_lib.mli @@ -38,7 +38,7 @@ val bake_block : ?mempool:string -> ?context_path:string -> ?src_sk:Client_keys.sk_uri -> - liquidity_baker_escape_flag:bool -> + liquidity_baking_escape_flag:bool -> chain:Chain_services.chain -> head:Block_services.block -> public_key_hash -> diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index e3d83cc03b71..99beb0397607 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -94,7 +94,7 @@ end module Baker = struct let run (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~liquidity_baker_escape_flag ~chain ~context_path ~keep_alive delegates = + ~liquidity_baking_escape_flag ~chain ~context_path ~keep_alive delegates = let process () = Config_services.user_activated_upgrades cctxt >>=? fun user_activated_upgrades -> @@ -112,7 +112,7 @@ module Baker = struct ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~liquidity_baker_escape_flag + ~liquidity_baking_escape_flag ~chain ~context_path delegates diff --git a/src/proto_alpha/lib_delegate/client_daemon.mli b/src/proto_alpha/lib_delegate/client_daemon.mli index 47825a483480..fde987d2b2f1 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.mli +++ b/src/proto_alpha/lib_delegate/client_daemon.mli @@ -43,7 +43,7 @@ module Baker : sig ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> - liquidity_baker_escape_flag:bool -> + liquidity_baking_escape_flag:bool -> chain:Chain_services.chain -> context_path:string -> keep_alive:bool -> diff --git a/src/proto_alpha/lib_delegate/delegate_commands.ml b/src/proto_alpha/lib_delegate/delegate_commands.ml index 9850875db227..9bf2c77a09f1 100644 --- a/src/proto_alpha/lib_delegate/delegate_commands.ml +++ b/src/proto_alpha/lib_delegate/delegate_commands.ml @@ -86,7 +86,7 @@ let keep_alive_arg = ~long:"keep-alive" () -let liquidity_baker_escape_flag_arg = +let liquidity_baking_escape_flag_arg = Clic.switch ~doc:"Vote to stop the liquidity baker subsidy." ~short:'F' @@ -107,7 +107,7 @@ let delegate_commands () = minimal_timestamp_switch mempool_arg context_path_arg - liquidity_baker_escape_flag_arg ) + liquidity_baking_escape_flag_arg ) ( prefixes ["bake"; "for"] @@ Client_keys.Public_key_hash.source_param ~name:"baker" @@ -121,7 +121,7 @@ let delegate_commands () = minimal_timestamp, mempool, context_path, - liquidity_baker_escape_flag ) + liquidity_baking_escape_flag ) delegate cctxt -> bake_block @@ -134,7 +134,7 @@ let delegate_commands () = ~minimal_timestamp ?mempool ?context_path - ~liquidity_baker_escape_flag + ~liquidity_baking_escape_flag ~chain:cctxt#chain ~head:cctxt#block delegate); @@ -264,7 +264,7 @@ let baker_commands () = minimal_nanotez_per_gas_unit_arg minimal_nanotez_per_byte_arg keep_alive_arg - liquidity_baker_escape_flag_arg) + liquidity_baking_escape_flag_arg) ( prefixes ["run"; "with"; "local"; "node"] @@ param ~name:"context_path" @@ -277,7 +277,7 @@ let baker_commands () = minimal_nanotez_per_gas_unit, minimal_nanotez_per_byte, keep_alive, - liquidity_baker_escape_flag ) + liquidity_baking_escape_flag ) node_path delegates cctxt -> @@ -294,7 +294,7 @@ let baker_commands () = ~minimal_nanotez_per_gas_unit ~minimal_nanotez_per_byte ?max_priority - ~liquidity_baker_escape_flag + ~liquidity_baking_escape_flag ~context_path:(Filename.concat node_path "context") ~keep_alive (List.map snd delegates)) ] diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 40eb9935fbad..0160b747f9b6 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -56,12 +56,12 @@ let constants_mainnet = min_proposal_quorum = 5_00l; initial_endorsers = 24; delay_per_missing_endorsement = Period.of_seconds_exn 8L; - liquidity_baker_origination_nonce = + liquidity_baking_origination_nonce = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) Contract_repr.initial_origination_nonce Operation_hash.zero; (* now + six months *) (* MUST BE ADJUSTED PRIOR TO INJECTION !!! *) - liquidity_baker_sunset = Int32.add 1292070l 262800l; + liquidity_baking_sunset = Int32.add 1292070l 262800l; } let constants_sandbox = @@ -77,7 +77,7 @@ let constants_sandbox = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baker_sunset = 1024l; + liquidity_baking_sunset = 1024l; } let constants_test = @@ -92,7 +92,7 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baker_sunset = 2058l; + liquidity_baking_sunset = 2058l; } let bootstrap_accounts_strings = diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index fd0c30fa0d5e..1e8d4e1d0bbd 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -298,19 +298,19 @@ let description = Raw_context.description module Parameters = Parameters_repr -let get_liquidity_baker_escape_flag = - Raw_context.get_liquidity_baker_escape_flag +let get_liquidity_baking_escape_flag = + Raw_context.get_liquidity_baking_escape_flag -let set_liquidity_baker_escape_flag = - Raw_context.set_liquidity_baker_escape_flag +let set_liquidity_baking_escape_flag = + Raw_context.set_liquidity_baking_escape_flag -let get_liquidity_baker_escape_ema = Storage.Liquidity_baker_escape_ema.get +let get_liquidity_baking_escape_ema = Storage.Liquidity_baking_escape_ema.get -let set_liquidity_baker_escape_ema ctxt flag = - Storage.Liquidity_baker_escape_ema.get ctxt +let set_liquidity_baking_escape_ema ctxt flag = + Storage.Liquidity_baking_escape_ema.get ctxt >>=? fun old_ema -> let new_ema = Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) in - Storage.Liquidity_baker_escape_ema.set ctxt new_ema + Storage.Liquidity_baking_escape_ema.set ctxt new_ema >|=? fun ctxt -> (ctxt, new_ema) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index bbb5615ad529..03bd28001600 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1177,7 +1177,7 @@ module Block_header : sig priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baker_escape_flag : bool; + liquidity_baking_escape_flag : bool; } type protocol_data = {contents : contents; signature : Signature.t} @@ -1642,11 +1642,11 @@ module Parameters : sig val encoding : t Data_encoding.t end -val get_liquidity_baker_escape_flag : context -> bool +val get_liquidity_baking_escape_flag : context -> bool -val set_liquidity_baker_escape_flag : context -> bool -> context +val set_liquidity_baking_escape_flag : context -> bool -> context -val get_liquidity_baker_escape_ema : context -> Int32.t tzresult Lwt.t +val get_liquidity_baking_escape_ema : context -> Int32.t tzresult Lwt.t -val set_liquidity_baker_escape_ema : +val set_liquidity_baking_escape_ema : context -> bool -> (context * Int32.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 7354cd62f1b1..433c0a341784 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1502,8 +1502,8 @@ let begin_full_construction ctxt pred_timestamp protocol_data = >>=? fun ctxt -> Baking.check_baking_rights ctxt protocol_data pred_timestamp >>=? fun (delegate_pk, block_delay) -> - set_liquidity_baker_escape_ema ctxt protocol_data.liquidity_baker_escape_flag - >>=? fun (ctxt, _liquidity_baker_escape_ema) -> + set_liquidity_baking_escape_ema ctxt protocol_data.liquidity_baking_escape_flag + >>=? fun (ctxt, _liquidity_baking_escape_ema) -> let ctxt = Fitness.increase ctxt in endorsement_rights_of_pred_level ctxt >|=? fun rights -> @@ -1597,40 +1597,40 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some nonce_hash -> Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> - let liquidity_baker = + let liquidity_baking = Contract.originated_contract - (Constants.liquidity_baker_origination_nonce ctxt) + (Constants.liquidity_baking_origination_nonce ctxt) in - get_liquidity_baker_escape_ema ctxt - >>=? fun liquidity_baker_escape_ema -> - (* set_liquidity_baker_escape_ema ctxt (get_liquidity_baker_escape_flag ctxt) - * >>=? fun (ctxt, liquidity_baker_escape_ema) -> *) - let liquidity_baker_reward = + get_liquidity_baking_escape_ema ctxt + >>=? fun liquidity_baking_escape_ema -> + (* set_liquidity_baking_escape_ema ctxt (get_liquidity_baking_escape_flag ctxt) + * >>=? fun (ctxt, liquidity_baking_escape_ema) -> *) + let liquidity_baking_reward = let level = Raw_level.to_int32 (Level.current ctxt).level in if - Compare.Int32.(level < Constants.liquidity_baker_sunset ctxt) - && Compare.Int32.(liquidity_baker_escape_ema < 5_000l) + Compare.Int32.(level < Constants.liquidity_baking_sunset ctxt) + && Compare.Int32.(liquidity_baking_escape_ema < 5_000l) then match Tez.of_mutez 5_000_000L with | None -> Tez.zero - | Some liquidity_baker_reward -> - liquidity_baker_reward + | Some liquidity_baking_reward -> + liquidity_baking_reward else Tez.zero in - Contract.credit ctxt liquidity_baker liquidity_baker_reward + Contract.credit ctxt liquidity_baking liquidity_baking_reward >>=? fun ctxt -> - Contract.get_script ctxt liquidity_baker + Contract.get_script ctxt liquidity_baking >>=? fun (ctxt, script) -> match script with | None -> Lwt.return (error (Script_tc_errors.No_such_entrypoint "default") ) | Some script -> let step_constants = let open Script_interpreter in - {source = liquidity_baker; - payer = liquidity_baker; - self = liquidity_baker; - amount = liquidity_baker_reward; + {source = liquidity_baking; + payer = liquidity_baking; + self = liquidity_baking; + amount = liquidity_baking_reward; chain_id = Chain_id.zero; } (* TODO: get chain_id *) in let parameter = Micheline.strip_locations Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) in @@ -1646,7 +1646,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay let _operations = operations in Contract.update_script_storage ctxt - liquidity_baker + liquidity_baking storage lazy_storage_diff >>=? fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/block_header_repr.ml b/src/proto_alpha/lib_protocol/block_header_repr.ml index 2599e3f5bcdc..f4d2b339b3cb 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.ml +++ b/src/proto_alpha/lib_protocol/block_header_repr.ml @@ -29,7 +29,7 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baker_escape_flag : bool; + liquidity_baking_escape_flag : bool; } type protocol_data = {contents : contents; signature : Signature.t} @@ -50,17 +50,17 @@ let contents_encoding = let open Data_encoding in def "block_header.alpha.unsigned_contents" @@ conv - (fun {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag} -> - (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baker_escape_flag)) - (fun (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baker_escape_flag) -> - {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag}) + (fun {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag} -> + (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baking_escape_flag)) + (fun (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baking_escape_flag) -> + {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag}) (obj4 (req "priority" uint16) (req "proof_of_work_nonce" (Fixed.bytes Constants_repr.proof_of_work_nonce_size)) (opt "seed_nonce_hash" Nonce_hash.encoding) - (req "liquidity_baker_escape_flag" Data_encoding.bool)) + (req "liquidity_baking_escape_flag" Data_encoding.bool)) let protocol_data_encoding = let open Data_encoding in @@ -110,7 +110,7 @@ let max_header_length = proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '0'; seed_nonce_hash = Some Nonce_hash.zero; - liquidity_baker_escape_flag = false; + liquidity_baking_escape_flag = false; } in Data_encoding.Binary.length diff --git a/src/proto_alpha/lib_protocol/block_header_repr.mli b/src/proto_alpha/lib_protocol/block_header_repr.mli index 738a8e0c0e55..2929597ba1b3 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.mli +++ b/src/proto_alpha/lib_protocol/block_header_repr.mli @@ -27,7 +27,7 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baker_escape_flag : bool; + liquidity_baking_escape_flag : bool; } type protocol_data = {contents : contents; signature : Signature.t} diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index 0f40ed6413ee..3ac29039028d 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -115,8 +115,8 @@ type parametric = { min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; - liquidity_baker_origination_nonce : Contract_repr.origination_nonce; - liquidity_baker_sunset : int32; + liquidity_baking_origination_nonce : Contract_repr.origination_nonce; + liquidity_baking_sunset : int32; } let parametric_encoding = @@ -154,8 +154,8 @@ let parametric_encoding = c.min_proposal_quorum, c.initial_endorsers, c.delay_per_missing_endorsement, - c.liquidity_baker_origination_nonce, - c.liquidity_baker_sunset ) ) )) + c.liquidity_baking_origination_nonce, + c.liquidity_baking_sunset ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -182,8 +182,8 @@ let parametric_encoding = min_proposal_quorum, initial_endorsers, delay_per_missing_endorsement, - liquidity_baker_origination_nonce, - liquidity_baker_sunset ) ) ) -> + liquidity_baking_origination_nonce, + liquidity_baking_sunset ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -210,8 +210,8 @@ let parametric_encoding = min_proposal_quorum; initial_endorsers; delay_per_missing_endorsement; - liquidity_baker_origination_nonce; - liquidity_baker_sunset; + liquidity_baking_origination_nonce; + liquidity_baking_sunset; }) (merge_objs (obj9 @@ -249,9 +249,9 @@ let parametric_encoding = (req "initial_endorsers" uint16) (req "delay_per_missing_endorsement" Period_repr.encoding) (req - "liquidity_baker_origination_nonce" + "liquidity_baking_origination_nonce" Contract_repr.origination_nonce_encoding) - (req "liquidity_baker_sunset" int32)))) + (req "liquidity_baking_sunset" int32)))) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index aa7ef5bbc9b6..72f58d8c55d0 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -123,12 +123,12 @@ let min_proposal_quorum c = let constants = Raw_context.constants c in constants.min_proposal_quorum -let liquidity_baker_origination_nonce c = +let liquidity_baking_origination_nonce c = let constants = Raw_context.constants c in - constants.liquidity_baker_origination_nonce + constants.liquidity_baking_origination_nonce -let liquidity_baker_sunset c = +let liquidity_baking_sunset c = let constants = Raw_context.constants c in - constants.liquidity_baker_sunset + constants.liquidity_baking_sunset let parametric c = Raw_context.constants c diff --git a/src/proto_alpha/lib_protocol/helpers_services.ml b/src/proto_alpha/lib_protocol/helpers_services.ml index a958f0fd93a6..ebdd5f165215 100644 --- a/src/proto_alpha/lib_protocol/helpers_services.ml +++ b/src/proto_alpha/lib_protocol/helpers_services.ml @@ -859,7 +859,7 @@ module Forge = struct "proof_of_work_nonce" (Fixed.bytes Alpha_context.Constants.proof_of_work_nonce_size) empty_proof_of_work_nonce) - (req "liquidity_baker_escape_flag" bool)) + (req "liquidity_baking_escape_flag" bool)) ~output:(obj1 (req "protocol_data" bytes)) RPC_path.(path / "protocol_data") @@ -881,11 +881,11 @@ module Forge = struct (shell, proto))) ; register0_noctxt S.protocol_data - (fun () (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baker_escape_flag) -> + (fun () (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baking_escape_flag) -> return (Data_encoding.Binary.to_bytes_exn Block_header.contents_encoding - {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baker_escape_flag})) + {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag})) module Manager = struct let[@coq_axiom_with_reason "cast on e"] operations ctxt block ~branch @@ -1040,16 +1040,16 @@ module Forge = struct let protocol_data ctxt block ~priority ?seed_nonce_hash ?(proof_of_work_nonce = empty_proof_of_work_nonce) - ~liquidity_baker_escape_flag () = + ~liquidity_baking_escape_flag () = RPC_context.make_call0 S.protocol_data ctxt block () - (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baker_escape_flag) + (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baking_escape_flag) - (* let set_liquidity_baker_escape_ema ctxt block flag = - * (\* Alpha_context.set_liquidity_baker_escape_ema ctxt flag + (* let set_liquidity_baking_escape_ema ctxt block flag = + * (\* Alpha_context.set_liquidity_baking_escape_ema ctxt flag * * >>=? fun (ctxt, new_ema) - *\) * RPC_context.make_call0 S.flags ctxt block () flag *) end diff --git a/src/proto_alpha/lib_protocol/helpers_services.mli b/src/proto_alpha/lib_protocol/helpers_services.mli index 55a1bb63253f..34e55825ae7a 100644 --- a/src/proto_alpha/lib_protocol/helpers_services.mli +++ b/src/proto_alpha/lib_protocol/helpers_services.mli @@ -289,7 +289,7 @@ module Forge : sig priority:int -> ?seed_nonce_hash:Nonce_hash.t -> ?proof_of_work_nonce:bytes -> - liquidity_baker_escape_flag:bool -> + liquidity_baking_escape_flag:bool -> unit -> bytes shell_tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index e534a791c4f7..c5c2ea8c31c6 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -99,7 +99,7 @@ type back = { internal_nonce : int; internal_nonces_used : Int_set.t; gas_counter_status : gas_counter_status; - liquidity_baker_escape_flag : bool; + liquidity_baking_escape_flag : bool; } (* @@ -752,7 +752,7 @@ let prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt = internal_nonce = 0; internal_nonces_used = Int_set.empty; gas_counter_status = Unlimited_operation_gas; - liquidity_baker_escape_flag = false; + liquidity_baking_escape_flag = false; }; } @@ -1006,7 +1006,7 @@ let map_temporary_lazy_storage_ids_s ctxt f = >|= fun (ctxt, temporary_lazy_storage_ids) -> update_temporary_lazy_storage_ids ctxt temporary_lazy_storage_ids -let get_liquidity_baker_escape_flag ctxt = ctxt.liquidity_baker_escape_flag +let get_liquidity_baking_escape_flag ctxt = ctxt.liquidity_baking_escape_flag -let set_liquidity_baker_escape_flag ctxt flag = - {ctxt with liquidity_baker_escape_flag = flag} +let set_liquidity_baking_escape_flag ctxt flag = + {ctxt with liquidity_baking_escape_flag = flag} diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index b946ed420211..be749cac9665 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -206,6 +206,6 @@ val map_temporary_lazy_storage_ids_s : (Lazy_storage_kind.Temp_ids.t -> (t * Lazy_storage_kind.Temp_ids.t) Lwt.t) -> t Lwt.t -val get_liquidity_baker_escape_flag : context -> bool +val get_liquidity_baking_escape_flag : context -> bool -val set_liquidity_baker_escape_flag : context -> bool -> context +val set_liquidity_baking_escape_flag : context -> bool -> context diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 67ead15c7794..12915f69e0ab 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1228,9 +1228,9 @@ module Pending_migration_balance_updates = let encoding = Receipt_repr.balance_updates_encoding end) -module Liquidity_baker_escape_ema = +module Liquidity_baking_escape_ema = Make_single_data_storage (Registered) (Raw_context) (struct - let name = ["liquidity_baker_escape_ema"] + let name = ["liquidity_baking_escape_ema"] end) (Int32) diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index ac4a23380666..66bfa7debb3c 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -488,5 +488,5 @@ module Pending_migration_balance_updates : with type value = Receipt_repr.balance_updates and type t := Raw_context.t -module Liquidity_baker_escape_ema : +module Liquidity_baking_escape_ema : Single_data_storage with type t := Raw_context.t and type value = Int32.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 3778f1fcdfec..32bad173070c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -145,9 +145,9 @@ module Forge = struct Bytes.create Constants.proof_of_work_nonce_size let make_contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ?(liquidity_baker_escape_flag = false) + ?(liquidity_baking_escape_flag = false) ~priority ~seed_nonce_hash () = - Block_header.{priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baker_escape_flag} + Block_header.{priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baking_escape_flag} let make_shell ~level ~predecessor ~timestamp ~fitness ~operations_hash = Tezos_base.Block_header. @@ -222,8 +222,8 @@ module Forge = struct (* compatibility only, needed by incremental *) let contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ?(priority = 0) ?seed_nonce_hash ?(liquidity_baker_escape_flag = false) () = - {Block_header.priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baker_escape_flag} + ?(priority = 0) ?seed_nonce_hash ?(liquidity_baking_escape_flag = false) () = + {Block_header.priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baking_escape_flag} end (********* Genesis creation *************) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index f9dd2ac3ff3c..cf79d88972cf 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -62,7 +62,7 @@ module Forge : sig ?proof_of_work_nonce:Bytes.t -> ?priority:int -> ?seed_nonce_hash:Nonce_hash.t -> - ?liquidity_baker_escape_flag:bool -> + ?liquidity_baking_escape_flag:bool -> unit -> Block_header.contents diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 1d6f57b7d408..182dbed29de8 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -31,18 +31,18 @@ let liquidity_baking_rewards n () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baker = + let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baker_origination_nonce + csts.parametric.liquidity_baking_origination_nonce in - Context.Contract.balance (B blk) liquidity_baker + Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n n blk >>=? fun blk -> Assert.balance_was_credited ~loc:__LOC__ (B blk) - liquidity_baker + liquidity_baking old_balance (Tez.of_int (5*n)) >>=? fun () -> return_unit @@ -52,19 +52,19 @@ let liquidity_baking_sunset () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baker = + let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baker_origination_nonce + csts.parametric.liquidity_baking_origination_nonce in - let sunset = csts.parametric.liquidity_baker_sunset in - Context.Contract.balance (B blk) liquidity_baker + let sunset = csts.parametric.liquidity_baking_sunset in + Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n Int32.(to_int (add sunset 100l)) blk >>=? fun blk -> Assert.balance_was_credited ~loc:__LOC__ (B blk) - liquidity_baker + liquidity_baking old_balance (Tez.of_int Int32.(to_int (mul 5l (sub sunset 1l)))) >>=? fun () -> return_unit @@ -74,19 +74,19 @@ let liquidity_baking_escape_hatch_100 () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baker = + let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baker_origination_nonce + csts.parametric.liquidity_baking_origination_nonce in let escape_level = 693 in - Context.Contract.balance (B blk) liquidity_baker + Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n (escape_level + 100) blk >>=? fun blk -> Assert.balance_was_credited ~loc:__LOC__ (B blk) - liquidity_baker + liquidity_baking old_balance (Tez.of_int (5*(escape_level - 1))) >>=? fun () -> return_unit @@ -96,12 +96,12 @@ let liquidity_baking_escape_hatch_80 () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baker = + let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baker_origination_nonce + csts.parametric.liquidity_baking_origination_nonce in let escape_level = 980 in - Context.Contract.balance (B blk) liquidity_baker + Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> let rec bake_80_percent_escaping blk i = if i < escape_level @@ -120,7 +120,7 @@ let liquidity_baking_escape_hatch_80 () = Assert.balance_was_credited ~loc:__LOC__ (B blk) - liquidity_baker + liquidity_baking old_balance (Tez.of_int (5*(escape_level - 1))) >>=? fun () -> return_unit @@ -130,12 +130,12 @@ let liquidity_baking_escape_hatch_60 () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baker = + let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baker_origination_nonce + csts.parametric.liquidity_baking_origination_nonce in let escape_level = 1790 in - Context.Contract.balance (B blk) liquidity_baker + Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> let rec bake_80_percent_escaping blk i = if i < escape_level @@ -154,7 +154,7 @@ let liquidity_baking_escape_hatch_60 () = Assert.balance_was_credited ~loc:__LOC__ (B blk) - liquidity_baker + liquidity_baking old_balance (Tez.of_int (5*(escape_level - 1))) >>=? fun () -> return_unit -- GitLab From 2de941e8f6267213bd63fee25d7452e4c4b2cbf1 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 11 Jan 2021 23:55:34 -0500 Subject: [PATCH 12/62] liquidity baking: patch after rebasing --- .../lib_delegate/client_baking_forge.ml | 41 +++++++---- src/proto_alpha/lib_delegate/client_daemon.ml | 3 +- .../lib_delegate/delegate_commands.ml | 2 +- .../lib_parameters/default_parameters.ml | 10 +-- .../lib_parameters/michelson_v1_parser.ml | 19 +++-- src/proto_alpha/lib_protocol/apply.ml | 55 ++++++++------- .../lib_protocol/block_header_repr.ml | 22 ++++-- .../lib_protocol/helpers_services.ml | 23 +++++-- src/proto_alpha/lib_protocol/init_storage.ml | 4 +- src/proto_alpha/lib_protocol/raw_context.ml | 5 +- .../lib_protocol/test/helpers/block.ml | 21 ++++-- src/proto_alpha/lib_protocol/test/main.ml | 2 +- .../test/test_liquidity_baking.ml | 69 ++++++++++++++----- 13 files changed, 192 insertions(+), 84 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index 4104115b7efa..aecd773e63b5 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -115,7 +115,12 @@ let generate_seed_nonce () = let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block delegate_sk shell priority seed_nonce_hash liquidity_baking_escape_flag = Client_baking_pow.mine cctxt chain block shell (fun proof_of_work_nonce -> - {Block_header.priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag }) + { + Block_header.priority; + seed_nonce_hash; + proof_of_work_nonce; + liquidity_baking_escape_flag; + }) >>=? fun contents -> let unsigned_header = Data_encoding.Binary.to_bytes_exn @@ -131,7 +136,7 @@ let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block unsigned_header let forge_faked_protocol_data ~priority ~seed_nonce_hash - ~liquidity_baking_escape_flag = + ~liquidity_baking_escape_flag = Alpha_context.Block_header. { contents = @@ -180,8 +185,8 @@ let compute_endorsing_power cctxt ~chain ~block operations = operations let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header - ~priority ~delegate_pkh ~delegate_sk ~level operations - liquidity_baking_escape_flag = + ~priority ~delegate_pkh ~delegate_sk ~level operations + liquidity_baking_escape_flag = assert_valid_operations_hash shell_header operations >>=? fun () -> let block = `Hash (shell_header.Tezos_base.Block_header.predecessor, 0) in @@ -842,8 +847,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ?(sort = best_effort) ?(minimal_fees = default_minimal_fees) ?(minimal_nanotez_per_gas_unit = default_minimal_nanotez_per_gas_unit) ?(minimal_nanotez_per_byte = default_minimal_nanotez_per_byte) ?timestamp - ?mempool ?context_path ?seed_nonce_hash - ~liquidity_baking_escape_flag + ?mempool ?context_path ?seed_nonce_hash ~liquidity_baking_escape_flag ~chain ~priority ~delegate_pkh ~delegate_sk block = (* making the arguments usable *) unopt_operations cctxt chain mempool operations @@ -855,7 +859,12 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) unopt_timestamp ?force timestamp minimal_timestamp >>=? fun timestamp -> (* get basic building blocks *) - let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baking_escape_flag in + let protocol_data = + forge_faked_protocol_data + ~priority + ~seed_nonce_hash + ~liquidity_baking_escape_flag + in Alpha_services.Constants.all cctxt (chain, block) >>=? fun Constants. { parametric = {hard_gas_limit_per_block; endorsers_per_block; _}; @@ -1052,7 +1061,12 @@ let shell_prevalidation (cctxt : #Protocol_client_context.full) ~chain ~block ~timestamp seed_nonce_hash operations ((_, (bi, priority, delegate)) as _slot) = let liquidity_baking_escape_flag = false in - let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baking_escape_flag in + let protocol_data = + forge_faked_protocol_data + ~priority + ~seed_nonce_hash + ~liquidity_baking_escape_flag + in Alpha_block_services.Helpers.Preapply.block cctxt ~chain @@ -1256,7 +1270,10 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash slot else let protocol_data = - forge_faked_protocol_data ~priority ~seed_nonce_hash ~liquidity_baking_escape_flag + forge_faked_protocol_data + ~priority + ~seed_nonce_hash + ~liquidity_baking_escape_flag in filter_and_apply_operations cctxt @@ -1613,9 +1630,9 @@ let reveal_potential_nonces (cctxt : #Client_context.full) constants ~chain starts individual baking operations when baking-slots are available to any of the [delegates] *) let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades - ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?max_priority ~liquidity_baking_escape_flag - ~chain ~context_path delegates block_stream = + ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte + ?max_priority ~liquidity_baking_escape_flag ~chain ~context_path delegates + block_stream = let state_maker bi = Alpha_services.Constants.all cctxt (chain, `Head 0) >>=? fun constants -> diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index 99beb0397607..b67dcde1b1d4 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -94,7 +94,8 @@ end module Baker = struct let run (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~liquidity_baking_escape_flag ~chain ~context_path ~keep_alive delegates = + ~liquidity_baking_escape_flag ~chain ~context_path ~keep_alive delegates + = let process () = Config_services.user_activated_upgrades cctxt >>=? fun user_activated_upgrades -> diff --git a/src/proto_alpha/lib_delegate/delegate_commands.ml b/src/proto_alpha/lib_delegate/delegate_commands.ml index 9bf2c77a09f1..953525ca2021 100644 --- a/src/proto_alpha/lib_delegate/delegate_commands.ml +++ b/src/proto_alpha/lib_delegate/delegate_commands.ml @@ -107,7 +107,7 @@ let delegate_commands () = minimal_timestamp_switch mempool_arg context_path_arg - liquidity_baking_escape_flag_arg ) + liquidity_baking_escape_flag_arg) ( prefixes ["bake"; "for"] @@ Client_keys.Public_key_hash.source_param ~name:"baker" diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 0160b747f9b6..ab0ba6647e8c 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -122,12 +122,14 @@ let bootstrap_contracts_strings = 2_000_000_000_000L, "fa12.json", "Pair {} 2000000000000", - Contract_repr.initial_origination_nonce Operation_hash.(of_hex_exn (`Hex (String.make (size * 2) '1')))); - ( None, + Contract_repr.initial_origination_nonce + Operation_hash.(of_hex_exn (`Hex (String.make (size * 2) '1'))) ); + ( None, 4_000_000_000_000L, "cpmm.json", - "Pair {} (Pair (Pair 4000000000000 False) (Pair 2000000000000 2000000000000))", - Contract_repr.initial_origination_nonce Operation_hash.zero ); ] + "Pair {} (Pair (Pair 4000000000000 False) (Pair 2000000000000 \ + 2000000000000))", + Contract_repr.initial_origination_nonce Operation_hash.zero ) ] let parse_storage source = Michelson_v1_parser.parse_expression ?check:(Some true) source diff --git a/src/proto_alpha/lib_parameters/michelson_v1_parser.ml b/src/proto_alpha/lib_parameters/michelson_v1_parser.ml index 5a2e5b8d1c16..fcfc8a3d6fa3 100644 --- a/src/proto_alpha/lib_parameters/michelson_v1_parser.ml +++ b/src/proto_alpha/lib_parameters/michelson_v1_parser.ml @@ -59,12 +59,19 @@ let expand_all source ast errors = in group ([], sorted) in - List.map2 - (fun (l, ploc) (l', elocs) -> - assert (l = l') ; - (l, (ploc, elocs))) - (List.sort compare loc_table) - (List.sort compare grouped) + match + List.map2 + ~when_different_lengths:() + (fun (l, ploc) (l', elocs) -> + assert (l = l') ; + (l, (ploc, elocs))) + (List.sort compare loc_table) + (List.sort compare grouped) + with + | Ok v -> + v + | Error () -> + invalid_arg "Michelson_v1_parser.expand_all" in match Environment.wrap_error (Michelson_v1_primitives.prims_of_strings expanded) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 433c0a341784..bb72ae1d3a5a 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1502,7 +1502,9 @@ let begin_full_construction ctxt pred_timestamp protocol_data = >>=? fun ctxt -> Baking.check_baking_rights ctxt protocol_data pred_timestamp >>=? fun (delegate_pk, block_delay) -> - set_liquidity_baking_escape_ema ctxt protocol_data.liquidity_baking_escape_flag + set_liquidity_baking_escape_ema + ctxt + protocol_data.liquidity_baking_escape_flag >>=? fun (ctxt, _liquidity_baking_escape_ema) -> let ctxt = Fitness.increase ctxt in endorsement_rights_of_pred_level ctxt @@ -1623,7 +1625,8 @@ let finalize_application ctxt protocol_data delegate ~block_delay Contract.get_script ctxt liquidity_baking >>=? fun (ctxt, script) -> match script with - | None -> Lwt.return (error (Script_tc_errors.No_such_entrypoint "default") ) + | None -> + Lwt.return (error (Script_tc_errors.No_such_entrypoint "default")) | Some script -> let step_constants = let open Script_interpreter in @@ -1677,27 +1680,27 @@ let finalize_application ctxt protocol_data delegate ~block_delay (* This value is different than the new [voting_period_info] below for compatibility reasons, the field [voting_period_kind] is deprecated and will be removed in a future version. *) - Alpha_context.Voting_period.get_current_info ctxt - >>=? fun {voting_period = {kind; _}; _} -> - Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt - >|=? fun ({voting_period; position; _} as voting_period_info) -> - let level_info = Alpha_context.Level.current ctxt in - let receipt = - Apply_results. - { - baker = delegate; - level = - Level.to_deprecated_type - level_info - ~voting_period_index:voting_period.index - ~voting_period_position:position; - level_info; - voting_period_info; - voting_period_kind = kind; - nonce_hash = protocol_data.seed_nonce_hash; - consumed_gas; - deactivated; - balance_updates; - } - in - (ctxt, receipt) + Alpha_context.Voting_period.get_current_info ctxt + >>=? fun {voting_period = {kind; _}; _} -> + Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt + >|=? fun ({voting_period; position; _} as voting_period_info) -> + let level_info = Alpha_context.Level.current ctxt in + let receipt = + Apply_results. + { + baker = delegate; + level = + Level.to_deprecated_type + level_info + ~voting_period_index:voting_period.index + ~voting_period_position:position; + level_info; + voting_period_info; + voting_period_kind = kind; + nonce_hash = protocol_data.seed_nonce_hash; + consumed_gas; + deactivated; + balance_updates; + } + in + (ctxt, receipt) diff --git a/src/proto_alpha/lib_protocol/block_header_repr.ml b/src/proto_alpha/lib_protocol/block_header_repr.ml index f4d2b339b3cb..387a9465b546 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.ml +++ b/src/proto_alpha/lib_protocol/block_header_repr.ml @@ -50,10 +50,24 @@ let contents_encoding = let open Data_encoding in def "block_header.alpha.unsigned_contents" @@ conv - (fun {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag} -> - (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baking_escape_flag)) - (fun (priority, proof_of_work_nonce, seed_nonce_hash, liquidity_baking_escape_flag) -> - {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag}) + (fun { priority; + seed_nonce_hash; + proof_of_work_nonce; + liquidity_baking_escape_flag } -> + ( priority, + proof_of_work_nonce, + seed_nonce_hash, + liquidity_baking_escape_flag )) + (fun ( priority, + proof_of_work_nonce, + seed_nonce_hash, + liquidity_baking_escape_flag ) -> + { + priority; + seed_nonce_hash; + proof_of_work_nonce; + liquidity_baking_escape_flag; + }) (obj4 (req "priority" uint16) (req diff --git a/src/proto_alpha/lib_protocol/helpers_services.ml b/src/proto_alpha/lib_protocol/helpers_services.ml index ebdd5f165215..247907804147 100644 --- a/src/proto_alpha/lib_protocol/helpers_services.ml +++ b/src/proto_alpha/lib_protocol/helpers_services.ml @@ -881,11 +881,21 @@ module Forge = struct (shell, proto))) ; register0_noctxt S.protocol_data - (fun () (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baking_escape_flag) -> + (fun () + ( priority, + seed_nonce_hash, + proof_of_work_nonce, + liquidity_baking_escape_flag ) + -> return (Data_encoding.Binary.to_bytes_exn Block_header.contents_encoding - {priority; seed_nonce_hash; proof_of_work_nonce; liquidity_baking_escape_flag})) + { + priority; + seed_nonce_hash; + proof_of_work_nonce; + liquidity_baking_escape_flag; + })) module Manager = struct let[@coq_axiom_with_reason "cast on e"] operations ctxt block ~branch @@ -1039,14 +1049,17 @@ module Forge = struct Bytes.make Constants_repr.proof_of_work_nonce_size '\000' let protocol_data ctxt block ~priority ?seed_nonce_hash - ?(proof_of_work_nonce = empty_proof_of_work_nonce) - ~liquidity_baking_escape_flag () = + ?(proof_of_work_nonce = empty_proof_of_work_nonce) + ~liquidity_baking_escape_flag () = RPC_context.make_call0 S.protocol_data ctxt block () - (priority, seed_nonce_hash, proof_of_work_nonce, liquidity_baking_escape_flag) + ( priority, + seed_nonce_hash, + proof_of_work_nonce, + liquidity_baking_escape_flag ) (* let set_liquidity_baking_escape_ema ctxt block flag = * (\* Alpha_context.set_liquidity_baking_escape_ema ctxt flag diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index b624b3f056fe..64ba1caa005a 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -74,7 +74,9 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = ~start_position:(Level_storage.current ctxt).level_position >>=? fun ctxt -> Storage.Block_priority.init ctxt 0 - >>=? fun ctxt -> Vote_storage.update_listings ctxt + >>=? fun ctxt -> + Vote_storage.update_listings ctxt + >>=? fun ctxt -> Storage.Liquidity_baking_escape_ema.init ctxt 0l | Edo_008 -> (* Add balance updates receipts to be attached on the first block of this protocol - see [[prepare]] function below. Any balance updates attached diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index c5c2ea8c31c6..3a82db31da76 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -1006,7 +1006,8 @@ let map_temporary_lazy_storage_ids_s ctxt f = >|= fun (ctxt, temporary_lazy_storage_ids) -> update_temporary_lazy_storage_ids ctxt temporary_lazy_storage_ids -let get_liquidity_baking_escape_flag ctxt = ctxt.liquidity_baking_escape_flag +let get_liquidity_baking_escape_flag ctxt = + ctxt.back.liquidity_baking_escape_flag let set_liquidity_baking_escape_flag ctxt flag = - {ctxt with liquidity_baking_escape_flag = flag} + update_back ctxt {ctxt.back with liquidity_baking_escape_flag = flag} diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 32bad173070c..d0391e62ea6c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -145,9 +145,14 @@ module Forge = struct Bytes.create Constants.proof_of_work_nonce_size let make_contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ?(liquidity_baking_escape_flag = false) - ~priority ~seed_nonce_hash () = - Block_header.{priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baking_escape_flag} + ?(liquidity_baking_escape_flag = false) ~priority ~seed_nonce_hash () = + Block_header. + { + priority; + proof_of_work_nonce; + seed_nonce_hash; + liquidity_baking_escape_flag; + } let make_shell ~level ~predecessor ~timestamp ~fitness ~operations_hash = Tezos_base.Block_header. @@ -222,8 +227,14 @@ module Forge = struct (* compatibility only, needed by incremental *) let contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ?(priority = 0) ?seed_nonce_hash ?(liquidity_baking_escape_flag = false) () = - {Block_header.priority; proof_of_work_nonce; seed_nonce_hash; liquidity_baking_escape_flag} + ?(priority = 0) ?seed_nonce_hash ?(liquidity_baking_escape_flag = false) + () = + { + Block_header.priority; + proof_of_work_nonce; + seed_nonce_hash; + liquidity_baking_escape_flag; + } end (********* Genesis creation *************) diff --git a/src/proto_alpha/lib_protocol/test/main.ml b/src/proto_alpha/lib_protocol/test/main.ml index 0d23a9efe922..ccdba4091cde 100644 --- a/src/proto_alpha/lib_protocol/test/main.ml +++ b/src/proto_alpha/lib_protocol/test/main.ml @@ -61,5 +61,5 @@ let () = ("failing_noop operation", Test_failing_noop.tests); ("storage description", Test_storage.tests); ("time", Test_time_repr.tests); - ("liquidity baking", Liquidity_baking.tests); ] + ("liquidity baking", Test_liquidity_baking.tests) ] |> Lwt_main.run diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 182dbed29de8..74d0c63ecb6c 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -44,7 +44,7 @@ let liquidity_baking_rewards n () = (B blk) liquidity_baking old_balance - (Tez.of_int (5*n)) + (Tez.of_int (5 * n)) >>=? fun () -> return_unit let liquidity_baking_sunset () = @@ -69,6 +69,46 @@ let liquidity_baking_sunset () = (Tez.of_int Int32.(to_int (mul 5l (sub sunset 1l)))) >>=? fun () -> return_unit +(* let liquidity_baking_storage n () = + * Context.init 1 + * >>=? fun (blk, _contracts) -> + * Context.get_constants (B blk) + * >>=? fun csts -> + * let liquidity_baking = + * Alpha_context.Contract.originated_contract + * csts.parametric.liquidity_baking_origination_nonce + * in + * let expected_storage = + * Expr.from_string + * (String.concat "" + * [ "Pair {} (Pair (Pair 4000000000000 False) (Pair 2000000000000"; + * (Printf.sprintf "%d" (2000000000000 + n*5)); + * "))"; ]) + * in + * (\* Alpha_context.Contract.get_storage (B blk) liquidity_baking + * * >>=? fun (ctxt, s) -> + * * match s with + * * | None -> return_unit + * * | Some old_storage -> *\) + * Block.bake_n n blk + * >>=? fun blk -> + * Context.Contract.storage (B blk) liquidity_baking + * >>=? fun s -> + * Expr.equal_tokens + * ~loc:__LOC__ + * s + * expected_storage + * >>=? fun () -> return_unit + * (\* let new_storage_string = Micheline.pp_tokens Format.pp_print_string s in + * * Assert.equal + * * ~loc:__LOC__ + * * String.equal + * * "Storage isn't equal" + * * Format.pp_print_string + * * new_storage_string + * * expected_storage_string + * * >>=? fun () -> return_unit *\) *) + let liquidity_baking_escape_hatch_100 () = Context.init 1 >>=? fun (blk, _contracts) -> @@ -88,7 +128,7 @@ let liquidity_baking_escape_hatch_100 () = (B blk) liquidity_baking old_balance - (Tez.of_int (5*(escape_level - 1))) + (Tez.of_int (5 * (escape_level - 1))) >>=? fun () -> return_unit let liquidity_baking_escape_hatch_80 () = @@ -104,13 +144,10 @@ let liquidity_baking_escape_hatch_80 () = Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> let rec bake_80_percent_escaping blk i = - if i < escape_level - then + if i < escape_level then Block.bake_n 4 blk (* with escape hatch flag *) >>=? fun blk -> - Block.bake blk - >>=? fun blk -> - bake_80_percent_escaping blk (i+5) + Block.bake blk >>=? fun blk -> bake_80_percent_escaping blk (i + 5) else return blk in bake_80_percent_escaping blk 0 @@ -122,7 +159,7 @@ let liquidity_baking_escape_hatch_80 () = (B blk) liquidity_baking old_balance - (Tez.of_int (5*(escape_level - 1))) + (Tez.of_int (5 * (escape_level - 1))) >>=? fun () -> return_unit let liquidity_baking_escape_hatch_60 () = @@ -138,13 +175,10 @@ let liquidity_baking_escape_hatch_60 () = Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> let rec bake_80_percent_escaping blk i = - if i < escape_level - then + if i < escape_level then Block.bake_n 3 blk (* with escape hatch flag *) >>=? fun blk -> - Block.bake_n 2 blk - >>=? fun blk -> - bake_80_percent_escaping blk (i+5) + Block.bake_n 2 blk >>=? fun blk -> bake_80_percent_escaping blk (i + 5) else return blk in bake_80_percent_escaping blk 0 @@ -156,7 +190,7 @@ let liquidity_baking_escape_hatch_60 () = (B blk) liquidity_baking old_balance - (Tez.of_int (5*(escape_level - 1))) + (Tez.of_int (5 * (escape_level - 1))) >>=? fun () -> return_unit let tests = @@ -164,6 +198,10 @@ let tests = "test liquidity baking rewards are correct" `Quick (liquidity_baking_rewards 64); + (* Test.tztest + * "test liquidity baking storage correct" + * `Quick + * (correct_liquidity_baking_storage 1024); *) Test.tztest "test liquidity baking shuts off at sunset level" `Quick @@ -179,5 +217,4 @@ let tests = Test.tztest "test liquidity baking escape hatch with 60% of bakers flagging" `Quick - liquidity_baking_escape_hatch_60; - ] + liquidity_baking_escape_hatch_60 ] -- GitLab From c93d089875ab922079db6e6f3daa0894af0592e1 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 12 Jan 2021 12:15:17 -0500 Subject: [PATCH 13/62] liquidity baking: add reward to constants and set ema --- .../lib_delegate/client_baking_forge.ml | 10 ---- .../lib_parameters/default_parameters.ml | 3 +- src/proto_alpha/lib_protocol/alpha_context.ml | 12 ++--- .../lib_protocol/alpha_context.mli | 4 -- src/proto_alpha/lib_protocol/apply.ml | 21 +++----- .../lib_protocol/constants_repr.ml | 23 +++++---- .../lib_protocol/constants_storage.ml | 4 ++ src/proto_alpha/lib_protocol/raw_context.ml | 8 --- src/proto_alpha/lib_protocol/raw_context.mli | 4 -- .../lib_protocol/test/helpers/block.ml | 25 ++++++--- .../lib_protocol/test/helpers/block.mli | 9 +++- .../lib_protocol/test/helpers/context.ml | 8 +++ .../lib_protocol/test/helpers/context.mli | 4 ++ .../test/test_liquidity_baking.ml | 51 ++++++++++++++----- 14 files changed, 108 insertions(+), 78 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index aecd773e63b5..ab82040218d9 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -778,16 +778,6 @@ let filter_and_apply_operations cctxt state ~chain ~block block_info ~priority state.index block_info >>=? fun inc -> - (* Alpha_services.Forge.set_liquidity_baking_escape_ema - * inc.state.ctxt - * block - * chain - * liquidity_baking_escape_flag - * >>=? fun ctxt -> *) - (* let ctxt = Alpha_context.set_liquidity_baking_escape_flag - * inc.state.ctxt - * liquidity_baking_escape_flag in - * let inc = { inc with state = {inc.state with ctxt } } in *) List.fold_left_es (fun inc op -> add_operation inc op >>=? fun (inc, _receipt) -> return inc) inc diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index ab0ba6647e8c..3ff8e49126f5 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -59,6 +59,7 @@ let constants_mainnet = liquidity_baking_origination_nonce = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) Contract_repr.initial_origination_nonce Operation_hash.zero; + liquidity_baking_reward = Tez_repr.of_mutez_exn 5_000_000L; (* now + six months *) (* MUST BE ADJUSTED PRIOR TO INJECTION !!! *) liquidity_baking_sunset = Int32.add 1292070l 262800l; @@ -92,7 +93,7 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baking_sunset = 2058l; + liquidity_baking_sunset = 2048l; } let bootstrap_accounts_strings = diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 1e8d4e1d0bbd..3f9b3c3bdf78 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -298,19 +298,17 @@ let description = Raw_context.description module Parameters = Parameters_repr -let get_liquidity_baking_escape_flag = - Raw_context.get_liquidity_baking_escape_flag - -let set_liquidity_baking_escape_flag = - Raw_context.set_liquidity_baking_escape_flag - let get_liquidity_baking_escape_ema = Storage.Liquidity_baking_escape_ema.get let set_liquidity_baking_escape_ema ctxt flag = Storage.Liquidity_baking_escape_ema.get ctxt >>=? fun old_ema -> let new_ema = - Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) + (* if ema ever reaches threshold, liquidity baking is permanently off *) + if Compare.Int32.(old_ema <= 500_000l) + then + Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) + else old_ema in Storage.Liquidity_baking_escape_ema.set ctxt new_ema >|=? fun ctxt -> (ctxt, new_ema) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 03bd28001600..03885d3aa0bd 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1642,10 +1642,6 @@ module Parameters : sig val encoding : t Data_encoding.t end -val get_liquidity_baking_escape_flag : context -> bool - -val set_liquidity_baking_escape_flag : context -> bool -> context - val get_liquidity_baking_escape_ema : context -> Int32.t tzresult Lwt.t val set_liquidity_baking_escape_ema : diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index bb72ae1d3a5a..9e704442dbd7 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1502,10 +1502,6 @@ let begin_full_construction ctxt pred_timestamp protocol_data = >>=? fun ctxt -> Baking.check_baking_rights ctxt protocol_data pred_timestamp >>=? fun (delegate_pk, block_delay) -> - set_liquidity_baking_escape_ema - ctxt - protocol_data.liquidity_baking_escape_flag - >>=? fun (ctxt, _liquidity_baking_escape_ema) -> let ctxt = Fitness.increase ctxt in endorsement_rights_of_pred_level ctxt >|=? fun rights -> @@ -1599,25 +1595,20 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some nonce_hash -> Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> + set_liquidity_baking_escape_ema + ctxt + protocol_data.liquidity_baking_escape_flag + >>=? fun (ctxt, liquidity_baking_escape_ema) -> let liquidity_baking = Contract.originated_contract (Constants.liquidity_baking_origination_nonce ctxt) in - get_liquidity_baking_escape_ema ctxt - >>=? fun liquidity_baking_escape_ema -> - (* set_liquidity_baking_escape_ema ctxt (get_liquidity_baking_escape_flag ctxt) - * >>=? fun (ctxt, liquidity_baking_escape_ema) -> *) let liquidity_baking_reward = let level = Raw_level.to_int32 (Level.current ctxt).level in if Compare.Int32.(level < Constants.liquidity_baking_sunset ctxt) - && Compare.Int32.(liquidity_baking_escape_ema < 5_000l) - then - match Tez.of_mutez 5_000_000L with - | None -> - Tez.zero - | Some liquidity_baking_reward -> - liquidity_baking_reward + && Compare.Int32.(liquidity_baking_escape_ema < 500_000l) + then Constants.liquidity_baking_reward ctxt else Tez.zero in Contract.credit ctxt liquidity_baking liquidity_baking_reward diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index 3ac29039028d..38e6124764b3 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -116,6 +116,7 @@ type parametric = { initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; liquidity_baking_origination_nonce : Contract_repr.origination_nonce; + liquidity_baking_reward : Tez_repr.t; liquidity_baking_sunset : int32; } @@ -140,9 +141,9 @@ let parametric_encoding = c.block_security_deposit, c.endorsement_security_deposit, c.baking_reward_per_endorsement, - c.endorsement_reward ), - ( c.cost_per_byte, - c.hard_storage_limit_per_operation, + c.endorsement_reward, + c.cost_per_byte ), + ( c.hard_storage_limit_per_operation, 0L, (* At this position in the encoding we used to have a test chain duration but it is not used anymore and should be @@ -155,6 +156,7 @@ let parametric_encoding = c.initial_endorsers, c.delay_per_missing_endorsement, c.liquidity_baking_origination_nonce, + c.liquidity_baking_reward, c.liquidity_baking_sunset ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, @@ -173,9 +175,9 @@ let parametric_encoding = block_security_deposit, endorsement_security_deposit, baking_reward_per_endorsement, - endorsement_reward ), - ( cost_per_byte, - hard_storage_limit_per_operation, + endorsement_reward, + cost_per_byte ), + ( hard_storage_limit_per_operation, _test_chain_duration, quorum_min, quorum_max, @@ -183,6 +185,7 @@ let parametric_encoding = initial_endorsers, delay_per_missing_endorsement, liquidity_baking_origination_nonce, + liquidity_baking_reward, liquidity_baking_sunset ) ) ) -> { preserved_cycles; @@ -211,6 +214,7 @@ let parametric_encoding = initial_endorsers; delay_per_missing_endorsement; liquidity_baking_origination_nonce; + liquidity_baking_reward; liquidity_baking_sunset; }) (merge_objs @@ -229,7 +233,7 @@ let parametric_encoding = "hard_gas_limit_per_block" Gas_limit_repr.Arith.z_integral_encoding)) (merge_objs - (obj9 + (obj10 (req "proof_of_work_threshold" int64) (req "tokens_per_roll" Tez_repr.encoding) (req "michelson_maximum_type_size" uint16) @@ -238,9 +242,9 @@ let parametric_encoding = (req "block_security_deposit" Tez_repr.encoding) (req "endorsement_security_deposit" Tez_repr.encoding) (req "baking_reward_per_endorsement" (list Tez_repr.encoding)) - (req "endorsement_reward" (list Tez_repr.encoding))) + (req "endorsement_reward" (list Tez_repr.encoding)) + (req "cost_per_byte" Tez_repr.encoding)) (obj10 - (req "cost_per_byte" Tez_repr.encoding) (req "hard_storage_limit_per_operation" z) (req "test_chain_duration" int64) (req "quorum_min" int32) @@ -251,6 +255,7 @@ let parametric_encoding = (req "liquidity_baking_origination_nonce" Contract_repr.origination_nonce_encoding) + (req "liquidity_baking_reward" Tez_repr.encoding) (req "liquidity_baking_sunset" int32)))) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index 72f58d8c55d0..9a6661b94007 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -127,6 +127,10 @@ let liquidity_baking_origination_nonce c = let constants = Raw_context.constants c in constants.liquidity_baking_origination_nonce +let liquidity_baking_reward c = + let constants = Raw_context.constants c in + constants.liquidity_baking_reward + let liquidity_baking_sunset c = let constants = Raw_context.constants c in constants.liquidity_baking_sunset diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 3a82db31da76..e28fb8bb8f81 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -99,7 +99,6 @@ type back = { internal_nonce : int; internal_nonces_used : Int_set.t; gas_counter_status : gas_counter_status; - liquidity_baking_escape_flag : bool; } (* @@ -752,7 +751,6 @@ let prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt = internal_nonce = 0; internal_nonces_used = Int_set.empty; gas_counter_status = Unlimited_operation_gas; - liquidity_baking_escape_flag = false; }; } @@ -1005,9 +1003,3 @@ let map_temporary_lazy_storage_ids_s ctxt f = f (temporary_lazy_storage_ids ctxt) >|= fun (ctxt, temporary_lazy_storage_ids) -> update_temporary_lazy_storage_ids ctxt temporary_lazy_storage_ids - -let get_liquidity_baking_escape_flag ctxt = - ctxt.back.liquidity_baking_escape_flag - -let set_liquidity_baking_escape_flag ctxt flag = - update_back ctxt {ctxt.back with liquidity_baking_escape_flag = flag} diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index be749cac9665..50e40c91793d 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -205,7 +205,3 @@ val map_temporary_lazy_storage_ids_s : t -> (Lazy_storage_kind.Temp_ids.t -> (t * Lazy_storage_kind.Temp_ids.t) Lwt.t) -> t Lwt.t - -val get_liquidity_baking_escape_flag : context -> bool - -val set_liquidity_baking_escape_flag : context -> bool -> context diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index d0391e62ea6c..fc18d1b22470 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -189,8 +189,8 @@ module Forge = struct in Block_header.{shell; protocol_data = {contents; signature}} - let forge_header ?(policy = By_priority 0) ?timestamp ?(operations = []) pred - = + let forge_header ?(policy = By_priority 0) ?timestamp ?(operations = []) + ?liquidity_baking_escape_flag pred = dispatch_policy policy pred >>=? fun (pkh, priority, _timestamp) -> Alpha_services.Delegate.Minimal_valid_time.get rpc_ctxt pred priority 0 @@ -222,7 +222,9 @@ module Forge = struct ~fitness ~operations_hash in - let contents = make_contents ~priority ~seed_nonce_hash () in + let contents = + make_contents ~priority ~seed_nonce_hash ?liquidity_baking_escape_flag () + in {baker = pkh; shell; contents} (* compatibility only, needed by incremental *) @@ -404,7 +406,8 @@ let apply header ?(operations = []) pred = let hash = Block_header.hash header in {hash; header; operations; context} -let bake ?policy ?timestamp ?operation ?operations pred = +let bake ?policy ?timestamp ?operation ?operations + ?liquidity_baking_escape_flag pred = let operations = match (operation, operations) with | (Some op, Some ops) -> @@ -416,7 +419,12 @@ let bake ?policy ?timestamp ?operation ?operations pred = | (None, None) -> None in - Forge.forge_header ?timestamp ?policy ?operations pred + Forge.forge_header + ?timestamp + ?policy + ?operations + ?liquidity_baking_escape_flag + pred >>=? fun header -> Forge.sign_header header >>=? fun header -> apply header ?operations pred @@ -425,8 +433,11 @@ let bake ?policy ?timestamp ?operation ?operations pred = (* This function is duplicated from Context to avoid a cyclic dependency *) let get_constants b = Alpha_services.Constants.all rpc_ctxt b -let bake_n ?policy n b = - List.fold_left_es (fun b _ -> bake ?policy b) b (1 -- n) +let bake_n ?policy ?liquidity_baking_escape_flag n b = + List.fold_left_es + (fun b _ -> bake ?policy ?liquidity_baking_escape_flag b) + b + (1 -- n) let bake_until_cycle_end ?policy b = get_constants b diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index cf79d88972cf..9029b82f4b17 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -74,6 +74,7 @@ module Forge : sig ?policy:baker_policy -> ?timestamp:Timestamp.time -> ?operations:Operation.packed list -> + ?liquidity_baking_escape_flag:bool -> t -> header tzresult Lwt.t @@ -123,11 +124,17 @@ val bake : ?timestamp:Timestamp.time -> ?operation:Operation.packed -> ?operations:Operation.packed list -> + ?liquidity_baking_escape_flag:bool -> t -> t tzresult Lwt.t (** Bakes [n] blocks. *) -val bake_n : ?policy:baker_policy -> int -> t -> block tzresult Lwt.t +val bake_n : + ?policy:baker_policy -> + ?liquidity_baking_escape_flag:bool -> + int -> + t -> + block tzresult Lwt.t val current_cycle : t -> Cycle.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 7b18159b68a3..90f93a0cd39e 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -173,6 +173,11 @@ let get_endorsing_reward ctxt ~priority ~endorsing_power = (Environment.wrap_tzresult Tez.(reward_per_endorsement *? Int64.of_int endorsing_power)) +let get_liquidity_baking_reward ctxt = + get_constants ctxt + >>=? fun {Constants.parametric = {liquidity_baking_reward; _}; _} -> + return liquidity_baking_reward + (* Voting *) module Vote = struct @@ -274,6 +279,9 @@ module Contract = struct let delegate_opt ctxt contract = Alpha_services.Contract.delegate_opt rpc_ctxt ctxt contract + + let storage ctxt contract = + Alpha_services.Contract.storage rpc_ctxt ctxt contract end module Delegate = struct diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 1a21dcd7cc92..9f0cf2100ffa 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -63,6 +63,8 @@ val get_baking_reward : val get_endorsing_reward : t -> priority:int -> endorsing_power:int -> Tez.t tzresult Lwt.t +val get_liquidity_baking_reward : t -> Tez.t tzresult Lwt.t + module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t @@ -108,6 +110,8 @@ module Contract : sig val delegate : t -> Contract.t -> public_key_hash tzresult Lwt.t val delegate_opt : t -> Contract.t -> public_key_hash option tzresult Lwt.t + + val storage : t -> Contract.t -> Script.expr tzresult Lwt.t end module Delegate : sig diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 74d0c63ecb6c..dbc71995aa43 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -39,12 +39,16 @@ let liquidity_baking_rewards n () = >>=? fun old_balance -> Block.bake_n n blk >>=? fun blk -> + Context.get_liquidity_baking_reward (B blk) + >>=? fun liquidity_baking_reward -> + Tez.(liquidity_baking_reward *? Int64.(of_int n)) + >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ (B blk) liquidity_baking old_balance - (Tez.of_int (5 * n)) + expected_balance >>=? fun () -> return_unit let liquidity_baking_sunset () = @@ -61,12 +65,16 @@ let liquidity_baking_sunset () = >>=? fun old_balance -> Block.bake_n Int32.(to_int (add sunset 100l)) blk >>=? fun blk -> + Context.get_liquidity_baking_reward (B blk) + >>=? fun liquidity_baking_reward -> + Tez.(liquidity_baking_reward *? Int64.(sub (of_int32 sunset) 1L)) + >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ (B blk) liquidity_baking old_balance - (Tez.of_int Int32.(to_int (mul 5l (sub sunset 1l)))) + expected_balance >>=? fun () -> return_unit (* let liquidity_baking_storage n () = @@ -118,17 +126,24 @@ let liquidity_baking_escape_hatch_100 () = Alpha_context.Contract.originated_contract csts.parametric.liquidity_baking_origination_nonce in - let escape_level = 693 in + (* log(1-1/2) / log(0.999) *) + let escape_level = 694 in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> - Block.bake_n (escape_level + 100) blk + Block.bake_n ~liquidity_baking_escape_flag:true escape_level blk >>=? fun blk -> + Block.bake_n 100 blk + >>=? fun blk -> + Context.get_liquidity_baking_reward (B blk) + >>=? fun liquidity_baking_reward -> + Tez.(liquidity_baking_reward *? Int64.(sub (of_int escape_level) 1L)) + >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ (B blk) liquidity_baking old_balance - (Tez.of_int (5 * (escape_level - 1))) + expected_balance >>=? fun () -> return_unit let liquidity_baking_escape_hatch_80 () = @@ -140,26 +155,32 @@ let liquidity_baking_escape_hatch_80 () = Alpha_context.Contract.originated_contract csts.parametric.liquidity_baking_origination_nonce in - let escape_level = 980 in + (* log(1-1/(2*.8)) / log(0.999) *) + let escape_level = 983 in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> let rec bake_80_percent_escaping blk i = if i < escape_level then - Block.bake_n 4 blk (* with escape hatch flag *) + Block.bake blk >>=? fun blk -> - Block.bake blk >>=? fun blk -> bake_80_percent_escaping blk (i + 5) + Block.bake_n ~liquidity_baking_escape_flag:true 4 blk + >>=? fun blk -> bake_80_percent_escaping blk (i + 5) else return blk in bake_80_percent_escaping blk 0 >>=? fun blk -> Block.bake_n 100 blk >>=? fun blk -> + Context.get_liquidity_baking_reward (B blk) + >>=? fun liquidity_baking_reward -> + Tez.(liquidity_baking_reward *? Int64.(sub (of_int escape_level) 1L)) + >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ (B blk) liquidity_baking old_balance - (Tez.of_int (5 * (escape_level - 1))) + expected_balance >>=? fun () -> return_unit let liquidity_baking_escape_hatch_60 () = @@ -171,26 +192,32 @@ let liquidity_baking_escape_hatch_60 () = Alpha_context.Contract.originated_contract csts.parametric.liquidity_baking_origination_nonce in + (* log(1-1/(2*.6)) / log(0.999) *) let escape_level = 1790 in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> let rec bake_80_percent_escaping blk i = if i < escape_level then - Block.bake_n 3 blk (* with escape hatch flag *) + Block.bake_n 2 blk >>=? fun blk -> - Block.bake_n 2 blk >>=? fun blk -> bake_80_percent_escaping blk (i + 5) + Block.bake_n ~liquidity_baking_escape_flag:true 3 blk + >>=? fun blk -> bake_80_percent_escaping blk (i + 5) else return blk in bake_80_percent_escaping blk 0 >>=? fun blk -> Block.bake_n 100 blk >>=? fun blk -> + Context.get_liquidity_baking_reward (B blk) + >>=? fun liquidity_baking_reward -> + Tez.(liquidity_baking_reward *? Int64.(sub (of_int escape_level) 1L)) + >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ (B blk) liquidity_baking old_balance - (Tez.of_int (5 * (escape_level - 1))) + expected_balance >>=? fun () -> return_unit let tests = -- GitLab From 59960bfc53ac0e2a543685c1eb5f4bdb8002c939 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 12 Jan 2021 21:04:01 -0500 Subject: [PATCH 14/62] liquidity baking: fix rebase errors --- .../lib_protocol/alpha_context.mli | 2 - src/proto_alpha/lib_protocol/baking.mli | 2 - src/proto_alpha/lib_protocol/roll_storage.ml | 10 - src/proto_alpha/lib_protocol/roll_storage.mli | 2 - .../lib_protocol/test/contracts/cpmm.tz | 1420 ----------------- 5 files changed, 1436 deletions(-) delete mode 100644 src/proto_alpha/lib_protocol/test/contracts/cpmm.tz diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 03885d3aa0bd..7a02d07d61c2 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1530,8 +1530,6 @@ module Roll : sig val get_change : context -> Signature.Public_key_hash.t -> Tez.t tzresult Lwt.t - - val num_rolls : context -> int tzresult Lwt.t end module Commitment : sig diff --git a/src/proto_alpha/lib_protocol/baking.mli b/src/proto_alpha/lib_protocol/baking.mli index d292305e26a2..a6eaee1da518 100644 --- a/src/proto_alpha/lib_protocol/baking.mli +++ b/src/proto_alpha/lib_protocol/baking.mli @@ -126,8 +126,6 @@ val check_proof_of_work_stamp : context -> Block_header.t -> unit tzresult and the given block is within the protocol parameters *) val check_fitness_gap : context -> Block_header.t -> unit tzresult -val last_of_a_cycle : context -> Level.t -> bool - val dawn_of_a_new_cycle : context -> Cycle.t option val earlier_predecessor_timestamp : context -> Level.t -> Timestamp.t tzresult diff --git a/src/proto_alpha/lib_protocol/roll_storage.ml b/src/proto_alpha/lib_protocol/roll_storage.ml index 1f1933b5f65b..42fb65627a50 100644 --- a/src/proto_alpha/lib_protocol/roll_storage.ml +++ b/src/proto_alpha/lib_protocol/roll_storage.ml @@ -576,13 +576,3 @@ let update_tokens_per_roll ctxt new_tokens_per_roll = >>?= fun amount -> if decrease then Delegate.add_amount ctxt pkh amount else Delegate.remove_amount ctxt pkh amount) - -let num_rolls ctxt = - Storage.Delegates.fold - ctxt - (Ok (0, ctxt)) - (fun pkh ctxt_opt -> - ctxt_opt - >>?= fun (accum, ctxt) -> - count_rolls ctxt pkh >>=? fun count -> return (count + accum, ctxt)) - >>=? fun (accum, _ctxt) -> return accum diff --git a/src/proto_alpha/lib_protocol/roll_storage.mli b/src/proto_alpha/lib_protocol/roll_storage.mli index 6553c5941198..e88cbefe9788 100644 --- a/src/proto_alpha/lib_protocol/roll_storage.mli +++ b/src/proto_alpha/lib_protocol/roll_storage.mli @@ -262,5 +262,3 @@ val get_contract_delegate : Raw_context.t -> Contract_repr.t -> Signature.Public_key_hash.t option tzresult Lwt.t - -val num_rolls : Raw_context.t -> int tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/contracts/cpmm.tz b/src/proto_alpha/lib_protocol/test/contracts/cpmm.tz deleted file mode 100644 index 07f0ff60eaeb..000000000000 --- a/src/proto_alpha/lib_protocol/test/contracts/cpmm.tz +++ /dev/null @@ -1,1420 +0,0 @@ -{ parameter - (or (or (or (pair %addLiquidity (pair address nat) (pair nat timestamp)) - (pair %approve address (pair nat nat))) - (or (pair %removeLiquidity - (pair address (pair address nat)) - (pair mutez (pair nat timestamp))) - (pair %tokenToXtz (pair address address) (pair nat (pair mutez timestamp))))) - (or (or (key_hash %updateTokenPool) (nat %updateTokenPoolInternal)) - (pair %xtzToToken address (pair nat timestamp)))) ; - storage - (pair (big_map %accounts address (pair (map %allowances address nat) (nat %balance))) - (pair %s - (pair (nat %lqt_total) (bool %self_is_updating_token_pool)) - (pair (nat %token_pool) (mutez %xtz_pool)))) ; - code { EMPTY_MAP address nat ; - PUSH address "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" ; - LAMBDA - mutez - nat - { PUSH mutez 1 ; - SWAP ; - EDIV ; - IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; - CAR } ; - LAMBDA nat mutez { PUSH mutez 1 ; SWAP ; MUL } ; - DIG 3 ; - DUP ; - DUG 4 ; - LAMBDA - (pair (map address nat) (pair address (big_map address (pair (map address nat) nat)))) - (pair (map address nat) nat) - { DUP ; - CDR ; - SWAP ; - CAR ; - SWAP ; - DUP ; - CDR ; - SWAP ; - CAR ; - GET ; - IF_NONE { PUSH nat 0 ; SWAP ; PAIR } { SWAP ; DROP } } ; - SWAP ; - APPLY ; - DIG 5 ; - DUP ; - CDR ; - SWAP ; - CAR ; - IF_LEFT - { IF_LEFT - { DIG 3 ; - DROP ; - IF_LEFT - { DUP ; - DUG 2 ; - CDR ; - CDR ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - PAIR ; - DIG 2 ; - DUP ; - DUG 3 ; - CAR ; - CDR ; - DIG 3 ; - CAR ; - CAR ; - DIG 2 ; - DUP ; - CDR ; - SWAP ; - CAR ; - DIG 4 ; - DUP ; - DUG 5 ; - CDR ; - CAR ; - CDR ; - IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; - SWAP ; - NOW ; - COMPARE ; - LT ; - IF {} - { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; - PUSH nat 0 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GT ; - IF {} - { PUSH string "max_tokens_deposited must be greater than zero." ; FAILWITH } ; - PUSH mutez 0 ; - AMOUNT ; - COMPARE ; - GT ; - IF {} - { PUSH string "The amount of XTZ sent to the contract to be greater than zero." ; - FAILWITH } ; - PUSH nat 0 ; - DIG 3 ; - DUP ; - DUG 4 ; - COMPARE ; - GT ; - IF {} { PUSH string "min_lqt_minted must be greater than zero." ; FAILWITH } ; - PUSH nat 0 ; - DIG 4 ; - DUP ; - DUG 5 ; - CDR ; - CAR ; - CAR ; - COMPARE ; - GT ; - IF { DIG 7 ; - DROP ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CDR ; - CDR ; - DIG 6 ; - DUP ; - DUG 7 ; - SWAP ; - EXEC ; - AMOUNT ; - DIG 7 ; - SWAP ; - EXEC ; - SWAP ; - DUP ; - DUG 2 ; - DIG 6 ; - DUP ; - DUG 7 ; - CDR ; - CDR ; - CAR ; - DIG 2 ; - DUP ; - DUG 3 ; - MUL ; - EDIV ; - IF_NONE - { PUSH string "DIV by 0" ; FAILWITH } - { PUSH nat 0 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - COMPARE ; - EQ ; - IF { CAR } { PUSH nat 1 ; SWAP ; CAR ; ADD } } ; - PUSH nat 0 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GT ; - IF {} - { PUSH string "tokens_deposited must be greater than zero." ; FAILWITH } ; - DUP ; - DIG 4 ; - COMPARE ; - GE ; - IF {} - { PUSH string - "max_tokens_deposited must be greater than or equal to tokens_deposited." ; - FAILWITH } ; - DIG 2 ; - DIG 5 ; - DUP ; - DUG 6 ; - CDR ; - CAR ; - CAR ; - DIG 3 ; - MUL ; - EDIV ; - IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; - CAR ; - DIG 3 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF {} - { PUSH string "lqt_minted must be greater than min_lqt_minted." ; FAILWITH } ; - DIG 3 ; - DUP ; - DUG 4 ; - CAR ; - DIG 3 ; - DUP ; - DUG 4 ; - PAIR ; - DIG 5 ; - SWAP ; - EXEC ; - SWAP ; - DUP ; - DUG 2 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - ADD ; - DIG 5 ; - DUP ; - DUG 6 ; - CDR ; - DIG 6 ; - CAR ; - DIG 2 ; - DIG 3 ; - CAR ; - PAIR ; - DIG 5 ; - DUP ; - DUG 6 ; - SWAP ; - SOME ; - SWAP ; - UPDATE ; - PAIR ; - DUP ; - CDR ; - CDR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - CDR ; - DIG 3 ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CAR ; - CAR ; - ADD ; - PAIR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - DUP ; - CDR ; - CDR ; - CDR ; - DIG 2 ; - DUP ; - DUG 3 ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CDR ; - CAR ; - ADD ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - AMOUNT ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - ADD ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - DIG 3 ; - CONTRACT %transfer (pair address (pair address nat)) ; - IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 3 ; - SELF ; - ADDRESS ; - PAIR ; - DIG 4 ; - PAIR ; - TRANSFER_TOKENS ; - SWAP ; - NIL operation ; - DIG 2 ; - CONS ; - PAIR } - { DIG 2 ; - DROP ; - DIG 3 ; - DROP ; - PUSH mutez 1000000 ; - AMOUNT ; - COMPARE ; - GE ; - IF {} - { PUSH string "The initial liquidity amount must be greater than or equal to zero." ; - FAILWITH } ; - AMOUNT ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CDR ; - CDR ; - ADD ; - DIG 4 ; - SWAP ; - EXEC ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CDR ; - DIG 4 ; - DUP ; - DUG 5 ; - CDR ; - CAR ; - CDR ; - DIG 2 ; - DUP ; - DUG 3 ; - PAIR ; - PAIR ; - DIG 4 ; - CAR ; - DIG 2 ; - DIG 6 ; - PAIR ; - DIG 4 ; - DUP ; - DUG 5 ; - SWAP ; - SOME ; - SWAP ; - UPDATE ; - PAIR ; - DUP ; - CDR ; - CDR ; - CDR ; - DIG 2 ; - DUP ; - DUG 3 ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - AMOUNT ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - ADD ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - DIG 3 ; - CONTRACT %transfer (pair address (pair address nat)) ; - IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 3 ; - SELF ; - ADDRESS ; - PAIR ; - DIG 4 ; - PAIR ; - TRANSFER_TOKENS ; - SWAP ; - NIL operation ; - DIG 2 ; - CONS ; - PAIR } } - { DIG 3 ; - DROP ; - DIG 3 ; - DROP ; - DIG 3 ; - DROP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - DIG 2 ; - CAR ; - DIG 2 ; - DUP ; - CDR ; - SWAP ; - CAR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - CDR ; - IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; - PUSH mutez 0 ; - AMOUNT ; - COMPARE ; - GT ; - IF { PUSH string "amount must be zero." ; FAILWITH } {} ; - SWAP ; - DUP ; - DUG 2 ; - CAR ; - SENDER ; - PAIR ; - DIG 5 ; - SWAP ; - EXEC ; - DUP ; - CAR ; - DUP ; - DIG 5 ; - DUP ; - DUG 6 ; - GET ; - IF_NONE { PUSH nat 0 } {} ; - DIG 3 ; - COMPARE ; - EQ ; - IF { DIG 4 ; - DIG 4 ; - SWAP ; - SOME ; - SWAP ; - UPDATE ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - DIG 3 ; - CAR ; - DIG 3 ; - CDR ; - DIG 3 ; - DUP ; - DUG 4 ; - PAIR ; - SOME ; - SENDER ; - UPDATE ; - PAIR ; - SWAP ; - PAIR } - { SWAP ; - DROP ; - DIG 2 ; - DROP ; - DIG 2 ; - DROP ; - PUSH string "current_allowance must equal account.allowances[spender]." ; - FAILWITH } ; - CDR ; - NIL operation ; - PAIR } } - { DIG 6 ; - DROP ; - IF_LEFT - { DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CDR ; - CAR ; - PAIR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - DIG 2 ; - DUP ; - DUG 3 ; - CAR ; - CDR ; - CDR ; - PAIR ; - DIG 2 ; - DUP ; - DUG 3 ; - CAR ; - CDR ; - CAR ; - DIG 3 ; - CAR ; - CAR ; - DIG 2 ; - DUP ; - CDR ; - SWAP ; - CAR ; - DIG 4 ; - DUP ; - CDR ; - SWAP ; - CAR ; - DUP ; - CDR ; - SWAP ; - CAR ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - CDR ; - IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; - SWAP ; - NOW ; - COMPARE ; - LT ; - IF {} - { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; - PUSH mutez 0 ; - AMOUNT ; - COMPARE ; - GT ; - IF { PUSH string "amount must be zero." ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 4 ; - DUP ; - DUG 5 ; - COMPARE ; - GT ; - IF {} - { PUSH string "min_xtz_withdrawn must be greater than zero." ; FAILWITH } ; - PUSH nat 0 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GT ; - IF {} - { PUSH string "min_tokens_withdrawn must be greater than zero." ; FAILWITH } ; - PUSH nat 0 ; - DIG 3 ; - DUP ; - DUG 4 ; - COMPARE ; - GT ; - IF {} { PUSH string "lqt_burned must be greater than zero." ; FAILWITH } ; - PUSH nat 0 ; - DIG 2 ; - DUP ; - DUG 3 ; - CAR ; - DIG 6 ; - DUP ; - DUG 7 ; - GET ; - IF_NONE - { PUSH string "The owner does not have any liquidity in this contract." ; - FAILWITH } - { DIG 6 ; - DUP ; - DUG 7 ; - SENDER ; - COMPARE ; - NEQ ; - IF { DUP ; - CAR ; - SENDER ; - GET ; - IF_NONE - { PUSH string - "The sender does not have an allowance from the give owner in this contract." ; - FAILWITH } - { DIG 2 ; - DROP ; - DUP ; - DIG 5 ; - DUP ; - DUG 6 ; - COMPARE ; - GT ; - IF { PUSH string "lqt_burned cannot be greater than the sender's allowance." ; - FAILWITH } - {} } } - { SWAP } ; - SWAP ; - CDR ; - PAIR } ; - DUP ; - CAR ; - DIG 4 ; - DUP ; - DUG 5 ; - COMPARE ; - GT ; - IF { PUSH string "lqt_burned cannot be greater than the owner's balance." ; - FAILWITH } - {} ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - CAR ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CDR ; - CDR ; - DIG 11 ; - SWAP ; - EXEC ; - DIG 5 ; - DUP ; - DUG 6 ; - MUL ; - EDIV ; - IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; - CAR ; - DIG 9 ; - SWAP ; - EXEC ; - DIG 5 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF {} - { PUSH string - "The amount of xtz withdrawn must be greater than or equal to min_xtz_withdrawn." ; - FAILWITH } ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CAR ; - CAR ; - DIG 4 ; - DUP ; - DUG 5 ; - CDR ; - CDR ; - CAR ; - DIG 6 ; - DUP ; - DUG 7 ; - MUL ; - EDIV ; - IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; - CAR ; - DIG 3 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF {} - { PUSH string - "The amount of tokens withdrawn must be greater than or equal to min_tokens_withdrawn." ; - FAILWITH } ; - DIG 3 ; - DUP ; - DUG 4 ; - CAR ; - DIG 6 ; - DUP ; - DUG 7 ; - PAIR ; - DIG 8 ; - DUP ; - DUG 9 ; - SWAP ; - EXEC ; - DIG 5 ; - DUP ; - DUG 6 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - SUB ; - PUSH int 0 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF { ABS } - { DROP ; - PUSH string "account.balance - lqt_burned resulted in a negative number." ; - FAILWITH } ; - DIG 5 ; - DUP ; - DUG 6 ; - CDR ; - DIG 6 ; - CAR ; - DIG 2 ; - DIG 3 ; - CAR ; - PAIR ; - DIG 7 ; - DUP ; - DUG 8 ; - SWAP ; - SOME ; - SWAP ; - UPDATE ; - PAIR ; - DIG 4 ; - DUP ; - DUG 5 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - CAR ; - SUB ; - DROP ; - SWAP ; - DUP ; - DUG 2 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - SUB ; - PUSH int 0 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF { SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - SWAP ; - ABS ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR } - { DROP ; - PUSH string - "storage.s.token_pool - tokens_withdrawn resulted in a negative number." ; - FAILWITH } ; - SENDER ; - DIG 6 ; - DUP ; - DUG 7 ; - COMPARE ; - NEQ ; - IF { DIG 4 ; - DIG 4 ; - CDR ; - SUB ; - PUSH int 0 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF { SWAP ; - DUP ; - DUG 2 ; - CAR ; - DIG 5 ; - DUP ; - DUG 6 ; - PAIR ; - DIG 7 ; - SWAP ; - EXEC ; - DUP ; - CDR ; - SWAP ; - CAR ; - DIG 2 ; - ABS ; - SOME ; - SENDER ; - UPDATE ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - DIG 2 ; - CAR ; - DIG 2 ; - DIG 5 ; - SWAP ; - SOME ; - SWAP ; - UPDATE ; - PAIR } - { DROP ; - DIG 3 ; - DROP ; - DIG 4 ; - DROP ; - PUSH string "sender_allowance - lqt_burned resulted in a negative number" ; - FAILWITH } } - { DIG 3 ; DROP ; DIG 3 ; DROP ; DIG 3 ; DROP ; DIG 4 ; DROP } ; - DIG 2 ; - DUP ; - DUG 3 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - SUB ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - DIG 3 ; - DUP ; - DUG 4 ; - CONTRACT unit ; - IF_NONE { PUSH string "bad address for get_contract" ; FAILWITH } {} ; - DIG 3 ; - UNIT ; - TRANSFER_TOKENS ; - DIG 4 ; - CONTRACT %transfer (pair address (pair address nat)) ; - IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 4 ; - DIG 5 ; - PAIR ; - SELF ; - ADDRESS ; - PAIR ; - TRANSFER_TOKENS ; - DIG 2 ; - NIL operation ; - DIG 2 ; - CONS ; - DIG 2 ; - CONS ; - PAIR } - { DIG 2 ; - DROP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - PAIR ; - DIG 2 ; - DUP ; - DUG 3 ; - CAR ; - CDR ; - DIG 3 ; - CAR ; - CAR ; - DIG 2 ; - DUP ; - CDR ; - SWAP ; - CAR ; - DIG 4 ; - DUP ; - CDR ; - SWAP ; - CAR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - CDR ; - IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; - NOW ; - COMPARE ; - LT ; - IF {} - { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; - PUSH mutez 0 ; - AMOUNT ; - COMPARE ; - GT ; - IF { PUSH string "amount must be zero." ; FAILWITH } {} ; - PUSH nat 0 ; - DIG 2 ; - DUP ; - DUG 3 ; - COMPARE ; - GT ; - IF { PUSH string "tokens_sold must be greater than zero." ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 3 ; - DUP ; - DUG 4 ; - COMPARE ; - GT ; - IF { PUSH string "min_xtz_bought must be greater than zero." ; FAILWITH } {} ; - PUSH mutez 0 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - COMPARE ; - EQ ; - IF { PUSH string "xtz_pool must be greater than zero." ; FAILWITH } {} ; - PUSH nat 0 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - COMPARE ; - EQ ; - IF { PUSH string "token_pool must be greater than zero." ; FAILWITH } {} ; - PUSH nat 999 ; - DIG 2 ; - DUP ; - DUG 3 ; - MUL ; - PUSH nat 1000 ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CDR ; - CAR ; - MUL ; - ADD ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - DIG 8 ; - SWAP ; - EXEC ; - PUSH nat 999 ; - DIG 4 ; - DUP ; - DUG 5 ; - MUL ; - MUL ; - EDIV ; - IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; - CAR ; - DIG 6 ; - SWAP ; - EXEC ; - DIG 3 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF {} - { PUSH string "xtz_bought must be greater than or equal to min_xtz_bought." ; - FAILWITH } ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - DIG 3 ; - DUP ; - DUG 4 ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CDR ; - CAR ; - ADD ; - PAIR ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - PAIR ; - DIG 2 ; - CAR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - SUB ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - DIG 4 ; - CONTRACT unit ; - IF_NONE { PUSH string "bad address for get_contract" ; FAILWITH } {} ; - DIG 2 ; - UNIT ; - TRANSFER_TOKENS ; - DIG 4 ; - CONTRACT %transfer (pair address (pair address nat)) ; - IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 4 ; - SELF ; - ADDRESS ; - PAIR ; - DIG 5 ; - PAIR ; - TRANSFER_TOKENS ; - DIG 2 ; - NIL operation ; - DIG 2 ; - CONS ; - DIG 2 ; - CONS ; - PAIR } } } - { DIG 2 ; - DROP ; - DIG 2 ; - DROP ; - DIG 4 ; - DROP ; - IF_LEFT - { DIG 2 ; - DROP ; - IF_LEFT - { IMPLICIT_ACCOUNT ; - ADDRESS ; - SENDER ; - COMPARE ; - EQ ; - IF { SELF %updateTokenPoolInternal ; - DIG 2 ; - CONTRACT %getBalance (pair address (contract nat)) ; - IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 2 ; - SELF ; - ADDRESS ; - PAIR ; - TRANSFER_TOKENS ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - PUSH bool True ; - DIG 3 ; - DUP ; - DUG 4 ; - CDR ; - CAR ; - CAR ; - PAIR ; - PAIR ; - DIG 2 ; - CAR ; - PAIR ; - NIL operation ; - DIG 2 ; - CONS ; - PAIR } - { SWAP ; DROP ; PUSH string "UnsafeUpdateTokenPool" ; FAILWITH } } - { DIG 2 ; - SENDER ; - COMPARE ; - NEQ ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - CDR ; - NOT ; - OR ; - IF { DROP ; - PUSH string - "This entrypoint may only be called by dexter itself via getBalance of tokenAddress." ; - FAILWITH } - { SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - SWAP ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - DUP ; - CDR ; - CDR ; - PUSH bool False ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - CAR ; - PAIR ; - PAIR ; - SWAP ; - CAR ; - PAIR } ; - NIL operation ; - PAIR } } - { DUP ; - DUG 2 ; - CDR ; - CDR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - DIG 2 ; - CAR ; - DIG 2 ; - DUP ; - CDR ; - SWAP ; - CAR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - CDR ; - IF { PUSH string "self_is_updating_token_pool must be false" ; FAILWITH } {} ; - NOW ; - COMPARE ; - LT ; - IF {} - { PUSH string "The current time must be less than the deadline." ; FAILWITH } ; - PUSH mutez 0 ; - AMOUNT ; - COMPARE ; - EQ ; - IF { PUSH string "amount must be greater than zero." ; FAILWITH } {} ; - PUSH nat 0 ; - DIG 3 ; - DUP ; - DUG 4 ; - COMPARE ; - EQ ; - IF { PUSH string "min_tokens_bought must be greater than zero." ; FAILWITH } - {} ; - PUSH mutez 0 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - COMPARE ; - EQ ; - IF { PUSH string "xtz_pool must be greater than zero." ; FAILWITH } {} ; - PUSH nat 0 ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - COMPARE ; - EQ ; - IF { PUSH string "token_pool must be greater than zero." ; FAILWITH } {} ; - DUP ; - CDR ; - CDR ; - CDR ; - DIG 4 ; - DUP ; - DUG 5 ; - SWAP ; - EXEC ; - AMOUNT ; - DIG 5 ; - SWAP ; - EXEC ; - PUSH nat 999 ; - SWAP ; - DUP ; - DUG 2 ; - MUL ; - PUSH nat 1000 ; - DIG 3 ; - MUL ; - ADD ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CDR ; - CAR ; - PUSH nat 999 ; - DIG 3 ; - MUL ; - MUL ; - EDIV ; - IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ; - CAR ; - DIG 3 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF {} - { PUSH string "tokens_bought must be greater than or equal to min_tokens_bought." ; - FAILWITH } ; - DUP ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CDR ; - CAR ; - SUB ; - PUSH int 0 ; - SWAP ; - DUP ; - DUG 2 ; - COMPARE ; - GE ; - IF { DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CDR ; - CDR ; - SWAP ; - ABS ; - PAIR ; - DIG 2 ; - DUP ; - DUG 3 ; - CDR ; - CAR ; - PAIR ; - DIG 2 ; - CAR ; - PAIR } - { DROP ; PUSH string "token_pool - tokens_bought is negative." ; FAILWITH } ; - AMOUNT ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CDR ; - ADD ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CDR ; - CAR ; - PAIR ; - SWAP ; - DUP ; - DUG 2 ; - CDR ; - CAR ; - PAIR ; - SWAP ; - CAR ; - PAIR ; - DIG 3 ; - CONTRACT %transfer (pair address (pair address nat)) ; - IF_NONE { PUSH string "bad address for get_entrypoint" ; FAILWITH } {} ; - PUSH mutez 0 ; - DIG 3 ; - DIG 4 ; - PAIR ; - SELF ; - ADDRESS ; - PAIR ; - TRANSFER_TOKENS ; - SWAP ; - NIL operation ; - DIG 2 ; - CONS ; - PAIR } } } } - -- GitLab From 1eb167715c3e67a7f7f57af4dfa7ada3b8e9e602 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 12 Jan 2021 22:16:53 -0500 Subject: [PATCH 15/62] liquidity baking: add docstrings and comments --- .../lib_parameters/default_parameters.ml | 8 +- .../lib_protocol/alpha_context.mli | 3 + src/proto_alpha/lib_protocol/apply.ml | 90 +++++++++++-------- .../lib_protocol/block_header_repr.mli | 2 +- .../lib_protocol/constants_repr.ml | 20 ++--- .../lib_protocol/constants_storage.ml | 8 +- src/proto_alpha/lib_protocol/storage.mli | 2 + .../test/test_liquidity_baking.ml | 18 ++-- 8 files changed, 86 insertions(+), 65 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 3ff8e49126f5..4103168d22f3 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -56,13 +56,13 @@ let constants_mainnet = min_proposal_quorum = 5_00l; initial_endorsers = 24; delay_per_missing_endorsement = Period.of_seconds_exn 8L; - liquidity_baking_origination_nonce = + liquidity_baking_cpmm_origination_nonce = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) Contract_repr.initial_origination_nonce Operation_hash.zero; liquidity_baking_reward = Tez_repr.of_mutez_exn 5_000_000L; (* now + six months *) (* MUST BE ADJUSTED PRIOR TO INJECTION !!! *) - liquidity_baking_sunset = Int32.add 1292070l 262800l; + liquidity_baking_sunset_level = Int32.add 1292070l 262800l; } let constants_sandbox = @@ -78,7 +78,7 @@ let constants_sandbox = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baking_sunset = 1024l; + liquidity_baking_sunset_level = 1024l; } let constants_test = @@ -93,7 +93,7 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baking_sunset = 2048l; + liquidity_baking_sunset_level = 2048l; } let bootstrap_accounts_strings = diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 7a02d07d61c2..89d191985d51 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1642,5 +1642,8 @@ end val get_liquidity_baking_escape_ema : context -> Int32.t tzresult Lwt.t +(** ema starts at zero + ema[n+1] = (999 * ema[n] // 1000) + (1000 if flag[n] else 0) + where flag is protocol_data.contents.liquidity_baking_escape_flag **) val set_liquidity_baking_escape_ema : context -> bool -> (context * Int32.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 9e704442dbd7..2fa86721f131 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1595,25 +1595,31 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some nonce_hash -> Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> + (* if ema is above 500_000 threshold this will be a no-op *) + (* liquidity baking permanently shuts off if threshold is reached once *) set_liquidity_baking_escape_ema ctxt protocol_data.liquidity_baking_escape_flag >>=? fun (ctxt, liquidity_baking_escape_ema) -> - let liquidity_baking = + let liquidity_baking_cpmm_contract = Contract.originated_contract - (Constants.liquidity_baking_origination_nonce ctxt) + (Constants.liquidity_baking_cpmm_origination_nonce ctxt) in + (* check that level is below sunset *) + (* we check that ema is below threshold again in case it just increased *) + (* if either condition is not met, liquidity baking reward is set to zero*) let liquidity_baking_reward = let level = Raw_level.to_int32 (Level.current ctxt).level in if - Compare.Int32.(level < Constants.liquidity_baking_sunset ctxt) + Compare.Int32.(level < Constants.liquidity_baking_sunset_level ctxt) && Compare.Int32.(liquidity_baking_escape_ema < 500_000l) then Constants.liquidity_baking_reward ctxt else Tez.zero in - Contract.credit ctxt liquidity_baking liquidity_baking_reward + (* credit liquidity baking reward to CPMM contract *) + Contract.credit ctxt liquidity_baking_cpmm_contract liquidity_baking_reward >>=? fun ctxt -> - Contract.get_script ctxt liquidity_baking + Contract.get_script ctxt liquidity_baking_cpmm_contract >>=? fun (ctxt, script) -> match script with | None -> @@ -1621,13 +1627,22 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some script -> let step_constants = let open Script_interpreter in - {source = liquidity_baking; - payer = liquidity_baking; - self = liquidity_baking; - amount = liquidity_baking_reward; - chain_id = Chain_id.zero; } (* TODO: get chain_id *) + { + source = liquidity_baking_cpmm_contract; + payer = liquidity_baking_cpmm_contract; + self = liquidity_baking_cpmm_contract; + amount = liquidity_baking_reward; + chain_id = Chain_id.zero; + } + (* TODO: get chain_id *) + in + let parameter = + Micheline.strip_locations + Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) in - let parameter = Micheline.strip_locations Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) in + (* call CPPM default entrypoint with parameter Unit *) + (* this is necessary for the CPMM's xtz_pool in storage to + increase since it cannot use BALANCE due to a transfer attack *) Script_interpreter.execute ctxt Optimized @@ -1638,37 +1653,38 @@ let finalize_application ctxt protocol_data delegate ~block_delay ~internal:true >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> let _operations = operations in + (* update CPMM storage *) Contract.update_script_storage ctxt - liquidity_baking + liquidity_baking_cpmm_contract storage lazy_storage_diff >>=? fun ctxt -> - (* end of cycle *) - may_snapshot_roll ctxt - >>=? fun ctxt -> - may_start_new_cycle ctxt - >>=? fun (ctxt, balance_updates, deactivated) -> - Amendment.may_start_new_voting_period ctxt - >>=? fun ctxt -> - let cycle = (Level.current ctxt).cycle in - let balance_updates = - Receipt.( - cleanup_balance_updates - ( migration_balance_updates - @ [ ( Contract (Contract.implicit_contract delegate), - Debited deposit, - Block_application ); - (Deposits (delegate, cycle), Credited deposit, Block_application); - (Rewards (delegate, cycle), Credited reward, Block_application) ] - @ balance_updates )) - in - let consumed_gas = - Gas.Arith.sub - (Gas.Arith.fp @@ Constants.hard_gas_limit_per_block ctxt) - (Alpha_context.Gas.block_level ctxt) - in - (* This value is different than the new [voting_period_info] below for + (* end of cycle *) + may_snapshot_roll ctxt + >>=? fun ctxt -> + may_start_new_cycle ctxt + >>=? fun (ctxt, balance_updates, deactivated) -> + Amendment.may_start_new_voting_period ctxt + >>=? fun ctxt -> + let cycle = (Level.current ctxt).cycle in + let balance_updates = + Receipt.( + cleanup_balance_updates + ( migration_balance_updates + @ [ ( Contract (Contract.implicit_contract delegate), + Debited deposit, + Block_application ); + (Deposits (delegate, cycle), Credited deposit, Block_application); + (Rewards (delegate, cycle), Credited reward, Block_application) ] + @ balance_updates )) + in + let consumed_gas = + Gas.Arith.sub + (Gas.Arith.fp @@ Constants.hard_gas_limit_per_block ctxt) + (Alpha_context.Gas.block_level ctxt) + in + (* This value is different than the new [voting_period_info] below for compatibility reasons, the field [voting_period_kind] is deprecated and will be removed in a future version. *) Alpha_context.Voting_period.get_current_info ctxt diff --git a/src/proto_alpha/lib_protocol/block_header_repr.mli b/src/proto_alpha/lib_protocol/block_header_repr.mli index 2929597ba1b3..d02baaf4bc69 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.mli +++ b/src/proto_alpha/lib_protocol/block_header_repr.mli @@ -27,7 +27,7 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baking_escape_flag : bool; + liquidity_baking_escape_flag : bool; (* set by baker to vote in favor of permanently disabling liquidity baking *) } type protocol_data = {contents : contents; signature : Signature.t} diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index 38e6124764b3..bf61cc2166cb 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -115,9 +115,9 @@ type parametric = { min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; - liquidity_baking_origination_nonce : Contract_repr.origination_nonce; + liquidity_baking_cpmm_origination_nonce : Contract_repr.origination_nonce; liquidity_baking_reward : Tez_repr.t; - liquidity_baking_sunset : int32; + liquidity_baking_sunset_level : int32; } let parametric_encoding = @@ -155,9 +155,9 @@ let parametric_encoding = c.min_proposal_quorum, c.initial_endorsers, c.delay_per_missing_endorsement, - c.liquidity_baking_origination_nonce, + c.liquidity_baking_cpmm_origination_nonce, c.liquidity_baking_reward, - c.liquidity_baking_sunset ) ) )) + c.liquidity_baking_sunset_level ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -184,9 +184,9 @@ let parametric_encoding = min_proposal_quorum, initial_endorsers, delay_per_missing_endorsement, - liquidity_baking_origination_nonce, + liquidity_baking_cpmm_origination_nonce, liquidity_baking_reward, - liquidity_baking_sunset ) ) ) -> + liquidity_baking_sunset_level ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -213,9 +213,9 @@ let parametric_encoding = min_proposal_quorum; initial_endorsers; delay_per_missing_endorsement; - liquidity_baking_origination_nonce; + liquidity_baking_cpmm_origination_nonce; liquidity_baking_reward; - liquidity_baking_sunset; + liquidity_baking_sunset_level; }) (merge_objs (obj9 @@ -253,10 +253,10 @@ let parametric_encoding = (req "initial_endorsers" uint16) (req "delay_per_missing_endorsement" Period_repr.encoding) (req - "liquidity_baking_origination_nonce" + "liquidity_baking_cpmm_origination_nonce" Contract_repr.origination_nonce_encoding) (req "liquidity_baking_reward" Tez_repr.encoding) - (req "liquidity_baking_sunset" int32)))) + (req "liquidity_baking_sunset_level" int32)))) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index 9a6661b94007..dfb60928444c 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -123,16 +123,16 @@ let min_proposal_quorum c = let constants = Raw_context.constants c in constants.min_proposal_quorum -let liquidity_baking_origination_nonce c = +let liquidity_baking_cpmm_origination_nonce c = let constants = Raw_context.constants c in - constants.liquidity_baking_origination_nonce + constants.liquidity_baking_cpmm_origination_nonce let liquidity_baking_reward c = let constants = Raw_context.constants c in constants.liquidity_baking_reward -let liquidity_baking_sunset c = +let liquidity_baking_sunset_level c = let constants = Raw_context.constants c in - constants.liquidity_baking_sunset + constants.liquidity_baking_sunset_level let parametric c = Raw_context.constants c diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 66bfa7debb3c..f59c617d0e7b 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -488,5 +488,7 @@ module Pending_migration_balance_updates : with type value = Receipt_repr.balance_updates and type t := Raw_context.t +(** Exponential moving average of flags set in protocol_data.contents. + If at any block it's >= 500_000, liquidity baking permanently shuts off. **) module Liquidity_baking_escape_ema : Single_data_storage with type t := Raw_context.t and type value = Int32.t diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index dbc71995aa43..34b96647ce4a 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -33,7 +33,7 @@ let liquidity_baking_rewards n () = >>=? fun csts -> let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_origination_nonce + csts.parametric.liquidity_baking_cpmm_origination_nonce in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> @@ -51,16 +51,16 @@ let liquidity_baking_rewards n () = expected_balance >>=? fun () -> return_unit -let liquidity_baking_sunset () = +let liquidity_baking_sunset_level () = Context.init 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_origination_nonce + csts.parametric.liquidity_baking_cpmm_origination_nonce in - let sunset = csts.parametric.liquidity_baking_sunset in + let sunset = csts.parametric.liquidity_baking_sunset_level in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n Int32.(to_int (add sunset 100l)) blk @@ -84,7 +84,7 @@ let liquidity_baking_sunset () = * >>=? fun csts -> * let liquidity_baking = * Alpha_context.Contract.originated_contract - * csts.parametric.liquidity_baking_origination_nonce + * csts.parametric.liquidity_baking_cpmm_origination_nonce * in * let expected_storage = * Expr.from_string @@ -124,7 +124,7 @@ let liquidity_baking_escape_hatch_100 () = >>=? fun csts -> let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_origination_nonce + csts.parametric.liquidity_baking_cpmm_origination_nonce in (* log(1-1/2) / log(0.999) *) let escape_level = 694 in @@ -153,7 +153,7 @@ let liquidity_baking_escape_hatch_80 () = >>=? fun csts -> let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_origination_nonce + csts.parametric.liquidity_baking_cpmm_origination_nonce in (* log(1-1/(2*.8)) / log(0.999) *) let escape_level = 983 in @@ -190,7 +190,7 @@ let liquidity_baking_escape_hatch_60 () = >>=? fun csts -> let liquidity_baking = Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_origination_nonce + csts.parametric.liquidity_baking_cpmm_origination_nonce in (* log(1-1/(2*.6)) / log(0.999) *) let escape_level = 1790 in @@ -232,7 +232,7 @@ let tests = Test.tztest "test liquidity baking shuts off at sunset level" `Quick - liquidity_baking_sunset; + liquidity_baking_sunset_level; Test.tztest "test liquidity baking escape hatch with 100% of bakers flagging" `Quick -- GitLab From 671ad32f0424694968d1b23717b3a1af90f9c6b1 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 12 Jan 2021 22:18:46 -0500 Subject: [PATCH 16/62] liquidity baking: update FA1.2 contract address in CPMM --- src/proto_alpha/lib_parameters/cpmm.json | 2 +- src/proto_alpha/lib_protocol/alpha_context.ml | 3 +-- src/proto_alpha/lib_protocol/block_header_repr.mli | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) mode change 100755 => 100644 src/proto_alpha/lib_parameters/cpmm.json diff --git a/src/proto_alpha/lib_parameters/cpmm.json b/src/proto_alpha/lib_parameters/cpmm.json old mode 100755 new mode 100644 index a57511937687..188d9347eb6d --- a/src/proto_alpha/lib_parameters/cpmm.json +++ b/src/proto_alpha/lib_parameters/cpmm.json @@ -110,7 +110,7 @@ { "prim": "PUSH", "args": [ { "prim": "address" }, - { "string": "KT1BEqzn5Wx8uJrZNvuS9DVHmLvG9td3fDLi" } ] }, + { "string": "KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP" } ] }, { "prim": "LAMBDA", "args": [ { "prim": "mutez" }, { "prim": "nat" }, diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 3f9b3c3bdf78..7da752e2ad8f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -305,8 +305,7 @@ let set_liquidity_baking_escape_ema ctxt flag = >>=? fun old_ema -> let new_ema = (* if ema ever reaches threshold, liquidity baking is permanently off *) - if Compare.Int32.(old_ema <= 500_000l) - then + if Compare.Int32.(old_ema <= 500_000l) then Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) else old_ema in diff --git a/src/proto_alpha/lib_protocol/block_header_repr.mli b/src/proto_alpha/lib_protocol/block_header_repr.mli index d02baaf4bc69..6b2639a5d665 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.mli +++ b/src/proto_alpha/lib_protocol/block_header_repr.mli @@ -27,7 +27,8 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baking_escape_flag : bool; (* set by baker to vote in favor of permanently disabling liquidity baking *) + liquidity_baking_escape_flag : bool; + (* set by baker to vote in favor of permanently disabling liquidity baking *) } type protocol_data = {contents : contents; signature : Signature.t} -- GitLab From 904f66e31a7ac1dfdcbd914b0f8dda5088f14946 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 12 Jan 2021 22:55:12 -0500 Subject: [PATCH 17/62] liquidity baking: make dune copy contracts in test --- src/proto_alpha/lib_protocol/test/dune | 8 ++++ .../test/test_liquidity_baking.ml | 44 ------------------- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/dune b/src/proto_alpha/lib_protocol/test/dune index 87b7e95ceff7..d734bbe984f1 100644 --- a/src/proto_alpha/lib_protocol/test/dune +++ b/src/proto_alpha/lib_protocol/test/dune @@ -30,6 +30,14 @@ (copy %{lib:tezos-protocol-alpha-parameters:test-parameters.json} protocol_parameters.json)) +(rule + (copy %{lib:tezos-protocol-alpha-parameters:fa12.json} + fa12.json)) + +(rule + (copy %{lib:tezos-protocol-alpha-parameters:cpmm.json} + cpmm.json)) + ; runs only the `Quick tests (rule (alias runtest_proto_alpha) diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 34b96647ce4a..c2957491ca11 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -77,46 +77,6 @@ let liquidity_baking_sunset_level () = expected_balance >>=? fun () -> return_unit -(* let liquidity_baking_storage n () = - * Context.init 1 - * >>=? fun (blk, _contracts) -> - * Context.get_constants (B blk) - * >>=? fun csts -> - * let liquidity_baking = - * Alpha_context.Contract.originated_contract - * csts.parametric.liquidity_baking_cpmm_origination_nonce - * in - * let expected_storage = - * Expr.from_string - * (String.concat "" - * [ "Pair {} (Pair (Pair 4000000000000 False) (Pair 2000000000000"; - * (Printf.sprintf "%d" (2000000000000 + n*5)); - * "))"; ]) - * in - * (\* Alpha_context.Contract.get_storage (B blk) liquidity_baking - * * >>=? fun (ctxt, s) -> - * * match s with - * * | None -> return_unit - * * | Some old_storage -> *\) - * Block.bake_n n blk - * >>=? fun blk -> - * Context.Contract.storage (B blk) liquidity_baking - * >>=? fun s -> - * Expr.equal_tokens - * ~loc:__LOC__ - * s - * expected_storage - * >>=? fun () -> return_unit - * (\* let new_storage_string = Micheline.pp_tokens Format.pp_print_string s in - * * Assert.equal - * * ~loc:__LOC__ - * * String.equal - * * "Storage isn't equal" - * * Format.pp_print_string - * * new_storage_string - * * expected_storage_string - * * >>=? fun () -> return_unit *\) *) - let liquidity_baking_escape_hatch_100 () = Context.init 1 >>=? fun (blk, _contracts) -> @@ -225,10 +185,6 @@ let tests = "test liquidity baking rewards are correct" `Quick (liquidity_baking_rewards 64); - (* Test.tztest - * "test liquidity baking storage correct" - * `Quick - * (correct_liquidity_baking_storage 1024); *) Test.tztest "test liquidity baking shuts off at sunset level" `Quick -- GitLab From 08de48a282ecce9a2c7006bcbfee69dcd229e274 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Wed, 13 Jan 2021 16:36:09 -0500 Subject: [PATCH 18/62] liquidity baking: remove erroneous TODO --- src/proto_alpha/lib_protocol/apply.ml | 33 +++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 2fa86721f131..befd787c684f 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1625,23 +1625,22 @@ let finalize_application ctxt protocol_data delegate ~block_delay | None -> Lwt.return (error (Script_tc_errors.No_such_entrypoint "default")) | Some script -> - let step_constants = - let open Script_interpreter in - { - source = liquidity_baking_cpmm_contract; - payer = liquidity_baking_cpmm_contract; - self = liquidity_baking_cpmm_contract; - amount = liquidity_baking_reward; - chain_id = Chain_id.zero; - } - (* TODO: get chain_id *) - in - let parameter = - Micheline.strip_locations - Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) - in - (* call CPPM default entrypoint with parameter Unit *) - (* this is necessary for the CPMM's xtz_pool in storage to + let step_constants = + let open Script_interpreter in + { + source = liquidity_baking_cpmm_contract; + payer = liquidity_baking_cpmm_contract; + self = liquidity_baking_cpmm_contract; + amount = liquidity_baking_reward; + chain_id = Chain_id.zero; + } + in + let parameter = + Micheline.strip_locations + Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) + in + (* call CPPM default entrypoint with parameter Unit *) + (* this is necessary for the CPMM's xtz_pool in storage to increase since it cannot use BALANCE due to a transfer attack *) Script_interpreter.execute ctxt -- GitLab From 30501be1f5eebf24ca7ca5d43657ce979042c1e9 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 19 Jan 2021 15:44:21 -0500 Subject: [PATCH 19/62] liquidity baking: tests for storage and balance updates --- .../lib_protocol/test/helpers/block.ml | 54 +++++++++++ .../lib_protocol/test/helpers/block.mli | 9 ++ .../test/test_liquidity_baking.ml | 90 ++++++++++++++++++- 3 files changed, 152 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index fc18d1b22470..9393c362a245 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -406,6 +406,28 @@ let apply header ?(operations = []) pred = let hash = Block_header.hash header in {hash; header; operations; context} +let apply_with_metadata header ?(operations = []) pred = + (let open Environment.Error_monad in + Main.begin_application + ~chain_id:Chain_id.zero + ~predecessor_context:pred.context + ~predecessor_fitness:pred.header.shell.fitness + ~predecessor_timestamp:pred.header.shell.timestamp + header + >>=? fun vstate -> + List.fold_left_es + (fun vstate op -> + apply_operation vstate op >|=? fun (state, _result) -> state) + vstate + operations + >>=? fun vstate -> + Main.finalize_block vstate + >|=? fun (validation, result) -> (validation.context, result)) + >|= Environment.wrap_error + >|=? fun (context, result) -> + let hash = Block_header.hash header in + ({hash; header; operations; context}, result) + let bake ?policy ?timestamp ?operation ?operations ?liquidity_baking_escape_flag pred = let operations = @@ -428,6 +450,29 @@ let bake ?policy ?timestamp ?operation ?operations >>=? fun header -> Forge.sign_header header >>=? fun header -> apply header ?operations pred +let bake_with_metadata ?policy ?timestamp ?operation ?operations + ?liquidity_baking_escape_flag pred = + let operations = + match (operation, operations) with + | (Some op, Some ops) -> + Some (op :: ops) + | (Some op, None) -> + Some [op] + | (None, Some ops) -> + Some ops + | (None, None) -> + None + in + Forge.forge_header + ?timestamp + ?policy + ?operations + ?liquidity_baking_escape_flag + pred + >>=? fun header -> + Forge.sign_header header + >>=? fun header -> apply_with_metadata header ?operations pred + (********** Cycles ****************) (* This function is duplicated from Context to avoid a cyclic dependency *) @@ -439,6 +484,15 @@ let bake_n ?policy ?liquidity_baking_escape_flag n b = b (1 -- n) +let bake_n_with_balance_updates ?policy ?liquidity_baking_escape_flag n b = + List.fold_left_es + (fun (b, balance_updates_list) _ -> + bake_with_metadata ?policy ?liquidity_baking_escape_flag b + >>=? fun (b, metadata) -> + return (b, metadata.balance_updates @ balance_updates_list)) + (b, []) + (1 -- n) + let bake_until_cycle_end ?policy b = get_constants b >>=? fun Constants.{parametric = {blocks_per_cycle; _}; _} -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 9029b82f4b17..acb68720b40d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -136,6 +136,15 @@ val bake_n : t -> block tzresult Lwt.t +(** Version of bake_n that returns a list of all balance updates included + in the metadata of baked blocks. **) +val bake_n_with_balance_updates : + ?policy:baker_policy -> + ?liquidity_baking_escape_flag:bool -> + int -> + t -> + (block * Alpha_context.Delegate.balance_updates) tzresult Lwt.t + val current_cycle : t -> Cycle.t tzresult Lwt.t (** Given a block [b] at level [l] bakes enough blocks to complete a cycle, diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index c2957491ca11..5163a71d2cf8 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -25,6 +25,7 @@ open Protocol open Test_tez +open Micheline_printer let liquidity_baking_rewards n () = Context.init 1 @@ -180,6 +181,85 @@ let liquidity_baking_escape_hatch_60 () = expected_balance >>=? fun () -> return_unit +let liquidity_baking_storage n () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baking = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baking_cpmm_origination_nonce + in + let expected_storage = + Expr.from_string + (String.concat + "" + [ "Pair 1 (Pair False 4000000000000) (Pair 2000000000000 "; + Printf.sprintf " %d" (2000000000000 + (n * 5000000));]) + in + Block.bake_n n blk + >>=? fun blk -> + Context.Contract.storage (B blk) liquidity_baking + >>=? fun storage -> + let to_string expr = + expr |> Michelson_v1_primitives.strings_of_prims + |> Micheline.inject_locations (fun _ -> {comment = None}) + |> Format.asprintf "%a" Micheline_printer.print_expr + in + Assert.equal + ~loc:__LOC__ + String.equal + "Storage isn't equal" + Format.pp_print_string + (to_string storage) + (to_string expected_storage) + >>=? fun () -> return_unit + +let liquidity_baking_balance_update () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baking = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baking_cpmm_origination_nonce + in + let sunset = csts.parametric.liquidity_baking_sunset_level in + Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk + >>=? fun (_blk, balance_updates) -> + let liquidity_baking_updates = + List.filter + (fun el -> + match el with + | ( Alpha_context.Delegate.Misc contract, + Alpha_context.Delegate.Credited _ ) -> + if Alpha_context.Contract.(contract = liquidity_baking) then true + else false + | _ -> + false) + balance_updates + in + let rewards = + List.fold_left + (fun accum (_, update) -> + match update with + | Alpha_context.Delegate.Credited x -> + Tez.(accum + x) + | Alpha_context.Delegate.Debited x -> ( + match Tez.(accum -? x) with + | Ok r -> + r + | Error _ -> + Stdlib.failwith "subtracting tez" )) + Tez.(of_int 0) + liquidity_baking_updates + in + Assert.equal_tez + ~loc:__LOC__ + rewards + (Tez.of_int ((Int32.to_int sunset - 1) * 5)) + >>=? fun () -> return_unit + let tests = [ Test.tztest "test liquidity baking rewards are correct" @@ -200,4 +280,12 @@ let tests = Test.tztest "test liquidity baking escape hatch with 60% of bakers flagging" `Quick - liquidity_baking_escape_hatch_60 ] + liquidity_baking_escape_hatch_60; + Test.tztest + "test liquidity baking storage is updated" + `Quick + (liquidity_baking_storage 64); + Test.tztest + "test liquidity baking balance updates" + `Quick + liquidity_baking_balance_update ] -- GitLab From c2d45fbbc55307459ebe825348848f04383b1aeb Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Tue, 19 Jan 2021 16:10:40 -0500 Subject: [PATCH 20/62] liquidity baking: make dune pass bootstrap contracts as cli args --- src/proto_alpha/lib_parameters/cpmm.json | 5346 ++++++++++------- .../lib_parameters/default_parameters.ml | 50 +- .../lib_parameters/default_parameters.mli | 5 + src/proto_alpha/lib_parameters/dune | 14 +- src/proto_alpha/lib_parameters/gen.ml | 16 +- src/proto_alpha/lib_protocol/test/dune | 18 +- .../lib_protocol/test/helpers/block.ml | 3 + .../test/test_liquidity_baking.ml | 8 +- 8 files changed, 3159 insertions(+), 2301 deletions(-) diff --git a/src/proto_alpha/lib_parameters/cpmm.json b/src/proto_alpha/lib_parameters/cpmm.json index 188d9347eb6d..7b44615b1c89 100644 --- a/src/proto_alpha/lib_parameters/cpmm.json +++ b/src/proto_alpha/lib_parameters/cpmm.json @@ -1,2298 +1,3126 @@ [ { "prim": "parameter", "args": - [ { "prim": "or", - "args": + [ { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ ":spender" ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", + "annots": [ ":allowance" ] }, + { "prim": "nat", + "annots": + [ ":currentAllowance" ] } ] } ], + "annots": [ "%approve" ] }, + { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ ":owner" ] }, + { "prim": "nat", + "annots": [ ":minLqtMinted" ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", + "annots": + [ ":maxTokensDeposited" ] }, + { "prim": "timestamp", + "annots": [ ":deadline" ] } ] } ], + "annots": [ "%addLiquidity" ] } ] }, + { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ ":owner" ] }, + { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ ":to" ] }, + { "prim": "nat", + "annots": + [ ":lqtBurned" ] } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "mutez", + "annots": + [ ":minXtzWithdrawn" ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", + "annots": + [ ":minTokensWithdrawn" ] }, + { "prim": "timestamp", + "annots": [ ":deadline" ] } ] } ] } ], + "annots": [ "%removeLiquidity" ] }, + { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ ":to" ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", + "annots": + [ ":minTokensBought" ] }, + { "prim": "timestamp", + "annots": [ ":deadline" ] } ] } ], + "annots": [ "%xtzToToken" ] } ] } ] }, + { "prim": "or", + "args": [ { "prim": "or", "args": + [ { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ ":owner" ] }, + { "prim": "address", + "annots": [ ":to" ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", + "annots": [ ":tokensSold" ] }, + { "prim": "pair", + "args": + [ { "prim": "mutez", + "annots": + [ ":minXtzBought" ] }, + { "prim": "timestamp", + "annots": [ ":deadline" ] } ] } ] } ], + "annots": [ "%tokenToXtz" ] }, + { "prim": "key_hash", + "annots": [ "%updateTokenPool" ] } ] }, + { "prim": "or", + "args": + [ { "prim": "nat", + "annots": [ "%updateTokenPoolInternal" ] }, + { "prim": "unit", "annots": [ "%default" ] } ] } ] } ] } ] }, + { "prim": "storage", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "big_map", + "args": + [ { "prim": "address", "annots": [ ":owner" ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", "annots": [ ":balance" ] }, + { "prim": "map", + "args": + [ { "prim": "address", + "annots": [ ":spender" ] }, + { "prim": "nat", + "annots": [ ":allowance" ] } ] } ] } ], + "annots": [ "%accounts" ] }, + { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "bool", + "annots": [ ":selfIsUpdatingTokenPool" ] }, + { "prim": "nat", "annots": [ ":lqtTotal" ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "address", + "annots": [ ":tokenAddress" ] }, + { "prim": "pair", + "args": + [ { "prim": "nat", + "annots": [ ":tokenPool" ] }, + { "prim": "mutez", + "annots": [ ":xtzPool" ] } ] } ] } ] } ] } ] }, + { "prim": "code", + "args": + [ [ { "prim": "CAST", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "or", + "args": [ { "prim": "or", "args": - [ { "prim": "pair", - "args": + [ { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, + { "prim": "nat" } ] } ] }, + { "prim": "pair", + "args": [ { "prim": "pair", "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, + [ { "prim": "address" }, + { "prim": "nat" } ] }, { "prim": "pair", "args": - [ { "prim": "nat" }, - { "prim": "timestamp" } ] } ], - "annots": [ "%addLiquidity" ] }, - { "prim": "pair", - "args": + [ { "prim": "nat" }, + { "prim": + "timestamp" } ] } ] } ] }, + { "prim": "or", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": + "nat" } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "mutez" }, + { "prim": "pair", + "args": + [ { "prim": + "nat" }, + { "prim": + "timestamp" } ] } ] } ] }, + { "prim": "pair", + "args": [ { "prim": "address" }, { "prim": "pair", "args": - [ { "prim": "nat" }, { "prim": "nat" } ] } ], - "annots": [ "%approve" ] } ] }, + [ { "prim": "nat" }, + { "prim": + "timestamp" } ] } ] } ] } ] }, { "prim": "or", "args": - [ { "prim": "unit", "annots": [ "%default" ] }, - { "prim": "pair", - "args": + [ { "prim": "or", + "args": + [ { "prim": "pair", + "args": [ { "prim": "pair", "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] } ] }, + [ { "prim": "address" }, + { "prim": "address" } ] }, { "prim": "pair", "args": - [ { "prim": "mutez" }, - { "prim": "pair", - "args": - [ { "prim": "nat" }, - { "prim": "timestamp" } ] } ] } ], - "annots": [ "%removeLiquidity" ] } ] } ] }, - { "prim": "or", + [ { "prim": "nat" }, + { "prim": "pair", + "args": + [ { "prim": + "mutez" }, + { "prim": + "timestamp" } ] } ] } ] }, + { "prim": "key_hash" } ] }, + { "prim": "or", + "args": + [ { "prim": "nat" }, + { "prim": "unit" } ] } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "big_map", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, + { "prim": "map", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] } ] } ] }, + { "prim": "pair", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "bool" }, + { "prim": "nat" } ] }, + { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", + "args": + [ { "prim": "nat" }, + { "prim": "mutez" } ] } ] } ] } ] } ] } ] }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] }, + { "prim": "IF_LEFT", + "args": + [ [ { "prim": "IF_LEFT", "args": - [ { "prim": "or", + [ [ { "prim": "IF_LEFT", "args": - [ { "prim": "pair", + [ [ { "prim": "DIP", "args": - [ { "prim": "pair", + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "IF", "args": - [ { "prim": "address" }, - { "prim": "address" } ] }, - { "prim": "pair", + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "selfIsUpdatingToken must be false." } ] }, + { "prim": "FAILWITH" } ], + [] ] } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Amount must be zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "SENDER" }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "EMPTY_MAP", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "PAIR" } ], [] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] } ], + [] ] }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The current allowance parameter must equal the sender's current allowance for the owner." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "SOME" } ] ] }, + { "prim": "UPDATE" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CAR" } ] ] }, + { "prim": "SOME" }, + { "prim": "SENDER" }, + { "prim": "UPDATE" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } ], + [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "IF", "args": - [ { "prim": "nat" }, - { "prim": "pair", + [ [ { "prim": "PUSH", "args": - [ { "prim": "mutez" }, - { "prim": "timestamp" } ] } ] } ], - "annots": [ "%tokenToXtz" ] }, - { "prim": "key_hash", - "annots": [ "%updateTokenPool" ] } ] }, - { "prim": "or", - "args": - [ { "prim": "nat", - "annots": [ "%updateTokenPoolInternal" ] }, - { "prim": "pair", + [ { "prim": + "string" }, + { "string": + "selfIsUpdatingToken must be false." } ] }, + { "prim": "FAILWITH" } ], + [] ] } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "NOW" }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", "args": - [ { "prim": "address" }, - { "prim": "pair", + [ [], + [ { "prim": "PUSH", "args": - [ { "prim": "nat" }, - { "prim": "timestamp" } ] } ], - "annots": [ "%xtzToToken" ] } ] } ] } ] } ] }, - { "prim": "storage", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "big_map", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "map", + [ { "prim": "string" }, + { "string": + "NOW is greater than deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", "args": - [ { "prim": "address" }, { "prim": "nat" } ], - "annots": [ "%allowances" ] }, - { "prim": "nat", "annots": [ "%balance" ] } ] } ], - "annots": [ "%accounts" ] }, - { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "nat", "annots": [ "%lqt_total" ] }, - { "prim": "bool", - "annots": [ "%self_is_updating_token_pool" ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", "annots": [ "%token_pool" ] }, - { "prim": "mutez", "annots": [ "%xtz_pool" ] } ] } ], - "annots": [ "%s" ] } ] } ] }, - { "prim": "code", - "args": - [ [ { "prim": "EMPTY_MAP", - "args": [ { "prim": "address" }, { "prim": "nat" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "address" }, - { "string": "KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP" } ] }, - { "prim": "LAMBDA", - "args": - [ { "prim": "mutez" }, { "prim": "nat" }, - [ { "prim": "PUSH", - "args": [ { "prim": "mutez" }, { "int": "1" } ] }, - { "prim": "SWAP" }, { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", "args": - [ { "prim": "string" }, - { "string": "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "LAMBDA", - "args": - [ { "prim": "nat" }, { "prim": "mutez" }, - [ { "prim": "PUSH", - "args": [ { "prim": "mutez" }, { "int": "1" } ] }, - { "prim": "SWAP" }, { "prim": "MUL" } ] ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "4" } ] }, - { "prim": "LAMBDA", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "map", - "args": [ { "prim": "address" }, { "prim": "nat" } ] }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "big_map", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "map", + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "maxTokensDeposited must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "minLqtMinted must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Amount must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CDR" }, { "prim": "INT" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "AMOUNT" }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1000000" } ] }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "The initial liquidity amount must be greater than or equal to 1 XTZ." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "SWAP" }, + { "prim": "AMOUNT" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "mutez" }, + { "int": "1" } ] } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": + "DUP" }, + { "prim": + "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": + "DUP" }, + { "prim": + "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": + "CAR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": + "DUP" }, + { "prim": + "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": + "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "DUP" }, + { "prim": + "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": + "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CAR" } ] ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "EMPTY_MAP", + "args": + [ { "prim": + "address" }, + { "prim": "nat" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "PAIR" } ], + [] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CAR" } ] ] }, + { "prim": "SOME" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "UPDATE" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "AMOUNT" }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" }, + { "prim": + "CAR" } ] ] } ] ] }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": "pair", "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, - { "prim": "nat" } ] } ] } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "map", - "args": [ { "prim": "address" }, { "prim": "nat" } ] }, - { "prim": "nat" } ] }, - [ { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "CDR" }, { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "PAIR" } ], - [ { "prim": "SWAP" }, { "prim": "DROP" } ] ] } ] ] }, - { "prim": "SWAP" }, { "prim": "APPLY" }, - { "prim": "DIG", "args": [ { "int": "5" } ] }, { "prim": "DUP" }, - { "prim": "CDR" }, { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "self_is_updating_token_pool must be false" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "SWAP" }, { "prim": "NOW" }, - { "prim": "COMPARE" }, { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The current time must be less than the deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "max_tokens_deposited must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The amount of XTZ sent to the contract to be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, + [ { "prim": + "address" }, + { "prim": + "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "PAIR" } ] ] }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIP", + "args": + [ [ { "prim": "NIL", + "args": + [ { "prim": + "operation" } ] } ] ] }, + { "prim": "CONS" }, + { "prim": "PAIR" } ], + [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "mutez" }, + { "int": "1" } ] } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "AMOUNT" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "mutez" }, + { "int": "1" } ] } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ { "int": "4" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "MUL" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "divByZero." } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "INT" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": + "PUSH", + "args": + [ { "prim": + "nat" }, + { "int": + "1" } ] }, + { "prim": + "ADD" } ] ] } ] ] }, + { "prim": "DUP" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "tokensDeposited is zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DIP", + "args": + [ { "int": "4" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "MUL" }, + { "prim": "DIP", + "args": + [ [ { "prim": "SWAP" } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" } ] ] }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "lqtMinted must be greater than or equal to minLqtMinted." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": + "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "DUP" } ] ] }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": + "PUSH", + "args": + [ { "prim": + "string" }, { "string": - "min_lqt_minted must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CAR" }, { "prim": "COMPARE" }, - { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": "DIG", - "args": [ { "int": "7" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "7" } ] }, - { "prim": "SWAP" }, - { "prim": "EXEC" }, - { "prim": "AMOUNT" }, - { "prim": "DIG", - "args": [ { "int": "7" } ] }, - { "prim": "SWAP" }, - { "prim": "EXEC" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "7" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": - [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "CAR" } ], - [ { "prim": "PUSH", - "args": - [ { "prim": - "nat" }, - { "int": "1" } ] }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "ADD" } ] ] } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, - { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "tokens_deposited must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "max_tokens_deposited must be greater than or equal to tokens_deposited." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "6" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "lqt_minted must be greater than min_lqt_minted." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, - { "prim": "EXEC" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "ADD" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "6" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "6" } ] }, - { "prim": "SWAP" }, - { "prim": "SOME" }, - { "prim": "SWAP" }, - { "prim": "UPDATE" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "ADD" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "ADD" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "AMOUNT" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "ADD" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "SWAP" }, - { "prim": "NIL", - "args": - [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, - { "prim": "PAIR" } ], - [ { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1000000" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The initial liquidity amount must be greater than or equal to zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "AMOUNT" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "ADD" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "SWAP" }, - { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, - { "prim": "SOME" }, - { "prim": "SWAP" }, - { "prim": "UPDATE" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "AMOUNT" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "ADD" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "SWAP" }, - { "prim": "NIL", - "args": - [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, - { "prim": "PAIR" } ] ] } ], - [ { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "self_is_updating_token_pool must be false" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "amount must be zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "SENDER" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "DUP" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "6" } ] }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] } ], [] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "COMPARE" }, { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "SWAP" }, - { "prim": "SOME" }, - { "prim": "SWAP" }, - { "prim": "UPDATE" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, - { "prim": "SOME" }, - { "prim": "SENDER" }, - { "prim": "UPDATE" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" } ], - [ { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "current_allowance must equal account.allowances[spender]." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "CDR" }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "PAIR" } ] ] } ], - [ { "prim": "DIG", "args": [ { "int": "6" } ] }, - { "prim": "DROP" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DROP" }, { "prim": "SWAP" }, - { "prim": "DROP" }, { "prim": "SWAP" }, - { "prim": "DROP" }, { "prim": "SWAP" }, - { "prim": "DROP" }, { "prim": "SWAP" }, - { "prim": "DROP" }, { "prim": "AMOUNT" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "ADD" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "PAIR" } ], - [ { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "self_is_updating_token_pool must be false" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "SWAP" }, { "prim": "NOW" }, - { "prim": "COMPARE" }, { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The current time must be less than the deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "amount must be zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "min_xtz_withdrawn must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "min_tokens_withdrawn must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "lqt_burned must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "7" } ] }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The owner does not have any liquidity in this contract." } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "7" } ] }, - { "prim": "SENDER" }, - { "prim": "COMPARE" }, - { "prim": "NEQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CAR" }, - { "prim": "SENDER" }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "The sender does not have an allowance from the give owner in this contract." } ] }, - { "prim": - "FAILWITH" } ], - [ { "prim": "DIG", - "args": - [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DUP" }, - { "prim": "DIG", - "args": - [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": - [ { "int": "6" } ] }, - { "prim": "COMPARE" }, - { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": - "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "lqt_burned cannot be greater than the sender's allowance." } ] }, - { "prim": - "FAILWITH" } ], - [] ] } ] ] } ], - [ { "prim": "SWAP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, - { "prim": "PAIR" } ] ] }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "lqt_burned cannot be greater than the owner's balance." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "11" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "6" } ] }, - { "prim": "MUL" }, { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "9" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The amount of xtz withdrawn must be greater than or equal to min_xtz_withdrawn." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "7" } ] }, - { "prim": "MUL" }, { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The amount of tokens withdrawn must be greater than or equal to min_tokens_withdrawn." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "7" } ] }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "8" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "9" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "6" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "SUB" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [ { "prim": "ABS" } ], - [ { "prim": "DROP" }, - { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "account.balance - lqt_burned resulted in a negative number." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "6" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "7" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "8" } ] }, - { "prim": "SWAP" }, { "prim": "SOME" }, - { "prim": "SWAP" }, { "prim": "UPDATE" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CAR" }, { "prim": "SUB" }, - { "prim": "DROP" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "SUB" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [ { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "SWAP" }, - { "prim": "ABS" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" } ], - [ { "prim": "DROP" }, - { "prim": "PUSH", - "args": - [ { "prim": "string" }, + "tokensDeposited is greater than maxTokensDeposited." } ] }, + { "prim": + "FAILWITH" } ] ] } ] ] }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "EMPTY_MAP", + "args": + [ { "prim": + "address" }, + { "prim": "nat" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "PAIR" } ], + [] ] }, + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "SOME" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": + "DIG", + "args": + [ { "int": + "3" } ] }, + { "prim": + "DUP" }, + { "prim": + "CAR" } ] ] } ] ] }, + { "prim": "UPDATE" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "AMOUNT" }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" }, + { "prim": + "CAR" } ] ] } ] ] }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": + "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "PAIR" } ] ] }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIP", + "args": + [ [ { "prim": "NIL", + "args": + [ { "prim": + "operation" } ] } ] ] }, + { "prim": "CONS" }, + { "prim": "PAIR" } ] ] } ] ] } ], + [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "selfIsUpdatingToken must be false." } ] }, + { "prim": "FAILWITH" } ], + [] ] } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "NOW" }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "NOW is greater than deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Amount must be zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "minXtzWithdrawn must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "minTokensWithdrawn must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "lqtBurned must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CAR" } ] ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "owner has no liquidity." } ] }, + { "prim": "FAILWITH" } ], + [] ] }, { "prim": "SWAP" }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "lqtBurned is greater than owner's balance." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "SENDER" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [ { "prim": "SWAP" }, + { "prim": "CAR" } ], + [ { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SENDER" }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "sender has no approval balance." } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "PUSH", + "args": + [ { "prim": + "int" }, + { "int": + "0" } ] } ] ] } ] ] }, + { "prim": "SUB" }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": + "PUSH", + "args": + [ { "prim": + "string" }, { "string": - "storage.s.token_pool - tokens_withdrawn resulted in a negative number." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "SENDER" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "7" } ] }, - { "prim": "COMPARE" }, { "prim": "NEQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "SUB" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, - { "int": "0" } ] }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [ { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": - [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": - [ { "int": "5" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": - [ { "int": "6" } ] }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": - [ { "int": "7" } ] }, - { "prim": "SWAP" }, - { "prim": "EXEC" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": - [ { "int": "2" } ] }, - { "prim": "ABS" }, - { "prim": "SOME" }, - { "prim": "SENDER" }, - { "prim": "UPDATE" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": - [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": - [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": - [ { "int": "2" } ] }, - { "prim": "DIG", - "args": - [ { "int": "5" } ] }, - { "prim": "SWAP" }, - { "prim": "SOME" }, - { "prim": "SWAP" }, - { "prim": "UPDATE" }, - { "prim": "PAIR" } ], - [ { "prim": "DROP" }, - { "prim": "DIG", - "args": - [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", + "sender approval balance is less than LQT burned." } ] }, + { "prim": + "FAILWITH" } ] ] } ] ] }, + { "prim": "ABS" }, + { "prim": "SOME" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "SENDER" }, + { "prim": "UPDATE" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "SOME" }, + { "prim": "DUG", + "args": + [ { "int": "1" } ] }, + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "SWAP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "DIP", + "args": + [ [ { "prim": + "DIP", "args": - [ { "int": "4" } ] }, - { "prim": "DROP" }, - { "prim": "PUSH", + [ [ { "prim": + "DUP" }, + { "prim": + "CAR" } ] ] } ] ] }, + { "prim": + "UPDATE" }, + { "prim": + "DIP", + "args": + [ [ { "prim": + "DUP" }, + { "prim": + "DIP", "args": - [ { "prim": "string" }, - { "string": - "sender_allowance - lqt_burned resulted in a negative number" } ] }, - { "prim": "FAILWITH" } ] ] } ], - [ { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DROP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "SUB" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CONTRACT", - "args": [ { "prim": "unit" } ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_contract" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "UNIT" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "PAIR" }, { "prim": "SELF" }, - { "prim": "ADDRESS" }, { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ], - [ { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", "args": [ { "int": "5" } ] }, - { "prim": "DROP" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "self_is_updating_token_pool must be false" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "NOW" }, { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The current time must be less than the deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "amount must be zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "tokens_sold must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "min_xtz_bought must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "xtz_pool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "token_pool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "999" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "MUL" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "1000" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "MUL" }, - { "prim": "ADD" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "8" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "999" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "MUL" }, { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "6" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "xtz_bought must be greater than or equal to min_xtz_bought." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "ADD" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "SUB" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CONTRACT", - "args": [ { "prim": "unit" } ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_contract" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "UNIT" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", + [ [ { "prim": + "CDR" } ] ] }, + { "prim": + "CAR" } ] ] }, + { "prim": + "SWAP" }, + { "prim": + "DROP" }, + { "prim": + "PAIR" } ] ] } ] ] } ] ] }, + { "prim": "DIP", + "args": [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1" } ] } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "MUL" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CDR" } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "divByZero." } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1" } ] }, + { "prim": "MUL" }, { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "xtzWithdrawn is less than minXtzWithdrawn." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" } ] ] }, + { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "divByZero." } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ { "int": "4" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "tokensWithdrawn is less than minTokensWithdrawn." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SUB" }, { "prim": "DUP" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [ { "prim": "ABS" } ], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ { "int": "5" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "DIP", + "args": [ [ { "prim": "CAR" } ] ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "EMPTY_MAP", + "args": + [ { "prim": "address" }, + { "prim": "nat" } ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "PAIR" } ], [] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CAR" } ] ] }, + { "prim": "SOME" }, + { "prim": "DIP", + "args": + [ { "int": "5" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "UPDATE" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ { "int": "4" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "SUB" }, { "prim": "DUP" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [ { "prim": "ABS" } ], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, + { "prim": "SUB" }, { "prim": "DUP" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [ { "prim": "ABS" } ], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SWAP" }, + { "prim": "SUB" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CONTRACT", + "args": [ { "prim": "unit" } ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "UNIT" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" }, + { "prim": + "CDR" }, + { "prim": + "CAR" } ] ] } ] ] }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": "pair", "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "SELF" }, { "prim": "ADDRESS" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, { "prim": "PAIR" } ], - [ { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "IMPLICIT_ACCOUNT" }, - { "prim": "ADDRESS" }, - { "prim": "SENDER" }, - { "prim": "COMPARE" }, { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "SELF", - "annots": - [ "%updateTokenPoolInternal" ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "contract", - "args": - [ { "prim": "nat" } ] } ] } ], - "annots": [ "%getBalance" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "bool" }, - { "prim": "True" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "NIL", - "args": - [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, - { "prim": "PAIR" } ], - [ { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "UnsafeUpdateTokenPool" } ] }, - { "prim": "FAILWITH" } ] ] } ] ] } ], - [ { "prim": "DIG", "args": [ { "int": "2" } ] }, + [ { "prim": + "address" }, + { "prim": + "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DIG", + "args": [ { "int": "4" } ] }, + { "prim": "PAIR" }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" } ] ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "SWAP" }, + { "prim": "CONS" }, + { "prim": "SWAP" }, + { "prim": "CONS" }, + { "prim": "PAIR" } ], + [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "selfIsUpdatingToken must be false." } ] }, + { "prim": "FAILWITH" } ], + [] ] } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "NOW" }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "NOW is greater than deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "GT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Amount must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "minTokensBought must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "xtzPool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "tokenPool must be greater than zero" } ] }, + { "prim": "FAILWITH" } ] ] } ] ] }, + { "prim": "DIP", + "args": [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1" } ] } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "1000" } ] }, + { "prim": "MUL" }, + { "prim": "AMOUNT" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1" } ] } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "999" } ] }, + { "prim": "MUL" }, + { "prim": "ADD" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "999" } ] }, + { "prim": "MUL" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "divByZero." } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" } ] ] }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "tokensBought is less than minTokensBought." } ] }, + { "prim": "FAILWITH" } ] ] } ] ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "SUB" }, { "prim": "DUP" }, + { "prim": "PUSH", + "args": + [ { "prim": "int" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LE" }, + { "prim": "IF", + "args": + [ [ { "prim": "ABS" } ], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIG", + "args": [ { "int": "2" } ] } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, { "prim": "DROP" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "SENDER" }, - { "prim": "COMPARE" }, { "prim": "NEQ" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, { "prim": "NOT" }, - { "prim": "OR" }, - { "prim": "IF", - "args": - [ [ { "prim": "DROP" }, - { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "This entrypoint may only be called by dexter itself via getBalance of tokenAddress." } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "bool" }, - { "prim": "False" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "PAIR" } ] ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "PAIR" } ], - [ { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "self_is_updating_token_pool must be false" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "NOW" }, { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The current time must be less than the deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "amount must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "COMPARE" }, { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "min_tokens_bought must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "xtz_pool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "token_pool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "AMOUNT" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "999" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "MUL" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "1000" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "MUL" }, { "prim": "ADD" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "999" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "MUL" }, { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "DIV by 0" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "tokens_bought must be greater than or equal to min_tokens_bought." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "SUB" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, { "int": "0" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GE" }, - { "prim": "IF", - "args": - [ [ { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "SWAP" }, - { "prim": "ABS" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "PAIR" } ], - [ { "prim": "DROP" }, - { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "token_pool - tokens_bought is negative." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "AMOUNT" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "ADD" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CONTRACT", + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "AMOUNT" }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "CAR" }, + { "prim": "SELF" }, + { "prim": "ADDRESS" } ] ] } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "pair", "args": - [ { "prim": "pair", + [ { "prim": "address" }, + { "prim": "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DIP", + "args": [ [ { "prim": "PAIR" } ] ] }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIP", + "args": + [ [ { "prim": "NIL", + "args": + [ { "prim": "operation" } ] } ] ] }, + { "prim": "CONS" }, + { "prim": "PAIR" } ] ] } ] ] } ], + [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "selfIsUpdatingToken must be false." } ] }, + { "prim": "FAILWITH" } ], + [] ] } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "NOW" }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "NOW is greater than deadline." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Amount must be zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "xtzPool must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "tokenPool must be greater than zero" } ] }, + { "prim": "FAILWITH" } ] ] } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "tokensSold is zero" } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "COMPARE" }, + { "prim": "LT" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "minXtzBought must be greater than zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "999" } ] }, + { "prim": "MUL" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "1000" } ] }, + { "prim": "MUL" }, { "prim": "ADD" }, + { "prim": "DIP", + "args": [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "PUSH", + "args": + [ { "prim": "nat" }, + { "int": "999" } ] }, + { "prim": "MUL" }, + { "prim": "DIP", + "args": + [ { "int": "3" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1" } ] } ] ] }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": "" } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "MUL" }, + { "prim": "EDIV" }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "divByZero." } ] }, + { "prim": "FAILWITH" } ], + [ { "prim": "CAR" } ] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "1" } ] }, + { "prim": "MUL" }, { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" } ] ] }, + { "prim": "COMPARE" }, + { "prim": "GE" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "xtzBought is less than minXtzBought." } ] }, + { "prim": "FAILWITH" } ] ] } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" } ] ] }, + { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "SUB" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" } ] ] }, + { "prim": "DIP", + "args": + [ { "int": "2" }, + [ { "prim": "DUP" } ] ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, { "prim": "CDR" }, + { "prim": "CONTRACT", + "args": [ { "prim": "unit" } ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "DIG", + "args": [ { "int": "1" } ] }, + { "prim": "UNIT" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIP", + "args": + [ [ { "prim": + "CAR" }, + { "prim": + "CAR" } ] ] } ] ] }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": + "address" }, + { "prim": "pair", "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "PUSH", + [ { "prim": + "address" }, + { "prim": + "nat" } ] } ] } ], + "annots": [ "%transfer" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": + "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "DIG", + "args": [ { "int": "3" } ] }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "DIG", + "args": [ { "int": "5" } ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "PAIR" } ] ] }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" } ] ] }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "DIG", + "args": [ { "int": "2" } ] }, + { "prim": "CONS" }, + { "prim": "SWAP" }, + { "prim": "CONS" }, + { "prim": "PAIR" } ], + [ { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Amount must be zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "IMPLICIT_ACCOUNT" }, + { "prim": "ADDRESS" }, + { "prim": "SENDER" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "unsafeUpdateTokenPool" } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "selfIsUpdatingToken must be false." } ] }, + { "prim": "FAILWITH" } ], + [] ] }, { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "bool" }, + { "prim": "True" } ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CONTRACT", + "args": + [ { "prim": "pair", + "args": + [ { "prim": "address" }, + { "prim": "contract", "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, { "prim": "SELF" }, - { "prim": "ADDRESS" }, { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "SWAP" }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ] ] } ] ] } ] - + [ { "prim": "nat" } ] } ] } ], + "annots": [ "%getBalance" ] }, + { "prim": "IF_NONE", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "bad address for get_entrypoint" } ] }, + { "prim": "FAILWITH" } ], + [] ] }, + { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "SELF", + "annots": + [ "%updateTokenPoolInternal" ] }, + { "prim": "SELF" }, + { "prim": "ADDRESS" }, + { "prim": "PAIR" }, + { "prim": "TRANSFER_TOKENS" }, + { "prim": "DIP", + "args": + [ [ { "prim": "NIL", + "args": + [ { "prim": "operation" } ] } ] ] }, + { "prim": "CONS" }, + { "prim": "PAIR" } ] ] } ], + [ { "prim": "IF_LEFT", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "mutez" }, + { "int": "0" } ] }, + { "prim": "AMOUNT" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Amount must be zero." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "Dexter did not initiate this operation." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": [ [ { "prim": "DUP" } ] ] }, + { "prim": "SWAP" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "SENDER" }, + { "prim": "COMPARE" }, + { "prim": "EQ" }, + { "prim": "IF", + "args": + [ [], + [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "The sender is not the token contract associated with this contract." } ] }, + { "prim": "FAILWITH" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "PUSH", + "args": + [ { "prim": "bool" }, + { "prim": "False" } ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CDR" } ] ] }, + { "prim": "CAR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } ], + [ { "prim": "DROP" }, + { "prim": "DUP" }, { "prim": "CDR" }, + { "prim": "CAR" }, { "prim": "CAR" }, + { "prim": "IF", + "args": + [ [ { "prim": "PUSH", + "args": + [ { "prim": "string" }, + { "string": + "selfIsUpdatingToken must be false." } ] }, + { "prim": "FAILWITH" } ], + [] ] }, { "prim": "DUP" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "CDR" }, { "prim": "CDR" }, + { "prim": "AMOUNT" }, + { "prim": "ADD" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DIP", + "args": + [ [ { "prim": "DUP" }, + { "prim": "DIP", + "args": + [ [ { "prim": "CAR" } ] ] }, + { "prim": "CDR" } ] ] }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "NIL", + "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } ] ] } ] ] } ] ] } ] ] } ] diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 4103168d22f3..84af0727b64f 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -118,20 +118,22 @@ let bootstrap_accounts = }) bootstrap_accounts_strings +(* For testing liquidity baking. The first is a sample FA1.2 contract and the second the CPMM. The operation hashes are forced so that the CPMM's corresponds to the origination nonce in constants (corresponding to the address KT1BEqzn5Wx8uJrZNvuS9DVHmLvG9td3fDLi) and the FA1.2's address (KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP) is included in the CPMM's initial storage. The file paths are passed by dune to gen.exe or the relative ones here are used if parameters_of_constants is called directly. *) let bootstrap_contracts_strings = [ ( None, 2_000_000_000_000L, - "fa12.json", "Pair {} 2000000000000", Contract_repr.initial_origination_nonce Operation_hash.(of_hex_exn (`Hex (String.make (size * 2) '1'))) ); ( None, 4_000_000_000_000L, - "cpmm.json", - "Pair {} (Pair (Pair 4000000000000 False) (Pair 2000000000000 \ - 2000000000000))", + "Pair {} (Pair (Pair False 4000000000000) (Pair \ + \"KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP\" (Pair 2000000000000 \ + 2000000000000)))", Contract_repr.initial_origination_nonce Operation_hash.zero ) ] +let bootstrap_contracts_filepaths = ["fa12.json"; "cpmm.json"] + let parse_storage source = Michelson_v1_parser.parse_expression ?check:(Some true) source |> Tezos_micheline.Micheline_parser.no_parsing_error @@ -169,23 +171,26 @@ let parse_file file = with Ezjsonm.Parse_error (_, message) -> fail "%s: invalid JSON: %s" file message -let bootstrap_contracts = - List.map - (fun (d, a, sc, st, n) -> - let amount = Tez_repr.of_mutez_exn a in - let code = parse_file sc in - let script = - Script_repr. - { - code = - Script_repr.lazy_expr - (Data_encoding.Json.destruct Script_repr.expr_encoding code); - storage = Script_repr.lazy_expr (parse_storage st); - } - in - Parameters_repr. - {delegate = d; amount; script; origination_nonce = Some n}) - bootstrap_contracts_strings +let build_bootstrap_contracts filepaths = + Result.get_ok + (List.map2 + ~when_different_lengths:"" + (fun (d, a, st, n) sc -> + let amount = Tez_repr.of_mutez_exn a in + let code = parse_file sc in + let script = + Script_repr. + { + code = + Script_repr.lazy_expr + (Data_encoding.Json.destruct Script_repr.expr_encoding code); + storage = Script_repr.lazy_expr (parse_storage st); + } + in + Parameters_repr. + {delegate = d; amount; script; origination_nonce = Some n}) + bootstrap_contracts_strings + filepaths) (* TODO this could be generated from OCaml together with the faucet for now these are hardcoded values in the tests *) @@ -216,8 +221,7 @@ let make_bootstrap_account (pkh, pk, amount) = Parameters.{public_key_hash = pkh; public_key = Some pk; amount} let parameters_of_constants ?(bootstrap_accounts = bootstrap_accounts) - ?(bootstrap_contracts = bootstrap_contracts) ?(with_commitments = false) - constants = + ?(bootstrap_contracts = []) ?(with_commitments = false) constants = let commitments = if with_commitments then commitments else [] in Parameters. { diff --git a/src/proto_alpha/lib_parameters/default_parameters.mli b/src/proto_alpha/lib_parameters/default_parameters.mli index 0a99181fe345..4e5afb1c5162 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.mli +++ b/src/proto_alpha/lib_parameters/default_parameters.mli @@ -35,6 +35,11 @@ val make_bootstrap_account : Signature.public_key_hash * Signature.public_key * Tez.t -> Parameters.bootstrap_account +val build_bootstrap_contracts : + string list -> Parameters_repr.bootstrap_contract list + +val bootstrap_contracts_filepaths : string list + val parameters_of_constants : ?bootstrap_accounts:Parameters.bootstrap_account list -> ?bootstrap_contracts:Parameters.bootstrap_contract list -> diff --git a/src/proto_alpha/lib_parameters/dune b/src/proto_alpha/lib_parameters/dune index a33342f225e8..2a3097764d16 100644 --- a/src/proto_alpha/lib_parameters/dune +++ b/src/proto_alpha/lib_parameters/dune @@ -24,12 +24,20 @@ (rule (targets sandbox-parameters.json) (deps gen.exe) - (action (run %{deps} --sandbox))) + (action (run + %{deps} + --sandbox + %{lib:tezos-protocol-alpha-parameters:fa12.json} + %{lib:tezos-protocol-alpha-parameters:cpmm.json}))) (rule (targets test-parameters.json) (deps gen.exe) - (action (run %{deps} --test))) + (action (run + %{deps} + --test + %{lib:tezos-protocol-alpha-parameters:fa12.json} + %{lib:tezos-protocol-alpha-parameters:cpmm.json}))) (rule (targets mainnet-parameters.json) @@ -38,7 +46,7 @@ (install (section lib) - (files sandbox-parameters.json test-parameters.json mainnet-parameters.json)) + (files sandbox-parameters.json test-parameters.json mainnet-parameters.json fa12.json cpmm.json)) (rule (alias runtest_lint) diff --git a/src/proto_alpha/lib_parameters/gen.ml b/src/proto_alpha/lib_parameters/gen.ml index 93a0a459dd39..3a447725c385 100644 --- a/src/proto_alpha/lib_parameters/gen.ml +++ b/src/proto_alpha/lib_parameters/gen.ml @@ -44,13 +44,25 @@ let () = else match Sys.argv.(1) with | "--sandbox" -> + let bootstrap_contracts = + Default_parameters.build_bootstrap_contracts + (Array.to_list (Array.sub Sys.argv 2 2)) + in dump - Default_parameters.(parameters_of_constants constants_sandbox) + Default_parameters.( + parameters_of_constants constants_sandbox ~bootstrap_contracts) "sandbox-parameters.json" | "--test" -> + let bootstrap_contracts = + Default_parameters.build_bootstrap_contracts + (Array.to_list (Array.sub Sys.argv 2 2)) + in dump Default_parameters.( - parameters_of_constants ~with_commitments:true constants_sandbox) + parameters_of_constants + ~with_commitments:true + constants_test + ~bootstrap_contracts) "test-parameters.json" | "--mainnet" -> dump diff --git a/src/proto_alpha/lib_protocol/test/dune b/src/proto_alpha/lib_protocol/test/dune index d734bbe984f1..4b492e108ac7 100644 --- a/src/proto_alpha/lib_protocol/test/dune +++ b/src/proto_alpha/lib_protocol/test/dune @@ -27,28 +27,26 @@ (action (progn))) (rule - (copy %{lib:tezos-protocol-alpha-parameters:test-parameters.json} - protocol_parameters.json)) + (alias fa12.json) + (action (copy %{lib:tezos-protocol-alpha-parameters:fa12.json} + fa12.json))) (rule - (copy %{lib:tezos-protocol-alpha-parameters:fa12.json} - fa12.json)) - -(rule - (copy %{lib:tezos-protocol-alpha-parameters:cpmm.json} - cpmm.json)) + (alias cpmm.json) + (action (copy %{lib:tezos-protocol-alpha-parameters:cpmm.json} + cpmm.json))) ; runs only the `Quick tests (rule (alias runtest_proto_alpha) - (deps (glob_files contracts/*)) + (deps (glob_files contracts/*) fa12.json cpmm.json) (package tezos-protocol-alpha-tests) (action (run %{exe:main.exe} -v -q))) ; runs both `Quick and `Slow tests (rule (alias runtest_slow) - (deps (glob_files contracts/*)) + (deps (glob_files contracts/*) test-parameters) (package tezos-protocol-alpha-tests) (action (run %{exe:main.exe} -v))) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 9393c362a245..3b4a0009eaf2 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -271,6 +271,9 @@ let initial_context ?(with_commitments = false) constants header let parameters = Default_parameters.parameters_of_constants ~bootstrap_accounts + ~bootstrap_contracts: + Default_parameters.( + build_bootstrap_contracts bootstrap_contracts_filepaths) ~with_commitments constants in diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 5163a71d2cf8..1592cb7756d6 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -192,10 +192,10 @@ let liquidity_baking_storage n () = in let expected_storage = Expr.from_string - (String.concat - "" - [ "Pair 1 (Pair False 4000000000000) (Pair 2000000000000 "; - Printf.sprintf " %d" (2000000000000 + (n * 5000000));]) + (Printf.sprintf + "Pair 1 (Pair False 4000000000000) \ + \"KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP\" 2000000000000 %d" + (2000000000000 + (n * 5000000))) in Block.bake_n n blk >>=? fun blk -> -- GitLab From f51435312fb00dcabe985687e03d247d0923b336 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Wed, 27 Jan 2021 12:19:32 -0500 Subject: [PATCH 21/62] liquidity baking: bump OPAMSOLVERTIMEOUT to 6000 so CI will pass --- scripts/update_opam_repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_opam_repo.sh b/scripts/update_opam_repo.sh index 53b1531af224..2d2c1510670a 100755 --- a/scripts/update_opam_repo.sh +++ b/scripts/update_opam_repo.sh @@ -88,7 +88,7 @@ done ## Filtering unrequired packages cd $tmp_dir git reset --hard "$full_opam_repository_tag" -OPAMSOLVERTIMEOUT=600 opam admin filter --yes --resolve \ +OPAMSOLVERTIMEOUT=6000 opam admin filter --yes --resolve \ $packages,ocaml,ocaml-base-compiler,odoc,opam-depext,js_of_ocaml-ppx,reactiveData,opam-ed ## Adding useful compiler variants -- GitLab From 4a5e2b8711ca4f2ac5d62da16a5b54e439d5d64d Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Wed, 27 Jan 2021 15:17:08 -0500 Subject: [PATCH 22/62] liquidity baking: update bootstrap_contract sig --- .../lib_parameters/default_parameters.ml | 21 +++++++++---------- .../lib_parameters/default_parameters.mli | 2 +- .../lib_protocol/alpha_context.mli | 5 ++++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 84af0727b64f..8df4288aa482 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -58,8 +58,8 @@ let constants_mainnet = delay_per_missing_endorsement = Period.of_seconds_exn 8L; liquidity_baking_cpmm_origination_nonce = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) - Contract_repr.initial_origination_nonce Operation_hash.zero; - liquidity_baking_reward = Tez_repr.of_mutez_exn 5_000_000L; + Contract.initial_origination_nonce Operation_hash.zero; + liquidity_baking_reward = Tez.of_mutez_exn 5_000_000L; (* now + six months *) (* MUST BE ADJUSTED PRIOR TO INJECTION !!! *) liquidity_baking_sunset_level = Int32.add 1292070l 262800l; @@ -123,14 +123,14 @@ let bootstrap_contracts_strings = [ ( None, 2_000_000_000_000L, "Pair {} 2000000000000", - Contract_repr.initial_origination_nonce + Contract.initial_origination_nonce Operation_hash.(of_hex_exn (`Hex (String.make (size * 2) '1'))) ); ( None, 4_000_000_000_000L, "Pair {} (Pair (Pair False 4000000000000) (Pair \ \"KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP\" (Pair 2000000000000 \ 2000000000000)))", - Contract_repr.initial_origination_nonce Operation_hash.zero ) ] + Contract.initial_origination_nonce Operation_hash.zero ) ] let bootstrap_contracts_filepaths = ["fa12.json"; "cpmm.json"] @@ -176,19 +176,18 @@ let build_bootstrap_contracts filepaths = (List.map2 ~when_different_lengths:"" (fun (d, a, st, n) sc -> - let amount = Tez_repr.of_mutez_exn a in + let amount = Tez.of_mutez_exn a in let code = parse_file sc in let script = - Script_repr. + Script. { code = - Script_repr.lazy_expr - (Data_encoding.Json.destruct Script_repr.expr_encoding code); - storage = Script_repr.lazy_expr (parse_storage st); + Script.lazy_expr + (Data_encoding.Json.destruct Script.expr_encoding code); + storage = Script.lazy_expr (parse_storage st); } in - Parameters_repr. - {delegate = d; amount; script; origination_nonce = Some n}) + Parameters.{delegate = d; amount; script; origination_nonce = Some n}) bootstrap_contracts_strings filepaths) diff --git a/src/proto_alpha/lib_parameters/default_parameters.mli b/src/proto_alpha/lib_parameters/default_parameters.mli index 4e5afb1c5162..3700e1350a7d 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.mli +++ b/src/proto_alpha/lib_parameters/default_parameters.mli @@ -36,7 +36,7 @@ val make_bootstrap_account : Parameters.bootstrap_account val build_bootstrap_contracts : - string list -> Parameters_repr.bootstrap_contract list + string list -> Parameters.bootstrap_contract list val bootstrap_contracts_filepaths : string list diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 89d191985d51..4f5929910e74 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -968,6 +968,8 @@ module Contract : sig (* Only for testing *) type origination_nonce + val origination_nonce_encoding : origination_nonce Data_encoding.t + val initial_origination_nonce : Operation_hash.t -> origination_nonce val originated_contract : origination_nonce -> contract @@ -1623,9 +1625,10 @@ module Parameters : sig } type bootstrap_contract = { - delegate : public_key_hash; + delegate : public_key_hash option; amount : Tez.t; script : Script.t; + origination_nonce : Contract.origination_nonce option; } type t = { -- GitLab From 0d66f6e67ee3ffef3ca548cb84173a3a35da11d1 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 28 Jan 2021 15:10:06 -0500 Subject: [PATCH 23/62] liquidity baking: fix rebase errors --- .../lib_client/operation_result.ml | 2 - .../lib_parameters/default_parameters.ml | 38 +++--- .../lib_protocol/alpha_context.mli | 126 ++++++++++++++++++ src/proto_alpha/lib_protocol/apply.ml | 87 ++++++------ src/proto_alpha/lib_protocol/init_storage.ml | 2 +- .../lib_protocol/test/helpers/block.mli | 2 +- .../test/test_liquidity_baking.ml | 98 +++++++------- 7 files changed, 242 insertions(+), 113 deletions(-) diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index b71dd260784c..80370e7c9d6f 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -159,8 +159,6 @@ let pp_balance_updates ppf = function Format.asprintf "fees(%a,%a)" pp_baker pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" pp_baker pkh Cycle.pp l - | Misc c -> - Format.asprintf "miscellaneous(%a)" Contract.pp c in let balance = match origin with diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 8df4288aa482..0b1b7ebe6b1d 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -172,24 +172,26 @@ let parse_file file = fail "%s: invalid JSON: %s" file message let build_bootstrap_contracts filepaths = - Result.get_ok - (List.map2 - ~when_different_lengths:"" - (fun (d, a, st, n) sc -> - let amount = Tez.of_mutez_exn a in - let code = parse_file sc in - let script = - Script. - { - code = - Script.lazy_expr - (Data_encoding.Json.destruct Script.expr_encoding code); - storage = Script.lazy_expr (parse_storage st); - } - in - Parameters.{delegate = d; amount; script; origination_nonce = Some n}) - bootstrap_contracts_strings - filepaths) + let result = + List.map2 + ~when_different_lengths:"" + (fun (d, a, st, n) sc -> + let amount = Tez.of_mutez_exn a in + let code = parse_file sc in + let script = + Script. + { + code = + Script.lazy_expr + (Data_encoding.Json.destruct Script.expr_encoding code); + storage = Script.lazy_expr (parse_storage st); + } + in + Parameters.{delegate = d; amount; script; origination_nonce = Some n}) + bootstrap_contracts_strings + filepaths + in + match result with Ok x -> x | Error _ -> [] (* TODO this could be generated from OCaml together with the faucet for now these are hardcoded values in the tests *) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 4f5929910e74..647eb5f066bb 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -975,6 +975,132 @@ module Contract : sig val originated_contract : origination_nonce -> contract end +module Constants : sig + (** Fixed constants *) + type fixed = { + proof_of_work_nonce_size : int; + nonce_length : int; + max_anon_ops_per_block : int; + max_operation_data_length : int; + max_proposals_per_delegate : int; + } + + val fixed_encoding : fixed Data_encoding.t + + val fixed : fixed + + val proof_of_work_nonce_size : int + + val nonce_length : int + + val max_anon_ops_per_block : int + + val max_operation_data_length : int + + val max_proposals_per_delegate : int + + (** Constants parameterized by context *) + type parametric = { + preserved_cycles : int; + blocks_per_cycle : int32; + blocks_per_commitment : int32; + blocks_per_roll_snapshot : int32; + blocks_per_voting_period : int32; + time_between_blocks : Period.t list; + endorsers_per_block : int; + hard_gas_limit_per_operation : Gas.Arith.integral; + hard_gas_limit_per_block : Gas.Arith.integral; + proof_of_work_threshold : int64; + tokens_per_roll : Tez.t; + michelson_maximum_type_size : int; + seed_nonce_revelation_tip : Tez.t; + origination_size : int; + block_security_deposit : Tez.t; + endorsement_security_deposit : Tez.t; + baking_reward_per_endorsement : Tez.t list; + endorsement_reward : Tez.t list; + cost_per_byte : Tez.t; + hard_storage_limit_per_operation : Z.t; + test_chain_duration : int64; + quorum_min : int32; + quorum_max : int32; + min_proposal_quorum : int32; + initial_endorsers : int; + delay_per_missing_endorsement : Period.t; + liquidity_baking_cpmm_origination_nonce : Contract.origination_nonce; + liquidity_baking_reward : Tez.t; + liquidity_baking_sunset_level : int32; + } + + val parametric_encoding : parametric Data_encoding.t + + val parametric : context -> parametric + + val preserved_cycles : context -> int + + val blocks_per_cycle : context -> int32 + + val blocks_per_commitment : context -> int32 + + val blocks_per_roll_snapshot : context -> int32 + + val blocks_per_voting_period : context -> int32 + + val time_between_blocks : context -> Period.t list + + val endorsers_per_block : context -> int + + val initial_endorsers : context -> int + + val delay_per_missing_endorsement : context -> Period.t + + val hard_gas_limit_per_operation : context -> Gas.Arith.integral + + val hard_gas_limit_per_block : context -> Gas.Arith.integral + + val cost_per_byte : context -> Tez.t + + val hard_storage_limit_per_operation : context -> Z.t + + val proof_of_work_threshold : context -> int64 + + val tokens_per_roll : context -> Tez.t + + val michelson_maximum_type_size : context -> int + + val baking_reward_per_endorsement : context -> Tez.t list + + val endorsement_reward : context -> Tez.t list + + val seed_nonce_revelation_tip : context -> Tez.t + + val origination_size : context -> int + + val block_security_deposit : context -> Tez.t + + val endorsement_security_deposit : context -> Tez.t + + val test_chain_duration : context -> int64 + + val quorum_min : context -> int32 + + val quorum_max : context -> int32 + + val min_proposal_quorum : context -> int32 + + val liquidity_baking_cpmm_origination_nonce : + context -> Contract.origination_nonce + + val liquidity_baking_reward : context -> Tez.t + + val liquidity_baking_sunset_level : context -> int32 + + (** All constants: fixed and parametric *) + type t = {fixed : fixed; parametric : parametric} + + val encoding : t Data_encoding.t +end + module Receipt : sig type balance = | Contract of Contract.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index befd787c684f..1ca209a37b14 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1642,48 +1642,51 @@ let finalize_application ctxt protocol_data delegate ~block_delay (* call CPPM default entrypoint with parameter Unit *) (* this is necessary for the CPMM's xtz_pool in storage to increase since it cannot use BALANCE due to a transfer attack *) - Script_interpreter.execute - ctxt - Optimized - step_constants - ~script - ~parameter - ~entrypoint:"default" - ~internal:true - >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> - let _operations = operations in - (* update CPMM storage *) - Contract.update_script_storage - ctxt - liquidity_baking_cpmm_contract - storage - lazy_storage_diff - >>=? fun ctxt -> - (* end of cycle *) - may_snapshot_roll ctxt - >>=? fun ctxt -> - may_start_new_cycle ctxt - >>=? fun (ctxt, balance_updates, deactivated) -> - Amendment.may_start_new_voting_period ctxt - >>=? fun ctxt -> - let cycle = (Level.current ctxt).cycle in - let balance_updates = - Receipt.( - cleanup_balance_updates - ( migration_balance_updates - @ [ ( Contract (Contract.implicit_contract delegate), - Debited deposit, - Block_application ); - (Deposits (delegate, cycle), Credited deposit, Block_application); - (Rewards (delegate, cycle), Credited reward, Block_application) ] - @ balance_updates )) - in - let consumed_gas = - Gas.Arith.sub - (Gas.Arith.fp @@ Constants.hard_gas_limit_per_block ctxt) - (Alpha_context.Gas.block_level ctxt) - in - (* This value is different than the new [voting_period_info] below for + Script_interpreter.execute + ctxt + Optimized + step_constants + ~script + ~parameter + ~entrypoint:"default" + ~internal:true + >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> + let _operations = operations in + (* update CPMM storage *) + Contract.update_script_storage + ctxt + liquidity_baking_cpmm_contract + storage + lazy_storage_diff + >>=? fun ctxt -> + (* end of cycle *) + may_snapshot_roll ctxt + >>=? fun ctxt -> + may_start_new_cycle ctxt + >>=? fun (ctxt, balance_updates, deactivated) -> + Amendment.may_start_new_voting_period ctxt + >>=? fun ctxt -> + let cycle = (Level.current ctxt).cycle in + let balance_updates = + Receipt.( + cleanup_balance_updates + ( migration_balance_updates + @ [ ( Contract (Contract.implicit_contract delegate), + Debited deposit, + Block_application ); + ( Deposits (delegate, cycle), + Credited deposit, + Block_application ); + (Rewards (delegate, cycle), Credited reward, Block_application) + ] + @ balance_updates )) + in + let consumed_gas = + Gas.Arith.sub + (Gas.Arith.fp @@ Constants.hard_gas_limit_per_block ctxt) + (Alpha_context.Gas.block_level ctxt) + in + (* This value is different than the new [voting_period_info] below for compatibility reasons, the field [voting_period_kind] is deprecated and will be removed in a future version. *) Alpha_context.Voting_period.get_current_info ctxt diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 64ba1caa005a..68bb2a2eaf8d 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -88,7 +88,7 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = ~amount_mutez:100_000_000L >>= fun (ctxt, balance_updates) -> Storage.Pending_migration_balance_updates.init ctxt balance_updates - >>=? fun ctxt -> Storage.Liquidity_baker_escape_ema.init ctxt 0l + >>=? fun ctxt -> Storage.Liquidity_baking_escape_ema.init ctxt 0l let prepare ctxt ~level ~predecessor_timestamp ~timestamp ~fitness = Raw_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index acb68720b40d..0de1fd906150 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -143,7 +143,7 @@ val bake_n_with_balance_updates : ?liquidity_baking_escape_flag:bool -> int -> t -> - (block * Alpha_context.Delegate.balance_updates) tzresult Lwt.t + (block * Alpha_context.Receipt.balance_updates) tzresult Lwt.t val current_cycle : t -> Cycle.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 1592cb7756d6..54d77aea88f4 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -215,50 +215,50 @@ let liquidity_baking_storage n () = (to_string expected_storage) >>=? fun () -> return_unit -let liquidity_baking_balance_update () = - Context.init 1 - >>=? fun (blk, _contracts) -> - Context.get_constants (B blk) - >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in - let sunset = csts.parametric.liquidity_baking_sunset_level in - Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk - >>=? fun (_blk, balance_updates) -> - let liquidity_baking_updates = - List.filter - (fun el -> - match el with - | ( Alpha_context.Delegate.Misc contract, - Alpha_context.Delegate.Credited _ ) -> - if Alpha_context.Contract.(contract = liquidity_baking) then true - else false - | _ -> - false) - balance_updates - in - let rewards = - List.fold_left - (fun accum (_, update) -> - match update with - | Alpha_context.Delegate.Credited x -> - Tez.(accum + x) - | Alpha_context.Delegate.Debited x -> ( - match Tez.(accum -? x) with - | Ok r -> - r - | Error _ -> - Stdlib.failwith "subtracting tez" )) - Tez.(of_int 0) - liquidity_baking_updates - in - Assert.equal_tez - ~loc:__LOC__ - rewards - (Tez.of_int ((Int32.to_int sunset - 1) * 5)) - >>=? fun () -> return_unit +(* let liquidity_baking_balance_update () = + * Context.init 1 + * >>=? fun (blk, _contracts) -> + * Context.get_constants (B blk) + * >>=? fun csts -> + * let liquidity_baking = + * Alpha_context.Contract.originated_contract + * csts.parametric.liquidity_baking_cpmm_origination_nonce + * in + * let sunset = csts.parametric.liquidity_baking_sunset_level in + * Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk + * >>=? fun (_blk, balance_updates) -> + * let liquidity_baking_updates = + * List.filter + * (fun el -> + * match el with + * | ( Alpha_context.Delegate.Misc contract, + * Alpha_context.Delegate.Credited _ ) -> + * if Alpha_context.Contract.(contract = liquidity_baking) then true + * else false + * | _ -> + * false) + * balance_updates + * in + * let rewards = + * List.fold_left + * (fun accum (_, update) -> + * match update with + * | Alpha_context.Delegate.Credited x -> + * Tez.(accum + x) + * | Alpha_context.Delegate.Debited x -> ( + * match Tez.(accum -? x) with + * | Ok r -> + * r + * | Error _ -> + * Stdlib.failwith "subtracting tez" )) + * Tez.(of_int 0) + * liquidity_baking_updates + * in + * Assert.equal_tez + * ~loc:__LOC__ + * rewards + * (Tez.of_int ((Int32.to_int sunset - 1) * 5)) + * >>=? fun () -> return_unit *) let tests = [ Test.tztest @@ -284,8 +284,8 @@ let tests = Test.tztest "test liquidity baking storage is updated" `Quick - (liquidity_baking_storage 64); - Test.tztest - "test liquidity baking balance updates" - `Quick - liquidity_baking_balance_update ] + (liquidity_baking_storage 64) + (* Test.tztest + * "test liquidity baking balance updates" + * `Quick + * liquidity_baking_balance_update *) ] -- GitLab From eb4fc582b84bd19e047c84937fa8c60e5c26d7e6 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 28 Jan 2021 15:20:44 -0500 Subject: [PATCH 24/62] liquidity_baking: add Subsidy contructor for update_origin --- .../lib_client/operation_result.ml | 2 + .../lib_protocol/alpha_context.mli | 2 +- src/proto_alpha/lib_protocol/apply.ml | 6 +- src/proto_alpha/lib_protocol/receipt_repr.ml | 10 +- src/proto_alpha/lib_protocol/receipt_repr.mli | 1 + .../test/test_liquidity_baking.ml | 99 ++++++++++--------- 6 files changed, 66 insertions(+), 54 deletions(-) diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 80370e7c9d6f..39cde840a0ff 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -166,6 +166,8 @@ let pp_balance_updates ppf = function balance | Protocol_migration -> Format.asprintf "migration %s" balance + | Subsidy -> + Format.asprintf "subsidy %s" balance in (balance, update)) balance_updates diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 647eb5f066bb..3f34c8e3f4cb 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1110,7 +1110,7 @@ module Receipt : sig type balance_update = Debited of Tez.t | Credited of Tez.t - type update_origin = Block_application | Protocol_migration + type update_origin = Block_application | Protocol_migration | Subsidy type balance_updates = (balance * balance_update * update_origin) list diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 1ca209a37b14..1788e5494e4a 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1677,8 +1677,10 @@ let finalize_application ctxt protocol_data delegate ~block_delay ( Deposits (delegate, cycle), Credited deposit, Block_application ); - (Rewards (delegate, cycle), Credited reward, Block_application) - ] + (Rewards (delegate, cycle), Credited reward, Block_application); + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_reward, + Subsidy ) ] @ balance_updates )) in let consumed_gas = diff --git a/src/proto_alpha/lib_protocol/receipt_repr.ml b/src/proto_alpha/lib_protocol/receipt_repr.ml index 13a7fd507291..3a9a4f6ab1b6 100644 --- a/src/proto_alpha/lib_protocol/receipt_repr.ml +++ b/src/proto_alpha/lib_protocol/receipt_repr.ml @@ -103,7 +103,7 @@ let balance_update_encoding = failwith "Qty.of_mutez" ) int64)) -type update_origin = Block_application | Protocol_migration +type update_origin = Block_application | Protocol_migration | Subsidy let update_origin_encoding = let open Data_encoding in @@ -121,7 +121,13 @@ let update_origin_encoding = ~title:"Protocol_migration" (constant "migration") (function Protocol_migration -> Some () | _ -> None) - (fun () -> Protocol_migration) ] + (fun () -> Protocol_migration); + case + (Tag 2) + ~title:"Subsidy" + (constant "subsidy") + (function Subsidy -> Some () | _ -> None) + (fun () -> Subsidy) ] type balance_updates = (balance * balance_update * update_origin) list diff --git a/src/proto_alpha/lib_protocol/receipt_repr.mli b/src/proto_alpha/lib_protocol/receipt_repr.mli index 616e82225d2d..89930f84addb 100644 --- a/src/proto_alpha/lib_protocol/receipt_repr.mli +++ b/src/proto_alpha/lib_protocol/receipt_repr.mli @@ -38,6 +38,7 @@ type balance_update = Debited of Tez_repr.t | Credited of Tez_repr.t type update_origin = | Block_application (** Update from a block application *) | Protocol_migration (** Update from a protocol migration *) + | Subsidy (** Update from an inflationary subsidy *) (** A list of balance updates. Duplicates may happen. *) type balance_updates = (balance * balance_update * update_origin) list diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 54d77aea88f4..0fa220402098 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -215,50 +215,51 @@ let liquidity_baking_storage n () = (to_string expected_storage) >>=? fun () -> return_unit -(* let liquidity_baking_balance_update () = - * Context.init 1 - * >>=? fun (blk, _contracts) -> - * Context.get_constants (B blk) - * >>=? fun csts -> - * let liquidity_baking = - * Alpha_context.Contract.originated_contract - * csts.parametric.liquidity_baking_cpmm_origination_nonce - * in - * let sunset = csts.parametric.liquidity_baking_sunset_level in - * Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk - * >>=? fun (_blk, balance_updates) -> - * let liquidity_baking_updates = - * List.filter - * (fun el -> - * match el with - * | ( Alpha_context.Delegate.Misc contract, - * Alpha_context.Delegate.Credited _ ) -> - * if Alpha_context.Contract.(contract = liquidity_baking) then true - * else false - * | _ -> - * false) - * balance_updates - * in - * let rewards = - * List.fold_left - * (fun accum (_, update) -> - * match update with - * | Alpha_context.Delegate.Credited x -> - * Tez.(accum + x) - * | Alpha_context.Delegate.Debited x -> ( - * match Tez.(accum -? x) with - * | Ok r -> - * r - * | Error _ -> - * Stdlib.failwith "subtracting tez" )) - * Tez.(of_int 0) - * liquidity_baking_updates - * in - * Assert.equal_tez - * ~loc:__LOC__ - * rewards - * (Tez.of_int ((Int32.to_int sunset - 1) * 5)) - * >>=? fun () -> return_unit *) +let liquidity_baking_balance_update () = + Context.init 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baking = + Alpha_context.Contract.originated_contract + csts.parametric.liquidity_baking_cpmm_origination_nonce + in + let sunset = csts.parametric.liquidity_baking_sunset_level in + Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk + >>=? fun (_blk, balance_updates) -> + let liquidity_baking_updates = + List.filter + (fun el -> + match el with + | ( Alpha_context.Receipt.Contract contract, + Alpha_context.Receipt.Credited _, + Alpha_context.Receipt.Subsidy ) -> + if Alpha_context.Contract.(contract = liquidity_baking) then true + else false + | _ -> + false) + balance_updates + in + let rewards = + List.fold_left + (fun accum (_, update, _) -> + match update with + | Alpha_context.Receipt.Credited x -> + Tez.(accum + x) + | Alpha_context.Receipt.Debited x -> ( + match Tez.(accum -? x) with + | Ok r -> + r + | Error _ -> + Stdlib.failwith "subtracting tez" )) + Tez.(of_int 0) + liquidity_baking_updates + in + Assert.equal_tez + ~loc:__LOC__ + rewards + (Tez.of_int ((Int32.to_int sunset - 1) * 5)) + >>=? fun () -> return_unit let tests = [ Test.tztest @@ -284,8 +285,8 @@ let tests = Test.tztest "test liquidity baking storage is updated" `Quick - (liquidity_baking_storage 64) - (* Test.tztest - * "test liquidity baking balance updates" - * `Quick - * liquidity_baking_balance_update *) ] + (liquidity_baking_storage 64); + Test.tztest + "test liquidity baking balance updates" + `Quick + liquidity_baking_balance_update ] -- GitLab From 8e543fe3b1e062c6112fe51d1037c61b9d5e100c Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 28 Jan 2021 16:46:48 -0500 Subject: [PATCH 25/62] liquidity baking: factor out application of subsidy --- src/proto_alpha/lib_protocol/apply.ml | 200 +++++++++++++------------- 1 file changed, 104 insertions(+), 96 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 1788e5494e4a..a7729a72bcb6 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1557,44 +1557,8 @@ let check_minimum_endorsements ctxt protocol_data block_delay timestamp; }) -let finalize_application ctxt protocol_data delegate ~block_delay - migration_balance_updates = - let included_endorsements = included_endorsements ctxt in - check_minimum_endorsements - ctxt - protocol_data - block_delay - included_endorsements - >>?= fun () -> - let deposit = Constants.block_security_deposit ctxt in - add_deposit ctxt delegate deposit - >>?= fun ctxt -> - Baking.baking_reward - ctxt - ~block_priority:protocol_data.priority - ~included_endorsements - >>?= fun reward -> - add_rewards ctxt reward - >>?= fun ctxt -> - Signature.Public_key_hash.Map.fold - (fun delegate deposit ctxt -> - ctxt >>=? fun ctxt -> Delegate.freeze_deposit ctxt delegate deposit) - (get_deposits ctxt) - (return ctxt) - >>=? fun ctxt -> - (* end of level (from this point nothing should fail) *) - let fees = Alpha_context.get_fees ctxt in - Delegate.freeze_fees ctxt delegate fees - >>=? fun ctxt -> - let rewards = Alpha_context.get_rewards ctxt in - Delegate.freeze_rewards ctxt delegate rewards - >>=? fun ctxt -> - ( match protocol_data.Block_header.seed_nonce_hash with - | None -> - return ctxt - | Some nonce_hash -> - Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) - >>=? fun ctxt -> +let apply_liquidity_baking_subsidy ctxt + (protocol_data : Alpha_context.Block_header.contents) = (* if ema is above 500_000 threshold this will be a no-op *) (* liquidity baking permanently shuts off if threshold is reached once *) set_liquidity_baking_escape_ema @@ -1607,8 +1571,8 @@ let finalize_application ctxt protocol_data delegate ~block_delay in (* check that level is below sunset *) (* we check that ema is below threshold again in case it just increased *) - (* if either condition is not met, liquidity baking reward is set to zero*) - let liquidity_baking_reward = + (* if either condition is not met, liquidity baking subsidy is set to zero*) + let liquidity_baking_subsidy = let level = Raw_level.to_int32 (Level.current ctxt).level in if Compare.Int32.(level < Constants.liquidity_baking_sunset_level ctxt) @@ -1616,8 +1580,8 @@ let finalize_application ctxt protocol_data delegate ~block_delay then Constants.liquidity_baking_reward ctxt else Tez.zero in - (* credit liquidity baking reward to CPMM contract *) - Contract.credit ctxt liquidity_baking_cpmm_contract liquidity_baking_reward + (* credit liquidity baking subsidy to CPMM contract *) + Contract.credit ctxt liquidity_baking_cpmm_contract liquidity_baking_subsidy >>=? fun ctxt -> Contract.get_script ctxt liquidity_baking_cpmm_contract >>=? fun (ctxt, script) -> @@ -1631,7 +1595,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay source = liquidity_baking_cpmm_contract; payer = liquidity_baking_cpmm_contract; self = liquidity_baking_cpmm_contract; - amount = liquidity_baking_reward; + amount = liquidity_baking_subsidy; chain_id = Chain_id.zero; } in @@ -1659,59 +1623,103 @@ let finalize_application ctxt protocol_data delegate ~block_delay storage lazy_storage_diff >>=? fun ctxt -> - (* end of cycle *) - may_snapshot_roll ctxt - >>=? fun ctxt -> - may_start_new_cycle ctxt - >>=? fun (ctxt, balance_updates, deactivated) -> - Amendment.may_start_new_voting_period ctxt - >>=? fun ctxt -> - let cycle = (Level.current ctxt).cycle in - let balance_updates = - Receipt.( - cleanup_balance_updates - ( migration_balance_updates - @ [ ( Contract (Contract.implicit_contract delegate), - Debited deposit, - Block_application ); - ( Deposits (delegate, cycle), - Credited deposit, - Block_application ); - (Rewards (delegate, cycle), Credited reward, Block_application); - ( Contract liquidity_baking_cpmm_contract, - Credited liquidity_baking_reward, - Subsidy ) ] - @ balance_updates )) - in - let consumed_gas = - Gas.Arith.sub - (Gas.Arith.fp @@ Constants.hard_gas_limit_per_block ctxt) - (Alpha_context.Gas.block_level ctxt) + let balance_update = + Receipt. + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_subsidy, + Subsidy ) in - (* This value is different than the new [voting_period_info] below for + return (ctxt, balance_update) + +let finalize_application ctxt protocol_data delegate ~block_delay + migration_balance_updates = + let included_endorsements = included_endorsements ctxt in + check_minimum_endorsements + ctxt + protocol_data + block_delay + included_endorsements + >>?= fun () -> + let deposit = Constants.block_security_deposit ctxt in + add_deposit ctxt delegate deposit + >>?= fun ctxt -> + Baking.baking_reward + ctxt + ~block_priority:protocol_data.priority + ~included_endorsements + >>?= fun reward -> + add_rewards ctxt reward + >>?= fun ctxt -> + Signature.Public_key_hash.Map.fold + (fun delegate deposit ctxt -> + ctxt >>=? fun ctxt -> Delegate.freeze_deposit ctxt delegate deposit) + (get_deposits ctxt) + (return ctxt) + >>=? fun ctxt -> + (* end of level (from this point nothing should fail) *) + let fees = Alpha_context.get_fees ctxt in + Delegate.freeze_fees ctxt delegate fees + >>=? fun ctxt -> + let rewards = Alpha_context.get_rewards ctxt in + Delegate.freeze_rewards ctxt delegate rewards + >>=? fun ctxt -> + ( match protocol_data.Block_header.seed_nonce_hash with + | None -> + return ctxt + | Some nonce_hash -> + Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) + >>=? fun ctxt -> + apply_liquidity_baking_subsidy ctxt protocol_data + >>=? fun (ctxt, liquidity_baking_balance_update) -> + (* end of cycle *) + may_snapshot_roll ctxt + >>=? fun ctxt -> + may_start_new_cycle ctxt + >>=? fun (ctxt, balance_updates, deactivated) -> + Amendment.may_start_new_voting_period ctxt + >>=? fun ctxt -> + let cycle = (Level.current ctxt).cycle in + let balance_updates = + Receipt.( + cleanup_balance_updates + ( migration_balance_updates + @ [ ( Contract (Contract.implicit_contract delegate), + Debited deposit, + Block_application ); + (Deposits (delegate, cycle), Credited deposit, Block_application); + (Rewards (delegate, cycle), Credited reward, Block_application); + liquidity_baking_balance_update ] + @ balance_updates )) + in + let consumed_gas = + Gas.Arith.sub + (Gas.Arith.fp @@ Constants.hard_gas_limit_per_block ctxt) + (Alpha_context.Gas.block_level ctxt) + in + (* This value is different than the new [voting_period_info] below for compatibility reasons, the field [voting_period_kind] is deprecated and will be removed in a future version. *) - Alpha_context.Voting_period.get_current_info ctxt - >>=? fun {voting_period = {kind; _}; _} -> - Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt - >|=? fun ({voting_period; position; _} as voting_period_info) -> - let level_info = Alpha_context.Level.current ctxt in - let receipt = - Apply_results. - { - baker = delegate; - level = - Level.to_deprecated_type - level_info - ~voting_period_index:voting_period.index - ~voting_period_position:position; - level_info; - voting_period_info; - voting_period_kind = kind; - nonce_hash = protocol_data.seed_nonce_hash; - consumed_gas; - deactivated; - balance_updates; - } - in - (ctxt, receipt) + Alpha_context.Voting_period.get_current_info ctxt + >>=? fun {voting_period = {kind; _}; _} -> + Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt + >|=? fun ({voting_period; position; _} as voting_period_info) -> + let level_info = Alpha_context.Level.current ctxt in + let receipt = + Apply_results. + { + baker = delegate; + level = + Level.to_deprecated_type + level_info + ~voting_period_index:voting_period.index + ~voting_period_position:position; + level_info; + voting_period_info; + voting_period_kind = kind; + nonce_hash = protocol_data.seed_nonce_hash; + consumed_gas; + deactivated; + balance_updates; + } + in + (ctxt, receipt) -- GitLab From f727e4e05788e7309651ae4657a5ad99fb324b17 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 28 Jan 2021 17:40:06 -0500 Subject: [PATCH 26/62] liquidity baking: add ema window size to constants --- .../lib_parameters/default_parameters.ml | 2 + src/proto_alpha/lib_protocol/alpha_context.ml | 7 ++- .../lib_protocol/alpha_context.mli | 3 ++ src/proto_alpha/lib_protocol/apply.ml | 9 +++- .../lib_protocol/constants_repr.ml | 45 ++++++++++--------- .../lib_protocol/constants_storage.ml | 4 ++ src/proto_alpha/lib_protocol/storage.mli | 5 ++- 7 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 0b1b7ebe6b1d..3fdd0598933d 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -63,6 +63,8 @@ let constants_mainnet = (* now + six months *) (* MUST BE ADJUSTED PRIOR TO INJECTION !!! *) liquidity_baking_sunset_level = Int32.add 1292070l 262800l; + (* Window in blocks over which the ema is calculated *) + liquidity_baking_escape_ema_window = 1000l; } let constants_sandbox = diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 7da752e2ad8f..cc50d22fc287 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -303,9 +303,14 @@ let get_liquidity_baking_escape_ema = Storage.Liquidity_baking_escape_ema.get let set_liquidity_baking_escape_ema ctxt flag = Storage.Liquidity_baking_escape_ema.get ctxt >>=? fun old_ema -> + (* 1/2 window size with precision of 1000 for integer computation *) + let threshold = + Int32.( + mul (div (Constants.liquidity_baking_escape_ema_window ctxt) 2l) 1000l) + in let new_ema = (* if ema ever reaches threshold, liquidity baking is permanently off *) - if Compare.Int32.(old_ema <= 500_000l) then + if Compare.Int32.(old_ema <= threshold) then Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) else old_ema in diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 3f34c8e3f4cb..010e7922e731 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1030,6 +1030,7 @@ module Constants : sig liquidity_baking_cpmm_origination_nonce : Contract.origination_nonce; liquidity_baking_reward : Tez.t; liquidity_baking_sunset_level : int32; + liquidity_baking_escape_ema_window : int32; } val parametric_encoding : parametric Data_encoding.t @@ -1095,6 +1096,8 @@ module Constants : sig val liquidity_baking_sunset_level : context -> int32 + val liquidity_baking_escape_ema_window : context -> int32 + (** All constants: fixed and parametric *) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index a7729a72bcb6..874b5c7af585 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1559,7 +1559,12 @@ let check_minimum_endorsements ctxt protocol_data block_delay let apply_liquidity_baking_subsidy ctxt (protocol_data : Alpha_context.Block_header.contents) = - (* if ema is above 500_000 threshold this will be a no-op *) + (* if ema is above threshold this will be a no-op *) + (* threshold is 1/2 window size with precision of 1000 for integer computation *) + let ema_threshold = + Int32.( + mul (div (Constants.liquidity_baking_escape_ema_window ctxt) 2l) 1000l) + in (* liquidity baking permanently shuts off if threshold is reached once *) set_liquidity_baking_escape_ema ctxt @@ -1576,7 +1581,7 @@ let apply_liquidity_baking_subsidy ctxt let level = Raw_level.to_int32 (Level.current ctxt).level in if Compare.Int32.(level < Constants.liquidity_baking_sunset_level ctxt) - && Compare.Int32.(liquidity_baking_escape_ema < 500_000l) + && Compare.Int32.(liquidity_baking_escape_ema < ema_threshold) then Constants.liquidity_baking_reward ctxt else Tez.zero in diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index bf61cc2166cb..36835fc20b55 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -118,6 +118,7 @@ type parametric = { liquidity_baking_cpmm_origination_nonce : Contract_repr.origination_nonce; liquidity_baking_reward : Tez_repr.t; liquidity_baking_sunset_level : int32; + liquidity_baking_escape_ema_window : int32; } let parametric_encoding = @@ -132,9 +133,9 @@ let parametric_encoding = c.time_between_blocks, c.endorsers_per_block, c.hard_gas_limit_per_operation, - c.hard_gas_limit_per_block ), - ( ( c.proof_of_work_threshold, - c.tokens_per_roll, + c.hard_gas_limit_per_block, + c.proof_of_work_threshold ), + ( ( c.tokens_per_roll, c.michelson_maximum_type_size, c.seed_nonce_revelation_tip, c.origination_size, @@ -142,9 +143,9 @@ let parametric_encoding = c.endorsement_security_deposit, c.baking_reward_per_endorsement, c.endorsement_reward, - c.cost_per_byte ), - ( c.hard_storage_limit_per_operation, - 0L, + c.cost_per_byte, + c.hard_storage_limit_per_operation ), + ( 0L, (* At this position in the encoding we used to have a test chain duration but it is not used anymore and should be removed when this encoding is updated. When the test @@ -157,7 +158,8 @@ let parametric_encoding = c.delay_per_missing_endorsement, c.liquidity_baking_cpmm_origination_nonce, c.liquidity_baking_reward, - c.liquidity_baking_sunset_level ) ) )) + c.liquidity_baking_sunset_level, + c.liquidity_baking_escape_ema_window ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -166,9 +168,9 @@ let parametric_encoding = time_between_blocks, endorsers_per_block, hard_gas_limit_per_operation, - hard_gas_limit_per_block ), - ( ( proof_of_work_threshold, - tokens_per_roll, + hard_gas_limit_per_block, + proof_of_work_threshold ), + ( ( tokens_per_roll, michelson_maximum_type_size, seed_nonce_revelation_tip, origination_size, @@ -176,9 +178,9 @@ let parametric_encoding = endorsement_security_deposit, baking_reward_per_endorsement, endorsement_reward, - cost_per_byte ), - ( hard_storage_limit_per_operation, - _test_chain_duration, + cost_per_byte, + hard_storage_limit_per_operation ), + ( _test_chain_duration, quorum_min, quorum_max, min_proposal_quorum, @@ -186,7 +188,8 @@ let parametric_encoding = delay_per_missing_endorsement, liquidity_baking_cpmm_origination_nonce, liquidity_baking_reward, - liquidity_baking_sunset_level ) ) ) -> + liquidity_baking_sunset_level, + liquidity_baking_escape_ema_window ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -216,9 +219,10 @@ let parametric_encoding = liquidity_baking_cpmm_origination_nonce; liquidity_baking_reward; liquidity_baking_sunset_level; + liquidity_baking_escape_ema_window; }) (merge_objs - (obj9 + (obj10 (req "preserved_cycles" uint8) (req "blocks_per_cycle" int32) (req "blocks_per_commitment" int32) @@ -231,10 +235,10 @@ let parametric_encoding = Gas_limit_repr.Arith.z_integral_encoding) (req "hard_gas_limit_per_block" - Gas_limit_repr.Arith.z_integral_encoding)) + Gas_limit_repr.Arith.z_integral_encoding) + (req "proof_of_work_threshold" int64)) (merge_objs (obj10 - (req "proof_of_work_threshold" int64) (req "tokens_per_roll" Tez_repr.encoding) (req "michelson_maximum_type_size" uint16) (req "seed_nonce_revelation_tip" Tez_repr.encoding) @@ -243,9 +247,9 @@ let parametric_encoding = (req "endorsement_security_deposit" Tez_repr.encoding) (req "baking_reward_per_endorsement" (list Tez_repr.encoding)) (req "endorsement_reward" (list Tez_repr.encoding)) - (req "cost_per_byte" Tez_repr.encoding)) + (req "cost_per_byte" Tez_repr.encoding) + (req "hard_storage_limit_per_operation" z)) (obj10 - (req "hard_storage_limit_per_operation" z) (req "test_chain_duration" int64) (req "quorum_min" int32) (req "quorum_max" int32) @@ -256,7 +260,8 @@ let parametric_encoding = "liquidity_baking_cpmm_origination_nonce" Contract_repr.origination_nonce_encoding) (req "liquidity_baking_reward" Tez_repr.encoding) - (req "liquidity_baking_sunset_level" int32)))) + (req "liquidity_baking_sunset_level" int32) + (req "liquidity_baking_escape_ema_window" int32)))) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index dfb60928444c..bdb7a697b446 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -135,4 +135,8 @@ let liquidity_baking_sunset_level c = let constants = Raw_context.constants c in constants.liquidity_baking_sunset_level +let liquidity_baking_escape_ema_window c = + let constants = Raw_context.constants c in + constants.liquidity_baking_escape_ema_window + let parametric c = Raw_context.constants c diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index f59c617d0e7b..6eac8c361cfe 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -488,7 +488,8 @@ module Pending_migration_balance_updates : with type value = Receipt_repr.balance_updates and type t := Raw_context.t -(** Exponential moving average of flags set in protocol_data.contents. - If at any block it's >= 500_000, liquidity baking permanently shuts off. **) +(** Exponential moving average (ema) of flags set in protocol_data.contents. + If at any block it's above half the window size set in constants, + liquidity baking permanently shuts off. **) module Liquidity_baking_escape_ema : Single_data_storage with type t := Raw_context.t and type value = Int32.t -- GitLab From b6d86ad0f05ad2d204e509cc76f99fae1c8bff20 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 28 Jan 2021 17:45:46 -0500 Subject: [PATCH 27/62] liquidity baking: add label and comment for escape flag --- src/proto_alpha/lib_delegate/client_baking_forge.ml | 6 +++--- src/proto_alpha/lib_delegate/client_baking_forge.mli | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index ab82040218d9..327665858ea6 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -186,7 +186,7 @@ let compute_endorsing_power cctxt ~chain ~block operations = let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header ~priority ~delegate_pkh ~delegate_sk ~level operations - liquidity_baking_escape_flag = + ~liquidity_baking_escape_flag = assert_valid_operations_hash shell_header operations >>=? fun () -> let block = `Hash (shell_header.Tezos_base.Block_header.predecessor, 0) in @@ -1031,7 +1031,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ~delegate_sk ~level operations - liquidity_baking_escape_flag + ~liquidity_baking_escape_flag >>= function | Ok hash -> return hash @@ -1427,7 +1427,7 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ~delegate_sk ~level operations - liquidity_baking_escape_flag + ~liquidity_baking_escape_flag >>= function | Error errs -> lwt_log_error diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.mli b/src/proto_alpha/lib_delegate/client_baking_forge.mli index 509935aea1c4..eda8a9e93a76 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.mli +++ b/src/proto_alpha/lib_delegate/client_baking_forge.mli @@ -33,7 +33,8 @@ open Alpha_context val generate_seed_nonce : unit -> Nonce.t (** [inject_block cctxt blk ?force ~priority ~timestamp ~fitness - ~seed_nonce ~src_sk ops] tries to inject a block in the node. If + ~seed_nonce ~src_sk ops liquidity_baking_escape_flag] + tries to inject a block in the node. If [?force] is set, the fitness check will be bypassed. [priority] will be used to compute the baking slot (level is precomputed). [src_sk] is used to sign the block header. *) @@ -48,7 +49,7 @@ val inject_block : delegate_sk:Client_keys.sk_uri -> level:Raw_level.t -> Operation.raw list list -> - bool -> + liquidity_baking_escape_flag:bool -> Block_hash.t tzresult Lwt.t type error += Failed_to_preapply of Tezos_base.Operation.t * error list -- GitLab From 11f5f8c09bc2f53a6f8d92dee2e4aeceecc3d8db Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 28 Jan 2021 18:01:38 -0500 Subject: [PATCH 28/62] liquidity baking: add escape_hatch_ema to block_metadata --- src/proto_alpha/lib_protocol/apply.ml | 5 +++-- src/proto_alpha/lib_protocol/apply_results.ml | 16 +++++++++++----- src/proto_alpha/lib_protocol/apply_results.mli | 1 + src/proto_alpha/lib_protocol/main.ml | 6 ++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 874b5c7af585..c9aa9aa48093 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1634,7 +1634,7 @@ let apply_liquidity_baking_subsidy ctxt Credited liquidity_baking_subsidy, Subsidy ) in - return (ctxt, balance_update) + return (ctxt, balance_update, liquidity_baking_escape_ema) let finalize_application ctxt protocol_data delegate ~block_delay migration_balance_updates = @@ -1675,7 +1675,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> apply_liquidity_baking_subsidy ctxt protocol_data - >>=? fun (ctxt, liquidity_baking_balance_update) -> + >>=? fun (ctxt, liquidity_baking_balance_update, liquidity_baking_escape_ema) -> (* end of cycle *) may_snapshot_roll ctxt >>=? fun ctxt -> @@ -1725,6 +1725,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay consumed_gas; deactivated; balance_updates; + liquidity_baking_escape_ema; } in (ctxt, receipt) diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index 7bfaf2943301..fc517858aeab 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -1237,6 +1237,7 @@ type block_metadata = { consumed_gas : Gas.Arith.fp; deactivated : Signature.Public_key_hash.t list; balance_updates : Receipt.balance_updates; + liquidity_baking_escape_ema : int32; } let block_metadata_encoding = @@ -1251,7 +1252,8 @@ let block_metadata_encoding = nonce_hash; consumed_gas; deactivated; - balance_updates } -> + balance_updates; + liquidity_baking_escape_ema } -> ( baker, level, level_info, @@ -1260,7 +1262,8 @@ let block_metadata_encoding = nonce_hash, consumed_gas, deactivated, - balance_updates )) + balance_updates, + liquidity_baking_escape_ema )) (fun ( baker, level, level_info, @@ -1269,7 +1272,8 @@ let block_metadata_encoding = nonce_hash, consumed_gas, deactivated, - balance_updates ) -> + balance_updates, + liquidity_baking_escape_ema ) -> { baker; level; @@ -1280,8 +1284,9 @@ let block_metadata_encoding = consumed_gas; deactivated; balance_updates; + liquidity_baking_escape_ema; }) - (obj9 + (obj10 (req "baker" Signature.Public_key_hash.encoding) (req ~description:"This field is DEPRECATED: use level_info instead" @@ -1297,4 +1302,5 @@ let block_metadata_encoding = (req "nonce_hash" (option Nonce_hash.encoding)) (req "consumed_gas" Gas.Arith.n_fp_encoding) (req "deactivated" (list Signature.Public_key_hash.encoding)) - (req "balance_updates" Receipt.balance_updates_encoding)) + (req "balance_updates" Receipt.balance_updates_encoding) + (req "liquidity_baking_escape_ema" int32)) diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index ac2877daa1c6..94590f527cbf 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -191,6 +191,7 @@ type block_metadata = { consumed_gas : Gas.Arith.fp; deactivated : Signature.Public_key_hash.t list; balance_updates : Receipt.balance_updates; + liquidity_baking_escape_ema : int32; } val block_metadata_encoding : block_metadata Data_encoding.encoding diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index 1439a430f337..08a4adff37ba 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -220,6 +220,8 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = >>=? fun {voting_period = {kind; _}; _} -> Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt >>=? fun ({voting_period; position; _} as voting_period_info) -> + Alpha_context.get_liquidity_baking_escape_ema ctxt + >>=? fun liquidity_baking_escape_ema -> let level_info = Alpha_context.Level.current ctxt in let baker = Signature.Public_key_hash.zero in Signature.Public_key_hash.Map.fold @@ -247,6 +249,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = consumed_gas = Alpha_context.Gas.Arith.zero; deactivated = []; balance_updates = migration_balance_updates; + liquidity_baking_escape_ema; } ) | Partial_application {block_header; baker; block_delay} -> let included_endorsements = Alpha_context.included_endorsements ctxt in @@ -258,6 +261,8 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = >>?= fun () -> Alpha_context.Voting_period.get_current_info ctxt >>=? fun {voting_period = {kind; _}; _} -> + Alpha_context.get_liquidity_baking_escape_ema ctxt + >>=? fun liquidity_baking_escape_ema -> Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt >|=? fun ({voting_period; position; _} as voting_period_info) -> let level_info = Alpha_context.Level.current ctxt in @@ -278,6 +283,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = consumed_gas = Alpha_context.Gas.Arith.zero; deactivated = []; balance_updates = migration_balance_updates; + liquidity_baking_escape_ema; } ) | Application { baker; -- GitLab From 077df859e886695566bd103a03c906a320d7aed6 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 28 Jan 2021 19:14:35 -0500 Subject: [PATCH 29/62] liquidity baking: set sunset level in stitching --- .../lib_parameters/default_parameters.ml | 10 ++--- src/proto_alpha/lib_protocol/alpha_context.ml | 42 +++++++++++-------- .../lib_protocol/alpha_context.mli | 21 ++++++---- src/proto_alpha/lib_protocol/apply.ml | 6 ++- .../lib_protocol/constants_repr.ml | 10 ++--- .../lib_protocol/constants_storage.ml | 4 +- src/proto_alpha/lib_protocol/init_storage.ml | 11 ++++- src/proto_alpha/lib_protocol/main.ml | 4 +- src/proto_alpha/lib_protocol/storage.ml | 21 +++++++--- src/proto_alpha/lib_protocol/storage.mli | 13 ++++-- .../test/test_liquidity_baking.ml | 4 +- 11 files changed, 91 insertions(+), 55 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 3fdd0598933d..e11c2d390eb2 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -60,9 +60,9 @@ let constants_mainnet = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) Contract.initial_origination_nonce Operation_hash.zero; liquidity_baking_reward = Tez.of_mutez_exn 5_000_000L; - (* now + six months *) - (* MUST BE ADJUSTED PRIOR TO INJECTION !!! *) - liquidity_baking_sunset_level = Int32.add 1292070l 262800l; + (* level after protocol activation when liquidity baking shuts off *) + (* set to six months *) + liquidity_baking_sunset_duration = 262800l; (* Window in blocks over which the ema is calculated *) liquidity_baking_escape_ema_window = 1000l; } @@ -80,7 +80,7 @@ let constants_sandbox = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baking_sunset_level = 1024l; + liquidity_baking_sunset_duration = 1024l; } let constants_test = @@ -95,7 +95,7 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baking_sunset_level = 2048l; + liquidity_baking_sunset_duration = 2048l; } let bootstrap_accounts_strings = diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index cc50d22fc287..a235d769efc3 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -298,21 +298,27 @@ let description = Raw_context.description module Parameters = Parameters_repr -let get_liquidity_baking_escape_ema = Storage.Liquidity_baking_escape_ema.get - -let set_liquidity_baking_escape_ema ctxt flag = - Storage.Liquidity_baking_escape_ema.get ctxt - >>=? fun old_ema -> - (* 1/2 window size with precision of 1000 for integer computation *) - let threshold = - Int32.( - mul (div (Constants.liquidity_baking_escape_ema_window ctxt) 2l) 1000l) - in - let new_ema = - (* if ema ever reaches threshold, liquidity baking is permanently off *) - if Compare.Int32.(old_ema <= threshold) then - Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) - else old_ema - in - Storage.Liquidity_baking_escape_ema.set ctxt new_ema - >|=? fun ctxt -> (ctxt, new_ema) +module Liquidity_baking = struct + let get_escape_ema = Storage.Liquidity_baking.Escape_ema.get + + let set_escape_ema ctxt flag = + Storage.Liquidity_baking.Escape_ema.get ctxt + >>=? fun old_ema -> + (* 1/2 window size with precision of 1000 for integer computation *) + let threshold = + Int32.( + mul (div (Constants.liquidity_baking_escape_ema_window ctxt) 2l) 1000l) + in + let new_ema = + (* if ema ever reaches threshold, liquidity baking is permanently off *) + if Compare.Int32.(old_ema <= threshold) then + Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) + else old_ema + in + Storage.Liquidity_baking.Escape_ema.set ctxt new_ema + >|=? fun ctxt -> (ctxt, new_ema) + + let get_sunset_level = Storage.Liquidity_baking.Sunset_level.get + + let set_sunset_level = Storage.Liquidity_baking.Sunset_level.set +end diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 010e7922e731..5ab9821a1ef5 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1029,7 +1029,7 @@ module Constants : sig delay_per_missing_endorsement : Period.t; liquidity_baking_cpmm_origination_nonce : Contract.origination_nonce; liquidity_baking_reward : Tez.t; - liquidity_baking_sunset_level : int32; + liquidity_baking_sunset_duration : int32; liquidity_baking_escape_ema_window : int32; } @@ -1094,7 +1094,7 @@ module Constants : sig val liquidity_baking_reward : context -> Tez.t - val liquidity_baking_sunset_level : context -> int32 + val liquidity_baking_sunset_duration : context -> int32 val liquidity_baking_escape_ema_window : context -> int32 @@ -1772,10 +1772,15 @@ module Parameters : sig val encoding : t Data_encoding.t end -val get_liquidity_baking_escape_ema : context -> Int32.t tzresult Lwt.t +module Liquidity_baking : sig + val get_escape_ema : context -> Int32.t tzresult Lwt.t -(** ema starts at zero - ema[n+1] = (999 * ema[n] // 1000) + (1000 if flag[n] else 0) - where flag is protocol_data.contents.liquidity_baking_escape_flag **) -val set_liquidity_baking_escape_ema : - context -> bool -> (context * Int32.t) tzresult Lwt.t + (** ema starts at zero + ema[n+1] = (999 * ema[n] // 1000) + (1000 if flag[n] else 0) + where flag is protocol_data.contents.liquidity_baking_escape_flag **) + val set_escape_ema : context -> bool -> (context * Int32.t) tzresult Lwt.t + + val get_sunset_level : context -> Int32.t tzresult Lwt.t + + val set_sunset_level : context -> Int32.t -> context tzresult Lwt.t +end diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index c9aa9aa48093..b1ed0d3c5421 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1566,7 +1566,7 @@ let apply_liquidity_baking_subsidy ctxt mul (div (Constants.liquidity_baking_escape_ema_window ctxt) 2l) 1000l) in (* liquidity baking permanently shuts off if threshold is reached once *) - set_liquidity_baking_escape_ema + Liquidity_baking.set_escape_ema ctxt protocol_data.liquidity_baking_escape_flag >>=? fun (ctxt, liquidity_baking_escape_ema) -> @@ -1574,13 +1574,15 @@ let apply_liquidity_baking_subsidy ctxt Contract.originated_contract (Constants.liquidity_baking_cpmm_origination_nonce ctxt) in + Liquidity_baking.get_sunset_level ctxt + >>=? fun sunset_level -> (* check that level is below sunset *) (* we check that ema is below threshold again in case it just increased *) (* if either condition is not met, liquidity baking subsidy is set to zero*) let liquidity_baking_subsidy = let level = Raw_level.to_int32 (Level.current ctxt).level in if - Compare.Int32.(level < Constants.liquidity_baking_sunset_level ctxt) + Compare.Int32.(level < sunset_level) && Compare.Int32.(liquidity_baking_escape_ema < ema_threshold) then Constants.liquidity_baking_reward ctxt else Tez.zero diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index 36835fc20b55..d266d658b1d1 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -117,7 +117,7 @@ type parametric = { delay_per_missing_endorsement : Period_repr.t; liquidity_baking_cpmm_origination_nonce : Contract_repr.origination_nonce; liquidity_baking_reward : Tez_repr.t; - liquidity_baking_sunset_level : int32; + liquidity_baking_sunset_duration : int32; liquidity_baking_escape_ema_window : int32; } @@ -158,7 +158,7 @@ let parametric_encoding = c.delay_per_missing_endorsement, c.liquidity_baking_cpmm_origination_nonce, c.liquidity_baking_reward, - c.liquidity_baking_sunset_level, + c.liquidity_baking_sunset_duration, c.liquidity_baking_escape_ema_window ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, @@ -188,7 +188,7 @@ let parametric_encoding = delay_per_missing_endorsement, liquidity_baking_cpmm_origination_nonce, liquidity_baking_reward, - liquidity_baking_sunset_level, + liquidity_baking_sunset_duration, liquidity_baking_escape_ema_window ) ) ) -> { preserved_cycles; @@ -218,7 +218,7 @@ let parametric_encoding = delay_per_missing_endorsement; liquidity_baking_cpmm_origination_nonce; liquidity_baking_reward; - liquidity_baking_sunset_level; + liquidity_baking_sunset_duration; liquidity_baking_escape_ema_window; }) (merge_objs @@ -260,7 +260,7 @@ let parametric_encoding = "liquidity_baking_cpmm_origination_nonce" Contract_repr.origination_nonce_encoding) (req "liquidity_baking_reward" Tez_repr.encoding) - (req "liquidity_baking_sunset_level" int32) + (req "liquidity_baking_sunset_duration" int32) (req "liquidity_baking_escape_ema_window" int32)))) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index bdb7a697b446..b2c6744f29da 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -131,9 +131,9 @@ let liquidity_baking_reward c = let constants = Raw_context.constants c in constants.liquidity_baking_reward -let liquidity_baking_sunset_level c = +let liquidity_baking_sunset_duration c = let constants = Raw_context.constants c in - constants.liquidity_baking_sunset_level + constants.liquidity_baking_sunset_duration let liquidity_baking_escape_ema_window c = let constants = Raw_context.constants c in diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 68bb2a2eaf8d..d916ba5f5d31 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -76,7 +76,15 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = Storage.Block_priority.init ctxt 0 >>=? fun ctxt -> Vote_storage.update_listings ctxt - >>=? fun ctxt -> Storage.Liquidity_baking_escape_ema.init ctxt 0l + >>=? fun ctxt -> + Storage.Liquidity_baking.Escape_ema.init ctxt 0l + >>=? fun ctxt -> + Storage.Liquidity_baking.Sunset_level.init + ctxt + Int32.( + add + (Raw_level_repr.to_int32 (Level_storage.current ctxt).level) + (Constants_storage.liquidity_baking_sunset_duration ctxt)) | Edo_008 -> (* Add balance updates receipts to be attached on the first block of this protocol - see [[prepare]] function below. Any balance updates attached @@ -88,7 +96,6 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = ~amount_mutez:100_000_000L >>= fun (ctxt, balance_updates) -> Storage.Pending_migration_balance_updates.init ctxt balance_updates - >>=? fun ctxt -> Storage.Liquidity_baking_escape_ema.init ctxt 0l let prepare ctxt ~level ~predecessor_timestamp ~timestamp ~fitness = Raw_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index 08a4adff37ba..cee86d00880e 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -220,7 +220,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = >>=? fun {voting_period = {kind; _}; _} -> Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt >>=? fun ({voting_period; position; _} as voting_period_info) -> - Alpha_context.get_liquidity_baking_escape_ema ctxt + Alpha_context.Liquidity_baking.get_escape_ema ctxt >>=? fun liquidity_baking_escape_ema -> let level_info = Alpha_context.Level.current ctxt in let baker = Signature.Public_key_hash.zero in @@ -261,7 +261,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = >>?= fun () -> Alpha_context.Voting_period.get_current_info ctxt >>=? fun {voting_period = {kind; _}; _} -> - Alpha_context.get_liquidity_baking_escape_ema ctxt + Alpha_context.Liquidity_baking.get_escape_ema ctxt >>=? fun liquidity_baking_escape_ema -> Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt >|=? fun ({voting_period; position; _} as voting_period_info) -> diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 12915f69e0ab..acc5136609d8 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1228,9 +1228,18 @@ module Pending_migration_balance_updates = let encoding = Receipt_repr.balance_updates_encoding end) -module Liquidity_baking_escape_ema = - Make_single_data_storage (Registered) (Raw_context) - (struct - let name = ["liquidity_baking_escape_ema"] - end) - (Int32) +module Liquidity_baking = struct + module Escape_ema = + Make_single_data_storage (Registered) (Raw_context) + (struct + let name = ["liquidity_baking_escape_ema"] + end) + (Int32) + + module Sunset_level = + Make_single_data_storage (Registered) (Raw_context) + (struct + let name = ["liquidity_baking_sunset_level"] + end) + (Int32) +end diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 6eac8c361cfe..6af73b50e6ca 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -488,8 +488,15 @@ module Pending_migration_balance_updates : with type value = Receipt_repr.balance_updates and type t := Raw_context.t -(** Exponential moving average (ema) of flags set in protocol_data.contents. +module Liquidity_baking : sig + (** Exponential moving average (ema) of flags set in protocol_data.contents. If at any block it's above half the window size set in constants, liquidity baking permanently shuts off. **) -module Liquidity_baking_escape_ema : - Single_data_storage with type t := Raw_context.t and type value = Int32.t + module Escape_ema : + Single_data_storage with type t := Raw_context.t and type value = Int32.t + + (** Level at which liquidity baking automatically shuts off. + Set in stitching to six months from activation of Florence. **) + module Sunset_level : + Single_data_storage with type t := Raw_context.t and type value = Int32.t +end diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 0fa220402098..cb2bb5f09a12 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -61,7 +61,7 @@ let liquidity_baking_sunset_level () = Alpha_context.Contract.originated_contract csts.parametric.liquidity_baking_cpmm_origination_nonce in - let sunset = csts.parametric.liquidity_baking_sunset_level in + let sunset = csts.parametric.liquidity_baking_sunset_duration in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n Int32.(to_int (add sunset 100l)) blk @@ -224,7 +224,7 @@ let liquidity_baking_balance_update () = Alpha_context.Contract.originated_contract csts.parametric.liquidity_baking_cpmm_origination_nonce in - let sunset = csts.parametric.liquidity_baking_sunset_level in + let sunset = csts.parametric.liquidity_baking_sunset_duration in Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk >>=? fun (_blk, balance_updates) -> let liquidity_baking_updates = -- GitLab From b4ff34bc0e9b3a3437b631adb6d1df50b5c44bd1 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 29 Jan 2021 17:07:52 -0500 Subject: [PATCH 30/62] liquidity baking: use ema threshold instead of window in constants --- src/proto_alpha/lib_parameters/default_parameters.ml | 4 ++-- src/proto_alpha/lib_protocol/alpha_context.ml | 10 ++++------ src/proto_alpha/lib_protocol/alpha_context.mli | 4 ++-- src/proto_alpha/lib_protocol/apply.ml | 9 +++------ src/proto_alpha/lib_protocol/constants_repr.ml | 10 +++++----- src/proto_alpha/lib_protocol/constants_storage.ml | 4 ++-- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index e11c2d390eb2..ebdec246c414 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -63,8 +63,8 @@ let constants_mainnet = (* level after protocol activation when liquidity baking shuts off *) (* set to six months *) liquidity_baking_sunset_duration = 262800l; - (* Window in blocks over which the ema is calculated *) - liquidity_baking_escape_ema_window = 1000l; + (* 1/2 window size of 1000 blocks with precision of 1000 for integer computation *) + liquidity_baking_escape_ema_threshold = 500_000l; } let constants_sandbox = diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index a235d769efc3..afc6e19903a4 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -304,14 +304,12 @@ module Liquidity_baking = struct let set_escape_ema ctxt flag = Storage.Liquidity_baking.Escape_ema.get ctxt >>=? fun old_ema -> - (* 1/2 window size with precision of 1000 for integer computation *) - let threshold = - Int32.( - mul (div (Constants.liquidity_baking_escape_ema_window ctxt) 2l) 1000l) - in let new_ema = (* if ema ever reaches threshold, liquidity baking is permanently off *) - if Compare.Int32.(old_ema <= threshold) then + if + Compare.Int32.( + old_ema <= Constants.liquidity_baking_escape_ema_threshold ctxt) + then Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) else old_ema in diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 5ab9821a1ef5..13506588cb19 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1030,7 +1030,7 @@ module Constants : sig liquidity_baking_cpmm_origination_nonce : Contract.origination_nonce; liquidity_baking_reward : Tez.t; liquidity_baking_sunset_duration : int32; - liquidity_baking_escape_ema_window : int32; + liquidity_baking_escape_ema_threshold : int32; } val parametric_encoding : parametric Data_encoding.t @@ -1096,7 +1096,7 @@ module Constants : sig val liquidity_baking_sunset_duration : context -> int32 - val liquidity_baking_escape_ema_window : context -> int32 + val liquidity_baking_escape_ema_threshold : context -> int32 (** All constants: fixed and parametric *) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index b1ed0d3c5421..a3f1847e27cb 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1560,11 +1560,6 @@ let check_minimum_endorsements ctxt protocol_data block_delay let apply_liquidity_baking_subsidy ctxt (protocol_data : Alpha_context.Block_header.contents) = (* if ema is above threshold this will be a no-op *) - (* threshold is 1/2 window size with precision of 1000 for integer computation *) - let ema_threshold = - Int32.( - mul (div (Constants.liquidity_baking_escape_ema_window ctxt) 2l) 1000l) - in (* liquidity baking permanently shuts off if threshold is reached once *) Liquidity_baking.set_escape_ema ctxt @@ -1583,7 +1578,9 @@ let apply_liquidity_baking_subsidy ctxt let level = Raw_level.to_int32 (Level.current ctxt).level in if Compare.Int32.(level < sunset_level) - && Compare.Int32.(liquidity_baking_escape_ema < ema_threshold) + && Compare.Int32.( + liquidity_baking_escape_ema + < Constants.liquidity_baking_escape_ema_threshold ctxt) then Constants.liquidity_baking_reward ctxt else Tez.zero in diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index d266d658b1d1..aea318d57f8e 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -118,7 +118,7 @@ type parametric = { liquidity_baking_cpmm_origination_nonce : Contract_repr.origination_nonce; liquidity_baking_reward : Tez_repr.t; liquidity_baking_sunset_duration : int32; - liquidity_baking_escape_ema_window : int32; + liquidity_baking_escape_ema_threshold : int32; } let parametric_encoding = @@ -159,7 +159,7 @@ let parametric_encoding = c.liquidity_baking_cpmm_origination_nonce, c.liquidity_baking_reward, c.liquidity_baking_sunset_duration, - c.liquidity_baking_escape_ema_window ) ) )) + c.liquidity_baking_escape_ema_threshold ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -189,7 +189,7 @@ let parametric_encoding = liquidity_baking_cpmm_origination_nonce, liquidity_baking_reward, liquidity_baking_sunset_duration, - liquidity_baking_escape_ema_window ) ) ) -> + liquidity_baking_escape_ema_threshold ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -219,7 +219,7 @@ let parametric_encoding = liquidity_baking_cpmm_origination_nonce; liquidity_baking_reward; liquidity_baking_sunset_duration; - liquidity_baking_escape_ema_window; + liquidity_baking_escape_ema_threshold; }) (merge_objs (obj10 @@ -261,7 +261,7 @@ let parametric_encoding = Contract_repr.origination_nonce_encoding) (req "liquidity_baking_reward" Tez_repr.encoding) (req "liquidity_baking_sunset_duration" int32) - (req "liquidity_baking_escape_ema_window" int32)))) + (req "liquidity_baking_escape_ema_threshold" int32)))) type t = {fixed : fixed; parametric : parametric} diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index b2c6744f29da..b6f9b13a79fd 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -135,8 +135,8 @@ let liquidity_baking_sunset_duration c = let constants = Raw_context.constants c in constants.liquidity_baking_sunset_duration -let liquidity_baking_escape_ema_window c = +let liquidity_baking_escape_ema_threshold c = let constants = Raw_context.constants c in - constants.liquidity_baking_escape_ema_window + constants.liquidity_baking_escape_ema_threshold let parametric c = Raw_context.constants c -- GitLab From 3a417486fa7ac0d5b996d353304928fd5f8cb89a Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 29 Jan 2021 18:27:30 -0500 Subject: [PATCH 31/62] liquidity baking: minimize touching storage when applying subsidy --- src/proto_alpha/lib_protocol/apply.ml | 145 ++++++++++++++------------ 1 file changed, 77 insertions(+), 68 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index a3f1847e27cb..8e29bdbf6261 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1559,81 +1559,90 @@ let check_minimum_endorsements ctxt protocol_data block_delay let apply_liquidity_baking_subsidy ctxt (protocol_data : Alpha_context.Block_header.contents) = - (* if ema is above threshold this will be a no-op *) - (* liquidity baking permanently shuts off if threshold is reached once *) - Liquidity_baking.set_escape_ema - ctxt - protocol_data.liquidity_baking_escape_flag - >>=? fun (ctxt, liquidity_baking_escape_ema) -> - let liquidity_baking_cpmm_contract = - Contract.originated_contract - (Constants.liquidity_baking_cpmm_origination_nonce ctxt) - in + (* check level is below sunset *) Liquidity_baking.get_sunset_level ctxt >>=? fun sunset_level -> - (* check that level is below sunset *) - (* we check that ema is below threshold again in case it just increased *) - (* if either condition is not met, liquidity baking subsidy is set to zero*) - let liquidity_baking_subsidy = - let level = Raw_level.to_int32 (Level.current ctxt).level in - if - Compare.Int32.(level < sunset_level) - && Compare.Int32.( - liquidity_baking_escape_ema - < Constants.liquidity_baking_escape_ema_threshold ctxt) - then Constants.liquidity_baking_reward ctxt - else Tez.zero + let level = Raw_level.to_int32 (Level.current ctxt).level in + (* zero credit will be filtered out by cleanup_balance_updates *) + let noop_balance_update = + Receipt. + ( Rewards (Ed25519 Ed25519.Public_key_hash.zero, Cycle.root), + Credited Tez.zero, + Subsidy ) in - (* credit liquidity baking subsidy to CPMM contract *) - Contract.credit ctxt liquidity_baking_cpmm_contract liquidity_baking_subsidy - >>=? fun ctxt -> - Contract.get_script ctxt liquidity_baking_cpmm_contract - >>=? fun (ctxt, script) -> - match script with - | None -> - Lwt.return (error (Script_tc_errors.No_such_entrypoint "default")) - | Some script -> - let step_constants = - let open Script_interpreter in - { - source = liquidity_baking_cpmm_contract; - payer = liquidity_baking_cpmm_contract; - self = liquidity_baking_cpmm_contract; - amount = liquidity_baking_subsidy; - chain_id = Chain_id.zero; - } - in - let parameter = - Micheline.strip_locations - Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) + if Compare.Int32.(level >= sunset_level) then + (* don't set or get ema if past sunset *) + return (ctxt, noop_balance_update, 0l) + else + Liquidity_baking.set_escape_ema + ctxt + protocol_data.liquidity_baking_escape_flag + >>=? fun (ctxt, liquidity_baking_escape_ema) -> + (* liquidity baking permanently shuts off if threshold is reached once *) + if + Compare.Int32.( + liquidity_baking_escape_ema + >= Constants.liquidity_baking_escape_ema_threshold ctxt) + then return (ctxt, noop_balance_update, liquidity_baking_escape_ema) + else + let liquidity_baking_cpmm_contract = + Contract.originated_contract + (Constants.liquidity_baking_cpmm_origination_nonce ctxt) in - (* call CPPM default entrypoint with parameter Unit *) - (* this is necessary for the CPMM's xtz_pool in storage to - increase since it cannot use BALANCE due to a transfer attack *) - Script_interpreter.execute - ctxt - Optimized - step_constants - ~script - ~parameter - ~entrypoint:"default" - ~internal:true - >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> - let _operations = operations in - (* update CPMM storage *) - Contract.update_script_storage + let liquidity_baking_subsidy = Constants.liquidity_baking_reward ctxt in + (* credit liquidity baking subsidy to CPMM contract *) + Contract.credit ctxt liquidity_baking_cpmm_contract - storage - lazy_storage_diff + liquidity_baking_subsidy >>=? fun ctxt -> - let balance_update = - Receipt. - ( Contract liquidity_baking_cpmm_contract, - Credited liquidity_baking_subsidy, - Subsidy ) - in - return (ctxt, balance_update, liquidity_baking_escape_ema) + Contract.get_script ctxt liquidity_baking_cpmm_contract + >>=? fun (ctxt, script) -> + match script with + | None -> + Lwt.return (error (Script_tc_errors.No_such_entrypoint "default")) + | Some script -> + let step_constants = + let open Script_interpreter in + { + source = liquidity_baking_cpmm_contract; + payer = liquidity_baking_cpmm_contract; + self = liquidity_baking_cpmm_contract; + amount = liquidity_baking_subsidy; + chain_id = Chain_id.zero; + } + in + let parameter = + Micheline.strip_locations + Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) + in + (* call CPPM default entrypoint with parameter Unit *) + (* this is necessary for the CPMM's xtz_pool in storage to + increase since it cannot use BALANCE due to a transfer attack *) + Script_interpreter.execute + ctxt + Optimized + step_constants + ~script + ~parameter + ~entrypoint:"default" + ~internal:true + >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> + let _operations = operations in + (* update CPMM storage *) + Contract.update_script_storage + ctxt + liquidity_baking_cpmm_contract + storage + lazy_storage_diff + >>=? fun ctxt -> + let balance_update = + Receipt. + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_subsidy, + Subsidy ) + in + return (ctxt, balance_update, liquidity_baking_escape_ema) let finalize_application ctxt protocol_data delegate ~block_delay migration_balance_updates = -- GitLab From b8bac7659ac113ac92bbf678472c455c194d307a Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 29 Jan 2021 18:44:32 -0500 Subject: [PATCH 32/62] liquidity baking: don't update ema if already above threshold --- src/proto_alpha/lib_protocol/alpha_context.ml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index afc6e19903a4..1e4272bd0e0d 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -304,17 +304,17 @@ module Liquidity_baking = struct let set_escape_ema ctxt flag = Storage.Liquidity_baking.Escape_ema.get ctxt >>=? fun old_ema -> - let new_ema = - (* if ema ever reaches threshold, liquidity baking is permanently off *) - if - Compare.Int32.( - old_ema <= Constants.liquidity_baking_escape_ema_threshold ctxt) - then + (* if ema is over threshold, we don't update it because liquidity baking is permanently off *) + if + Compare.Int32.( + old_ema < Constants.liquidity_baking_escape_ema_threshold ctxt) + then + let new_ema = Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) - else old_ema - in - Storage.Liquidity_baking.Escape_ema.set ctxt new_ema - >|=? fun ctxt -> (ctxt, new_ema) + in + Storage.Liquidity_baking.Escape_ema.set ctxt new_ema + >|=? fun ctxt -> (ctxt, new_ema) + else return (ctxt, old_ema) let get_sunset_level = Storage.Liquidity_baking.Sunset_level.get -- GitLab From 64460ad11ada37bed7b23a0f0b53b7d445660bd0 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 1 Feb 2021 00:47:46 -0500 Subject: [PATCH 33/62] liquidity baking: migrate constants --- .../lib_protocol/constants_repr.ml | 152 ++++++++++++++++++ src/proto_alpha/lib_protocol/raw_context.ml | 65 +++++++- 2 files changed, 216 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index aea318d57f8e..d411c93f3a1e 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -271,3 +271,155 @@ let encoding = (fun {fixed; parametric} -> (fixed, parametric)) (fun (fixed, parametric) -> {fixed; parametric}) (merge_objs fixed_encoding parametric_encoding) + +module Proto_previous = struct + type parametric = { + preserved_cycles : int; + blocks_per_cycle : int32; + blocks_per_commitment : int32; + blocks_per_roll_snapshot : int32; + blocks_per_voting_period : int32; + time_between_blocks : Period_repr.t list; + endorsers_per_block : int; + hard_gas_limit_per_operation : Gas_limit_repr.Arith.integral; + hard_gas_limit_per_block : Gas_limit_repr.Arith.integral; + proof_of_work_threshold : int64; + tokens_per_roll : Tez_repr.t; + michelson_maximum_type_size : int; + seed_nonce_revelation_tip : Tez_repr.t; + origination_size : int; + block_security_deposit : Tez_repr.t; + endorsement_security_deposit : Tez_repr.t; + baking_reward_per_endorsement : Tez_repr.t list; + endorsement_reward : Tez_repr.t list; + cost_per_byte : Tez_repr.t; + hard_storage_limit_per_operation : Z.t; + test_chain_duration : int64; + (* in seconds *) + quorum_min : int32; + quorum_max : int32; + min_proposal_quorum : int32; + initial_endorsers : int; + delay_per_missing_endorsement : Period_repr.t; + } + + let parametric_encoding = + let open Data_encoding in + conv + (fun c -> + ( ( c.preserved_cycles, + c.blocks_per_cycle, + c.blocks_per_commitment, + c.blocks_per_roll_snapshot, + c.blocks_per_voting_period, + c.time_between_blocks, + c.endorsers_per_block, + c.hard_gas_limit_per_operation, + c.hard_gas_limit_per_block ), + ( ( c.proof_of_work_threshold, + c.tokens_per_roll, + c.michelson_maximum_type_size, + c.seed_nonce_revelation_tip, + c.origination_size, + c.block_security_deposit, + c.endorsement_security_deposit, + c.baking_reward_per_endorsement ), + ( c.endorsement_reward, + c.cost_per_byte, + c.hard_storage_limit_per_operation, + c.test_chain_duration, + c.quorum_min, + c.quorum_max, + c.min_proposal_quorum, + c.initial_endorsers, + c.delay_per_missing_endorsement ) ) )) + (fun ( ( preserved_cycles, + blocks_per_cycle, + blocks_per_commitment, + blocks_per_roll_snapshot, + blocks_per_voting_period, + time_between_blocks, + endorsers_per_block, + hard_gas_limit_per_operation, + hard_gas_limit_per_block ), + ( ( proof_of_work_threshold, + tokens_per_roll, + michelson_maximum_type_size, + seed_nonce_revelation_tip, + origination_size, + block_security_deposit, + endorsement_security_deposit, + baking_reward_per_endorsement ), + ( endorsement_reward, + cost_per_byte, + hard_storage_limit_per_operation, + test_chain_duration, + quorum_min, + quorum_max, + min_proposal_quorum, + initial_endorsers, + delay_per_missing_endorsement ) ) ) -> + { + preserved_cycles; + blocks_per_cycle; + blocks_per_commitment; + blocks_per_roll_snapshot; + blocks_per_voting_period; + time_between_blocks; + endorsers_per_block; + hard_gas_limit_per_operation; + hard_gas_limit_per_block; + proof_of_work_threshold; + tokens_per_roll; + michelson_maximum_type_size; + seed_nonce_revelation_tip; + origination_size; + block_security_deposit; + endorsement_security_deposit; + baking_reward_per_endorsement; + endorsement_reward; + cost_per_byte; + hard_storage_limit_per_operation; + test_chain_duration; + quorum_min; + quorum_max; + min_proposal_quorum; + initial_endorsers; + delay_per_missing_endorsement; + }) + (merge_objs + (obj9 + (req "preserved_cycles" uint8) + (req "blocks_per_cycle" int32) + (req "blocks_per_commitment" int32) + (req "blocks_per_roll_snapshot" int32) + (req "blocks_per_voting_period" int32) + (req "time_between_blocks" (list Period_repr.encoding)) + (req "endorsers_per_block" uint16) + (req + "hard_gas_limit_per_operation" + Gas_limit_repr.Arith.z_integral_encoding) + (req + "hard_gas_limit_per_block" + Gas_limit_repr.Arith.z_integral_encoding)) + (merge_objs + (obj8 + (req "proof_of_work_threshold" int64) + (req "tokens_per_roll" Tez_repr.encoding) + (req "michelson_maximum_type_size" uint16) + (req "seed_nonce_revelation_tip" Tez_repr.encoding) + (req "origination_size" int31) + (req "block_security_deposit" Tez_repr.encoding) + (req "endorsement_security_deposit" Tez_repr.encoding) + (req "baking_reward_per_endorsement" (list Tez_repr.encoding))) + (obj9 + (req "endorsement_reward" (list Tez_repr.encoding)) + (req "cost_per_byte" Tez_repr.encoding) + (req "hard_storage_limit_per_operation" z) + (req "test_chain_duration" int64) + (req "quorum_min" int32) + (req "quorum_max" int32) + (req "min_proposal_quorum" int32) + (req "initial_endorsers" uint16) + (req "delay_per_missing_endorsement" Period_repr.encoding)))) +end diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index e28fb8bb8f81..887512bd21e5 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -786,6 +786,26 @@ let check_and_update_protocol_version ctxt = encoding directly in a way which is compatible with the previous protocol. However, by doing so, you do not change the value of these constants inside the context. *) + +(* only for the migration *) +let get_previous_protocol_constants ctxt = + Context.get ctxt constants_key + >>= function + | None -> + failwith + "Internal error: cannot read previous protocol constants in context." + | Some bytes -> ( + match + Data_encoding.Binary.of_bytes + Constants_repr.Proto_previous.parametric_encoding + bytes + with + | None -> + failwith + "Internal error: cannot parse previous protocol constants in context." + | Some constants -> + Lwt.return constants ) + let prepare_first_block ~level ~timestamp ~fitness ctxt = check_and_update_protocol_version ctxt >>=? fun (previous_proto, ctxt) -> @@ -796,7 +816,50 @@ let prepare_first_block ~level ~timestamp ~fitness ctxt = set_first_level ctxt first_level >>=? fun ctxt -> add_constants ctxt param.constants >|= ok | Edo_008 -> - return ctxt ) + get_previous_protocol_constants ctxt + >>= fun c -> + let constants = + Constants_repr. + { + preserved_cycles = c.preserved_cycles; + blocks_per_cycle = c.blocks_per_cycle; + blocks_per_commitment = c.blocks_per_commitment; + blocks_per_roll_snapshot = c.blocks_per_roll_snapshot; + blocks_per_voting_period = c.blocks_per_voting_period; + time_between_blocks = c.time_between_blocks; + endorsers_per_block = c.endorsers_per_block; + hard_gas_limit_per_operation = c.hard_gas_limit_per_operation; + hard_gas_limit_per_block = + Gas_limit_repr.Arith.(integral_of_int_exn 5_200_000); + proof_of_work_threshold = c.proof_of_work_threshold; + tokens_per_roll = c.tokens_per_roll; + michelson_maximum_type_size = c.michelson_maximum_type_size; + seed_nonce_revelation_tip = c.seed_nonce_revelation_tip; + origination_size = c.origination_size; + block_security_deposit = Tez_repr.(mul_exn one 640); + endorsement_security_deposit = Tez_repr.(mul_exn one_cent 250); + baking_reward_per_endorsement = + Tez_repr.[of_mutez_exn 78_125L; of_mutez_exn 11_719L]; + endorsement_reward = + Tez_repr.[of_mutez_exn 78_125L; of_mutez_exn 52_083L]; + hard_storage_limit_per_operation = + c.hard_storage_limit_per_operation; + cost_per_byte = c.cost_per_byte; + test_chain_duration = c.test_chain_duration; + quorum_min = c.quorum_min; + quorum_max = c.quorum_max; + min_proposal_quorum = c.min_proposal_quorum; + initial_endorsers = c.initial_endorsers; + delay_per_missing_endorsement = c.delay_per_missing_endorsement; + liquidity_baking_cpmm_origination_nonce = + (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) + Contract_repr.initial_origination_nonce Operation_hash.zero; + liquidity_baking_reward = Tez_repr.of_mutez_exn 5_000_000L; + liquidity_baking_sunset_duration = 262800l; + liquidity_baking_escape_ema_threshold = 500_000l; + } + in + set_constants ctxt constants >|= ok ) >>=? fun ctxt -> prepare ctxt ~level ~predecessor_timestamp:timestamp ~timestamp ~fitness >|=? fun ctxt -> (previous_proto, ctxt) -- GitLab From b29a073989cdca56d178bad363f59d143f82519c Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 1 Feb 2021 00:49:52 -0500 Subject: [PATCH 34/62] liquidity baking: update tezt regressions --- tezt/_regressions/encoding/alpha.block_header.out | 6 ++++-- .../encoding/alpha.block_header.unsigned.out | 10 ++++++---- tezt/_regressions/encoding/alpha.operation.out | 8 ++++++-- .../encoding/alpha.operation.unsigned.out | 8 ++++++-- tezt/_regressions/rpc/alpha.client.contracts.out | 8 +++++--- tezt/_regressions/rpc/current.client.others.out | 11 ++++++++--- .../block_header.unsigned.sample.json | 3 ++- .../alpha/block_header/block_header.sample.json | 1 + ...ration.unsigned-double-baking-evidence.sample.json | 2 ++ .../operation-double-baking-evidence.sample.json | 2 ++ 10 files changed, 42 insertions(+), 17 deletions(-) diff --git a/tezt/_regressions/encoding/alpha.block_header.out b/tezt/_regressions/encoding/alpha.block_header.out index 92ee2f6fe8da..3460e449da98 100644 --- a/tezt/_regressions/encoding/alpha.block_header.out +++ b/tezt/_regressions/encoding/alpha.block_header.out @@ -15,11 +15,12 @@ tezt/_regressions/encoding/alpha.block_header.out "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }' -00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d55866804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c +00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d5580066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c -./tezos-codec decode alpha.block_header from 00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d55866804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c +./tezos-codec decode alpha.block_header from 00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d5580066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c { "level": 1331, "proto": 1, "predecessor": "BKpbfCvh777DQHnXjU2sqHvVUNZ7dBAdqEfKkdw8EGSkD9LSYXb", "timestamp": "2020-04-20T16:20:00Z", "validation_pass": 2, @@ -28,5 +29,6 @@ tezt/_regressions/encoding/alpha.block_header.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } diff --git a/tezt/_regressions/encoding/alpha.block_header.unsigned.out b/tezt/_regressions/encoding/alpha.block_header.unsigned.out index 6ce4df4b3ead..2c7f681f0c7c 100644 --- a/tezt/_regressions/encoding/alpha.block_header.unsigned.out +++ b/tezt/_regressions/encoding/alpha.block_header.unsigned.out @@ -14,11 +14,12 @@ tezt/_regressions/encoding/alpha.block_header.unsigned.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 21021, "proof_of_work_nonce": "101895ca00000000", - "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3" + "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", + "liquidity_baking_escape_flag": false }' -00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d558 +00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d55800 -./tezos-codec decode alpha.block_header.unsigned from 00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d558 +./tezos-codec decode alpha.block_header.unsigned from 00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d55800 { "level": 1331, "proto": 1, "predecessor": "BKpbfCvh777DQHnXjU2sqHvVUNZ7dBAdqEfKkdw8EGSkD9LSYXb", "timestamp": "2020-04-20T16:20:00Z", "validation_pass": 2, @@ -26,4 +27,5 @@ tezt/_regressions/encoding/alpha.block_header.unsigned.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 21021, "proof_of_work_nonce": "101895ca00000000", - "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3" } + "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", + "liquidity_baking_escape_flag": false } diff --git a/tezt/_regressions/encoding/alpha.operation.out b/tezt/_regressions/encoding/alpha.operation.out index 2335ce7ef35f..3cfa05c156cb 100644 --- a/tezt/_regressions/encoding/alpha.operation.out +++ b/tezt/_regressions/encoding/alpha.operation.out @@ -120,6 +120,7 @@ tezt/_regressions/encoding/alpha.operation.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -136,15 +137,16 @@ tezt/_regressions/encoding/alpha.operation.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } ], "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }' -0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c66804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c +0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c66804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c -./tezos-codec decode alpha.operation from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c66804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c +./tezos-codec decode alpha.operation from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c66804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c { "branch": "BKpbfCvh777DQHnXjU2sqHvVUNZ7dBAdqEfKkdw8EGSkD9LSYXb", "contents": [ { "kind": "double_baking_evidence", @@ -158,6 +160,7 @@ tezt/_regressions/encoding/alpha.operation.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": @@ -170,6 +173,7 @@ tezt/_regressions/encoding/alpha.operation.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } ], "signature": diff --git a/tezt/_regressions/encoding/alpha.operation.unsigned.out b/tezt/_regressions/encoding/alpha.operation.unsigned.out index 2eba3e1fe38e..39ac60fe2d58 100644 --- a/tezt/_regressions/encoding/alpha.operation.unsigned.out +++ b/tezt/_regressions/encoding/alpha.operation.unsigned.out @@ -108,6 +108,7 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -124,14 +125,15 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } ] }' -0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c +0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c -./tezos-codec decode alpha.operation.unsigned from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000ce00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c +./tezos-codec decode alpha.operation.unsigned from 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a803000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c000000cf00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00442e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c0000101895ca00000000000066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c { "branch": "BKpbfCvh777DQHnXjU2sqHvVUNZ7dBAdqEfKkdw8EGSkD9LSYXb", "contents": [ { "kind": "double_baking_evidence", @@ -145,6 +147,7 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": @@ -157,6 +160,7 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } ] } diff --git a/tezt/_regressions/rpc/alpha.client.contracts.out b/tezt/_regressions/rpc/alpha.client.contracts.out index dad019e8278f..c8134cad0a5c 100644 --- a/tezt/_regressions/rpc/alpha.client.contracts.out +++ b/tezt/_regressions/rpc/alpha.client.contracts.out @@ -2,7 +2,9 @@ tezt/_regressions/rpc/alpha.client.contracts.out ./tezos-client rpc get /chains/main/blocks/head/context/contracts [ "[PUBLIC_KEY_HASH]", + "[CONTRACT_HASH]", "[PUBLIC_KEY_HASH]", + "[CONTRACT_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]" ] @@ -310,7 +312,7 @@ null "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], "storage": - { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } } + { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } } ./tezos-client rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/balance' "0" @@ -518,10 +520,10 @@ null { "prim": "PAIR" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], - "storage": { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } + "storage": { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } ./tezos-client rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/storage' -{ "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } +{ "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } ./tezos-client rpc post '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/big_map_get' with '{ "key": { diff --git a/tezt/_regressions/rpc/current.client.others.out b/tezt/_regressions/rpc/current.client.others.out index 147327f758db..0036e92b60de 100644 --- a/tezt/_regressions/rpc/current.client.others.out +++ b/tezt/_regressions/rpc/current.client.others.out @@ -11,14 +11,19 @@ tezt/_regressions/rpc/current.client.others.out "hard_gas_limit_per_block": "10400000", "proof_of_work_threshold": "-1", "tokens_per_roll": "8000000000", "michelson_maximum_type_size": 1000, "seed_nonce_revelation_tip": "125000", "origination_size": 257, - "block_security_deposit": "512000000", + "block_security_deposit": "544000000", "endorsement_security_deposit": "64000000", "baking_reward_per_endorsement": [ "1250000", "187500" ], "endorsement_reward": [ "1250000", "833333" ], "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", - "test_chain_duration": "1228800", "quorum_min": 2000, "quorum_max": 7000, + "test_chain_duration": "0", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 1, - "delay_per_missing_endorsement": "1" } + "delay_per_missing_endorsement": "1", + "liquidity_baking_cpmm_origination_nonce": + { "operation": "oneDGhZacw99EEFaYDTtWfz5QEhUW3PPVFsHa7GShnLPuDn7gSd" }, + "liquidity_baking_reward": "5000000", + "liquidity_baking_sunset_duration": 1024, + "liquidity_baking_escape_ema_threshold": 500000 } ./tezos-client rpc get /chains/main/blocks/head/helpers/baking_rights [ { "level": 2, "delegate": "[PUBLIC_KEY_HASH]", diff --git a/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json b/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json index 1347e3ebbe47..d8fffaea03d5 100644 --- a/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json +++ b/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json @@ -9,5 +9,6 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 21021, "proof_of_work_nonce": "101895ca00000000", - "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3" + "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", + "liquidity_baking_escape_flag": false } diff --git a/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json b/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json index 8890db3a0439..a84e53347abc 100644 --- a/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json +++ b/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json @@ -10,5 +10,6 @@ "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } diff --git a/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json b/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json index 88a2ec6de05d..c0cb6c57b1a4 100644 --- a/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json +++ b/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json @@ -13,6 +13,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -26,6 +27,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } }] diff --git a/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json b/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json index 8f5adf00f849..d2f06895d9d3 100644 --- a/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json +++ b/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json @@ -13,6 +13,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -26,6 +27,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", + "liquidity_baking_escape_flag": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } }], -- GitLab From 394c5582a5db80ebfec2eb5a99857cff5c7e1257 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 1 Feb 2021 00:50:07 -0500 Subject: [PATCH 35/62] liquidity baking: add docs --- docs/alpha/liquidity_baking.rst | 36 +++++++++++++++++++++++++++++++++ docs/alpha/proof_of_stake.rst | 2 +- docs/protocols/alpha.rst | 18 +++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 docs/alpha/liquidity_baking.rst diff --git a/docs/alpha/liquidity_baking.rst b/docs/alpha/liquidity_baking.rst new file mode 100644 index 000000000000..e354ed9c285e --- /dev/null +++ b/docs/alpha/liquidity_baking.rst @@ -0,0 +1,36 @@ +Liquidity Baking +================ + +Liquidity baking incentivizes large amounts of decentralized liquidity provision between tez and tzBTC by minting a small amount of tez every block and depositing it inside of a constant product market making smart-contract. It includes an escape hatch mechanism as a contingency. + +Contract +~~~~~~~~~~~~ + +A constant product market making (CPMM) Michelson contract is first deployed on the chain. This contract maintains a balance of ``a`` tez and ``b`` tzBTC, where tzBTC is the FA1.2 token found at address KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn. The smart contract accepts deposits of ``da`` tez and returns ``db`` tzBTC (or vice versa) where the invariant ``(a + da * (1 - f)) * (b - db) = a b`` is preserved, and ``f`` is a fee, set at 0.1%. + +To implement this contract, we use a fork of the open source code base used by the "Dexter" project. The implementation of this contract has been `formally verified`_ against its functional specification. The contract code is modified in the following way: + +1. The fee is set to 0.1% only. Rationale: given the subsidy it is not necessary to charge a large fee and better to improve liquidity. +2. The ability to set a manager has been removed. +3. The ability to set a delegate and receive rewards has been removed. Rationale: the subsidy means there is no need for a baker for that contract and having one would create an imbalance. + +Subsidy +~~~~~~~~~~~ + +At every block in the chain, 5 tez are minted and credited to the CPMM contract, and the CPMM's ``%default`` entrypoint is called to update the ``xtz_pool`` balance in its storage. This corresponds to 1/16th of 80 tez which is the typical block reward and endorsement reward for a block of priority 0 with all endorsements. If for any reason this constant changes, the amount of 5 tez should also be changed adequately. + +So the credits to the CPMM contract can be accounted for by indexers, they are included in block metadata as a balance update with a new constructor for ``update_origin``, ``Subsidy``. + +As a safety precaution, the subsidy expires automatically after 6 months but it can be renewed periodically by protocol amendment. + +Escape hatch +~~~~~~~~~~~~~~~~ + +In addition to the 6 months sunset, an escape hatch is included. At every block, a baker can choose to include a flag that requests ending the subsidy. The context maintains an exponential moving average of that flag calculated as such with integer arithmetic: + +``e[0] = 0`` +``e[n+1] = (999 * e[n] // 1000) + (1000 if flag[n] else 0)`` + +If at any block `e[n] >= 500000` then it means that an exponential moving average with a window size on the order of one thousand blocks has had roughly a majority of blocks demanding the end of the subsidy. If that is the case, the subsidy is permanently halted (though it can be reactivated by a protocol upgrade). + +For indicative purposes, if a fraction ``f`` of blocks start signalling the flag, the threshold is reached after roughly ``log(1-1/(2f)) / log(0.999)`` blocks, about 693 blocks if everyone signals, 980 blocks if 80% do, 1790 blocks if 60% do, etc. diff --git a/docs/alpha/proof_of_stake.rst b/docs/alpha/proof_of_stake.rst index 25883f5accae..8b64638ed8ae 100644 --- a/docs/alpha/proof_of_stake.rst +++ b/docs/alpha/proof_of_stake.rst @@ -322,7 +322,7 @@ blocks of priority 1 or higher will be rewarded ``e * 0.8333333`` Security deposits ~~~~~~~~~~~~~~~~~ -The cost of a security deposit is ``BLOCK_SECURITY_DEPOSIT`` = 512 ꜩ +The cost of a security deposit is ``BLOCK_SECURITY_DEPOSIT`` = 544 ꜩ per block created and ``ENDORSEMENT_SECURITY_DEPOSIT`` = 64 ꜩ per endorsement slot. diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 654961597381..c1274e2a4790 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -12,8 +12,26 @@ The code can be found in the ``src/proto_alpha`` directory of the This page documents the changes brought by protocol Alpha with respect to Florence. +The main novelties in the Alpha protocol are: .. contents:: Summary of changes - Fix handling of potential integer overflow in `Time_repr` addition `Protocol/time_repr: check for potential overflow on addition `_ + +Liquidity Baking +~~~~~~~~~~~~~~~~ + +5 tez per block is credited to a CPMM contract, the contract's ``%default`` entrypoint is called to update its storage, and the credit is included in block metadata as a balance update with a new ``update_origin`` type, ``Subsidy``. + +The liquidity baking subsidy shuts off automatically at six months from protocol activation if not renewed in a future upgrade. The sunset duration is included in constants and sunset level calculated during stitching. + +At any time bakers can vote to shut off the liquidity baking subsidy by setting a boolean flag in protocol_data. An exponential moving average (ema) of this escape flag is calculated with a window size of 1000 blocks and the subsidy permanently shuts off if the ema is ever over a threshold included in constants (half the window size with precision of 1000 added for integer computation). + +The block security deposit is increased by 1/16th to 544. + +- `TZIP `_ +- MR: + :gl:`tezos!2473` + +More detailed docs for liquidity baking can be found `here<../alpha/liquidity_baking.rst>`_ -- GitLab From 65b4a71e351fead35cc27aa1a83be60d6181d51f Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 1 Feb 2021 13:49:05 -0500 Subject: [PATCH 36/62] liquidity baking: fix errors in tests --- .../lib_delegate/client_baking_forge.ml | 36 +- .../lib_delegate/client_baking_forge.mli | 8 +- .../lib_delegate/client_baking_lib.ml | 4 +- .../lib_delegate/client_baking_lib.mli | 2 +- src/proto_alpha/lib_delegate/client_daemon.ml | 4 +- .../lib_delegate/client_daemon.mli | 2 +- .../lib_delegate/delegate_commands.ml | 68 +- src/proto_alpha/lib_parameters/cpmm.json | 3126 ---- .../lib_parameters/default_parameters.ml | 156 +- .../lib_parameters/default_parameters.mli | 5 +- src/proto_alpha/lib_parameters/dune | 14 +- src/proto_alpha/lib_parameters/fa12.json | 443 - src/proto_alpha/lib_parameters/gen.ml | 18 +- .../lib_parameters/michelson_v1_macros.ml | 1542 -- .../lib_parameters/michelson_v1_macros.mli | 86 - .../lib_parameters/michelson_v1_parser.ml | 108 - .../lib_parameters/michelson_v1_parser.mli | 53 - src/proto_alpha/lib_parameters/test_cpmm.ml | 12993 ++++++++++++++++ src/proto_alpha/lib_parameters/test_fa12.ml | 1249 ++ src/proto_alpha/lib_protocol/alpha_context.ml | 5 +- .../lib_protocol/alpha_context.mli | 135 +- src/proto_alpha/lib_protocol/apply.ml | 120 +- .../lib_protocol/block_header_repr.ml | 14 +- .../lib_protocol/block_header_repr.mli | 2 +- .../lib_protocol/bootstrap_storage.ml | 38 +- .../lib_protocol/constants_repr.ml | 22 +- .../lib_protocol/constants_repr.mli | 38 + .../lib_protocol/constants_storage.ml | 8 +- .../lib_protocol/constants_storage.mli | 8 + src/proto_alpha/lib_protocol/dune.inc | 21 +- .../lib_protocol/helpers_services.ml | 23 +- .../lib_protocol/helpers_services.mli | 2 +- src/proto_alpha/lib_protocol/init_storage.ml | 9 + .../lib_protocol/parameters_repr.ml | 15 +- .../lib_protocol/parameters_repr.mli | 1 - src/proto_alpha/lib_protocol/raw_context.ml | 23 +- src/proto_alpha/lib_protocol/storage.mli | 2 +- src/proto_alpha/lib_protocol/test/dune | 12 +- .../lib_protocol/test/helpers/block.ml | 32 +- .../lib_protocol/test/helpers/block.mli | 10 +- .../lib_protocol/test/helpers/context.ml | 6 +- .../lib_protocol/test/helpers/context.mli | 2 +- .../test/test_liquidity_baking.ml | 99 +- ...tion::test_big_map_origination_literal.out | 4 +- ...(Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" | 42 + ...(Some 5) { Elt \"hello\" 4.129664940f.out" | 42 + ...(Some 5) { Elt \"hello\" 4.7f9778b826.out" | 43 + ...None { Elt \"1\" 1 ; .a8fbd9ff17.out" | 43 + ...None { Elt \"1\" 1 ; .cfc446b130.out" | 43 + ...None { Elt \"hello\" 4 })-.54dc01b7ba.out" | 42 + ...None {})-\"hello\"-(Pair N.c793d810c2.out" | 42 + ..." \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" | 51 + ...ello\" \"hi\" } None)-\"\".2fe16a2420.out" | 50 + ...hello\" \"hi\" } None)-\"h.9de65c712d.out" | 50 + ...one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" | 54 + ...one\" ; Elt \"2\" \"two\" .590c060653.out" | 54 + ...one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" | 55 + ...one\" ; Elt \"2\" \"two\" .bc065fddfe.out" | 54 + ...one\" ; Elt \"2\" \"two\" .c83cecb062.out" | 43 + ...one\" ; Elt \"2\" \"two\" .d78cba5123.out" | 55 + ... \"two\" }) )-(Right (Righ.3789a260e7.out" | 80 + ... \"two\" }))-(Left Unit)-(.1fc7748f5b.out" | 43 + ... \"two\" }))-(Right (Left .45ba7bbe6e.out" | 35 + ... \"two\" }))-(Right (Right.b11b9d15f4.out" | 74 + ...Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" | 128 + ...lt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out | 46 + ...lt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out | 46 + ...lt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out | 46 + ...lt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out | 46 + ...lt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out | 47 + ...lt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out | 47 + ...lt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out | 47 + ...lt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out | 47 + ...lt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out | 47 + ...lt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out | 47 + ...air {} None)-1-(Pair 2 (Some False))0].out | 45 + ...air {} None)-1-(Pair 2 (Some False))1].out | 45 + ... \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" | 47 + ... \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" | 47 + ... \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" | 47 + ... \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" | 46 + ... \"foo\" 1 } None)-\"bar\".68bbace451.out" | 46 + ... None)-\"bar\"-(Pair 2 (Some False))].out" | 45 + .../tests_alpha/test_contract_opcodes.py | 208 +- tests_python/tests_alpha/test_voting_full.py | 23 + .../encoding/alpha.block_header.out | 4 +- .../encoding/alpha.block_header.unsigned.out | 4 +- .../_regressions/encoding/alpha.operation.out | 8 +- .../encoding/alpha.operation.unsigned.out | 8 +- .../rpc/alpha.client.contracts.out | 2 +- .../rpc/current.client.others.out | 14 +- .../block_header.unsigned.sample.json | 2 +- .../block_header/block_header.sample.json | 2 +- ...nsigned-double-baking-evidence.sample.json | 4 +- ...eration-double-baking-evidence.sample.json | 4 +- vendors/flextesa-lib/tezos_protocol.ml | 67 +- 96 files changed, 16822 insertions(+), 6053 deletions(-) delete mode 100644 src/proto_alpha/lib_parameters/cpmm.json delete mode 100644 src/proto_alpha/lib_parameters/fa12.json delete mode 100644 src/proto_alpha/lib_parameters/michelson_v1_macros.ml delete mode 100644 src/proto_alpha/lib_parameters/michelson_v1_macros.mli delete mode 100644 src/proto_alpha/lib_parameters/michelson_v1_parser.ml delete mode 100644 src/proto_alpha/lib_parameters/michelson_v1_parser.mli create mode 100644 src/proto_alpha/lib_parameters/test_cpmm.ml create mode 100644 src/proto_alpha/lib_parameters/test_fa12.ml create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" create mode 100644 "tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index 327665858ea6..f51ab1d46ac6 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -113,13 +113,13 @@ let generate_seed_nonce () = nonce let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block - delegate_sk shell priority seed_nonce_hash liquidity_baking_escape_flag = + delegate_sk shell priority seed_nonce_hash liquidity_baking_escape_vote = Client_baking_pow.mine cctxt chain block shell (fun proof_of_work_nonce -> { Block_header.priority; seed_nonce_hash; proof_of_work_nonce; - liquidity_baking_escape_flag; + liquidity_baking_escape_vote; }) >>=? fun contents -> let unsigned_header = @@ -136,7 +136,7 @@ let forge_block_header (cctxt : #Protocol_client_context.full) ~chain block unsigned_header let forge_faked_protocol_data ~priority ~seed_nonce_hash - ~liquidity_baking_escape_flag = + ~liquidity_baking_escape_vote = Alpha_context.Block_header. { contents = @@ -144,7 +144,7 @@ let forge_faked_protocol_data ~priority ~seed_nonce_hash priority; seed_nonce_hash; proof_of_work_nonce = Client_baking_pow.empty_proof_of_work_nonce; - liquidity_baking_escape_flag; + liquidity_baking_escape_vote; }; signature = Signature.zero; } @@ -186,7 +186,7 @@ let compute_endorsing_power cctxt ~chain ~block operations = let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header ~priority ~delegate_pkh ~delegate_sk ~level operations - ~liquidity_baking_escape_flag = + ~liquidity_baking_escape_vote = assert_valid_operations_hash shell_header operations >>=? fun () -> let block = `Hash (shell_header.Tezos_base.Block_header.predecessor, 0) in @@ -198,7 +198,7 @@ let inject_block cctxt ?(force = false) ?seed_nonce_hash ~chain ~shell_header shell_header priority seed_nonce_hash - liquidity_baking_escape_flag + liquidity_baking_escape_vote >>=? fun signed_header -> (* Record baked blocks to prevent double baking *) let open Client_baking_highwatermarks in @@ -837,7 +837,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ?(sort = best_effort) ?(minimal_fees = default_minimal_fees) ?(minimal_nanotez_per_gas_unit = default_minimal_nanotez_per_gas_unit) ?(minimal_nanotez_per_byte = default_minimal_nanotez_per_byte) ?timestamp - ?mempool ?context_path ?seed_nonce_hash ~liquidity_baking_escape_flag + ?mempool ?context_path ?seed_nonce_hash ~liquidity_baking_escape_vote ~chain ~priority ~delegate_pkh ~delegate_sk block = (* making the arguments usable *) unopt_operations cctxt chain mempool operations @@ -853,7 +853,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) forge_faked_protocol_data ~priority ~seed_nonce_hash - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote in Alpha_services.Constants.all cctxt (chain, block) >>=? fun Constants. @@ -1031,7 +1031,7 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) ~delegate_sk ~level operations - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote >>= function | Ok hash -> return hash @@ -1050,12 +1050,12 @@ let forge_block cctxt ?force ?operations ?(best_effort = operations = None) let shell_prevalidation (cctxt : #Protocol_client_context.full) ~chain ~block ~timestamp seed_nonce_hash operations ((_, (bi, priority, delegate)) as _slot) = - let liquidity_baking_escape_flag = false in + let liquidity_baking_escape_vote = false in let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote in Alpha_block_services.Helpers.Preapply.block cctxt @@ -1194,7 +1194,7 @@ let fetch_operations (cctxt : #Protocol_client_context.full) ~chain validation *) let build_block cctxt ~user_activated_upgrades state seed_nonce_hash ((slot_timestamp, (bi, priority, delegate)) as slot) - ~liquidity_baking_escape_flag = + ~liquidity_baking_escape_vote = let chain = `Hash bi.Client_baking_blocks.chain_id in let block = `Hash (bi.hash, 0) in Alpha_services.Helpers.current_level cctxt ~offset:1l (chain, block) @@ -1263,7 +1263,7 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash forge_faked_protocol_data ~priority ~seed_nonce_hash - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote in filter_and_apply_operations cctxt @@ -1381,7 +1381,7 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash so. All the necessary information is available in the [state.best_slot]. *) let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades - ~chain state ~liquidity_baking_escape_flag = + ~chain state ~liquidity_baking_escape_vote = ( match state.best_slot with | None -> assert false (* unreachable *) @@ -1396,7 +1396,7 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades state seed_nonce_hash slot - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote >>=? function | Some (head, priority, shell_header, operations, delegate, seed_nonce_hash) -> ( @@ -1427,7 +1427,7 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ~delegate_sk ~level operations - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote >>= function | Error errs -> lwt_log_error @@ -1621,7 +1621,7 @@ let reveal_potential_nonces (cctxt : #Client_context.full) constants ~chain the [delegates] *) let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?max_priority ~liquidity_baking_escape_flag ~chain ~context_path delegates + ?max_priority ~liquidity_baking_escape_vote ~chain ~context_path delegates block_stream = let state_maker bi = Alpha_services.Constants.all cctxt (chain, `Head 0) @@ -1677,7 +1677,7 @@ let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ~user_activated_upgrades ~chain state - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote >>= function | Error err -> if state.retry_counter = 0 then ( diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.mli b/src/proto_alpha/lib_delegate/client_baking_forge.mli index eda8a9e93a76..4e89408f5269 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.mli +++ b/src/proto_alpha/lib_delegate/client_baking_forge.mli @@ -33,7 +33,7 @@ open Alpha_context val generate_seed_nonce : unit -> Nonce.t (** [inject_block cctxt blk ?force ~priority ~timestamp ~fitness - ~seed_nonce ~src_sk ops liquidity_baking_escape_flag] + ~seed_nonce ~src_sk ops liquidity_baking_escape_vote] tries to inject a block in the node. If [?force] is set, the fitness check will be bypassed. [priority] will be used to compute the baking slot (level is @@ -49,7 +49,7 @@ val inject_block : delegate_sk:Client_keys.sk_uri -> level:Raw_level.t -> Operation.raw list list -> - liquidity_baking_escape_flag:bool -> + liquidity_baking_escape_vote:bool -> Block_hash.t tzresult Lwt.t type error += Failed_to_preapply of Tezos_base.Operation.t * error list @@ -87,7 +87,7 @@ val forge_block : ?mempool:string -> ?context_path:string -> ?seed_nonce_hash:Nonce_hash.t -> - liquidity_baking_escape_flag:bool -> + liquidity_baking_escape_vote:bool -> chain:Chain_services.chain -> priority:[`Set of int | `Auto of public_key_hash * int option] -> delegate_pkh:Signature.Public_key_hash.t -> @@ -102,7 +102,7 @@ val create : ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> - liquidity_baking_escape_flag:bool -> + liquidity_baking_escape_vote:bool -> chain:Chain_services.chain -> context_path:string -> public_key_hash list -> diff --git a/src/proto_alpha/lib_delegate/client_baking_lib.ml b/src/proto_alpha/lib_delegate/client_baking_lib.ml index b9a159669523..ec5c41904123 100644 --- a/src/proto_alpha/lib_delegate/client_baking_lib.ml +++ b/src/proto_alpha/lib_delegate/client_baking_lib.ml @@ -29,7 +29,7 @@ open Alpha_context let bake_block (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force ?max_priority ?(minimal_timestamp = false) ?mempool ?context_path ?src_sk - ~liquidity_baking_escape_flag ~chain ~head delegate = + ~liquidity_baking_escape_vote ~chain ~head delegate = ( match src_sk with | None -> Client_keys.get_key cctxt delegate @@ -60,7 +60,7 @@ let bake_block (cctxt : #Protocol_client_context.full) ?minimal_fees ?seed_nonce_hash ?mempool ?context_path - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote ~chain ~priority:(`Auto (delegate, max_priority)) ~delegate_pkh:delegate diff --git a/src/proto_alpha/lib_delegate/client_baking_lib.mli b/src/proto_alpha/lib_delegate/client_baking_lib.mli index bdde7435e72c..a93daedc308c 100644 --- a/src/proto_alpha/lib_delegate/client_baking_lib.mli +++ b/src/proto_alpha/lib_delegate/client_baking_lib.mli @@ -38,7 +38,7 @@ val bake_block : ?mempool:string -> ?context_path:string -> ?src_sk:Client_keys.sk_uri -> - liquidity_baking_escape_flag:bool -> + liquidity_baking_escape_vote:bool -> chain:Chain_services.chain -> head:Block_services.block -> public_key_hash -> diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index b67dcde1b1d4..eb73d4530976 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -94,7 +94,7 @@ end module Baker = struct let run (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~liquidity_baking_escape_flag ~chain ~context_path ~keep_alive delegates + ~liquidity_baking_escape_vote ~chain ~context_path ~keep_alive delegates = let process () = Config_services.user_activated_upgrades cctxt @@ -113,7 +113,7 @@ module Baker = struct ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote ~chain ~context_path delegates diff --git a/src/proto_alpha/lib_delegate/client_daemon.mli b/src/proto_alpha/lib_delegate/client_daemon.mli index fde987d2b2f1..6473cb5adc80 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.mli +++ b/src/proto_alpha/lib_delegate/client_daemon.mli @@ -43,7 +43,7 @@ module Baker : sig ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> - liquidity_baking_escape_flag:bool -> + liquidity_baking_escape_vote:bool -> chain:Chain_services.chain -> context_path:string -> keep_alive:bool -> diff --git a/src/proto_alpha/lib_delegate/delegate_commands.ml b/src/proto_alpha/lib_delegate/delegate_commands.ml index 953525ca2021..68eb11864d7a 100644 --- a/src/proto_alpha/lib_delegate/delegate_commands.ml +++ b/src/proto_alpha/lib_delegate/delegate_commands.ml @@ -86,12 +86,52 @@ let keep_alive_arg = ~long:"keep-alive" () -let liquidity_baking_escape_flag_arg = - Clic.switch - ~doc:"Vote to stop the liquidity baker subsidy." - ~short:'F' - ~long:"liquidity-baker-escape-flag" - () +type per_block_votes = {liquidity_baking_escape_vote : bool option} + +let per_block_votes_encoding = + let open Data_encoding in + def "per_block_votes.alpha" + @@ conv + (fun {liquidity_baking_escape_vote} -> liquidity_baking_escape_vote) + (fun liquidity_baking_escape_vote -> {liquidity_baking_escape_vote}) + (obj1 (opt "liquidity_baking_escape_vote" Data_encoding.bool)) + +let json_file_or_text_parameter = + Clic.parameter (fun _ p -> + match String.split ~limit:1 ':' p with + | ["text"; text] -> + return (Ezjsonm.from_string text) + | ["file"; path] -> + Lwt_utils_unix.Json.read_file path + | _ -> ( + if Sys.file_exists p then Lwt_utils_unix.Json.read_file p + else + try return (Ezjsonm.from_string p) + with Ezjsonm.Parse_error _ -> + failwith "Neither an existing file nor valid JSON: '%s'" p )) + +let per_block_votes_arg = + Clic.arg + ~doc:"read per block votes as json or json file" + ~short:'V' + ~long:"votes" + ~placeholder:"per block votes" + json_file_or_text_parameter + +let liquidity_baking_escape_vote per_block_votes = + match per_block_votes with + | None -> + return false + | Some votes -> ( + match Data_encoding.Json.destruct per_block_votes_encoding votes with + | exception e -> + Lwt.return (error_exn e) + | votes -> ( + match votes.liquidity_baking_escape_vote with + | None -> + return false + | Some escape_vote -> + return escape_vote ) ) let delegate_commands () = let open Clic in @@ -107,7 +147,7 @@ let delegate_commands () = minimal_timestamp_switch mempool_arg context_path_arg - liquidity_baking_escape_flag_arg) + per_block_votes_arg) ( prefixes ["bake"; "for"] @@ Client_keys.Public_key_hash.source_param ~name:"baker" @@ -121,9 +161,11 @@ let delegate_commands () = minimal_timestamp, mempool, context_path, - liquidity_baking_escape_flag ) + per_block_votes ) delegate cctxt -> + liquidity_baking_escape_vote per_block_votes + >>=? fun liquidity_baking_escape_vote -> bake_block cctxt ~minimal_fees @@ -134,7 +176,7 @@ let delegate_commands () = ~minimal_timestamp ?mempool ?context_path - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote ~chain:cctxt#chain ~head:cctxt#block delegate); @@ -264,7 +306,7 @@ let baker_commands () = minimal_nanotez_per_gas_unit_arg minimal_nanotez_per_byte_arg keep_alive_arg - liquidity_baking_escape_flag_arg) + per_block_votes_arg) ( prefixes ["run"; "with"; "local"; "node"] @@ param ~name:"context_path" @@ -277,12 +319,14 @@ let baker_commands () = minimal_nanotez_per_gas_unit, minimal_nanotez_per_byte, keep_alive, - liquidity_baking_escape_flag ) + per_block_votes ) node_path delegates cctxt -> may_lock_pidfile pidfile >>=? fun () -> + liquidity_baking_escape_vote per_block_votes + >>=? fun liquidity_baking_escape_vote -> Tezos_signer_backends.Encrypted.decrypt_list cctxt (List.map fst delegates) @@ -294,7 +338,7 @@ let baker_commands () = ~minimal_nanotez_per_gas_unit ~minimal_nanotez_per_byte ?max_priority - ~liquidity_baking_escape_flag + ~liquidity_baking_escape_vote ~context_path:(Filename.concat node_path "context") ~keep_alive (List.map snd delegates)) ] diff --git a/src/proto_alpha/lib_parameters/cpmm.json b/src/proto_alpha/lib_parameters/cpmm.json deleted file mode 100644 index 7b44615b1c89..000000000000 --- a/src/proto_alpha/lib_parameters/cpmm.json +++ /dev/null @@ -1,3126 +0,0 @@ -[ { "prim": "parameter", - "args": - [ { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ ":spender" ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", - "annots": [ ":allowance" ] }, - { "prim": "nat", - "annots": - [ ":currentAllowance" ] } ] } ], - "annots": [ "%approve" ] }, - { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ ":owner" ] }, - { "prim": "nat", - "annots": [ ":minLqtMinted" ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", - "annots": - [ ":maxTokensDeposited" ] }, - { "prim": "timestamp", - "annots": [ ":deadline" ] } ] } ], - "annots": [ "%addLiquidity" ] } ] }, - { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ ":owner" ] }, - { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ ":to" ] }, - { "prim": "nat", - "annots": - [ ":lqtBurned" ] } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "mutez", - "annots": - [ ":minXtzWithdrawn" ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", - "annots": - [ ":minTokensWithdrawn" ] }, - { "prim": "timestamp", - "annots": [ ":deadline" ] } ] } ] } ], - "annots": [ "%removeLiquidity" ] }, - { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ ":to" ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", - "annots": - [ ":minTokensBought" ] }, - { "prim": "timestamp", - "annots": [ ":deadline" ] } ] } ], - "annots": [ "%xtzToToken" ] } ] } ] }, - { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ ":owner" ] }, - { "prim": "address", - "annots": [ ":to" ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", - "annots": [ ":tokensSold" ] }, - { "prim": "pair", - "args": - [ { "prim": "mutez", - "annots": - [ ":minXtzBought" ] }, - { "prim": "timestamp", - "annots": [ ":deadline" ] } ] } ] } ], - "annots": [ "%tokenToXtz" ] }, - { "prim": "key_hash", - "annots": [ "%updateTokenPool" ] } ] }, - { "prim": "or", - "args": - [ { "prim": "nat", - "annots": [ "%updateTokenPoolInternal" ] }, - { "prim": "unit", "annots": [ "%default" ] } ] } ] } ] } ] }, - { "prim": "storage", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "big_map", - "args": - [ { "prim": "address", "annots": [ ":owner" ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", "annots": [ ":balance" ] }, - { "prim": "map", - "args": - [ { "prim": "address", - "annots": [ ":spender" ] }, - { "prim": "nat", - "annots": [ ":allowance" ] } ] } ] } ], - "annots": [ "%accounts" ] }, - { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "bool", - "annots": [ ":selfIsUpdatingTokenPool" ] }, - { "prim": "nat", "annots": [ ":lqtTotal" ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ ":tokenAddress" ] }, - { "prim": "pair", - "args": - [ { "prim": "nat", - "annots": [ ":tokenPool" ] }, - { "prim": "mutez", - "annots": [ ":xtzPool" ] } ] } ] } ] } ] } ] }, - { "prim": "code", - "args": - [ [ { "prim": "CAST", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "nat" }, - { "prim": "nat" } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, - { "prim": "pair", - "args": - [ { "prim": "nat" }, - { "prim": - "timestamp" } ] } ] } ] }, - { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": - "nat" } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "mutez" }, - { "prim": "pair", - "args": - [ { "prim": - "nat" }, - { "prim": - "timestamp" } ] } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "nat" }, - { "prim": - "timestamp" } ] } ] } ] } ] }, - { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "address" } ] }, - { "prim": "pair", - "args": - [ { "prim": "nat" }, - { "prim": "pair", - "args": - [ { "prim": - "mutez" }, - { "prim": - "timestamp" } ] } ] } ] }, - { "prim": "key_hash" } ] }, - { "prim": "or", - "args": - [ { "prim": "nat" }, - { "prim": "unit" } ] } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "big_map", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "nat" }, - { "prim": "map", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "bool" }, - { "prim": "nat" } ] }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "nat" }, - { "prim": "mutez" } ] } ] } ] } ] } ] } ] }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "DIP", "args": [ [ { "prim": "CDR" } ] ] }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "selfIsUpdatingToken must be false." } ] }, - { "prim": "FAILWITH" } ], - [] ] } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Amount must be zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CAR" }, - { "prim": "SENDER" }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "EMPTY_MAP", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "PAIR" } ], [] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] } ], - [] ] }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The current allowance parameter must equal the sender's current allowance for the owner." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "SOME" } ] ] }, - { "prim": "UPDATE" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CAR" } ] ] }, - { "prim": "SOME" }, - { "prim": "SENDER" }, - { "prim": "UPDATE" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "PAIR" } ], - [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "selfIsUpdatingToken must be false." } ] }, - { "prim": "FAILWITH" } ], - [] ] } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "NOW" }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "NOW is greater than deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "maxTokensDeposited must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "minLqtMinted must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Amount must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CDR" }, { "prim": "INT" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "AMOUNT" }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1000000" } ] }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "The initial liquidity amount must be greater than or equal to 1 XTZ." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "SWAP" }, - { "prim": "AMOUNT" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "mutez" }, - { "int": "1" } ] } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": - "DUP" }, - { "prim": - "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": - "DUP" }, - { "prim": - "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": - "CAR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": - "DUP" }, - { "prim": - "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": - "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "DUP" }, - { "prim": - "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": - "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CAR" } ] ] }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "EMPTY_MAP", - "args": - [ { "prim": - "address" }, - { "prim": "nat" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "PAIR" } ], - [] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CAR" } ] ] }, - { "prim": "SOME" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "UPDATE" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "AMOUNT" }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" }, - { "prim": - "CAR" } ] ] } ] ] }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": - "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "PAIR" } ] ] }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIP", - "args": - [ [ { "prim": "NIL", - "args": - [ { "prim": - "operation" } ] } ] ] }, - { "prim": "CONS" }, - { "prim": "PAIR" } ], - [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "mutez" }, - { "int": "1" } ] } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "AMOUNT" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "mutez" }, - { "int": "1" } ] } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ { "int": "4" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "MUL" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "divByZero." } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "DUP" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "INT" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": - "PUSH", - "args": - [ { "prim": - "nat" }, - { "int": - "1" } ] }, - { "prim": - "ADD" } ] ] } ] ] }, - { "prim": "DUP" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "tokensDeposited is zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DIP", - "args": - [ { "int": "4" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "MUL" }, - { "prim": "DIP", - "args": - [ [ { "prim": "SWAP" } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" } ] ] }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "lqtMinted must be greater than or equal to minLqtMinted." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": - "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "DUP" } ] ] }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": - "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "tokensDeposited is greater than maxTokensDeposited." } ] }, - { "prim": - "FAILWITH" } ] ] } ] ] }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "EMPTY_MAP", - "args": - [ { "prim": - "address" }, - { "prim": "nat" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "PAIR" } ], - [] ] }, - { "prim": "DUP" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "SOME" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": - "DIG", - "args": - [ { "int": - "3" } ] }, - { "prim": - "DUP" }, - { "prim": - "CAR" } ] ] } ] ] }, - { "prim": "UPDATE" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "AMOUNT" }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" }, - { "prim": - "CAR" } ] ] } ] ] }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": - "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "PAIR" } ] ] }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIP", - "args": - [ [ { "prim": "NIL", - "args": - [ { "prim": - "operation" } ] } ] ] }, - { "prim": "CONS" }, - { "prim": "PAIR" } ] ] } ] ] } ], - [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "selfIsUpdatingToken must be false." } ] }, - { "prim": "FAILWITH" } ], - [] ] } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "NOW" }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "NOW is greater than deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Amount must be zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "minXtzWithdrawn must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "minTokensWithdrawn must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "lqtBurned must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CAR" } ] ] }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "owner has no liquidity." } ] }, - { "prim": "FAILWITH" } ], - [] ] }, { "prim": "SWAP" }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "lqtBurned is greater than owner's balance." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "SENDER" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "SWAP" }, - { "prim": "CAR" } ], - [ { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "SENDER" }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "sender has no approval balance." } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "PUSH", - "args": - [ { "prim": - "int" }, - { "int": - "0" } ] } ] ] } ] ] }, - { "prim": "SUB" }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": - "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "sender approval balance is less than LQT burned." } ] }, - { "prim": - "FAILWITH" } ] ] } ] ] }, - { "prim": "ABS" }, - { "prim": "SOME" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "SENDER" }, - { "prim": "UPDATE" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "SOME" }, - { "prim": "DUG", - "args": - [ { "int": "1" } ] }, - { "prim": "DUP" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "SWAP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "DIP", - "args": - [ [ { "prim": - "DIP", - "args": - [ [ { "prim": - "DUP" }, - { "prim": - "CAR" } ] ] } ] ] }, - { "prim": - "UPDATE" }, - { "prim": - "DIP", - "args": - [ [ { "prim": - "DUP" }, - { "prim": - "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": - "CAR" } ] ] }, - { "prim": - "SWAP" }, - { "prim": - "DROP" }, - { "prim": - "PAIR" } ] ] } ] ] } ] ] }, - { "prim": "DIP", - "args": [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1" } ] } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "MUL" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CDR" } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "divByZero." } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1" } ] }, - { "prim": "MUL" }, { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "xtzWithdrawn is less than minXtzWithdrawn." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CDR" }, - { "prim": "SWAP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" } ] ] }, - { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "divByZero." } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ { "int": "4" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "tokensWithdrawn is less than minTokensWithdrawn." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SUB" }, { "prim": "DUP" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [ { "prim": "ABS" } ], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ { "int": "5" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "DIP", - "args": [ [ { "prim": "CAR" } ] ] }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "EMPTY_MAP", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "PAIR" } ], [] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CAR" } ] ] }, - { "prim": "SOME" }, - { "prim": "DIP", - "args": - [ { "int": "5" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "UPDATE" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ { "int": "4" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "SWAP" }, - { "prim": "SUB" }, { "prim": "DUP" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [ { "prim": "ABS" } ], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, - { "prim": "SUB" }, { "prim": "DUP" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [ { "prim": "ABS" } ], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, - { "prim": "SUB" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CONTRACT", - "args": [ { "prim": "unit" } ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "UNIT" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" }, - { "prim": - "CDR" }, - { "prim": - "CAR" } ] ] } ] ] }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": - "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" } ] ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "SWAP" }, - { "prim": "CONS" }, - { "prim": "SWAP" }, - { "prim": "CONS" }, - { "prim": "PAIR" } ], - [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "selfIsUpdatingToken must be false." } ] }, - { "prim": "FAILWITH" } ], - [] ] } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "NOW" }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "NOW is greater than deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "GT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Amount must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "minTokensBought must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "xtzPool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "tokenPool must be greater than zero" } ] }, - { "prim": "FAILWITH" } ] ] } ] ] }, - { "prim": "DIP", - "args": [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1" } ] } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "1000" } ] }, - { "prim": "MUL" }, - { "prim": "AMOUNT" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1" } ] } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "999" } ] }, - { "prim": "MUL" }, - { "prim": "ADD" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "999" } ] }, - { "prim": "MUL" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "divByZero." } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" } ] ] }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "tokensBought is less than minTokensBought." } ] }, - { "prim": "FAILWITH" } ] ] } ] ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "SUB" }, { "prim": "DUP" }, - { "prim": "PUSH", - "args": - [ { "prim": "int" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LE" }, - { "prim": "IF", - "args": - [ [ { "prim": "ABS" } ], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIG", - "args": [ { "int": "2" } ] } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "AMOUNT" }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "CAR" }, - { "prim": "SELF" }, - { "prim": "ADDRESS" } ] ] } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DIP", - "args": [ [ { "prim": "PAIR" } ] ] }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIP", - "args": - [ [ { "prim": "NIL", - "args": - [ { "prim": "operation" } ] } ] ] }, - { "prim": "CONS" }, - { "prim": "PAIR" } ] ] } ] ] } ], - [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "selfIsUpdatingToken must be false." } ] }, - { "prim": "FAILWITH" } ], - [] ] } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "NOW" }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "NOW is greater than deadline." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Amount must be zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "xtzPool must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "tokenPool must be greater than zero" } ] }, - { "prim": "FAILWITH" } ] ] } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "tokensSold is zero" } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "COMPARE" }, - { "prim": "LT" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "minXtzBought must be greater than zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "999" } ] }, - { "prim": "MUL" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "1000" } ] }, - { "prim": "MUL" }, { "prim": "ADD" }, - { "prim": "DIP", - "args": [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, - { "int": "999" } ] }, - { "prim": "MUL" }, - { "prim": "DIP", - "args": - [ { "int": "3" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1" } ] } ] ] }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "" } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "MUL" }, - { "prim": "EDIV" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "divByZero." } ] }, - { "prim": "FAILWITH" } ], - [ { "prim": "CAR" } ] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "1" } ] }, - { "prim": "MUL" }, { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" } ] ] }, - { "prim": "COMPARE" }, - { "prim": "GE" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "xtzBought is less than minXtzBought." } ] }, - { "prim": "FAILWITH" } ] ] } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" } ] ] }, - { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "SUB" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" } ] ] }, - { "prim": "DIP", - "args": - [ { "int": "2" }, - [ { "prim": "DUP" } ] ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "CONTRACT", - "args": [ { "prim": "unit" } ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "DIG", - "args": [ { "int": "1" } ] }, - { "prim": "UNIT" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "DIP", - "args": - [ [ { "prim": - "CAR" }, - { "prim": - "CAR" } ] ] } ] ] }, - { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": "pair", - "args": - [ { "prim": - "address" }, - { "prim": - "nat" } ] } ] } ], - "annots": [ "%transfer" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": - "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "PAIR" } ] ] }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" } ] ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CONS" }, - { "prim": "SWAP" }, - { "prim": "CONS" }, - { "prim": "PAIR" } ], - [ { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Amount must be zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "IMPLICIT_ACCOUNT" }, - { "prim": "ADDRESS" }, - { "prim": "SENDER" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "unsafeUpdateTokenPool" } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "selfIsUpdatingToken must be false." } ] }, - { "prim": "FAILWITH" } ], - [] ] }, { "prim": "DUP" }, - { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "bool" }, - { "prim": "True" } ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CONTRACT", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "contract", - "args": - [ { "prim": "nat" } ] } ] } ], - "annots": [ "%getBalance" ] }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "bad address for get_entrypoint" } ] }, - { "prim": "FAILWITH" } ], - [] ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "SELF", - "annots": - [ "%updateTokenPoolInternal" ] }, - { "prim": "SELF" }, - { "prim": "ADDRESS" }, - { "prim": "PAIR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "DIP", - "args": - [ [ { "prim": "NIL", - "args": - [ { "prim": "operation" } ] } ] ] }, - { "prim": "CONS" }, - { "prim": "PAIR" } ] ] } ], - [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, - { "int": "0" } ] }, - { "prim": "AMOUNT" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Amount must be zero." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "Dexter did not initiate this operation." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": [ [ { "prim": "DUP" } ] ] }, - { "prim": "SWAP" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CAR" }, - { "prim": "SENDER" }, - { "prim": "COMPARE" }, - { "prim": "EQ" }, - { "prim": "IF", - "args": - [ [], - [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "The sender is not the token contract associated with this contract." } ] }, - { "prim": "FAILWITH" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "PUSH", - "args": - [ { "prim": "bool" }, - { "prim": "False" } ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CDR" } ] ] }, - { "prim": "CAR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "PAIR" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "PAIR" } ], - [ { "prim": "DROP" }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "selfIsUpdatingToken must be false." } ] }, - { "prim": "FAILWITH" } ], - [] ] }, { "prim": "DUP" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "AMOUNT" }, - { "prim": "ADD" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "DIP", - "args": - [ [ { "prim": "DUP" }, - { "prim": "DIP", - "args": - [ [ { "prim": "CAR" } ] ] }, - { "prim": "CDR" } ] ] }, - { "prim": "SWAP" }, - { "prim": "DROP" }, - { "prim": "SWAP" }, - { "prim": "PAIR" }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "PAIR" } ] ] } ] ] } ] ] } ] ] } ] diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index ebdec246c414..0d8e1e37b0ea 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -24,6 +24,7 @@ (*****************************************************************************) open Protocol.Alpha_context +open Micheline let constants_mainnet = Constants. @@ -43,7 +44,7 @@ let constants_mainnet = seed_nonce_revelation_tip = (match Tez.(one /? 8L) with Ok c -> c | Error _ -> assert false); origination_size = 257; - block_security_deposit = Tez.(mul_exn one 544); + block_security_deposit = Tez.(mul_exn one 512); endorsement_security_deposit = Tez.(mul_exn one 64); baking_reward_per_endorsement = Tez.[of_mutez_exn 1_250_000L; of_mutez_exn 187_500L]; @@ -56,10 +57,14 @@ let constants_mainnet = min_proposal_quorum = 5_00l; initial_endorsers = 24; delay_per_missing_endorsement = Period.of_seconds_exn 8L; - liquidity_baking_cpmm_origination_nonce = + liquidity_baking_cpmm_address = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) - Contract.initial_origination_nonce Operation_hash.zero; - liquidity_baking_reward = Tez.of_mutez_exn 5_000_000L; + Contract.( + originated_contract + (initial_origination_nonce + (Operation_hash.hash_bytes + [Bytes.of_string "Un festival de GADT."]))); + liquidity_baking_subsidy = Tez.of_mutez_exn 5_000_000L; (* level after protocol activation when liquidity baking shuts off *) (* set to six months *) liquidity_baking_sunset_duration = 262800l; @@ -80,6 +85,12 @@ let constants_sandbox = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; + liquidity_baking_cpmm_address = + Contract.( + originated_contract + (initial_origination_nonce + (Operation_hash.hash_bytes + [Bytes.of_string "Un festival de GADT."]))); liquidity_baking_sunset_duration = 1024l; } @@ -95,6 +106,12 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; + liquidity_baking_cpmm_address = + Contract.( + originated_contract + (initial_origination_nonce + (Operation_hash.hash_bytes + [Bytes.of_string "Un festival de GADT."]))); liquidity_baking_sunset_duration = 2048l; } @@ -120,80 +137,71 @@ let bootstrap_accounts = }) bootstrap_accounts_strings -(* For testing liquidity baking. The first is a sample FA1.2 contract and the second the CPMM. The operation hashes are forced so that the CPMM's corresponds to the origination nonce in constants (corresponding to the address KT1BEqzn5Wx8uJrZNvuS9DVHmLvG9td3fDLi) and the FA1.2's address (KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP) is included in the CPMM's initial storage. The file paths are passed by dune to gen.exe or the relative ones here are used if parameters_of_constants is called directly. *) -let bootstrap_contracts_strings = - [ ( None, - 2_000_000_000_000L, - "Pair {} 2000000000000", - Contract.initial_origination_nonce - Operation_hash.(of_hex_exn (`Hex (String.make (size * 2) '1'))) ); - ( None, - 4_000_000_000_000L, - "Pair {} (Pair (Pair False 4000000000000) (Pair \ - \"KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP\" (Pair 2000000000000 \ - 2000000000000)))", - Contract.initial_origination_nonce Operation_hash.zero ) ] - -let bootstrap_contracts_filepaths = ["fa12.json"; "cpmm.json"] - -let parse_storage source = - Michelson_v1_parser.parse_expression ?check:(Some true) source - |> Tezos_micheline.Micheline_parser.no_parsing_error - |> function - | Error _ -> - assert false - | Ok parsing_result -> - parsing_result.Michelson_v1_parser.expanded - -exception Failed of string - -let fail_awakener = ref None - -let fail x = - Printf.ksprintf - (fun message -> - ( match !fail_awakener with - | None -> - () - | Some awakener -> - fail_awakener := None ; - Lwt.wakeup_later_exn awakener (Failed message) ) ; - raise (Failed message)) - x - -let parse_file file = - let with_open_in file read_f = - let chan = open_in file in - try - let value = read_f chan in - close_in chan ; value - with x -> close_in chan ; raise x - in - try with_open_in file (fun chan -> Ezjsonm.from_channel chan) - with Ezjsonm.Parse_error (_, message) -> - fail "%s: invalid JSON: %s" file message - -let build_bootstrap_contracts filepaths = - let result = - List.map2 - ~when_different_lengths:"" - (fun (d, a, st, n) sc -> - let amount = Tez.of_mutez_exn a in - let code = parse_file sc in - let script = +(* For testing liquidity baking. The first is a sample FA1.2 contract and the second the CPMM. The FA1.2 contract's address is included in the CPMM's initial storage. *) +let test_bootstrap_contracts = + [ Parameters. + { + delegate = None; + amount = Tez.of_mutez_exn 4_000_000_000_000L; + script = Script. { code = + Script.lazy_expr (Micheline.strip_locations Test_cpmm.script); + storage = Script.lazy_expr - (Data_encoding.Json.destruct Script.expr_encoding code); - storage = Script.lazy_expr (parse_storage st); - } - in - Parameters.{delegate = d; amount; script; origination_nonce = Some n}) - bootstrap_contracts_strings - filepaths - in - match result with Ok x -> x | Error _ -> [] + (Micheline.strip_locations + (Prim + ( 0, + D_Pair, + [ Seq (1, []); + Prim + ( 2, + D_Pair, + [ Prim + ( 3, + D_Pair, + [ Prim (4, D_False, [], []); + Int (5, Z.of_int 4000000000000) ], + [] ); + Prim + ( 6, + D_Pair, + [ String + ( 7, + "KT1CSKPf2jeLpMmrgKquN2bCjBTkAcAdRVDy" + ); + Prim + ( 8, + D_Pair, + [ Int (9, Z.of_int 2000000000000); + Int (10, Z.of_int 2000000000000) + ], + [] ) ], + [] ) ], + [] ) ], + [] ))); + }; + }; + Parameters. + { + delegate = None; + amount = Tez.of_mutez_exn 2_000_000_000_000L; + script = + Script. + { + code = + Script.lazy_expr (Micheline.strip_locations Test_fa12.script); + storage = + Script.lazy_expr + (Micheline.strip_locations + (Prim + ( 0, + D_Pair, + [Seq (1, []); Int (2, Z.of_int 2000000000000)], + [] ))); + }; + } ] (* TODO this could be generated from OCaml together with the faucet for now these are hardcoded values in the tests *) diff --git a/src/proto_alpha/lib_parameters/default_parameters.mli b/src/proto_alpha/lib_parameters/default_parameters.mli index 3700e1350a7d..3f59176d3409 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.mli +++ b/src/proto_alpha/lib_parameters/default_parameters.mli @@ -35,10 +35,7 @@ val make_bootstrap_account : Signature.public_key_hash * Signature.public_key * Tez.t -> Parameters.bootstrap_account -val build_bootstrap_contracts : - string list -> Parameters.bootstrap_contract list - -val bootstrap_contracts_filepaths : string list +val test_bootstrap_contracts : Parameters.bootstrap_contract list val parameters_of_constants : ?bootstrap_accounts:Parameters.bootstrap_account list -> diff --git a/src/proto_alpha/lib_parameters/dune b/src/proto_alpha/lib_parameters/dune index 2a3097764d16..a33342f225e8 100644 --- a/src/proto_alpha/lib_parameters/dune +++ b/src/proto_alpha/lib_parameters/dune @@ -24,20 +24,12 @@ (rule (targets sandbox-parameters.json) (deps gen.exe) - (action (run - %{deps} - --sandbox - %{lib:tezos-protocol-alpha-parameters:fa12.json} - %{lib:tezos-protocol-alpha-parameters:cpmm.json}))) + (action (run %{deps} --sandbox))) (rule (targets test-parameters.json) (deps gen.exe) - (action (run - %{deps} - --test - %{lib:tezos-protocol-alpha-parameters:fa12.json} - %{lib:tezos-protocol-alpha-parameters:cpmm.json}))) + (action (run %{deps} --test))) (rule (targets mainnet-parameters.json) @@ -46,7 +38,7 @@ (install (section lib) - (files sandbox-parameters.json test-parameters.json mainnet-parameters.json fa12.json cpmm.json)) + (files sandbox-parameters.json test-parameters.json mainnet-parameters.json)) (rule (alias runtest_lint) diff --git a/src/proto_alpha/lib_parameters/fa12.json b/src/proto_alpha/lib_parameters/fa12.json deleted file mode 100644 index 815c399b2201..000000000000 --- a/src/proto_alpha/lib_parameters/fa12.json +++ /dev/null @@ -1,443 +0,0 @@ -[ { "prim": "parameter", - "args": - [ { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ "%spender" ] }, - { "prim": "nat", "annots": [ "%value" ] } ], - "annots": [ "%approve" ] }, - { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address", - "annots": [ "%owner" ] }, - { "prim": "address", - "annots": [ "%spender" ] } ] }, - { "prim": "contract", - "args": [ { "prim": "nat" } ] } ], - "annots": [ "%getAllowance" ] } ] }, - { "prim": "or", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address", "annots": [ "%owner" ] }, - { "prim": "contract", - "args": [ { "prim": "nat" } ] } ], - "annots": [ "%getBalance" ] }, - { "prim": "pair", - "args": - [ { "prim": "unit" }, - { "prim": "contract", - "args": [ { "prim": "nat" } ] } ], - "annots": [ "%getTotalSupply" ] } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "address", "annots": [ "%from" ] }, - { "prim": "pair", - "args": - [ { "prim": "address", "annots": [ "%to" ] }, - { "prim": "nat", "annots": [ "%value" ] } ] } ], - "annots": [ "%transfer" ] } ] } ] }, - { "prim": "storage", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "big_map", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "map", - "args": - [ { "prim": "address" }, { "prim": "nat" } ], - "annots": [ "%allowances" ] }, - { "prim": "nat", "annots": [ "%balance" ] } ] } ], - "annots": [ "%ledger" ] }, - { "prim": "nat", "annots": [ "%totalSupply" ] } ] } ] }, - { "prim": "code", - "args": - [ [ { "prim": "NIL", "args": [ { "prim": "operation" } ] }, - { "prim": "LAMBDA", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "big_map", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "map", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, - { "prim": "nat" } ] } ] }, - { "prim": "nat" } ] } ] }, - { "prim": "pair", - "args": - [ { "prim": "map", - "args": [ { "prim": "address" }, { "prim": "nat" } ] }, - { "prim": "nat" } ] }, - [ { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "SWAP" }, { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "EMPTY_MAP", - "args": - [ { "prim": "address" }, { "prim": "nat" } ] }, - { "prim": "PAIR" } ], [] ] } ] ] }, - { "prim": "LAMBDA", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "pair", - "args": - [ { "prim": "map", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, - { "prim": "nat" } ] }, - { "prim": "address" } ] }, - { "prim": "pair", - "args": - [ { "prim": "big_map", - "args": - [ { "prim": "address" }, - { "prim": "pair", - "args": - [ { "prim": "map", - "args": - [ { "prim": "address" }, - { "prim": "nat" } ] }, - { "prim": "nat" } ] } ] }, - { "prim": "nat" } ] } ] }, { "prim": "nat" }, - [ { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "DROP" }, - { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "CAR" }, { "prim": "SWAP" }, - { "prim": "GET" }, - { "prim": "IF_NONE", - "args": - [ [ { "prim": "PUSH", - "args": [ { "prim": "nat" }, { "int": "0" } ] } ], - [] ] } ] ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, { "prim": "DUP" }, - { "prim": "CDR" }, { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "SENDER" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "PAIR" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "5" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "PUSH", - "args": - [ { "prim": "nat" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "GT" }, - { "prim": "AND" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": - "UnsafeAllowanceChange" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "SOME" }, - { "prim": "SWAP" }, { "prim": "UPDATE" }, - { "prim": "PAIR" }, { "prim": "SOME" }, - { "prim": "SENDER" }, { "prim": "UPDATE" }, - { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "PAIR" } ], - [ { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DROP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "CDR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "5" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "PAIR" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ], - [ { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "DROP" }, - { "prim": "IF_LEFT", - "args": - [ [ { "prim": "DUP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "CAR" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "PAIR" }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "3" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "CONS" }, { "prim": "PAIR" } ], - [ { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "DROP" }, { "prim": "CDR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", - "args": [ { "int": "2" } ] }, - { "prim": "NIL", - "args": [ { "prim": "operation" } ] }, - { "prim": "DIG", - "args": [ { "int": "2" } ] }, - { "prim": "PUSH", - "args": - [ { "prim": "mutez" }, { "int": "0" } ] }, - { "prim": "DIG", - "args": [ { "int": "4" } ] }, - { "prim": "CDR" }, - { "prim": "TRANSFER_TOKENS" }, - { "prim": "CONS" }, { "prim": "PAIR" } ] ] } ] ] } ], - [ { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CDR" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, { "prim": "CDR" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, - { "prim": "DIG", "args": [ { "int": "6" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "7" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "COMPARE" }, { "prim": "LT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "NotEnoughBalance" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "SENDER" }, - { "prim": "DIG", "args": [ { "int": "4" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "5" } ] }, - { "prim": "COMPARE" }, { "prim": "NEQ" }, - { "prim": "IF", - "args": - [ [ { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "3" } ] }, - { "prim": "SENDER" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "3" } ] }, - { "prim": "PAIR" }, { "prim": "PAIR" }, - { "prim": "DIG", "args": [ { "int": "6" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "COMPARE" }, { "prim": "LT" }, - { "prim": "IF", - "args": - [ [ { "prim": "PUSH", - "args": - [ { "prim": "string" }, - { "string": "NotEnoughAllowance" } ] }, - { "prim": "FAILWITH" } ], [] ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "4" } ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "SUB" }, { "prim": "ABS" }, - { "prim": "SOME" }, { "prim": "SENDER" }, - { "prim": "UPDATE" }, { "prim": "PAIR" } ], - [ { "prim": "DIG", "args": [ { "int": "5" } ] }, - { "prim": "DROP" } ] ] }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "SUB" }, { "prim": "ABS" }, - { "prim": "SWAP" }, { "prim": "CAR" }, { "prim": "PAIR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "3" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DIG", "args": [ { "int": "4" } ] }, - { "prim": "SWAP" }, { "prim": "SOME" }, { "prim": "SWAP" }, - { "prim": "UPDATE" }, { "prim": "PAIR" }, - { "prim": "DUP" }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "4" } ] }, - { "prim": "PAIR" }, - { "prim": "DIG", "args": [ { "int": "4" } ] }, - { "prim": "SWAP" }, { "prim": "EXEC" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "SWAP" }, { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, { "prim": "ADD" }, { "prim": "SWAP" }, - { "prim": "CAR" }, { "prim": "PAIR" }, { "prim": "SWAP" }, - { "prim": "DUP" }, - { "prim": "DUG", "args": [ { "int": "2" } ] }, - { "prim": "CDR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "CAR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, - { "prim": "DIG", "args": [ { "int": "3" } ] }, - { "prim": "SWAP" }, { "prim": "SOME" }, { "prim": "SWAP" }, - { "prim": "UPDATE" }, { "prim": "PAIR" }, - { "prim": "SWAP" }, { "prim": "PAIR" } ] ] } ] ] } ] - diff --git a/src/proto_alpha/lib_parameters/gen.ml b/src/proto_alpha/lib_parameters/gen.ml index 3a447725c385..ea006d42f506 100644 --- a/src/proto_alpha/lib_parameters/gen.ml +++ b/src/proto_alpha/lib_parameters/gen.ml @@ -25,7 +25,7 @@ (* Prints the json encoding of the parametric constants of protocol alpha. $ dune utop src/proto_alpha/lib_protocol/test/helpers/ constants.ml -*) + *) let () = let print_usage_and_fail s = @@ -44,25 +44,19 @@ let () = else match Sys.argv.(1) with | "--sandbox" -> - let bootstrap_contracts = - Default_parameters.build_bootstrap_contracts - (Array.to_list (Array.sub Sys.argv 2 2)) - in dump Default_parameters.( - parameters_of_constants constants_sandbox ~bootstrap_contracts) + parameters_of_constants + constants_sandbox + ~bootstrap_contracts:test_bootstrap_contracts) "sandbox-parameters.json" | "--test" -> - let bootstrap_contracts = - Default_parameters.build_bootstrap_contracts - (Array.to_list (Array.sub Sys.argv 2 2)) - in dump Default_parameters.( parameters_of_constants ~with_commitments:true - constants_test - ~bootstrap_contracts) + constants_sandbox + ~bootstrap_contracts:test_bootstrap_contracts) "test-parameters.json" | "--mainnet" -> dump diff --git a/src/proto_alpha/lib_parameters/michelson_v1_macros.ml b/src/proto_alpha/lib_parameters/michelson_v1_macros.ml deleted file mode 100644 index a2e1bb897b08..000000000000 --- a/src/proto_alpha/lib_parameters/michelson_v1_macros.ml +++ /dev/null @@ -1,1542 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* Copyright (c) 2019 Nomadic Labs *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -open Tezos_micheline -open Micheline -module IntMap = Map.Make (Compare.Int) - -type 'l node = ('l, string) Micheline.node - -type error += Unexpected_macro_annotation of string - -type error += Sequence_expected of string - -type error += Invalid_arity of string * int * int - -let rec check_letters str i j f = - i > j || (f str.[i] && check_letters str (i + 1) j f) - -let expand_caddadr original = - match original with - | Prim (loc, str, args, annot) -> - let len = String.length str in - if - len > 3 - && str.[0] = 'C' - && str.[len - 1] = 'R' - && check_letters str 1 (len - 2) (function - | 'A' | 'D' -> - true - | _ -> - false) - then - ( match args with - | [] -> - ok () - | _ :: _ -> - error (Invalid_arity (str, List.length args, 0)) ) - >>? fun () -> - let path_annot = - List.filter (function "@%" | "@%%" -> true | _ -> false) annot - in - let rec parse i acc = - if i = 0 then Seq (loc, acc) - else - let annot = if i = len - 2 then annot else path_annot in - match str.[i] with - | 'A' -> - parse (i - 1) (Prim (loc, "CAR", [], annot) :: acc) - | 'D' -> - parse (i - 1) (Prim (loc, "CDR", [], annot) :: acc) - | _ -> - assert false - in - ok (Some (parse (len - 2) [])) - else ok None - | _ -> - ok None - -let expand_carn original = - match original with - | Prim (loc, "CAR", [Int (loc2, n)], annot) -> - ok - (Some - (Seq - ( loc, - [ Prim - ( loc, - "GET", - [Int (loc2, Z.(of_int 1 + (n * of_int 2)))], - annot ) ] ))) - | _ -> - ok None - -let expand_cdrn original = - match original with - | Prim (loc, "CDR", [Int (loc2, n)], annot) -> - ok - (Some - (Seq - (loc, [Prim (loc, "GET", [Int (loc2, Z.(n * of_int 2))], annot)]))) - | _ -> - ok None - -let extract_field_annots annot = - List.partition - (fun a -> - match a.[0] with - | '%' -> - true - | _ -> - false - | exception Invalid_argument _ -> - false) - annot - -let expand_set_caddadr original = - match original with - | Prim (loc, str, args, annot) -> - let len = String.length str in - if - len >= 7 - && String.sub str 0 5 = "SET_C" - && str.[len - 1] = 'R' - && check_letters str 5 (len - 2) (function - | 'A' | 'D' -> - true - | _ -> - false) - then - ( match args with - | [] -> - ok () - | _ :: _ -> - error (Invalid_arity (str, List.length args, 0)) ) - >>? fun () -> - ( match extract_field_annots annot with - | ([], annot) -> - ok (None, annot) - | ([f], annot) -> - ok (Some f, annot) - | (_, _) -> - error (Unexpected_macro_annotation str) ) - >>? fun (field_annot, annot) -> - let rec parse i acc = - if i = 4 then acc - else - let annot = if i = 5 then annot else [] in - match str.[i] with - | 'A' -> - let acc = - Seq - ( loc, - [ Prim (loc, "DUP", [], []); - Prim - ( loc, - "DIP", - [Seq (loc, [Prim (loc, "CAR", [], ["@%%"]); acc])], - [] ); - Prim (loc, "CDR", [], ["@%%"]); - Prim (loc, "SWAP", [], []); - Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) - in - parse (i - 1) acc - | 'D' -> - let acc = - Seq - ( loc, - [ Prim (loc, "DUP", [], []); - Prim - ( loc, - "DIP", - [Seq (loc, [Prim (loc, "CDR", [], ["@%%"]); acc])], - [] ); - Prim (loc, "CAR", [], ["@%%"]); - Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) - in - parse (i - 1) acc - | _ -> - assert false - in - match str.[len - 2] with - | 'A' -> - let access_check = - match field_annot with - | None -> - [] - | Some f -> - [ Prim (loc, "DUP", [], []); - Prim (loc, "CAR", [], [f]); - Prim (loc, "DROP", [], []) ] - in - let encoding = - [Prim (loc, "CDR", [], ["@%%"]); Prim (loc, "SWAP", [], [])] - in - let pair = - [ Prim - ( loc, - "PAIR", - [], - [Option.value field_annot ~default:"%"; "%@"] ) ] - in - let init = Seq (loc, access_check @ encoding @ pair) in - ok (Some (parse (len - 3) init)) - | 'D' -> - let access_check = - match field_annot with - | None -> - [] - | Some f -> - [ Prim (loc, "DUP", [], []); - Prim (loc, "CDR", [], [f]); - Prim (loc, "DROP", [], []) ] - in - let encoding = [Prim (loc, "CAR", [], ["@%%"])] in - let pair = - [ Prim - ( loc, - "PAIR", - [], - ["%@"; Option.value field_annot ~default:"%"] ) ] - in - let init = Seq (loc, access_check @ encoding @ pair) in - ok (Some (parse (len - 3) init)) - | _ -> - assert false - else ok None - | _ -> - ok None - -let expand_map_caddadr original = - match original with - | Prim (loc, str, args, annot) -> - let len = String.length str in - if - len >= 7 - && String.sub str 0 5 = "MAP_C" - && str.[len - 1] = 'R' - && check_letters str 5 (len - 2) (function - | 'A' | 'D' -> - true - | _ -> - false) - then - ( match args with - | [(Seq _ as code)] -> - ok code - | [_] -> - error (Sequence_expected str) - | [] | _ :: _ :: _ -> - error (Invalid_arity (str, List.length args, 1)) ) - >>? fun code -> - ( match extract_field_annots annot with - | ([], annot) -> - ok (None, annot) - | ([f], annot) -> - ok (Some f, annot) - | (_, _) -> - error (Unexpected_macro_annotation str) ) - >>? fun (field_annot, annot) -> - let rec parse i acc = - if i = 4 then acc - else - let annot = if i = 5 then annot else [] in - match str.[i] with - | 'A' -> - let acc = - Seq - ( loc, - [ Prim (loc, "DUP", [], []); - Prim - ( loc, - "DIP", - [Seq (loc, [Prim (loc, "CAR", [], ["@%%"]); acc])], - [] ); - Prim (loc, "CDR", [], ["@%%"]); - Prim (loc, "SWAP", [], []); - Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) - in - parse (i - 1) acc - | 'D' -> - let acc = - Seq - ( loc, - [ Prim (loc, "DUP", [], []); - Prim - ( loc, - "DIP", - [Seq (loc, [Prim (loc, "CDR", [], ["@%%"]); acc])], - [] ); - Prim (loc, "CAR", [], ["@%%"]); - Prim (loc, "PAIR", [], "%@" :: "%@" :: annot) ] ) - in - parse (i - 1) acc - | _ -> - assert false - in - let cr_annot = - match field_annot with - | None -> - [] - | Some f -> - ["@" ^ String.sub f 1 (String.length f - 1)] - in - match str.[len - 2] with - | 'A' -> - let init = - Seq - ( loc, - [ Prim (loc, "DUP", [], []); - Prim (loc, "CDR", [], ["@%%"]); - Prim - ( loc, - "DIP", - [Seq (loc, [Prim (loc, "CAR", [], cr_annot); code])], - [] ); - Prim (loc, "SWAP", [], []); - Prim - ( loc, - "PAIR", - [], - [Option.value field_annot ~default:"%"; "%@"] ) ] ) - in - ok (Some (parse (len - 3) init)) - | 'D' -> - let init = - Seq - ( loc, - [ Prim (loc, "DUP", [], []); - Prim (loc, "CDR", [], cr_annot); - code; - Prim (loc, "SWAP", [], []); - Prim (loc, "CAR", [], ["@%%"]); - Prim - ( loc, - "PAIR", - [], - ["%@"; Option.value field_annot ~default:"%"] ) ] ) - in - ok (Some (parse (len - 3) init)) - | _ -> - assert false - else ok None - | _ -> - ok None - -exception Not_a_roman - -let decimal_of_roman roman = - (* http://rosettacode.org/wiki/Roman_numerals/Decode#OCaml *) - let arabic = ref 0 in - let lastval = ref 0 in - for i = String.length roman - 1 downto 0 do - let n = - match roman.[i] with - | 'M' -> - 1000 - | 'D' -> - 500 - | 'C' -> - 100 - | 'L' -> - 50 - | 'X' -> - 10 - | 'V' -> - 5 - | 'I' -> - 1 - | _ -> - raise_notrace Not_a_roman - in - if Compare.Int.(n < !lastval) then arabic := !arabic - n - else arabic := !arabic + n ; - lastval := n - done ; - !arabic - -let dip ~loc ?(annot = []) depth instr = - assert (depth >= 0) ; - if depth = 1 then Prim (loc, "DIP", [instr], annot) - else Prim (loc, "DIP", [Int (loc, Z.of_int depth); instr], annot) - -let expand_deprecated_dxiiivp original = - (* transparently expands deprecated macro [DI...IP] to instruction [DIP n] *) - match original with - | Prim (loc, str, args, annot) -> - let len = String.length str in - if len > 3 && str.[0] = 'D' && str.[len - 1] = 'P' then - try - let depth = decimal_of_roman (String.sub str 1 (len - 2)) in - match args with - | [(Seq (_, _) as arg)] -> - ok @@ Some (dip ~loc ~annot depth arg) - | [_] -> - error (Sequence_expected str) - | [] | _ :: _ :: _ -> - error (Invalid_arity (str, List.length args, 1)) - with Not_a_roman -> ok None - else ok None - | _ -> - ok None - -exception Not_a_pair - -type pair_item = A | I | P of int * pair_item * pair_item - -let parse_pair_substr str ~len start = - let rec parse ?left i = - if i = len - 1 then raise_notrace Not_a_pair - else if str.[i] = 'P' then - let (next_i, l) = parse ~left:true (i + 1) in - let (next_i, r) = parse ~left:false next_i in - (next_i, P (i, l, r)) - else if str.[i] = 'A' && left = Some true then (i + 1, A) - else if str.[i] = 'I' && left <> Some true then (i + 1, I) - else raise_notrace Not_a_pair - in - let (last, ast) = parse start in - if last <> len - 1 then raise_notrace Not_a_pair else ast - -let unparse_pair_item ast = - let rec unparse ast acc = - match ast with - | P (_, l, r) -> - unparse r (unparse l ("P" :: acc)) - | A -> - "A" :: acc - | I -> - "I" :: acc - in - List.rev ("R" :: unparse ast []) |> String.concat "" - -let pappaiir_annots_pos ast annot = - let rec find_annots_pos p_pos ast annots acc = - match (ast, annots) with - | (_, []) -> - (annots, acc) - | (P (i, left, right), _) -> - let (annots, acc) = find_annots_pos i left annots acc in - find_annots_pos i right annots acc - | (A, a :: annots) -> - let pos = - match IntMap.find p_pos acc with - | None -> - ([a], []) - | Some (_, cdr) -> - ([a], cdr) - in - (annots, IntMap.add p_pos pos acc) - | (I, a :: annots) -> - let pos = - match IntMap.find p_pos acc with - | None -> - ([], [a]) - | Some (car, _) -> - (car, [a]) - in - (annots, IntMap.add p_pos pos acc) - in - snd (find_annots_pos 0 ast annot IntMap.empty) - -let expand_pappaiir original = - match original with - | Prim (loc, str, args, annot) -> - let len = String.length str in - if - len > 4 - && str.[0] = 'P' - && str.[len - 1] = 'R' - && check_letters str 1 (len - 2) (function - | 'P' | 'A' | 'I' -> - true - | _ -> - false) - then - try - let (field_annots, annot) = extract_field_annots annot in - let ast = parse_pair_substr str ~len 0 in - let field_annots_pos = pappaiir_annots_pos ast field_annots in - let rec parse p (depth, acc) = - match p with - | P (i, left, right) -> - let annot = - match (i, IntMap.find i field_annots_pos) with - | (0, None) -> - annot - | (_, None) -> - [] - | (0, Some ([], cdr_annot)) -> - ("%" :: cdr_annot) @ annot - | (_, Some ([], cdr_annot)) -> - "%" :: cdr_annot - | (0, Some (car_annot, cdr_annot)) -> - car_annot @ cdr_annot @ annot - | (_, Some (car_annot, cdr_annot)) -> - car_annot @ cdr_annot - in - let acc = - if depth = 0 then Prim (loc, "PAIR", [], annot) :: acc - else - dip ~loc depth (Seq (loc, [Prim (loc, "PAIR", [], annot)])) - :: acc - in - (depth, acc) |> parse left |> parse right - | A | I -> - (depth + 1, acc) - in - let (_, expanded) = parse ast (0, []) in - ( match args with - | [] -> - ok () - | _ :: _ -> - error (Invalid_arity (str, List.length args, 0)) ) - >>? fun () -> ok (Some (Seq (loc, expanded))) - with Not_a_pair -> ok None - else ok None - | _ -> - ok None - -let expand_unpappaiir original = - match original with - | Prim (loc, str, args, _annot) -> - let len = String.length str in - if - len > 6 - && String.sub str 0 3 = "UNP" - && str.[len - 1] = 'R' - && check_letters str 3 (len - 2) (function - | 'P' | 'A' | 'I' -> - true - | _ -> - false) - then - try - let unpair = Prim (loc, "UNPAIR", [], []) in - let ast = parse_pair_substr str ~len 2 in - let rec parse p (depth, acc) = - match p with - | P (_i, left, right) -> - let acc = - if depth = 0 then unpair :: acc - else dip ~loc depth (Seq (loc, [unpair])) :: acc - in - (depth, acc) |> parse left |> parse right - | A | I -> - (depth + 1, acc) - in - let (_, rev_expanded) = parse ast (0, []) in - let expanded = Seq (loc, List.rev rev_expanded) in - ( match args with - | [] -> - ok () - | _ :: _ -> - error (Invalid_arity (str, List.length args, 0)) ) - >>? fun () -> ok (Some expanded) - with Not_a_pair -> ok None - else ok None - | _ -> - ok None - -exception Not_a_dup - -let expand_deprecated_duuuuup original = - (* transparently expands deprecated macro [DU...UP] to [{ DUP n }] *) - match original with - | Prim (loc, str, args, annot) -> - let len = String.length str in - if - len > 3 - && str.[0] = 'D' - && str.[len - 1] = 'P' - && check_letters str 1 (len - 2) (( = ) 'U') - then - ( match args with - | [] -> - ok () - | _ :: _ -> - error (Invalid_arity (str, List.length args, 0)) ) - >>? fun () -> - try - let rec parse i = - if i = 1 then - Prim (loc, "DUP", [Int (loc, Z.of_int (len - 2))], annot) - else if str.[i] = 'U' then parse (i - 1) - else raise_notrace Not_a_dup - in - ok (Some (parse (len - 2))) - with Not_a_dup -> ok None - else ok None - | _ -> - ok None - -let expand_compare original = - let cmp loc is annot = - let is = - match List.rev_map (fun i -> Prim (loc, i, [], [])) is with - | Prim (loc, i, args, _) :: r -> - List.rev (Prim (loc, i, args, annot) :: r) - | is -> - List.rev is - in - ok (Some (Seq (loc, is))) - in - let ifcmp loc is l r annot = - let is = - List.map (fun i -> Prim (loc, i, [], [])) is - @ [Prim (loc, "IF", [l; r], annot)] - in - ok (Some (Seq (loc, is))) - in - match original with - | Prim (loc, "CMPEQ", [], annot) -> - cmp loc ["COMPARE"; "EQ"] annot - | Prim (loc, "CMPNEQ", [], annot) -> - cmp loc ["COMPARE"; "NEQ"] annot - | Prim (loc, "CMPLT", [], annot) -> - cmp loc ["COMPARE"; "LT"] annot - | Prim (loc, "CMPGT", [], annot) -> - cmp loc ["COMPARE"; "GT"] annot - | Prim (loc, "CMPLE", [], annot) -> - cmp loc ["COMPARE"; "LE"] annot - | Prim (loc, "CMPGE", [], annot) -> - cmp loc ["COMPARE"; "GE"] annot - | Prim - ( _, - (("CMPEQ" | "CMPNEQ" | "CMPLT" | "CMPGT" | "CMPLE" | "CMPGE") as str), - args, - [] ) -> - error (Invalid_arity (str, List.length args, 0)) - | Prim (loc, "IFCMPEQ", [l; r], annot) -> - ifcmp loc ["COMPARE"; "EQ"] l r annot - | Prim (loc, "IFCMPNEQ", [l; r], annot) -> - ifcmp loc ["COMPARE"; "NEQ"] l r annot - | Prim (loc, "IFCMPLT", [l; r], annot) -> - ifcmp loc ["COMPARE"; "LT"] l r annot - | Prim (loc, "IFCMPGT", [l; r], annot) -> - ifcmp loc ["COMPARE"; "GT"] l r annot - | Prim (loc, "IFCMPLE", [l; r], annot) -> - ifcmp loc ["COMPARE"; "LE"] l r annot - | Prim (loc, "IFCMPGE", [l; r], annot) -> - ifcmp loc ["COMPARE"; "GE"] l r annot - | Prim (loc, "IFEQ", [l; r], annot) -> - ifcmp loc ["EQ"] l r annot - | Prim (loc, "IFNEQ", [l; r], annot) -> - ifcmp loc ["NEQ"] l r annot - | Prim (loc, "IFLT", [l; r], annot) -> - ifcmp loc ["LT"] l r annot - | Prim (loc, "IFGT", [l; r], annot) -> - ifcmp loc ["GT"] l r annot - | Prim (loc, "IFLE", [l; r], annot) -> - ifcmp loc ["LE"] l r annot - | Prim (loc, "IFGE", [l; r], annot) -> - ifcmp loc ["GE"] l r annot - | Prim - ( _, - ( ( "IFCMPEQ" - | "IFCMPNEQ" - | "IFCMPLT" - | "IFCMPGT" - | "IFCMPLE" - | "IFCMPGE" - | "IFEQ" - | "IFNEQ" - | "IFLT" - | "IFGT" - | "IFLE" - | "IFGE" ) as str ), - args, - [] ) -> - error (Invalid_arity (str, List.length args, 2)) - | Prim - ( _, - ( ( "IFCMPEQ" - | "IFCMPNEQ" - | "IFCMPLT" - | "IFCMPGT" - | "IFCMPLE" - | "IFCMPGE" - | "IFEQ" - | "IFNEQ" - | "IFLT" - | "IFGT" - | "IFLE" - | "IFGE" ) as str ), - [], - _ :: _ ) -> - error (Unexpected_macro_annotation str) - | _ -> - ok None - -let expand_asserts original = - let may_rename loc = function - | [] -> - Seq (loc, []) - | annot -> - Seq (loc, [Prim (loc, "RENAME", [], annot)]) - in - let fail_false ?(annot = []) loc = - [may_rename loc annot; Seq (loc, [Prim (loc, "FAIL", [], [])])] - in - let fail_true ?(annot = []) loc = - [Seq (loc, [Prim (loc, "FAIL", [], [])]); may_rename loc annot] - in - match original with - | Prim (loc, "ASSERT", [], []) -> - ok @@ Some (Seq (loc, [Prim (loc, "IF", fail_false loc, [])])) - | Prim (loc, "ASSERT_NONE", [], []) -> - ok @@ Some (Seq (loc, [Prim (loc, "IF_NONE", fail_false loc, [])])) - | Prim (loc, "ASSERT_SOME", [], annot) -> - ok @@ Some (Seq (loc, [Prim (loc, "IF_NONE", fail_true ~annot loc, [])])) - | Prim (loc, "ASSERT_LEFT", [], annot) -> - ok - @@ Some (Seq (loc, [Prim (loc, "IF_LEFT", fail_false ~annot loc, [])])) - | Prim (loc, "ASSERT_RIGHT", [], annot) -> - ok @@ Some (Seq (loc, [Prim (loc, "IF_LEFT", fail_true ~annot loc, [])])) - | Prim - ( _, - ( ( "ASSERT" - | "ASSERT_NONE" - | "ASSERT_SOME" - | "ASSERT_LEFT" - | "ASSERT_RIGHT" ) as str ), - args, - [] ) -> - error (Invalid_arity (str, List.length args, 0)) - | Prim (_, (("ASSERT" | "ASSERT_NONE") as str), [], _ :: _) -> - error (Unexpected_macro_annotation str) - | Prim (loc, s, args, annot) - when String.(length s > 7 && equal (sub s 0 7) "ASSERT_") -> ( - ( match args with - | [] -> - ok () - | _ :: _ -> - error (Invalid_arity (s, List.length args, 0)) ) - >>? fun () -> - ( match annot with - | _ :: _ -> - error (Unexpected_macro_annotation s) - | [] -> - ok () ) - >>? fun () -> - let remaining = String.(sub s 7 (length s - 7)) in - let remaining_prim = Prim (loc, remaining, [], []) in - match remaining with - | "EQ" | "NEQ" | "LT" | "LE" | "GE" | "GT" -> - ok - @@ Some - (Seq - (loc, [remaining_prim; Prim (loc, "IF", fail_false loc, [])])) - | _ -> ( - expand_compare remaining_prim - >|? function - | None -> - None - | Some seq -> - Some (Seq (loc, [seq; Prim (loc, "IF", fail_false loc, [])])) ) ) - | _ -> - ok None - -let expand_if_some = function - | Prim (loc, "IF_SOME", [right; left], annot) -> - ok @@ Some (Seq (loc, [Prim (loc, "IF_NONE", [left; right], annot)])) - | Prim (_, "IF_SOME", args, _annot) -> - error (Invalid_arity ("IF_SOME", List.length args, 2)) - | _ -> - ok @@ None - -let expand_if_right = function - | Prim (loc, "IF_RIGHT", [right; left], annot) -> - ok @@ Some (Seq (loc, [Prim (loc, "IF_LEFT", [left; right], annot)])) - | Prim (_, "IF_RIGHT", args, _annot) -> - error (Invalid_arity ("IF_RIGHT", List.length args, 2)) - | _ -> - ok @@ None - -let expand_fail = function - | Prim (loc, "FAIL", [], []) -> - ok - @@ Some - (Seq - ( loc, - [Prim (loc, "UNIT", [], []); Prim (loc, "FAILWITH", [], [])] )) - | _ -> - ok @@ None - -let expand original = - let rec try_expansions = function - | [] -> - ok @@ original - | expander :: expanders -> ( - expander original - >>? function - | None -> try_expansions expanders | Some rewritten -> ok rewritten ) - in - try_expansions - [ expand_carn; - expand_cdrn; - expand_caddadr; - expand_set_caddadr; - expand_map_caddadr; - expand_deprecated_dxiiivp; - (* expand_paaiair ; *) - expand_pappaiir; - (* expand_unpaaiair ; *) - expand_unpappaiir; - expand_deprecated_duuuuup; - expand_compare; - expand_asserts; - expand_if_some; - expand_if_right; - expand_fail ] - -let expand_rec expr = - let rec error_map (expanded, errors) f = function - | [] -> - (List.rev expanded, List.rev errors) - | hd :: tl -> - let (new_expanded, new_errors) = f hd in - error_map - (new_expanded :: expanded, List.rev_append new_errors errors) - f - tl - in - let error_map = error_map ([], []) in - let rec expand_rec expr = - match expand expr with - | Ok expanded -> ( - match expanded with - | Seq (loc, items) -> - let (items, errors) = error_map expand_rec items in - (Seq (loc, items), errors) - | Prim (loc, name, args, annot) -> - let (args, errors) = error_map expand_rec args in - (Prim (loc, name, args, annot), errors) - | (Int _ | String _ | Bytes _) as atom -> - (atom, []) ) - | Error errors -> - (expr, errors) - in - expand_rec expr - -let unexpand_carn_and_cdrn expanded = - match expanded with - | Seq (loc, [Prim (_, "GET", [Int (locn, n)], annot)]) -> - let (half, parity) = Z.ediv_rem n (Z.of_int 2) in - if Z.(parity = zero) then - Some (Prim (loc, "CDR", [Int (locn, half)], annot)) - else Some (Prim (loc, "CAR", [Int (locn, half)], annot)) - | _ -> - None - -let unexpand_caddadr expanded = - let rec rsteps acc = function - | [] -> - Some acc - | Prim (_, "CAR", [], []) :: rest -> - rsteps ("A" :: acc) rest - | Prim (_, "CDR", [], []) :: rest -> - rsteps ("D" :: acc) rest - | _ -> - None - in - match expanded with - | Seq (loc, (Prim (_, "CAR", [], []) :: _ as nodes)) - | Seq (loc, (Prim (_, "CDR", [], []) :: _ as nodes)) -> ( - match rsteps [] nodes with - | Some steps -> - let name = String.concat "" ("C" :: List.rev ("R" :: steps)) in - Some (Prim (loc, name, [], [])) - | None -> - None ) - | _ -> - None - -let unexpand_set_caddadr expanded = - let rec steps acc annots = function - | Seq - ( loc, - [ Prim (_, "CDR", [], _); - Prim (_, "SWAP", [], _); - Prim (_, "PAIR", [], _) ] ) -> - Some (loc, "A" :: acc, annots) - | Seq - ( loc, - [ Prim (_, "DUP", [], []); - Prim (_, "CAR", [], [field_annot]); - Prim (_, "DROP", [], []); - Prim (_, "CDR", [], _); - Prim (_, "SWAP", [], []); - Prim (_, "PAIR", [], _) ] ) -> - Some (loc, "A" :: acc, field_annot :: annots) - | Seq (loc, [Prim (_, "CAR", [], _); Prim (_, "PAIR", [], _)]) -> - Some (loc, "D" :: acc, annots) - | Seq - ( loc, - [ Prim (_, "DUP", [], []); - Prim (_, "CDR", [], [field_annot]); - Prim (_, "DROP", [], []); - Prim (_, "CAR", [], _); - Prim (_, "PAIR", [], _) ] ) -> - Some (loc, "D" :: acc, field_annot :: annots) - | Seq - ( _, - [ Prim (_, "DUP", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CAR", [], _); sub])], []); - Prim (_, "CDR", [], _); - Prim (_, "SWAP", [], []); - Prim (_, "PAIR", [], pair_annots) ] ) -> - let (_, pair_annots) = extract_field_annots pair_annots in - steps ("A" :: acc) (List.rev_append pair_annots annots) sub - | Seq - ( _, - [ Prim (_, "DUP", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], _); sub])], []); - Prim (_, "CAR", [], _); - Prim (_, "PAIR", [], pair_annots) ] ) -> - let (_, pair_annots) = extract_field_annots pair_annots in - steps ("D" :: acc) (List.rev_append pair_annots annots) sub - | _ -> - None - in - match steps [] [] expanded with - | Some (loc, steps, annots) -> - let name = String.concat "" ("SET_C" :: List.rev ("R" :: steps)) in - Some (Prim (loc, name, [], List.rev annots)) - | None -> - None - -let unexpand_map_caddadr expanded = - let rec steps acc annots = function - | Seq - ( loc, - [ Prim (_, "DUP", [], []); - Prim (_, "CDR", [], _); - Prim (_, "SWAP", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CAR", [], []); code])], []); - Prim (_, "PAIR", [], _) ] ) -> - Some (loc, "A" :: acc, annots, code) - | Seq - ( loc, - [ Prim (_, "DUP", [], []); - Prim (_, "CDR", [], _); - Prim (_, "SWAP", [], []); - Prim - ( _, - "DIP", - [Seq (_, [Prim (_, "CAR", [], [field_annot]); code])], - [] ); - Prim (_, "PAIR", [], _) ] ) -> - Some (loc, "A" :: acc, field_annot :: annots, code) - | Seq - ( loc, - [ Prim (_, "DUP", [], []); - Prim (_, "CDR", [], []); - code; - Prim (_, "SWAP", [], []); - Prim (_, "CAR", [], _); - Prim (_, "PAIR", [], _) ] ) -> - Some (loc, "D" :: acc, annots, code) - | Seq - ( loc, - [ Prim (_, "DUP", [], []); - Prim (_, "CDR", [], [field_annot]); - code; - Prim (_, "SWAP", [], []); - Prim (_, "CAR", [], _); - Prim (_, "PAIR", [], _) ] ) -> - Some (loc, "D" :: acc, field_annot :: annots, code) - | Seq - ( _, - [ Prim (_, "DUP", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CAR", [], _); sub])], []); - Prim (_, "CDR", [], _); - Prim (_, "SWAP", [], []); - Prim (_, "PAIR", [], pair_annots) ] ) -> - let (_, pair_annots) = extract_field_annots pair_annots in - steps ("A" :: acc) (List.rev_append pair_annots annots) sub - | Seq - ( _, - [ Prim (_, "DUP", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], []); sub])], []); - Prim (_, "CAR", [], []); - Prim (_, "PAIR", [], pair_annots) ] ) -> - let (_, pair_annots) = extract_field_annots pair_annots in - steps ("D" :: acc) (List.rev_append pair_annots annots) sub - | _ -> - None - in - match steps [] [] expanded with - | Some (loc, steps, annots, code) -> - let name = String.concat "" ("MAP_C" :: List.rev ("R" :: steps)) in - Some (Prim (loc, name, [code], List.rev annots)) - | None -> - None - -let unexpand_deprecated_dxiiivp expanded = - (* transparently turn the old expansion of deprecated [DI...IP] to [DIP n] *) - match expanded with - | Seq - ( loc, - [Prim (_, "DIP", [(Seq (_, [Prim (_, "DIP", [_], [])]) as sub)], [])] - ) -> - let rec count acc = function - | Seq (_, [Prim (_, "DIP", [sub], [])]) -> - count (acc + 1) sub - | sub -> - (acc, sub) - in - let (depth, sub) = count 1 sub in - Some (Prim (loc, "DIP", [Int (loc, Z.of_int depth); sub], [])) - | _ -> - None - -let unexpand_dupn expanded = - match expanded with - | Seq - ( loc, - [ Prim - (_, "DIP", [Int (_, np); Seq (_, [Prim (_, "DUP", [], annot)])], []); - Prim (_, "DIG", [Int (nloc, ng)], []) ] ) - when Z.equal np (Z.pred ng) -> - Some (Prim (loc, "DUP", [Int (nloc, ng)], annot)) - | _ -> - None - -let unexpand_deprecated_duuuuup expanded = - (* transparently turn the old expansion of deprecated [DU...UP] to [DUP n] *) - let rec expand n = function - | Seq (loc, [Prim (nloc, "DUP", [], annot)]) -> - if n = 1 then None - else Some (Prim (loc, "DUP", [Int (nloc, Z.of_int n)], annot)) - | Seq (_, [Prim (_, "DIP", [expanded'], []); Prim (_, "SWAP", [], [])]) -> - expand (n + 1) expanded' - | _ -> - None - in - expand 1 expanded - -let rec normalize_pair_item ?(right = false) = function - | P (i, a, b) -> - P (i, normalize_pair_item a, normalize_pair_item ~right:true b) - | A when right -> - I - | A -> - A - | I -> - I - -let unexpand_pappaiir expanded = - match expanded with - | Seq (_, [Prim (_, "PAIR", [], [])]) -> - Some expanded - | Seq (loc, (_ :: _ as nodes)) -> ( - let rec exec stack nodes = - match (nodes, stack) with - | ([], _) -> - stack - (* support new expansion using [DIP n] *) - | ( Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, - a :: rstack ) - when Z.to_int n > 1 -> - exec - ( a - :: exec - rstack - [ Prim - (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) - ] ) - rest - | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, a :: rstack) - when Z.to_int n = 1 -> - exec (a :: exec rstack sub) rest - | (Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, []) - when Z.to_int n > 1 -> - exec - ( A - :: exec - [] - [ Prim - (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) - ] ) - rest - | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, []) - when Z.to_int n = 1 -> - exec (A :: exec [] sub) rest - (* support old expansion using [DIP] *) - | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, a :: rstack) -> - exec (a :: exec rstack sub) rest - | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, []) -> - exec (A :: exec [] sub) rest - | (Prim (_, "PAIR", [], []) :: rest, a :: b :: rstack) -> - exec (P (0, a, b) :: rstack) rest - | (Prim (_, "PAIR", [], []) :: rest, [a]) -> - exec [P (0, a, I)] rest - | (Prim (_, "PAIR", [], []) :: rest, []) -> - exec [P (0, A, I)] rest - | _ -> - raise_notrace Not_a_pair - in - match exec [] nodes with - | [] -> - None - | res :: _ -> - let res = normalize_pair_item res in - let name = unparse_pair_item res in - Some (Prim (loc, name, [], [])) - | exception Not_a_pair -> - None ) - | _ -> - None - -let unexpand_unpappaiir expanded = - match expanded with - | Seq (loc, (_ :: _ as nodes)) -> ( - let rec exec stack nodes = - match (nodes, stack) with - | ([], _) -> - stack - (* support new expansion using [DIP n] *) - | ( Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, - a :: rstack ) - when Z.to_int n > 1 -> - exec - ( a - :: exec - rstack - [ Prim - (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) - ] ) - rest - | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, a :: rstack) - when Z.to_int n = 1 -> - exec (a :: exec rstack sub) rest - | (Prim (ploc, "DIP", [Int (loc, n); Seq (sloc, sub)], []) :: rest, []) - when Z.to_int n > 1 -> - exec - ( A - :: exec - [] - [ Prim - (ploc, "DIP", [Int (loc, Z.pred n); Seq (sloc, sub)], []) - ] ) - rest - | (Prim (_, "DIP", [Int (_, n); Seq (_, sub)], []) :: rest, []) - when Z.to_int n = 1 -> - exec (A :: exec [] sub) rest - (* support old expansion using [DIP] *) - | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, a :: rstack) -> - exec (a :: exec rstack sub) rest - | (Prim (_, "DIP", [Seq (_, sub)], []) :: rest, []) -> - exec (A :: exec [] sub) rest - | ( Seq - ( _, - [ Prim (_, "DUP", [], []); - Prim (_, "CAR", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], [])])], []) ] - ) - :: rest, - a :: b :: rstack ) -> - exec (P (0, a, b) :: rstack) rest - | ( Seq - ( _, - [ Prim (_, "DUP", [], []); - Prim (_, "CAR", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], [])])], []) ] - ) - :: rest, - [a] ) -> - exec [P (0, a, I)] rest - | ( Seq - ( _, - [ Prim (_, "DUP", [], []); - Prim (_, "CAR", [], []); - Prim (_, "DIP", [Seq (_, [Prim (_, "CDR", [], [])])], []) ] - ) - :: rest, - [] ) -> - exec [P (0, A, I)] rest - | _ -> - raise_notrace Not_a_pair - in - match exec [] (List.rev nodes) with - | [] -> - None - | res :: _ -> - let res = normalize_pair_item res in - let name = "UN" ^ unparse_pair_item res in - Some (Prim (loc, name, [], [])) - | exception Not_a_pair -> - None ) - | _ -> - None - -let unexpand_compare expanded = - match expanded with - | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "EQ", [], annot)]) -> - Some (Prim (loc, "CMPEQ", [], annot)) - | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "NEQ", [], annot)]) -> - Some (Prim (loc, "CMPNEQ", [], annot)) - | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "LT", [], annot)]) -> - Some (Prim (loc, "CMPLT", [], annot)) - | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "GT", [], annot)]) -> - Some (Prim (loc, "CMPGT", [], annot)) - | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "LE", [], annot)]) -> - Some (Prim (loc, "CMPLE", [], annot)) - | Seq (loc, [Prim (_, "COMPARE", [], _); Prim (_, "GE", [], annot)]) -> - Some (Prim (loc, "CMPGE", [], annot)) - | Seq - ( loc, - [ Prim (_, "COMPARE", [], _); - Prim (_, "EQ", [], _); - Prim (_, "IF", args, annot) ] ) -> - Some (Prim (loc, "IFCMPEQ", args, annot)) - | Seq - ( loc, - [ Prim (_, "COMPARE", [], _); - Prim (_, "NEQ", [], _); - Prim (_, "IF", args, annot) ] ) -> - Some (Prim (loc, "IFCMPNEQ", args, annot)) - | Seq - ( loc, - [ Prim (_, "COMPARE", [], _); - Prim (_, "LT", [], _); - Prim (_, "IF", args, annot) ] ) -> - Some (Prim (loc, "IFCMPLT", args, annot)) - | Seq - ( loc, - [ Prim (_, "COMPARE", [], _); - Prim (_, "GT", [], _); - Prim (_, "IF", args, annot) ] ) -> - Some (Prim (loc, "IFCMPGT", args, annot)) - | Seq - ( loc, - [ Prim (_, "COMPARE", [], _); - Prim (_, "LE", [], _); - Prim (_, "IF", args, annot) ] ) -> - Some (Prim (loc, "IFCMPLE", args, annot)) - | Seq - ( loc, - [ Prim (_, "COMPARE", [], _); - Prim (_, "GE", [], _); - Prim (_, "IF", args, annot) ] ) -> - Some (Prim (loc, "IFCMPGE", args, annot)) - | Seq (loc, [Prim (_, "EQ", [], _); Prim (_, "IF", args, annot)]) -> - Some (Prim (loc, "IFEQ", args, annot)) - | Seq (loc, [Prim (_, "NEQ", [], _); Prim (_, "IF", args, annot)]) -> - Some (Prim (loc, "IFNEQ", args, annot)) - | Seq (loc, [Prim (_, "LT", [], _); Prim (_, "IF", args, annot)]) -> - Some (Prim (loc, "IFLT", args, annot)) - | Seq (loc, [Prim (_, "GT", [], _); Prim (_, "IF", args, annot)]) -> - Some (Prim (loc, "IFGT", args, annot)) - | Seq (loc, [Prim (_, "LE", [], _); Prim (_, "IF", args, annot)]) -> - Some (Prim (loc, "IFLE", args, annot)) - | Seq (loc, [Prim (_, "GE", [], _); Prim (_, "IF", args, annot)]) -> - Some (Prim (loc, "IFGE", args, annot)) - | _ -> - None - -let unexpand_asserts expanded = - match expanded with - | Seq - ( loc, - [ Prim - ( _, - "IF", - [ Seq (_, []); - Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT", [], [])) - | Seq - ( loc, - [ Seq (_, [Prim (_, "COMPARE", [], []); Prim (_, comparison, [], [])]); - Prim - ( _, - "IF", - [ Seq (_, []); - Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_CMP" ^ comparison, [], [])) - | Seq - ( loc, - [ Prim (_, comparison, [], []); - Prim - ( _, - "IF", - [ Seq (_, []); - Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_" ^ comparison, [], [])) - | Seq - ( loc, - [ Prim - ( _, - "IF_NONE", - [ Seq (_, [Prim (_, "RENAME", [], annot)]); - Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_NONE", [], annot)) - | Seq - ( loc, - [ Prim - ( _, - "IF_NONE", - [ Seq (_, []); - Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_NONE", [], [])) - | Seq - ( loc, - [ Prim - ( _, - "IF_NONE", - [ Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ); - Seq (_, []) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_SOME", [], [])) - | Seq - ( loc, - [ Prim - ( _, - "IF_NONE", - [ Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ); - Seq (_, [Prim (_, "RENAME", [], annot)]) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_SOME", [], annot)) - | Seq - ( loc, - [ Prim - ( _, - "IF_LEFT", - [ Seq (_, []); - Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_LEFT", [], [])) - | Seq - ( loc, - [ Prim - ( _, - "IF_LEFT", - [ Seq (_, [Prim (_, "RENAME", [], annot)]); - Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_LEFT", [], annot)) - | Seq - ( loc, - [ Prim - ( _, - "IF_LEFT", - [ Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ); - Seq (_, []) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_RIGHT", [], [])) - | Seq - ( loc, - [ Prim - ( _, - "IF_LEFT", - [ Seq - ( _, - [ Seq - ( _, - [ Prim (_, "UNIT", [], []); - Prim (_, "FAILWITH", [], []) ] ) ] ); - Seq (_, [Prim (_, "RENAME", [], annot)]) ], - [] ) ] ) -> - Some (Prim (loc, "ASSERT_RIGHT", [], annot)) - | _ -> - None - -let unexpand_if_some = function - | Seq (loc, [Prim (_, "IF_NONE", [left; right], annot)]) -> - Some (Prim (loc, "IF_SOME", [right; left], annot)) - | _ -> - None - -let unexpand_if_right = function - | Seq (loc, [Prim (_, "IF_LEFT", [left; right], annot)]) -> - Some (Prim (loc, "IF_RIGHT", [right; left], annot)) - | _ -> - None - -let unexpand_fail = function - | Seq (loc, [Prim (_, "UNIT", [], []); Prim (_, "FAILWITH", [], [])]) -> - Some (Prim (loc, "FAIL", [], [])) - | _ -> - None - -let unexpand original = - let try_unexpansions unexpanders = - match - List.fold_left - (fun acc f -> - match acc with - | None -> - f original - | Some rewritten -> - Some rewritten) - None - unexpanders - with - | None -> - original - | Some rewritten -> - rewritten - in - try_unexpansions - [ unexpand_asserts; - unexpand_carn_and_cdrn; - unexpand_caddadr; - unexpand_set_caddadr; - unexpand_map_caddadr; - unexpand_deprecated_dxiiivp; - unexpand_pappaiir; - unexpand_unpappaiir; - unexpand_deprecated_duuuuup; - unexpand_dupn; - unexpand_compare; - unexpand_if_some; - unexpand_if_right; - unexpand_fail ] - -(* - If an argument of Prim is a sequence, we do not want to unexpand - its root in case the source already contains an expanded macro. In - which case unexpansion would remove surrounding braces and generate - ill-formed code. - - For example, DIIP { DIP { DUP }; SWAP } is not unexpandable but - DIIP {{ DIP { DUP }; SWAP }} (note the double braces) is unexpanded - to DIIP { DUUP }. - - unexpand_rec_but_root is the same as unexpand_rec but does not try - to unexpand at root *) - -let rec unexpand_rec expr = unexpand_rec_but_root (unexpand expr) - -and unexpand_rec_but_root = function - | Seq (loc, items) -> - Seq (loc, List.map unexpand_rec items) - | Prim (loc, name, args, annot) -> - Prim (loc, name, List.map unexpand_rec_but_root args, annot) - | (Int _ | String _ | Bytes _) as atom -> - atom - -let () = - let open Data_encoding in - register_error_kind - `Permanent - ~id:"michelson.macros.unexpected_annotation" - ~title:"Unexpected annotation" - ~description: - "A macro had an annotation, but no annotation was permitted on this \ - macro." - ~pp:(fun ppf -> Format.fprintf ppf "Unexpected annotation on macro %s.") - (obj1 (req "macro_name" string)) - (function Unexpected_macro_annotation str -> Some str | _ -> None) - (fun s -> Unexpected_macro_annotation s) ; - register_error_kind - `Permanent - ~id:"michelson.macros.sequence_expected" - ~title:"Macro expects a sequence" - ~description:"An macro expects a sequence, but a sequence was not provided" - ~pp:(fun ppf name -> - Format.fprintf - ppf - "Macro %s expects a sequence, but did not receive one." - name) - (obj1 (req "macro_name" string)) - (function Sequence_expected name -> Some name | _ -> None) - (fun name -> Sequence_expected name) ; - register_error_kind - `Permanent - ~id:"michelson.macros.bas_arity" - ~title:"Wrong number of arguments to macro" - ~description:"A wrong number of arguments was provided to a macro" - ~pp:(fun ppf (name, got, exp) -> - Format.fprintf - ppf - "Macro %s expects %d arguments, was given %d." - name - exp - got) - (obj3 - (req "macro_name" string) - (req "given_number_of_arguments" uint16) - (req "expected_number_of_arguments" uint16)) - (function - | Invalid_arity (name, got, exp) -> Some (name, got, exp) | _ -> None) - (fun (name, got, exp) -> Invalid_arity (name, got, exp)) diff --git a/src/proto_alpha/lib_parameters/michelson_v1_macros.mli b/src/proto_alpha/lib_parameters/michelson_v1_macros.mli deleted file mode 100644 index 352a59b00a9e..000000000000 --- a/src/proto_alpha/lib_parameters/michelson_v1_macros.mli +++ /dev/null @@ -1,86 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -open Tezos_micheline - -type 'l node = ('l, string) Micheline.node - -type error += Unexpected_macro_annotation of string - -type error += Sequence_expected of string - -type error += Invalid_arity of string * int * int - -val expand : 'l node -> 'l node tzresult - -val expand_rec : 'l node -> 'l node * error list - -val expand_caddadr : 'l node -> 'l node option tzresult - -val expand_set_caddadr : 'l node -> 'l node option tzresult - -val expand_map_caddadr : 'l node -> 'l node option tzresult - -val expand_deprecated_dxiiivp : 'l node -> 'l node option tzresult - -val expand_pappaiir : 'l node -> 'l node option tzresult - -val expand_deprecated_duuuuup : 'l node -> 'l node option tzresult - -val expand_compare : 'l node -> 'l node option tzresult - -val expand_asserts : 'l node -> 'l node option tzresult - -val expand_unpappaiir : 'l node -> 'l node option tzresult - -val expand_if_some : 'l node -> 'l node option tzresult - -val expand_if_right : 'l node -> 'l node option tzresult - -val unexpand : 'l node -> 'l node - -val unexpand_rec : 'l node -> 'l node - -val unexpand_caddadr : 'l node -> 'l node option - -val unexpand_set_caddadr : 'l node -> 'l node option - -val unexpand_map_caddadr : 'l node -> 'l node option - -val unexpand_deprecated_dxiiivp : 'l node -> 'l node option - -val unexpand_pappaiir : 'l node -> 'l node option - -val unexpand_deprecated_duuuuup : 'l node -> 'l node option - -val unexpand_compare : 'l node -> 'l node option - -val unexpand_asserts : 'l node -> 'l node option - -val unexpand_unpappaiir : 'l node -> 'l node option - -val unexpand_if_some : 'l node -> 'l node option - -val unexpand_if_right : 'l node -> 'l node option diff --git a/src/proto_alpha/lib_parameters/michelson_v1_parser.ml b/src/proto_alpha/lib_parameters/michelson_v1_parser.ml deleted file mode 100644 index fcfc8a3d6fa3..000000000000 --- a/src/proto_alpha/lib_parameters/michelson_v1_parser.ml +++ /dev/null @@ -1,108 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -open Protocol -open Tezos_micheline -open Micheline_parser -open Micheline - -type parsed = { - source : string; - unexpanded : string canonical; - expanded : Michelson_v1_primitives.prim canonical; - expansion_table : (int * (Micheline_parser.location * int list)) list; - unexpansion_table : (int * int) list; -} - -(* Unexpanded toplevel expression should be a sequence *) -let expand_all source ast errors = - let (unexpanded, loc_table) = extract_locations ast in - let (expanded, expansion_errors) = - Michelson_v1_macros.expand_rec (root unexpanded) - in - let (expanded, unexpansion_table) = extract_locations expanded in - let expansion_table = - let sorted = - List.sort (fun (_, a) (_, b) -> compare a b) unexpansion_table - in - let grouped = - let rec group = function - | (acc, []) -> - acc - | ([], (u, e) :: r) -> - group ([(e, [u])], r) - | (((pe, us) :: racc as acc), (u, e) :: r) -> - if e = pe then group ((e, u :: us) :: racc, r) - else group ((e, [u]) :: acc, r) - in - group ([], sorted) - in - match - List.map2 - ~when_different_lengths:() - (fun (l, ploc) (l', elocs) -> - assert (l = l') ; - (l, (ploc, elocs))) - (List.sort compare loc_table) - (List.sort compare grouped) - with - | Ok v -> - v - | Error () -> - invalid_arg "Michelson_v1_parser.expand_all" - in - match - Environment.wrap_error (Michelson_v1_primitives.prims_of_strings expanded) - with - | Ok expanded -> - ( {source; unexpanded; expanded; expansion_table; unexpansion_table}, - errors @ expansion_errors ) - | Error errs -> - ( { - source; - unexpanded; - expanded = Micheline.strip_locations (Seq ((), [])); - expansion_table; - unexpansion_table; - }, - errors @ expansion_errors @ errs ) - -let parse_toplevel ?check source = - let (tokens, lexing_errors) = Micheline_parser.tokenize source in - let (asts, parsing_errors) = Micheline_parser.parse_toplevel ?check tokens in - let ast = - let start = min_point asts and stop = max_point asts in - Seq ({start; stop}, asts) - in - expand_all source ast (lexing_errors @ parsing_errors) - -let parse_expression ?check source = - let (tokens, lexing_errors) = Micheline_parser.tokenize source in - let (ast, parsing_errors) = - Micheline_parser.parse_expression ?check tokens - in - expand_all source ast (lexing_errors @ parsing_errors) - -let expand_all ~source ~original = expand_all source original [] diff --git a/src/proto_alpha/lib_parameters/michelson_v1_parser.mli b/src/proto_alpha/lib_parameters/michelson_v1_parser.mli deleted file mode 100644 index 4f55e20943fa..000000000000 --- a/src/proto_alpha/lib_parameters/michelson_v1_parser.mli +++ /dev/null @@ -1,53 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -open Protocol -open Alpha_context -open Tezos_micheline - -(** The result of parsing and expanding a Michelson V1 script or data. *) -type parsed = { - source : string; (** The original source code. *) - unexpanded : string Micheline.canonical; - (** Original expression with macros. *) - expanded : Script.expr; (** Expression with macros fully expanded. *) - expansion_table : (int * (Micheline_parser.location * int list)) list; - (** Associates unexpanded nodes to their parsing locations and - the nodes expanded from it in the expanded expression. *) - unexpansion_table : (int * int) list; - (** Associates an expanded node to its source in the unexpanded - expression. *) -} - -val parse_toplevel : - ?check:bool -> string -> parsed Micheline_parser.parsing_result - -val parse_expression : - ?check:bool -> string -> parsed Micheline_parser.parsing_result - -val expand_all : - source:string -> - original:Micheline_parser.node -> - parsed Micheline_parser.parsing_result diff --git a/src/proto_alpha/lib_parameters/test_cpmm.ml b/src/proto_alpha/lib_parameters/test_cpmm.ml new file mode 100644 index 000000000000..7c3398f84d1d --- /dev/null +++ b/src/proto_alpha/lib_parameters/test_cpmm.ml @@ -0,0 +1,12993 @@ +open Protocol.Alpha_context.Script +open Micheline + +let script = + Seq + ( 0, + [ Prim + ( 1, + K_parameter, + [ Prim + ( 2, + T_or, + [ Prim + ( 3, + T_or, + [ Prim + ( 4, + T_or, + [ Prim + ( 5, + T_pair, + [ Prim (6, T_address, [], [":spender"]); + Prim + ( 7, + T_pair, + [ Prim (8, T_nat, [], [":allowance"]); + Prim + ( 9, + T_nat, + [], + [":currentAllowance"] ) ], + [] ) ], + ["%approve"] ); + Prim + ( 10, + T_pair, + [ Prim + ( 11, + T_pair, + [ Prim (12, T_address, [], [":owner"]); + Prim + (13, T_nat, [], [":minLqtMinted"]) + ], + [] ); + Prim + ( 14, + T_pair, + [ Prim + ( 15, + T_nat, + [], + [":maxTokensDeposited"] ); + Prim + ( 16, + T_timestamp, + [], + [":deadline"] ) ], + [] ) ], + ["%addLiquidity"] ) ], + [] ); + Prim + ( 17, + T_or, + [ Prim + ( 18, + T_pair, + [ Prim + ( 19, + T_pair, + [ Prim (20, T_address, [], [":owner"]); + Prim + ( 21, + T_pair, + [ Prim + (22, T_address, [], [":to"]); + Prim + ( 23, + T_nat, + [], + [":lqtBurned"] ) ], + [] ) ], + [] ); + Prim + ( 24, + T_pair, + [ Prim + ( 25, + T_mutez, + [], + [":minXtzWithdrawn"] ); + Prim + ( 26, + T_pair, + [ Prim + ( 27, + T_nat, + [], + [":minTokensWithdrawn"] + ); + Prim + ( 28, + T_timestamp, + [], + [":deadline"] ) ], + [] ) ], + [] ) ], + ["%removeLiquidity"] ); + Prim + ( 29, + T_pair, + [ Prim (30, T_address, [], [":to"]); + Prim + ( 31, + T_pair, + [ Prim + ( 32, + T_nat, + [], + [":minTokensBought"] ); + Prim + ( 33, + T_timestamp, + [], + [":deadline"] ) ], + [] ) ], + ["%xtzToToken"] ) ], + [] ) ], + [] ); + Prim + ( 34, + T_or, + [ Prim + ( 35, + T_or, + [ Prim + ( 36, + T_pair, + [ Prim + ( 37, + T_pair, + [ Prim (38, T_address, [], [":owner"]); + Prim (39, T_address, [], [":to"]) + ], + [] ); + Prim + ( 40, + T_pair, + [ Prim + (41, T_nat, [], [":tokensSold"]); + Prim + ( 42, + T_pair, + [ Prim + ( 43, + T_mutez, + [], + [":minXtzBought"] ); + Prim + ( 44, + T_timestamp, + [], + [":deadline"] ) ], + [] ) ], + [] ) ], + ["%tokenToXtz"] ); + Prim (45, T_key_hash, [], ["%updateTokenPool"]) + ], + [] ); + Prim + ( 46, + T_or, + [ Prim + (47, T_nat, [], ["%updateTokenPoolInternal"]); + Prim (48, T_unit, [], ["%default"]) ], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 49, + K_storage, + [ Prim + ( 50, + T_pair, + [ Prim + ( 51, + T_big_map, + [ Prim (52, T_address, [], [":owner"]); + Prim + ( 53, + T_pair, + [ Prim (54, T_nat, [], [":balance"]); + Prim + ( 55, + T_map, + [ Prim (56, T_address, [], [":spender"]); + Prim (57, T_nat, [], [":allowance"]) ], + [] ) ], + [] ) ], + ["%accounts"] ); + Prim + ( 58, + T_pair, + [ Prim + ( 59, + T_pair, + [ Prim + (60, T_bool, [], [":selfIsUpdatingTokenPool"]); + Prim (61, T_nat, [], [":lqtTotal"]) ], + [] ); + Prim + ( 62, + T_pair, + [ Prim (63, T_address, [], [":tokenAddress"]); + Prim + ( 64, + T_pair, + [ Prim (65, T_nat, [], [":tokenPool"]); + Prim (66, T_mutez, [], [":xtzPool"]) ], + [] ) ], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 67, + K_code, + [ Seq + ( 68, + [ Prim + ( 69, + I_CAST, + [ Prim + ( 70, + T_pair, + [ Prim + ( 71, + T_or, + [ Prim + ( 72, + T_or, + [ Prim + ( 73, + T_or, + [ Prim + ( 74, + T_pair, + [ Prim + ( 75, + T_address, + [], + [] ); + Prim + ( 76, + T_pair, + [ Prim + ( 77, + T_nat, + [], + [] ); + Prim + ( 78, + T_nat, + [], + [] ) ], + [] ) ], + [] ); + Prim + ( 79, + T_pair, + [ Prim + ( 80, + T_pair, + [ Prim + ( 81, + T_address, + [], + [] ); + Prim + ( 82, + T_nat, + [], + [] ) ], + [] ); + Prim + ( 83, + T_pair, + [ Prim + ( 84, + T_nat, + [], + [] ); + Prim + ( 85, + T_timestamp, + [], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 86, + T_or, + [ Prim + ( 87, + T_pair, + [ Prim + ( 88, + T_pair, + [ Prim + ( 89, + T_address, + [], + [] ); + Prim + ( 90, + T_pair, + [ Prim + ( 91, + T_address, + [], + [] ); + Prim + ( 92, + T_nat, + [], + [] ) ], + [] ) ], + [] ); + Prim + ( 93, + T_pair, + [ Prim + ( 94, + T_mutez, + [], + [] ); + Prim + ( 95, + T_pair, + [ Prim + ( 96, + T_nat, + [], + [] ); + Prim + ( 97, + T_timestamp, + [], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 98, + T_pair, + [ Prim + ( 99, + T_address, + [], + [] ); + Prim + ( 100, + T_pair, + [ Prim + ( 101, + T_nat, + [], + [] ); + Prim + ( 102, + T_timestamp, + [], + [] ) ], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 103, + T_or, + [ Prim + ( 104, + T_or, + [ Prim + ( 105, + T_pair, + [ Prim + ( 106, + T_pair, + [ Prim + ( 107, + T_address, + [], + [] ); + Prim + ( 108, + T_address, + [], + [] ) ], + [] ); + Prim + ( 109, + T_pair, + [ Prim + ( 110, + T_nat, + [], + [] ); + Prim + ( 111, + T_pair, + [ Prim + ( 112, + T_mutez, + [], + [] ); + Prim + ( 113, + T_timestamp, + [], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim (114, T_key_hash, [], []) + ], + [] ); + Prim + ( 115, + T_or, + [ Prim (116, T_nat, [], []); + Prim (117, T_unit, [], []) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 118, + T_pair, + [ Prim + ( 119, + T_big_map, + [ Prim (120, T_address, [], []); + Prim + ( 121, + T_pair, + [ Prim (122, T_nat, [], []); + Prim + ( 123, + T_map, + [ Prim + ( 124, + T_address, + [], + [] ); + Prim + (125, T_nat, [], []) + ], + [] ) ], + [] ) ], + [] ); + Prim + ( 126, + T_pair, + [ Prim + ( 127, + T_pair, + [ Prim (128, T_bool, [], []); + Prim (129, T_nat, [], []) ], + [] ); + Prim + ( 130, + T_pair, + [ Prim (131, T_address, [], []); + Prim + ( 132, + T_pair, + [ Prim + (133, T_nat, [], []); + Prim + (134, T_mutez, [], []) + ], + [] ) ], + [] ) ], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim (135, I_DUP, [], []); + Prim (136, I_CAR, [], []); + Prim + (137, I_DIP, [Seq (138, [Prim (139, I_CDR, [], [])])], []); + Prim + ( 140, + I_IF_LEFT, + [ Seq + ( 141, + [ Prim + ( 142, + I_IF_LEFT, + [ Seq + ( 143, + [ Prim + ( 144, + I_IF_LEFT, + [ Seq + ( 145, + [ Prim + ( 146, + I_DIP, + [ Seq + ( 147, + [ Prim + ( 148, + I_DUP, + [], + [] ); + Prim + ( 149, + I_CDR, + [], + [] ); + Prim + ( 150, + I_CAR, + [], + [] ); + Prim + ( 151, + I_CAR, + [], + [] ); + Prim + ( 152, + I_IF, + [ Seq + ( 153, + [ + Prim + ( + 154, + I_PUSH, + [ + Prim + ( + 155, + T_string, + [], + [] + ); + String + ( + 156, + "selfIsUpdatingToken \ + must \ + be \ + false." + ) + ], + [] + ); + Prim + ( + 157, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 158, + [] + ) + ], + [] ) ] + ) ], + [] ); + Prim + ( 159, + I_PUSH, + [ Prim + ( 160, + T_mutez, + [], + [] ); + Int (161, Z.zero) + ], + [] ); + Prim + ( 162, + I_AMOUNT, + [], + [] ); + Prim + ( 163, + I_COMPARE, + [], + [] ); + Prim (164, I_EQ, [], []); + Prim + ( 165, + I_IF, + [ Seq (166, []); + Seq + ( 167, + [ Prim + ( 168, + I_PUSH, + [ Prim + ( 169, + T_string, + [], + [] + ); + String + ( 170, + "Amount \ + must \ + be \ + zero." + ) + ], + [] ); + Prim + ( 171, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 172, + I_DIP, + [ Seq + ( 173, + [ Prim + ( 174, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + (175, I_SWAP, [], []); + Prim + (176, I_CAR, [], []); + Prim + ( 177, + I_SENDER, + [], + [] ); + Prim + (178, I_GET, [], []); + Prim + ( 179, + I_IF_NONE, + [ Seq + ( 180, + [ Prim + ( 181, + I_EMPTY_MAP, + [ Prim + ( 182, + T_address, + [], + [] + ); + Prim + ( 183, + T_nat, + [], + [] + ) + ], + [] ); + Prim + ( 184, + I_PUSH, + [ Prim + ( 185, + T_nat, + [], + [] + ); + Int + ( 186, + Z + .zero + ) + ], + [] ); + Prim + ( 187, + I_PAIR, + [], + [] ) ] + ); + Seq (188, []) ], + [] ); + Prim + (189, I_DUP, [], []); + Prim + (190, I_CDR, [], []); + Prim + ( 191, + I_DIP, + [ Int + ( 192, + Z.of_int 2 ); + Seq + ( 193, + [ Prim + ( 194, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 195, + I_DIG, + [ Int + ( 196, + Z.of_int 2 ) + ], + [] ); + Prim + (197, I_CAR, [], []); + Prim + (198, I_GET, [], []); + Prim + ( 199, + I_IF_NONE, + [ Seq + ( 200, + [ Prim + ( 201, + I_PUSH, + [ Prim + ( 202, + T_nat, + [], + [] + ); + Int + ( 203, + Z + .zero + ) + ], + [] ) ] + ); + Seq (204, []) ], + [] ); + Prim + ( 205, + I_DIP, + [ Int + ( 206, + Z.of_int 2 ); + Seq + ( 207, + [ Prim + ( 208, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 209, + I_DIG, + [ Int + ( 210, + Z.of_int 2 ) + ], + [] ); + Prim + (211, I_CDR, [], []); + Prim + (212, I_CDR, [], []); + Prim + ( 213, + I_COMPARE, + [], + [] ); + Prim (214, I_EQ, [], []); + Prim + ( 215, + I_IF, + [ Seq (216, []); + Seq + ( 217, + [ Prim + ( 218, + I_PUSH, + [ Prim + ( 219, + T_string, + [], + [] + ); + String + ( 220, + "The \ + current \ + allowance \ + parameter \ + must \ + equal \ + the \ + sender's \ + current \ + allowance \ + for \ + the \ + owner." + ) + ], + [] ); + Prim + ( 221, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (222, I_DUP, [], []); + Prim + (223, I_CDR, [], []); + Prim + ( 224, + I_DIG, + [ Int + ( 225, + Z.of_int 2 ) + ], + [] ); + Prim + (226, I_DUP, [], []); + Prim + (227, I_CAR, [], []); + Prim + ( 228, + I_DIP, + [ Seq + ( 229, + [ Prim + ( 230, + I_CDR, + [], + [] ); + Prim + ( 231, + I_CAR, + [], + [] ); + Prim + ( 232, + I_SOME, + [], + [] ) ] + ) ], + [] ); + Prim + ( 233, + I_UPDATE, + [], + [] ); + Prim + ( 234, + I_DIP, + [ Seq + ( 235, + [ Prim + ( 236, + I_DUP, + [], + [] ); + Prim + ( 237, + I_DIP, + [ Seq + ( 238, + [ + Prim + ( + 239, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 240, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (241, I_SWAP, [], []); + Prim + (242, I_DROP, [], []); + Prim + (243, I_SWAP, [], []); + Prim + (244, I_PAIR, [], []); + Prim + ( 245, + I_DIP, + [ Seq + ( 246, + [ Prim + ( 247, + I_DUP, + [], + [] ); + Prim + ( 248, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (249, I_SOME, [], []); + Prim + ( 250, + I_SENDER, + [], + [] ); + Prim + ( 251, + I_UPDATE, + [], + [] ); + Prim + ( 252, + I_DIP, + [ Seq + ( 253, + [ Prim + ( 254, + I_DUP, + [], + [] ); + Prim + ( 255, + I_DIP, + [ Seq + ( 256, + [ + Prim + ( + 257, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 258, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (259, I_SWAP, [], []); + Prim + (260, I_DROP, [], []); + Prim + (261, I_PAIR, [], []); + Prim + ( 262, + I_NIL, + [ Prim + ( 263, + T_operation, + [], + [] ) ], + [] ); + Prim + (264, I_PAIR, [], []) + ] ); + Seq + ( 265, + [ Prim + ( 266, + I_DIP, + [ Seq + ( 267, + [ Prim + ( 268, + I_DUP, + [], + [] ); + Prim + ( 269, + I_CDR, + [], + [] ); + Prim + ( 270, + I_CAR, + [], + [] ); + Prim + ( 271, + I_CAR, + [], + [] ); + Prim + ( 272, + I_IF, + [ Seq + ( 273, + [ + Prim + ( + 274, + I_PUSH, + [ + Prim + ( + 275, + T_string, + [], + [] + ); + String + ( + 276, + "selfIsUpdatingToken \ + must \ + be \ + false." + ) + ], + [] + ); + Prim + ( + 277, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 278, + [] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (279, I_DUP, [], []); + Prim + (280, I_CDR, [], []); + Prim + (281, I_CDR, [], []); + Prim + (282, I_NOW, [], []); + Prim + ( 283, + I_COMPARE, + [], + [] ); + Prim (284, I_LT, [], []); + Prim + ( 285, + I_IF, + [ Seq (286, []); + Seq + ( 287, + [ Prim + ( 288, + I_PUSH, + [ Prim + ( 289, + T_string, + [], + [] + ); + String + ( 290, + "NOW \ + is \ + greater \ + than \ + deadline." + ) + ], + [] ); + Prim + ( 291, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (292, I_DUP, [], []); + Prim + (293, I_CDR, [], []); + Prim + (294, I_CAR, [], []); + Prim + ( 295, + I_PUSH, + [ Prim + ( 296, + T_nat, + [], + [] ); + Int (297, Z.zero) + ], + [] ); + Prim + ( 298, + I_COMPARE, + [], + [] ); + Prim (299, I_LT, [], []); + Prim + ( 300, + I_IF, + [ Seq (301, []); + Seq + ( 302, + [ Prim + ( 303, + I_PUSH, + [ Prim + ( 304, + T_string, + [], + [] + ); + String + ( 305, + "maxTokensDeposited \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 306, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (307, I_DUP, [], []); + Prim + (308, I_CAR, [], []); + Prim + (309, I_CDR, [], []); + Prim + ( 310, + I_PUSH, + [ Prim + ( 311, + T_nat, + [], + [] ); + Int (312, Z.zero) + ], + [] ); + Prim + ( 313, + I_COMPARE, + [], + [] ); + Prim (314, I_LT, [], []); + Prim + ( 315, + I_IF, + [ Seq (316, []); + Seq + ( 317, + [ Prim + ( 318, + I_PUSH, + [ Prim + ( 319, + T_string, + [], + [] + ); + String + ( 320, + "minLqtMinted \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 321, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 322, + I_PUSH, + [ Prim + ( 323, + T_mutez, + [], + [] ); + Int (324, Z.zero) + ], + [] ); + Prim + ( 325, + I_AMOUNT, + [], + [] ); + Prim + ( 326, + I_COMPARE, + [], + [] ); + Prim (327, I_GT, [], []); + Prim + ( 328, + I_IF, + [ Seq (329, []); + Seq + ( 330, + [ Prim + ( 331, + I_PUSH, + [ Prim + ( 332, + T_string, + [], + [] + ); + String + ( 333, + "Amount \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 334, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 335, + I_DIP, + [ Seq + ( 336, + [ Prim + ( 337, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + (338, I_SWAP, [], []); + Prim + (339, I_CDR, [], []); + Prim + (340, I_CAR, [], []); + Prim + (341, I_CDR, [], []); + Prim + (342, I_INT, [], []); + Prim (343, I_EQ, [], []); + Prim + ( 344, + I_IF, + [ Seq + ( 345, + [ Prim + ( 346, + I_AMOUNT, + [], + [] ); + Prim + ( 347, + I_PUSH, + [ Prim + ( 348, + T_mutez, + [], + [] + ); + Int + ( 349, + Z + .of_int + 1000000 + ) + ], + [] ); + Prim + ( 350, + I_COMPARE, + [], + [] ); + Prim + ( 351, + I_LE, + [], + [] ); + Prim + ( 352, + I_IF, + [ Seq + ( 353, + [] + ); + Seq + ( 354, + [ + Prim + ( + 355, + I_PUSH, + [ + Prim + ( + 356, + T_string, + [], + [] + ); + String + ( + 357, + "The \ + initial \ + liquidity \ + amount \ + must \ + be \ + greater \ + than \ + or \ + equal \ + to \ + 1 \ + XTZ." + ) + ], + [] + ); + Prim + ( + 358, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 359, + I_SWAP, + [], + [] ); + Prim + ( 360, + I_AMOUNT, + [], + [] ); + Prim + ( 361, + I_DIP, + [ Seq + ( 362, + [ + Prim + ( + 363, + I_PUSH, + [ + Prim + ( + 364, + T_mutez, + [], + [] + ); + Int + ( + 365, + Z + .one + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 366, + I_EDIV, + [], + [] ); + Prim + ( 367, + I_IF_NONE, + [ Seq + ( 368, + [ + Prim + ( + 369, + I_PUSH, + [ + Prim + ( + 370, + T_string, + [], + [] + ); + String + ( + 371, + "" + ) + ], + [] + ); + Prim + ( + 372, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 373, + [ + Prim + ( + 374, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 375, + I_DUP, + [], + [] ); + Prim + ( 376, + I_DIP, + [ Seq + ( 377, + [ + Prim + ( + 378, + I_DIP, + [ + Seq + ( + 379, + [ + Prim + ( + 380, + I_DUP, + [], + [] + ); + Prim + ( + 381, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 382, + I_DIP, + [ + Seq + ( + 383, + [ + Prim + ( + 384, + I_DUP, + [], + [] + ); + Prim + ( + 385, + I_DIP, + [ + Seq + ( + 386, + [ + Prim + ( + 387, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 388, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 389, + I_DIP, + [ + Seq + ( + 390, + [ + Prim + ( + 391, + I_DUP, + [], + [] + ); + Prim + ( + 392, + I_DIP, + [ + Seq + ( + 393, + [ + Prim + ( + 394, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 395, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 396, + I_SWAP, + [], + [] + ); + Prim + ( + 397, + I_DROP, + [], + [] + ); + Prim + ( + 398, + I_SWAP, + [], + [] + ); + Prim + ( + 399, + I_PAIR, + [], + [] + ); + Prim + ( + 400, + I_PAIR, + [], + [] + ); + Prim + ( + 401, + I_DIP, + [ + Seq + ( + 402, + [ + Prim + ( + 403, + I_DUP, + [], + [] + ); + Prim + ( + 404, + I_DIP, + [ + Seq + ( + 405, + [ + Prim + ( + 406, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 407, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 408, + I_SWAP, + [], + [] + ); + Prim + ( + 409, + I_DROP, + [], + [] + ); + Prim + ( + 410, + I_SWAP, + [], + [] + ); + Prim + ( + 411, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 412, + I_SWAP, + [], + [] ); + Prim + ( 413, + I_DIP, + [ Int + ( 414, + Z + .of_int + 2 + ); + Seq + ( 415, + [ + Prim + ( + 416, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 417, + I_DIG, + [ Int + ( 418, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 419, + I_CAR, + [], + [] ); + Prim + ( 420, + I_CAR, + [], + [] ); + Prim + ( 421, + I_DIP, + [ Seq + ( 422, + [ + Prim + ( + 423, + I_DUP, + [], + [] + ); + Prim + ( + 424, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 425, + I_GET, + [], + [] ); + Prim + ( 426, + I_IF_NONE, + [ Seq + ( 427, + [ + Prim + ( + 428, + I_EMPTY_MAP, + [ + Prim + ( + 429, + T_address, + [], + [] + ); + Prim + ( + 430, + T_nat, + [], + [] + ) + ], + [] + ); + Prim + ( + 431, + I_PUSH, + [ + Prim + ( + 432, + T_nat, + [], + [] + ); + Int + ( + 433, + Z + .zero + ) + ], + [] + ); + Prim + ( + 434, + I_PAIR, + [], + [] + ) + ] + ); + Seq + ( 435, + [] + ) + ], + [] ); + Prim + ( 436, + I_DIG, + [ Int + ( 437, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 438, + I_DIP, + [ Seq + ( 439, + [ + Prim + ( + 440, + I_DUP, + [], + [] + ); + Prim + ( + 441, + I_DIP, + [ + Seq + ( + 442, + [ + Prim + ( + 443, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 444, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 445, + I_SWAP, + [], + [] ); + Prim + ( 446, + I_DROP, + [], + [] ); + Prim + ( 447, + I_PAIR, + [], + [] ); + Prim + ( 448, + I_DIP, + [ Seq + ( 449, + [ + Prim + ( + 450, + I_DUP, + [], + [] + ); + Prim + ( + 451, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 452, + I_SOME, + [], + [] ); + Prim + ( 453, + I_DIP, + [ Int + ( 454, + Z + .of_int + 3 + ); + Seq + ( 455, + [ + Prim + ( + 456, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 457, + I_DIG, + [ Int + ( 458, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 459, + I_CAR, + [], + [] ); + Prim + ( 460, + I_CAR, + [], + [] ); + Prim + ( 461, + I_UPDATE, + [], + [] ); + Prim + ( 462, + I_DIP, + [ Seq + ( 463, + [ + Prim + ( + 464, + I_DUP, + [], + [] + ); + Prim + ( + 465, + I_DIP, + [ + Seq + ( + 466, + [ + Prim + ( + 467, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 468, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 469, + I_SWAP, + [], + [] ); + Prim + ( 470, + I_DROP, + [], + [] ); + Prim + ( 471, + I_PAIR, + [], + [] ); + Prim + ( 472, + I_DUP, + [], + [] ); + Prim + ( 473, + I_CDR, + [], + [] ); + Prim + ( 474, + I_CDR, + [], + [] ); + Prim + ( 475, + I_CDR, + [], + [] ); + Prim + ( 476, + I_CDR, + [], + [] ); + Prim + ( 477, + I_AMOUNT, + [], + [] ); + Prim + ( 478, + I_ADD, + [], + [] ); + Prim + ( 479, + I_DIP, + [ Seq + ( 480, + [ + Prim + ( + 481, + I_DUP, + [], + [] + ); + Prim + ( + 482, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 483, + I_DIP, + [ Seq + ( 484, + [ + Prim + ( + 485, + I_DUP, + [], + [] + ); + Prim + ( + 486, + I_DIP, + [ + Seq + ( + 487, + [ + Prim + ( + 488, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 489, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 490, + I_DIP, + [ Seq + ( 491, + [ + Prim + ( + 492, + I_DUP, + [], + [] + ); + Prim + ( + 493, + I_DIP, + [ + Seq + ( + 494, + [ + Prim + ( + 495, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 496, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 497, + I_DIP, + [ Seq + ( 498, + [ + Prim + ( + 499, + I_DUP, + [], + [] + ); + Prim + ( + 500, + I_DIP, + [ + Seq + ( + 501, + [ + Prim + ( + 502, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 503, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 504, + I_SWAP, + [], + [] ); + Prim + ( 505, + I_DROP, + [], + [] ); + Prim + ( 506, + I_SWAP, + [], + [] ); + Prim + ( 507, + I_PAIR, + [], + [] ); + Prim + ( 508, + I_SWAP, + [], + [] ); + Prim + ( 509, + I_PAIR, + [], + [] ); + Prim + ( 510, + I_SWAP, + [], + [] ); + Prim + ( 511, + I_PAIR, + [], + [] ); + Prim + ( 512, + I_DIP, + [ Seq + ( 513, + [ + Prim + ( + 514, + I_DUP, + [], + [] + ); + Prim + ( + 515, + I_DIP, + [ + Seq + ( + 516, + [ + Prim + ( + 517, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 518, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 519, + I_SWAP, + [], + [] ); + Prim + ( 520, + I_DROP, + [], + [] ); + Prim + ( 521, + I_SWAP, + [], + [] ); + Prim + ( 522, + I_PAIR, + [], + [] ); + Prim + ( 523, + I_DUP, + [], + [] ); + Prim + ( 524, + I_CDR, + [], + [] ); + Prim + ( 525, + I_CDR, + [], + [] ); + Prim + ( 526, + I_CDR, + [], + [] ); + Prim + ( 527, + I_CAR, + [], + [] ); + Prim + ( 528, + I_DIP, + [ Int + ( 529, + Z + .of_int + 2 + ); + Seq + ( 530, + [ + Prim + ( + 531, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 532, + I_DIG, + [ Int + ( 533, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 534, + I_CDR, + [], + [] ); + Prim + ( 535, + I_CAR, + [], + [] ); + Prim + ( 536, + I_ADD, + [], + [] ); + Prim + ( 537, + I_DIP, + [ Seq + ( 538, + [ + Prim + ( + 539, + I_DUP, + [], + [] + ); + Prim + ( + 540, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 541, + I_DIP, + [ Seq + ( 542, + [ + Prim + ( + 543, + I_DUP, + [], + [] + ); + Prim + ( + 544, + I_DIP, + [ + Seq + ( + 545, + [ + Prim + ( + 546, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 547, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 548, + I_DIP, + [ Seq + ( 549, + [ + Prim + ( + 550, + I_DUP, + [], + [] + ); + Prim + ( + 551, + I_DIP, + [ + Seq + ( + 552, + [ + Prim + ( + 553, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 554, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 555, + I_DIP, + [ Seq + ( 556, + [ + Prim + ( + 557, + I_DUP, + [], + [] + ); + Prim + ( + 558, + I_DIP, + [ + Seq + ( + 559, + [ + Prim + ( + 560, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 561, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 562, + I_SWAP, + [], + [] ); + Prim + ( 563, + I_DROP, + [], + [] ); + Prim + ( 564, + I_PAIR, + [], + [] ); + Prim + ( 565, + I_SWAP, + [], + [] ); + Prim + ( 566, + I_PAIR, + [], + [] ); + Prim + ( 567, + I_SWAP, + [], + [] ); + Prim + ( 568, + I_PAIR, + [], + [] ); + Prim + ( 569, + I_DIP, + [ Seq + ( 570, + [ + Prim + ( + 571, + I_DUP, + [], + [] + ); + Prim + ( + 572, + I_DIP, + [ + Seq + ( + 573, + [ + Prim + ( + 574, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 575, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 576, + I_SWAP, + [], + [] ); + Prim + ( 577, + I_DROP, + [], + [] ); + Prim + ( 578, + I_SWAP, + [], + [] ); + Prim + ( 579, + I_PAIR, + [], + [] ); + Prim + ( 580, + I_DIP, + [ Seq + ( 581, + [ + Prim + ( + 582, + I_DUP, + [], + [] + ); + Prim + ( + 583, + I_CDR, + [], + [] + ); + Prim + ( + 584, + I_CAR, + [], + [] + ); + Prim + ( + 585, + I_DIP, + [ + Seq + ( + 586, + [ + Prim + ( + 587, + I_CAR, + [], + [] + ); + Prim + ( + 588, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 589, + I_DUP, + [], + [] ); + Prim + ( 590, + I_CDR, + [], + [] ); + Prim + ( 591, + I_CDR, + [], + [] ); + Prim + ( 592, + I_CAR, + [], + [] ); + Prim + ( 593, + I_CONTRACT, + [ Prim + ( 594, + T_pair, + [ + Prim + ( + 595, + T_address, + [], + [] + ); + Prim + ( + 596, + T_pair, + [ + Prim + ( + 597, + T_address, + [], + [] + ); + Prim + ( + 598, + T_nat, + [], + [] + ) + ], + [] + ) + ], + [] + ) + ], + [ "%transfer" + ] ); + Prim + ( 599, + I_IF_NONE, + [ Seq + ( 600, + [ + Prim + ( + 601, + I_PUSH, + [ + Prim + ( + 602, + T_string, + [], + [] + ); + String + ( + 603, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] + ); + Prim + ( + 604, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 605, + [] + ) + ], + [] ); + Prim + ( 606, + I_PUSH, + [ Prim + ( 607, + T_mutez, + [], + [] + ); + Int + ( 608, + Z + .zero + ) + ], + [] ); + Prim + ( 609, + I_DIG, + [ Int + ( 610, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 611, + I_SELF, + [], + [] ); + Prim + ( 612, + I_ADDRESS, + [], + [] ); + Prim + ( 613, + I_DIG, + [ Int + ( 614, + Z + .of_int + 5 + ) + ], + [] ); + Prim + ( 615, + I_DIP, + [ Seq + ( 616, + [ + Prim + ( + 617, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 618, + I_PAIR, + [], + [] ); + Prim + ( 619, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + ( 620, + I_DIP, + [ Seq + ( 621, + [ + Prim + ( + 622, + I_NIL, + [ + Prim + ( + 623, + T_operation, + [], + [] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 624, + I_CONS, + [], + [] ); + Prim + ( 625, + I_PAIR, + [], + [] ) ] + ); + Seq + ( 626, + [ Prim + ( 627, + I_DIP, + [ Seq + ( 628, + [ + Prim + ( + 629, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 630, + I_SWAP, + [], + [] ); + Prim + ( 631, + I_CDR, + [], + [] ); + Prim + ( 632, + I_CDR, + [], + [] ); + Prim + ( 633, + I_CDR, + [], + [] ); + Prim + ( 634, + I_CDR, + [], + [] ); + Prim + ( 635, + I_DIP, + [ Seq + ( 636, + [ + Prim + ( + 637, + I_PUSH, + [ + Prim + ( + 638, + T_mutez, + [], + [] + ); + Int + ( + 639, + Z + .one + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 640, + I_EDIV, + [], + [] ); + Prim + ( 641, + I_IF_NONE, + [ Seq + ( 642, + [ + Prim + ( + 643, + I_PUSH, + [ + Prim + ( + 644, + T_string, + [], + [] + ); + String + ( + 645, + "" + ) + ], + [] + ); + Prim + ( + 646, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 647, + [ + Prim + ( + 648, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 649, + I_AMOUNT, + [], + [] ); + Prim + ( 650, + I_DIP, + [ Seq + ( 651, + [ + Prim + ( + 652, + I_PUSH, + [ + Prim + ( + 653, + T_mutez, + [], + [] + ); + Int + ( + 654, + Z + .one + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 655, + I_EDIV, + [], + [] ); + Prim + ( 656, + I_IF_NONE, + [ Seq + ( 657, + [ + Prim + ( + 658, + I_PUSH, + [ + Prim + ( + 659, + T_string, + [], + [] + ); + String + ( + 660, + "" + ) + ], + [] + ); + Prim + ( + 661, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 662, + [ + Prim + ( + 663, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 664, + I_DUP, + [], + [] ); + Prim + ( 665, + I_DIP, + [ Int + ( 666, + Z + .of_int + 4 + ); + Seq + ( 667, + [ + Prim + ( + 668, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 669, + I_DIG, + [ Int + ( 670, + Z + .of_int + 4 + ) + ], + [] ); + Prim + ( 671, + I_CDR, + [], + [] ); + Prim + ( 672, + I_CDR, + [], + [] ); + Prim + ( 673, + I_CDR, + [], + [] ); + Prim + ( 674, + I_CAR, + [], + [] ); + Prim + ( 675, + I_MUL, + [], + [] ); + Prim + ( 676, + I_DIP, + [ Int + ( 677, + Z + .of_int + 2 + ); + Seq + ( 678, + [ + Prim + ( + 679, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 680, + I_DIG, + [ Int + ( 681, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 682, + I_SWAP, + [], + [] ); + Prim + ( 683, + I_EDIV, + [], + [] ); + Prim + ( 684, + I_IF_NONE, + [ Seq + ( 685, + [ + Prim + ( + 686, + I_PUSH, + [ + Prim + ( + 687, + T_string, + [], + [] + ); + String + ( + 688, + "divByZero." + ) + ], + [] + ); + Prim + ( + 689, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 690, + [ + Prim + ( + 691, + I_DUP, + [], + [] + ); + Prim + ( + 692, + I_CAR, + [], + [] + ); + Prim + ( + 693, + I_DIP, + [ + Seq + ( + 694, + [ + Prim + ( + 695, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 696, + I_SWAP, + [], + [] + ); + Prim + ( + 697, + I_INT, + [], + [] + ); + Prim + ( + 698, + I_EQ, + [], + [] + ); + Prim + ( + 699, + I_IF, + [ + Seq + ( + 700, + [] + ); + Seq + ( + 701, + [ + Prim + ( + 702, + I_PUSH, + [ + Prim + ( + 703, + T_nat, + [], + [] + ); + Int + ( + 704, + Z + .one + ) + ], + [] + ); + Prim + ( + 705, + I_ADD, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 706, + I_DUP, + [], + [] ); + Prim + ( 707, + I_PUSH, + [ Prim + ( 708, + T_nat, + [], + [] + ); + Int + ( 709, + Z + .zero + ) + ], + [] ); + Prim + ( 710, + I_COMPARE, + [], + [] ); + Prim + ( 711, + I_LT, + [], + [] ); + Prim + ( 712, + I_IF, + [ Seq + ( 713, + [] + ); + Seq + ( 714, + [ + Prim + ( + 715, + I_PUSH, + [ + Prim + ( + 716, + T_string, + [], + [] + ); + String + ( + 717, + "tokensDeposited \ + is \ + zero." + ) + ], + [] + ); + Prim + ( + 718, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 719, + I_SWAP, + [], + [] ); + Prim + ( 720, + I_DIP, + [ Int + ( 721, + Z + .of_int + 4 + ); + Seq + ( 722, + [ + Prim + ( + 723, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 724, + I_DIG, + [ Int + ( 725, + Z + .of_int + 4 + ) + ], + [] ); + Prim + ( 726, + I_CDR, + [], + [] ); + Prim + ( 727, + I_CAR, + [], + [] ); + Prim + ( 728, + I_CDR, + [], + [] ); + Prim + ( 729, + I_MUL, + [], + [] ); + Prim + ( 730, + I_DIP, + [ Seq + ( 731, + [ + Prim + ( + 732, + I_SWAP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 733, + I_EDIV, + [], + [] ); + Prim + ( 734, + I_IF_NONE, + [ Seq + ( 735, + [ + Prim + ( + 736, + I_PUSH, + [ + Prim + ( + 737, + T_string, + [], + [] + ); + String + ( + 738, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] + ); + Prim + ( + 739, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 740, + [ + Prim + ( + 741, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 742, + I_DIP, + [ Int + ( 743, + Z + .of_int + 2 + ); + Seq + ( 744, + [ + Prim + ( + 745, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 746, + I_DIG, + [ Int + ( 747, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 748, + I_CAR, + [], + [] ); + Prim + ( 749, + I_CDR, + [], + [] ); + Prim + ( 750, + I_DIP, + [ Seq + ( 751, + [ + Prim + ( + 752, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 753, + I_COMPARE, + [], + [] ); + Prim + ( 754, + I_LE, + [], + [] ); + Prim + ( 755, + I_IF, + [ Seq + ( 756, + [] + ); + Seq + ( 757, + [ + Prim + ( + 758, + I_PUSH, + [ + Prim + ( + 759, + T_string, + [], + [] + ); + String + ( + 760, + "lqtMinted \ + must \ + be \ + greater \ + than \ + or \ + equal \ + to \ + minLqtMinted." + ) + ], + [] + ); + Prim + ( + 761, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 762, + I_DIP, + [ Seq + ( 763, + [ + Prim + ( + 764, + I_DIP, + [ + Seq + ( + 765, + [ + Prim + ( + 766, + I_DUP, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 767, + I_SWAP, + [], + [] + ); + Prim + ( + 768, + I_CDR, + [], + [] + ); + Prim + ( + 769, + I_CAR, + [], + [] + ); + Prim + ( + 770, + I_DIP, + [ + Seq + ( + 771, + [ + Prim + ( + 772, + I_DUP, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 773, + I_COMPARE, + [], + [] + ); + Prim + ( + 774, + I_GE, + [], + [] + ); + Prim + ( + 775, + I_IF, + [ + Seq + ( + 776, + [] + ); + Seq + ( + 777, + [ + Prim + ( + 778, + I_PUSH, + [ + Prim + ( + 779, + T_string, + [], + [] + ); + String + ( + 780, + "tokensDeposited \ + is \ + greater \ + than \ + maxTokensDeposited." + ) + ], + [] + ); + Prim + ( + 781, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 782, + I_DIP, + [ Int + ( 783, + Z + .of_int + 3 + ); + Seq + ( 784, + [ + Prim + ( + 785, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 786, + I_DIG, + [ Int + ( 787, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 788, + I_DIP, + [ Int + ( 789, + Z + .of_int + 3 + ); + Seq + ( 790, + [ + Prim + ( + 791, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 792, + I_DIG, + [ Int + ( 793, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 794, + I_CAR, + [], + [] ); + Prim + ( 795, + I_CAR, + [], + [] ); + Prim + ( 796, + I_DIP, + [ Seq + ( 797, + [ + Prim + ( + 798, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 799, + I_GET, + [], + [] ); + Prim + ( 800, + I_IF_NONE, + [ Seq + ( 801, + [ + Prim + ( + 802, + I_EMPTY_MAP, + [ + Prim + ( + 803, + T_address, + [], + [] + ); + Prim + ( + 804, + T_nat, + [], + [] + ) + ], + [] + ); + Prim + ( + 805, + I_PUSH, + [ + Prim + ( + 806, + T_nat, + [], + [] + ); + Int + ( + 807, + Z + .zero + ) + ], + [] + ); + Prim + ( + 808, + I_PAIR, + [], + [] + ) + ] + ); + Seq + ( 809, + [] + ) + ], + [] ); + Prim + ( 810, + I_DUP, + [], + [] ); + Prim + ( 811, + I_CAR, + [], + [] ); + Prim + ( 812, + I_DIP, + [ Int + ( 813, + Z + .of_int + 2 + ); + Seq + ( 814, + [ + Prim + ( + 815, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 816, + I_DIG, + [ Int + ( 817, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 818, + I_ADD, + [], + [] ); + Prim + ( 819, + I_DIP, + [ Seq + ( 820, + [ + Prim + ( + 821, + I_DUP, + [], + [] + ); + Prim + ( + 822, + I_DIP, + [ + Seq + ( + 823, + [ + Prim + ( + 824, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 825, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 826, + I_SWAP, + [], + [] ); + Prim + ( 827, + I_DROP, + [], + [] ); + Prim + ( 828, + I_PAIR, + [], + [] ); + Prim + ( 829, + I_SOME, + [], + [] ); + Prim + ( 830, + I_DIP, + [ Int + ( 831, + Z + .of_int + 3 + ); + Seq + ( 832, + [ + Prim + ( + 833, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 834, + I_DIG, + [ Int + ( 835, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 836, + I_CAR, + [], + [] ); + Prim + ( 837, + I_CAR, + [], + [] ); + Prim + ( 838, + I_DIP, + [ Seq + ( 839, + [ + Prim + ( + 840, + I_DIP, + [ + Seq + ( + 841, + [ + Prim + ( + 842, + I_DIG, + [ + Int + ( + 843, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 844, + I_DUP, + [], + [] + ); + Prim + ( + 845, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 846, + I_UPDATE, + [], + [] ); + Prim + ( 847, + I_DIP, + [ Seq + ( 848, + [ + Prim + ( + 849, + I_DUP, + [], + [] + ); + Prim + ( + 850, + I_DIP, + [ + Seq + ( + 851, + [ + Prim + ( + 852, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 853, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 854, + I_SWAP, + [], + [] ); + Prim + ( 855, + I_DROP, + [], + [] ); + Prim + ( 856, + I_PAIR, + [], + [] ); + Prim + ( 857, + I_DUP, + [], + [] ); + Prim + ( 858, + I_CDR, + [], + [] ); + Prim + ( 859, + I_CAR, + [], + [] ); + Prim + ( 860, + I_CDR, + [], + [] ); + Prim + ( 861, + I_DIG, + [ Int + ( 862, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 863, + I_ADD, + [], + [] ); + Prim + ( 864, + I_DIP, + [ Seq + ( 865, + [ + Prim + ( + 866, + I_DUP, + [], + [] + ); + Prim + ( + 867, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 868, + I_DIP, + [ Seq + ( 869, + [ + Prim + ( + 870, + I_DUP, + [], + [] + ); + Prim + ( + 871, + I_DIP, + [ + Seq + ( + 872, + [ + Prim + ( + 873, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 874, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 875, + I_DIP, + [ Seq + ( 876, + [ + Prim + ( + 877, + I_DUP, + [], + [] + ); + Prim + ( + 878, + I_DIP, + [ + Seq + ( + 879, + [ + Prim + ( + 880, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 881, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 882, + I_SWAP, + [], + [] ); + Prim + ( 883, + I_DROP, + [], + [] ); + Prim + ( 884, + I_SWAP, + [], + [] ); + Prim + ( 885, + I_PAIR, + [], + [] ); + Prim + ( 886, + I_PAIR, + [], + [] ); + Prim + ( 887, + I_DIP, + [ Seq + ( 888, + [ + Prim + ( + 889, + I_DUP, + [], + [] + ); + Prim + ( + 890, + I_DIP, + [ + Seq + ( + 891, + [ + Prim + ( + 892, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 893, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 894, + I_SWAP, + [], + [] ); + Prim + ( 895, + I_DROP, + [], + [] ); + Prim + ( 896, + I_SWAP, + [], + [] ); + Prim + ( 897, + I_PAIR, + [], + [] ); + Prim + ( 898, + I_DUP, + [], + [] ); + Prim + ( 899, + I_CDR, + [], + [] ); + Prim + ( 900, + I_CDR, + [], + [] ); + Prim + ( 901, + I_CDR, + [], + [] ); + Prim + ( 902, + I_CDR, + [], + [] ); + Prim + ( 903, + I_AMOUNT, + [], + [] ); + Prim + ( 904, + I_ADD, + [], + [] ); + Prim + ( 905, + I_DIP, + [ Seq + ( 906, + [ + Prim + ( + 907, + I_DUP, + [], + [] + ); + Prim + ( + 908, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 909, + I_DIP, + [ Seq + ( 910, + [ + Prim + ( + 911, + I_DUP, + [], + [] + ); + Prim + ( + 912, + I_DIP, + [ + Seq + ( + 913, + [ + Prim + ( + 914, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 915, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 916, + I_DIP, + [ Seq + ( 917, + [ + Prim + ( + 918, + I_DUP, + [], + [] + ); + Prim + ( + 919, + I_DIP, + [ + Seq + ( + 920, + [ + Prim + ( + 921, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 922, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 923, + I_DIP, + [ Seq + ( 924, + [ + Prim + ( + 925, + I_DUP, + [], + [] + ); + Prim + ( + 926, + I_DIP, + [ + Seq + ( + 927, + [ + Prim + ( + 928, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 929, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 930, + I_SWAP, + [], + [] ); + Prim + ( 931, + I_DROP, + [], + [] ); + Prim + ( 932, + I_SWAP, + [], + [] ); + Prim + ( 933, + I_PAIR, + [], + [] ); + Prim + ( 934, + I_SWAP, + [], + [] ); + Prim + ( 935, + I_PAIR, + [], + [] ); + Prim + ( 936, + I_SWAP, + [], + [] ); + Prim + ( 937, + I_PAIR, + [], + [] ); + Prim + ( 938, + I_DIP, + [ Seq + ( 939, + [ + Prim + ( + 940, + I_DUP, + [], + [] + ); + Prim + ( + 941, + I_DIP, + [ + Seq + ( + 942, + [ + Prim + ( + 943, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 944, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 945, + I_SWAP, + [], + [] ); + Prim + ( 946, + I_DROP, + [], + [] ); + Prim + ( 947, + I_SWAP, + [], + [] ); + Prim + ( 948, + I_PAIR, + [], + [] ); + Prim + ( 949, + I_DUP, + [], + [] ); + Prim + ( 950, + I_CDR, + [], + [] ); + Prim + ( 951, + I_CDR, + [], + [] ); + Prim + ( 952, + I_CDR, + [], + [] ); + Prim + ( 953, + I_CAR, + [], + [] ); + Prim + ( 954, + I_DIP, + [ Int + ( 955, + Z + .of_int + 2 + ); + Seq + ( 956, + [ + Prim + ( + 957, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 958, + I_DIG, + [ Int + ( 959, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 960, + I_ADD, + [], + [] ); + Prim + ( 961, + I_DIP, + [ Seq + ( 962, + [ + Prim + ( + 963, + I_DUP, + [], + [] + ); + Prim + ( + 964, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 965, + I_DIP, + [ Seq + ( 966, + [ + Prim + ( + 967, + I_DUP, + [], + [] + ); + Prim + ( + 968, + I_DIP, + [ + Seq + ( + 969, + [ + Prim + ( + 970, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 971, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 972, + I_DIP, + [ Seq + ( 973, + [ + Prim + ( + 974, + I_DUP, + [], + [] + ); + Prim + ( + 975, + I_DIP, + [ + Seq + ( + 976, + [ + Prim + ( + 977, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 978, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 979, + I_DIP, + [ Seq + ( 980, + [ + Prim + ( + 981, + I_DUP, + [], + [] + ); + Prim + ( + 982, + I_DIP, + [ + Seq + ( + 983, + [ + Prim + ( + 984, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 985, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 986, + I_SWAP, + [], + [] ); + Prim + ( 987, + I_DROP, + [], + [] ); + Prim + ( 988, + I_PAIR, + [], + [] ); + Prim + ( 989, + I_SWAP, + [], + [] ); + Prim + ( 990, + I_PAIR, + [], + [] ); + Prim + ( 991, + I_SWAP, + [], + [] ); + Prim + ( 992, + I_PAIR, + [], + [] ); + Prim + ( 993, + I_DIP, + [ Seq + ( 994, + [ + Prim + ( + 995, + I_DUP, + [], + [] + ); + Prim + ( + 996, + I_DIP, + [ + Seq + ( + 997, + [ + Prim + ( + 998, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 999, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1000, + I_SWAP, + [], + [] ); + Prim + ( 1001, + I_DROP, + [], + [] ); + Prim + ( 1002, + I_SWAP, + [], + [] ); + Prim + ( 1003, + I_PAIR, + [], + [] ); + Prim + ( 1004, + I_DIP, + [ Seq + ( 1005, + [ + Prim + ( + 1006, + I_DIP, + [ + Seq + ( + 1007, + [ + Prim + ( + 1008, + I_CAR, + [], + [] + ); + Prim + ( + 1009, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1010, + I_DUP, + [], + [] ); + Prim + ( 1011, + I_CDR, + [], + [] ); + Prim + ( 1012, + I_CDR, + [], + [] ); + Prim + ( 1013, + I_CAR, + [], + [] ); + Prim + ( 1014, + I_CONTRACT, + [ Prim + ( 1015, + T_pair, + [ + Prim + ( + 1016, + T_address, + [], + [] + ); + Prim + ( + 1017, + T_pair, + [ + Prim + ( + 1018, + T_address, + [], + [] + ); + Prim + ( + 1019, + T_nat, + [], + [] + ) + ], + [] + ) + ], + [] + ) + ], + [ "%transfer" + ] ); + Prim + ( 1020, + I_IF_NONE, + [ Seq + ( 1021, + [ + Prim + ( + 1022, + I_PUSH, + [ + Prim + ( + 1023, + T_string, + [], + [] + ); + String + ( + 1024, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] + ); + Prim + ( + 1025, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 1026, + [] + ) + ], + [] ); + Prim + ( 1027, + I_PUSH, + [ Prim + ( 1028, + T_mutez, + [], + [] + ); + Int + ( 1029, + Z + .zero + ) + ], + [] ); + Prim + ( 1030, + I_DIG, + [ Int + ( 1031, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1032, + I_SELF, + [], + [] ); + Prim + ( 1033, + I_ADDRESS, + [], + [] ); + Prim + ( 1034, + I_DIG, + [ Int + ( 1035, + Z + .of_int + 5 + ) + ], + [] ); + Prim + ( 1036, + I_DIP, + [ Seq + ( 1037, + [ + Prim + ( + 1038, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1039, + I_PAIR, + [], + [] ); + Prim + ( 1040, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + ( 1041, + I_DIP, + [ Seq + ( 1042, + [ + Prim + ( + 1043, + I_NIL, + [ + Prim + ( + 1044, + T_operation, + [], + [] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1045, + I_CONS, + [], + [] ); + Prim + ( 1046, + I_PAIR, + [], + [] ) ] + ) ], + [] ) ] ) ], + [] ) ] ); + Seq + ( 1047, + [ Prim + ( 1048, + I_IF_LEFT, + [ Seq + ( 1049, + [ Prim + ( 1050, + I_DIP, + [ Seq + ( 1051, + [ Prim + ( 1052, + I_DUP, + [], + [] ); + Prim + ( 1053, + I_CDR, + [], + [] ); + Prim + ( 1054, + I_CAR, + [], + [] ); + Prim + ( 1055, + I_CAR, + [], + [] ); + Prim + ( 1056, + I_IF, + [ Seq + ( 1057, + [ + Prim + ( + 1058, + I_PUSH, + [ + Prim + ( + 1059, + T_string, + [], + [] + ); + String + ( + 1060, + "selfIsUpdatingToken \ + must \ + be \ + false." + ) + ], + [] + ); + Prim + ( + 1061, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 1062, + [] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (1063, I_DUP, [], []); + Prim + (1064, I_CDR, [], []); + Prim + (1065, I_CDR, [], []); + Prim + (1066, I_CDR, [], []); + Prim + (1067, I_NOW, [], []); + Prim + ( 1068, + I_COMPARE, + [], + [] ); + Prim + (1069, I_LT, [], []); + Prim + ( 1070, + I_IF, + [ Seq (1071, []); + Seq + ( 1072, + [ Prim + ( 1073, + I_PUSH, + [ Prim + ( 1074, + T_string, + [], + [] + ); + String + ( 1075, + "NOW \ + is \ + greater \ + than \ + deadline." + ) + ], + [] ); + Prim + ( 1076, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1077, + I_PUSH, + [ Prim + ( 1078, + T_mutez, + [], + [] ); + Int (1079, Z.zero) + ], + [] ); + Prim + ( 1080, + I_AMOUNT, + [], + [] ); + Prim + ( 1081, + I_COMPARE, + [], + [] ); + Prim + (1082, I_EQ, [], []); + Prim + ( 1083, + I_IF, + [ Seq (1084, []); + Seq + ( 1085, + [ Prim + ( 1086, + I_PUSH, + [ Prim + ( 1087, + T_string, + [], + [] + ); + String + ( 1088, + "Amount \ + must \ + be \ + zero." + ) + ], + [] ); + Prim + ( 1089, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (1090, I_DUP, [], []); + Prim + (1091, I_CDR, [], []); + Prim + (1092, I_CAR, [], []); + Prim + ( 1093, + I_PUSH, + [ Prim + ( 1094, + T_mutez, + [], + [] ); + Int (1095, Z.zero) + ], + [] ); + Prim + ( 1096, + I_COMPARE, + [], + [] ); + Prim + (1097, I_LT, [], []); + Prim + ( 1098, + I_IF, + [ Seq (1099, []); + Seq + ( 1100, + [ Prim + ( 1101, + I_PUSH, + [ Prim + ( 1102, + T_string, + [], + [] + ); + String + ( 1103, + "minXtzWithdrawn \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 1104, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (1105, I_DUP, [], []); + Prim + (1106, I_CDR, [], []); + Prim + (1107, I_CDR, [], []); + Prim + (1108, I_CAR, [], []); + Prim + ( 1109, + I_PUSH, + [ Prim + ( 1110, + T_nat, + [], + [] ); + Int (1111, Z.zero) + ], + [] ); + Prim + ( 1112, + I_COMPARE, + [], + [] ); + Prim + (1113, I_LT, [], []); + Prim + ( 1114, + I_IF, + [ Seq (1115, []); + Seq + ( 1116, + [ Prim + ( 1117, + I_PUSH, + [ Prim + ( 1118, + T_string, + [], + [] + ); + String + ( 1119, + "minTokensWithdrawn \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 1120, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (1121, I_DUP, [], []); + Prim + (1122, I_CAR, [], []); + Prim + (1123, I_CDR, [], []); + Prim + (1124, I_CDR, [], []); + Prim + ( 1125, + I_PUSH, + [ Prim + ( 1126, + T_nat, + [], + [] ); + Int (1127, Z.zero) + ], + [] ); + Prim + ( 1128, + I_COMPARE, + [], + [] ); + Prim + (1129, I_LT, [], []); + Prim + ( 1130, + I_IF, + [ Seq (1131, []); + Seq + ( 1132, + [ Prim + ( 1133, + I_PUSH, + [ Prim + ( 1134, + T_string, + [], + [] + ); + String + ( 1135, + "lqtBurned \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 1136, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (1137, I_DUP, [], []); + Prim + (1138, I_CAR, [], []); + Prim + (1139, I_CAR, [], []); + Prim + ( 1140, + I_DIP, + [ Seq + ( 1141, + [ Prim + ( 1142, + I_DIP, + [ Seq + ( 1143, + [ + Prim + ( + 1144, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1145, + I_SWAP, + [], + [] ); + Prim + ( 1146, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1147, I_GET, [], []); + Prim + ( 1148, + I_IF_NONE, + [ Seq + ( 1149, + [ Prim + ( 1150, + I_PUSH, + [ Prim + ( 1151, + T_string, + [], + [] + ); + String + ( 1152, + "owner \ + has \ + no \ + liquidity." + ) + ], + [] ); + Prim + ( 1153, + I_FAILWITH, + [], + [] ) ] + ); + Seq (1154, []) ], + [] ); + Prim + (1155, I_SWAP, [], []); + Prim + (1156, I_DUP, [], []); + Prim + (1157, I_CAR, [], []); + Prim + (1158, I_CDR, [], []); + Prim + (1159, I_CDR, [], []); + Prim + ( 1160, + I_DIP, + [ Int + ( 1161, + Z.of_int 2 ); + Seq + ( 1162, + [ Prim + ( 1163, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1164, + I_DIG, + [ Int + ( 1165, + Z.of_int 2 ) + ], + [] ); + Prim + (1166, I_CAR, [], []); + Prim + ( 1167, + I_COMPARE, + [], + [] ); + Prim + (1168, I_GE, [], []); + Prim + ( 1169, + I_IF, + [ Seq (1170, []); + Seq + ( 1171, + [ Prim + ( 1172, + I_PUSH, + [ Prim + ( 1173, + T_string, + [], + [] + ); + String + ( 1174, + "lqtBurned \ + is \ + greater \ + than \ + owner's \ + balance." + ) + ], + [] ); + Prim + ( 1175, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (1176, I_DUP, [], []); + Prim + (1177, I_CAR, [], []); + Prim + (1178, I_CAR, [], []); + Prim + ( 1179, + I_SENDER, + [], + [] ); + Prim + ( 1180, + I_COMPARE, + [], + [] ); + Prim + (1181, I_EQ, [], []); + Prim + ( 1182, + I_IF, + [ Seq + ( 1183, + [ Prim + ( 1184, + I_SWAP, + [], + [] ); + Prim + ( 1185, + I_CAR, + [], + [] ) ] + ); + Seq + ( 1186, + [ Prim + ( 1187, + I_SWAP, + [], + [] ); + Prim + ( 1188, + I_DUP, + [], + [] ); + Prim + ( 1189, + I_CDR, + [], + [] ); + Prim + ( 1190, + I_SENDER, + [], + [] ); + Prim + ( 1191, + I_GET, + [], + [] ); + Prim + ( 1192, + I_IF_NONE, + [ Seq + ( 1193, + [ + Prim + ( + 1194, + I_PUSH, + [ + Prim + ( + 1195, + T_string, + [], + [] + ); + String + ( + 1196, + "sender \ + has \ + no \ + approval \ + balance." + ) + ], + [] + ); + Prim + ( + 1197, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 1198, + [] + ) + ], + [] ); + Prim + ( 1199, + I_DIP, + [ Seq + ( 1200, + [ + Prim + ( + 1201, + I_SWAP, + [], + [] + ); + Prim + ( + 1202, + I_DUP, + [], + [] + ); + Prim + ( + 1203, + I_CAR, + [], + [] + ); + Prim + ( + 1204, + I_CDR, + [], + [] + ); + Prim + ( + 1205, + I_CDR, + [], + [] + ); + Prim + ( + 1206, + I_DIP, + [ + Seq + ( + 1207, + [ + Prim + ( + 1208, + I_PUSH, + [ + Prim + ( + 1209, + T_int, + [], + [] + ); + Int + ( + 1210, + Z + .zero + ) + ], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1211, + I_SUB, + [], + [] ); + Prim + ( 1212, + I_DUP, + [], + [] ); + Prim + ( 1213, + I_DIP, + [ Seq + ( 1214, + [ + Prim + ( + 1215, + I_COMPARE, + [], + [] + ); + Prim + ( + 1216, + I_GE, + [], + [] + ); + Prim + ( + 1217, + I_IF, + [ + Seq + ( + 1218, + [] + ); + Seq + ( + 1219, + [ + Prim + ( + 1220, + I_PUSH, + [ + Prim + ( + 1221, + T_string, + [], + [] + ); + String + ( + 1222, + "sender \ + approval \ + balance \ + is \ + less \ + than \ + LQT \ + burned." + ) + ], + [] + ); + Prim + ( + 1223, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1224, + I_ABS, + [], + [] ); + Prim + ( 1225, + I_SOME, + [], + [] ); + Prim + ( 1226, + I_DIG, + [ Int + ( 1227, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 1228, + I_DUP, + [], + [] ); + Prim + ( 1229, + I_CDR, + [], + [] ); + Prim + ( 1230, + I_DIG, + [ Int + ( 1231, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 1232, + I_SENDER, + [], + [] ); + Prim + ( 1233, + I_UPDATE, + [], + [] ); + Prim + ( 1234, + I_DIP, + [ Seq + ( 1235, + [ + Prim + ( + 1236, + I_DUP, + [], + [] + ); + Prim + ( + 1237, + I_DIP, + [ + Seq + ( + 1238, + [ + Prim + ( + 1239, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 1240, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1241, + I_SWAP, + [], + [] ); + Prim + ( 1242, + I_DROP, + [], + [] ); + Prim + ( 1243, + I_SWAP, + [], + [] ); + Prim + ( 1244, + I_PAIR, + [], + [] ); + Prim + ( 1245, + I_DUP, + [], + [] ); + Prim + ( 1246, + I_CAR, + [], + [] ); + Prim + ( 1247, + I_DIP, + [ Seq + ( 1248, + [ + Prim + ( + 1249, + I_SOME, + [], + [] + ); + Prim + ( + 1250, + I_DUG, + [ + Int + ( + 1251, + Z + .one + ) + ], + [] + ); + Prim + ( + 1252, + I_DUP, + [], + [] + ); + Prim + ( + 1253, + I_CAR, + [], + [] + ); + Prim + ( + 1254, + I_CAR, + [], + [] + ); + Prim + ( + 1255, + I_SWAP, + [], + [] + ); + Prim + ( + 1256, + I_DIP, + [ + Seq + ( + 1257, + [ + Prim + ( + 1258, + I_DIP, + [ + Seq + ( + 1259, + [ + Prim + ( + 1260, + I_DIP, + [ + Seq + ( + 1261, + [ + Prim + ( + 1262, + I_DUP, + [], + [] + ); + Prim + ( + 1263, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 1264, + I_UPDATE, + [], + [] + ); + Prim + ( + 1265, + I_DIP, + [ + Seq + ( + 1266, + [ + Prim + ( + 1267, + I_DUP, + [], + [] + ); + Prim + ( + 1268, + I_DIP, + [ + Seq + ( + 1269, + [ + Prim + ( + 1270, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 1271, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 1272, + I_SWAP, + [], + [] + ); + Prim + ( + 1273, + I_DROP, + [], + [] + ); + Prim + ( + 1274, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + ( 1275, + I_DIP, + [ Seq + ( 1276, + [ Prim + ( 1277, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + (1278, I_SWAP, [], []); + Prim + (1279, I_CAR, [], []); + Prim + (1280, I_CDR, [], []); + Prim + (1281, I_CDR, [], []); + Prim + ( 1282, + I_DIP, + [ Int + ( 1283, + Z.of_int 3 ); + Seq + ( 1284, + [ Prim + ( 1285, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1286, + I_DIG, + [ Int + ( 1287, + Z.of_int 3 ) + ], + [] ); + Prim + (1288, I_CDR, [], []); + Prim + (1289, I_CDR, [], []); + Prim + (1290, I_CDR, [], []); + Prim + (1291, I_CDR, [], []); + Prim + ( 1292, + I_DIP, + [ Seq + ( 1293, + [ Prim + ( 1294, + I_PUSH, + [ Prim + ( 1295, + T_mutez, + [], + [] + ); + Int + ( 1296, + Z + .one + ) + ], + [] ) ] + ) ], + [] ); + Prim + (1297, I_EDIV, [], []); + Prim + ( 1298, + I_IF_NONE, + [ Seq + ( 1299, + [ Prim + ( 1300, + I_PUSH, + [ Prim + ( 1301, + T_string, + [], + [] + ); + String + ( 1302, + "" + ) + ], + [] ); + Prim + ( 1303, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 1304, + [ Prim + ( 1305, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1306, I_MUL, [], []); + Prim + ( 1307, + I_DIP, + [ Seq + ( 1308, + [ Prim + ( 1309, + I_DIP, + [ Int + ( 1310, + Z + .of_int + 2 + ); + Seq + ( 1311, + [ + Prim + ( + 1312, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1313, + I_DIG, + [ Int + ( 1314, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 1315, + I_CDR, + [], + [] ); + Prim + ( 1316, + I_CAR, + [], + [] ); + Prim + ( 1317, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (1318, I_EDIV, [], []); + Prim + ( 1319, + I_IF_NONE, + [ Seq + ( 1320, + [ Prim + ( 1321, + I_PUSH, + [ Prim + ( 1322, + T_string, + [], + [] + ); + String + ( 1323, + "divByZero." + ) + ], + [] ); + Prim + ( 1324, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 1325, + [ Prim + ( 1326, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1327, + I_PUSH, + [ Prim + ( 1328, + T_mutez, + [], + [] ); + Int (1329, Z.one) + ], + [] ); + Prim + (1330, I_MUL, [], []); + Prim + (1331, I_DUP, [], []); + Prim + ( 1332, + I_DIP, + [ Int + ( 1333, + Z.of_int 3 ); + Seq + ( 1334, + [ Prim + ( 1335, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1336, + I_DIG, + [ Int + ( 1337, + Z.of_int 3 ) + ], + [] ); + Prim + (1338, I_CDR, [], []); + Prim + (1339, I_CAR, [], []); + Prim + ( 1340, + I_COMPARE, + [], + [] ); + Prim + (1341, I_LE, [], []); + Prim + ( 1342, + I_IF, + [ Seq (1343, []); + Seq + ( 1344, + [ Prim + ( 1345, + I_PUSH, + [ Prim + ( 1346, + T_string, + [], + [] + ); + String + ( 1347, + "xtzWithdrawn \ + is \ + less \ + than \ + minXtzWithdrawn." + ) + ], + [] ); + Prim + ( 1348, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1349, + I_DIP, + [ Int + ( 1350, + Z.of_int 2 ); + Seq + ( 1351, + [ Prim + ( 1352, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1353, + I_DIG, + [ Int + ( 1354, + Z.of_int 2 ) + ], + [] ); + Prim + (1355, I_CAR, [], []); + Prim + (1356, I_CDR, [], []); + Prim + (1357, I_CDR, [], []); + Prim + ( 1358, + I_DIP, + [ Seq + ( 1359, + [ Prim + ( 1360, + I_DIP, + [ Int + ( 1361, + Z + .of_int + 3 + ); + Seq + ( 1362, + [ + Prim + ( + 1363, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1364, + I_DIG, + [ Int + ( 1365, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1366, + I_DUP, + [], + [] ); + Prim + ( 1367, + I_CDR, + [], + [] ); + Prim + ( 1368, + I_CAR, + [], + [] ); + Prim + ( 1369, + I_CDR, + [], + [] ); + Prim + ( 1370, + I_SWAP, + [], + [] ); + Prim + ( 1371, + I_CDR, + [], + [] ); + Prim + ( 1372, + I_CDR, + [], + [] ); + Prim + ( 1373, + I_CDR, + [], + [] ); + Prim + ( 1374, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1375, I_MUL, [], []); + Prim + (1376, I_EDIV, [], []); + Prim + ( 1377, + I_IF_NONE, + [ Seq + ( 1378, + [ Prim + ( 1379, + I_PUSH, + [ Prim + ( 1380, + T_string, + [], + [] + ); + String + ( 1381, + "divByZero." + ) + ], + [] ); + Prim + ( 1382, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 1383, + [ Prim + ( 1384, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1385, I_DUP, [], []); + Prim + ( 1386, + I_DIP, + [ Int + ( 1387, + Z.of_int 4 ); + Seq + ( 1388, + [ Prim + ( 1389, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1390, + I_DIG, + [ Int + ( 1391, + Z.of_int 4 ) + ], + [] ); + Prim + (1392, I_CDR, [], []); + Prim + (1393, I_CDR, [], []); + Prim + (1394, I_CAR, [], []); + Prim + ( 1395, + I_COMPARE, + [], + [] ); + Prim + (1396, I_LE, [], []); + Prim + ( 1397, + I_IF, + [ Seq (1398, []); + Seq + ( 1399, + [ Prim + ( 1400, + I_PUSH, + [ Prim + ( 1401, + T_string, + [], + [] + ); + String + ( 1402, + "tokensWithdrawn \ + is \ + less \ + than \ + minTokensWithdrawn." + ) + ], + [] ); + Prim + ( 1403, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1404, + I_DIP, + [ Int + ( 1405, + Z.of_int 3 ); + Seq + ( 1406, + [ Prim + ( 1407, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1408, + I_DIG, + [ Int + ( 1409, + Z.of_int 3 ) + ], + [] ); + Prim + (1410, I_CAR, [], []); + Prim + (1411, I_CDR, [], []); + Prim + (1412, I_CDR, [], []); + Prim + ( 1413, + I_DIG, + [ Int + ( 1414, + Z.of_int 3 ) + ], + [] ); + Prim + (1415, I_SUB, [], []); + Prim + (1416, I_DUP, [], []); + Prim + ( 1417, + I_PUSH, + [ Prim + ( 1418, + T_int, + [], + [] ); + Int (1419, Z.zero) + ], + [] ); + Prim + ( 1420, + I_COMPARE, + [], + [] ); + Prim + (1421, I_LE, [], []); + Prim + ( 1422, + I_IF, + [ Seq + ( 1423, + [ Prim + ( 1424, + I_ABS, + [], + [] ) ] + ); + Seq + ( 1425, + [ Prim + ( 1426, + I_PUSH, + [ Prim + ( 1427, + T_string, + [], + [] + ); + String + ( 1428, + "" + ) + ], + [] ); + Prim + ( 1429, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1430, + I_DIG, + [ Int + ( 1431, + Z.of_int 4 ) + ], + [] ); + Prim + (1432, I_DUP, [], []); + Prim + ( 1433, + I_DIP, + [ Int + ( 1434, + Z.of_int 5 ); + Seq + ( 1435, + [ Prim + ( 1436, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1437, + I_DIG, + [ Int + ( 1438, + Z.of_int 5 ) + ], + [] ); + Prim + (1439, I_CAR, [], []); + Prim + (1440, I_CAR, [], []); + Prim + ( 1441, + I_DIP, + [ Seq + ( 1442, + [ Prim + ( 1443, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1444, I_GET, [], []); + Prim + ( 1445, + I_IF_NONE, + [ Seq + ( 1446, + [ Prim + ( 1447, + I_EMPTY_MAP, + [ Prim + ( 1448, + T_address, + [], + [] + ); + Prim + ( 1449, + T_nat, + [], + [] + ) + ], + [] ); + Prim + ( 1450, + I_PUSH, + [ Prim + ( 1451, + T_nat, + [], + [] + ); + Int + ( 1452, + Z + .zero + ) + ], + [] ); + Prim + ( 1453, + I_PAIR, + [], + [] ) ] + ); + Seq (1454, []) ], + [] ); + Prim + ( 1455, + I_DIG, + [ Int + ( 1456, + Z.of_int 2 ) + ], + [] ); + Prim + ( 1457, + I_DIP, + [ Seq + ( 1458, + [ Prim + ( 1459, + I_DUP, + [], + [] ); + Prim + ( 1460, + I_DIP, + [ Seq + ( 1461, + [ + Prim + ( + 1462, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1463, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1464, I_SWAP, [], []); + Prim + (1465, I_DROP, [], []); + Prim + (1466, I_PAIR, [], []); + Prim + ( 1467, + I_DIP, + [ Seq + ( 1468, + [ Prim + ( 1469, + I_DUP, + [], + [] ); + Prim + ( 1470, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1471, I_SOME, [], []); + Prim + ( 1472, + I_DIP, + [ Int + ( 1473, + Z.of_int 5 ); + Seq + ( 1474, + [ Prim + ( 1475, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1476, + I_DIG, + [ Int + ( 1477, + Z.of_int 5 ) + ], + [] ); + Prim + (1478, I_CAR, [], []); + Prim + (1479, I_CAR, [], []); + Prim + ( 1480, + I_UPDATE, + [], + [] ); + Prim + ( 1481, + I_DIP, + [ Seq + ( 1482, + [ Prim + ( 1483, + I_DUP, + [], + [] ); + Prim + ( 1484, + I_DIP, + [ Seq + ( 1485, + [ + Prim + ( + 1486, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1487, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1488, I_SWAP, [], []); + Prim + (1489, I_DROP, [], []); + Prim + (1490, I_PAIR, [], []); + Prim + (1491, I_DUP, [], []); + Prim + (1492, I_CDR, [], []); + Prim + (1493, I_CAR, [], []); + Prim + (1494, I_CDR, [], []); + Prim + ( 1495, + I_DIP, + [ Int + ( 1496, + Z.of_int 4 ); + Seq + ( 1497, + [ Prim + ( 1498, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1499, + I_DIG, + [ Int + ( 1500, + Z.of_int 4 ) + ], + [] ); + Prim + (1501, I_CAR, [], []); + Prim + (1502, I_CDR, [], []); + Prim + (1503, I_CDR, [], []); + Prim + (1504, I_SWAP, [], []); + Prim + (1505, I_SUB, [], []); + Prim + (1506, I_DUP, [], []); + Prim + ( 1507, + I_PUSH, + [ Prim + ( 1508, + T_int, + [], + [] ); + Int (1509, Z.zero) + ], + [] ); + Prim + ( 1510, + I_COMPARE, + [], + [] ); + Prim + (1511, I_LE, [], []); + Prim + ( 1512, + I_IF, + [ Seq + ( 1513, + [ Prim + ( 1514, + I_ABS, + [], + [] ) ] + ); + Seq + ( 1515, + [ Prim + ( 1516, + I_PUSH, + [ Prim + ( 1517, + T_string, + [], + [] + ); + String + ( 1518, + "" + ) + ], + [] ); + Prim + ( 1519, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1520, + I_DIP, + [ Seq + ( 1521, + [ Prim + ( 1522, + I_DUP, + [], + [] ); + Prim + ( 1523, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1524, + I_DIP, + [ Seq + ( 1525, + [ Prim + ( 1526, + I_DUP, + [], + [] ); + Prim + ( 1527, + I_DIP, + [ Seq + ( 1528, + [ + Prim + ( + 1529, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1530, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1531, + I_DIP, + [ Seq + ( 1532, + [ Prim + ( 1533, + I_DUP, + [], + [] ); + Prim + ( 1534, + I_DIP, + [ Seq + ( 1535, + [ + Prim + ( + 1536, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1537, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (1538, I_SWAP, [], []); + Prim + (1539, I_DROP, [], []); + Prim + (1540, I_SWAP, [], []); + Prim + (1541, I_PAIR, [], []); + Prim + (1542, I_PAIR, [], []); + Prim + ( 1543, + I_DIP, + [ Seq + ( 1544, + [ Prim + ( 1545, + I_DUP, + [], + [] ); + Prim + ( 1546, + I_DIP, + [ Seq + ( 1547, + [ + Prim + ( + 1548, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1549, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (1550, I_SWAP, [], []); + Prim + (1551, I_DROP, [], []); + Prim + (1552, I_SWAP, [], []); + Prim + (1553, I_PAIR, [], []); + Prim + (1554, I_DUP, [], []); + Prim + (1555, I_CDR, [], []); + Prim + (1556, I_CDR, [], []); + Prim + (1557, I_CDR, [], []); + Prim + (1558, I_CAR, [], []); + Prim + ( 1559, + I_DIP, + [ Int + ( 1560, + Z.of_int 2 ); + Seq + ( 1561, + [ Prim + ( 1562, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1563, + I_DIG, + [ Int + ( 1564, + Z.of_int 2 ) + ], + [] ); + Prim + (1565, I_SWAP, [], []); + Prim + (1566, I_SUB, [], []); + Prim + (1567, I_DUP, [], []); + Prim + ( 1568, + I_PUSH, + [ Prim + ( 1569, + T_int, + [], + [] ); + Int (1570, Z.zero) + ], + [] ); + Prim + ( 1571, + I_COMPARE, + [], + [] ); + Prim + (1572, I_LE, [], []); + Prim + ( 1573, + I_IF, + [ Seq + ( 1574, + [ Prim + ( 1575, + I_ABS, + [], + [] ) ] + ); + Seq + ( 1576, + [ Prim + ( 1577, + I_PUSH, + [ Prim + ( 1578, + T_string, + [], + [] + ); + String + ( 1579, + "" + ) + ], + [] ); + Prim + ( 1580, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1581, + I_DIP, + [ Seq + ( 1582, + [ Prim + ( 1583, + I_DUP, + [], + [] ); + Prim + ( 1584, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1585, + I_DIP, + [ Seq + ( 1586, + [ Prim + ( 1587, + I_DUP, + [], + [] ); + Prim + ( 1588, + I_DIP, + [ Seq + ( 1589, + [ + Prim + ( + 1590, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1591, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1592, + I_DIP, + [ Seq + ( 1593, + [ Prim + ( 1594, + I_DUP, + [], + [] ); + Prim + ( 1595, + I_DIP, + [ Seq + ( 1596, + [ + Prim + ( + 1597, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1598, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1599, + I_DIP, + [ Seq + ( 1600, + [ Prim + ( 1601, + I_DUP, + [], + [] ); + Prim + ( 1602, + I_DIP, + [ Seq + ( 1603, + [ + Prim + ( + 1604, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1605, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1606, I_SWAP, [], []); + Prim + (1607, I_DROP, [], []); + Prim + (1608, I_PAIR, [], []); + Prim + (1609, I_SWAP, [], []); + Prim + (1610, I_PAIR, [], []); + Prim + (1611, I_SWAP, [], []); + Prim + (1612, I_PAIR, [], []); + Prim + ( 1613, + I_DIP, + [ Seq + ( 1614, + [ Prim + ( 1615, + I_DUP, + [], + [] ); + Prim + ( 1616, + I_DIP, + [ Seq + ( 1617, + [ + Prim + ( + 1618, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1619, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (1620, I_SWAP, [], []); + Prim + (1621, I_DROP, [], []); + Prim + (1622, I_SWAP, [], []); + Prim + (1623, I_PAIR, [], []); + Prim + (1624, I_DUP, [], []); + Prim + (1625, I_CDR, [], []); + Prim + (1626, I_CDR, [], []); + Prim + (1627, I_CDR, [], []); + Prim + (1628, I_CDR, [], []); + Prim + ( 1629, + I_DIP, + [ Int + ( 1630, + Z.of_int 3 ); + Seq + ( 1631, + [ Prim + ( 1632, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1633, + I_DIG, + [ Int + ( 1634, + Z.of_int 3 ) + ], + [] ); + Prim + (1635, I_SWAP, [], []); + Prim + (1636, I_SUB, [], []); + Prim + ( 1637, + I_DIP, + [ Seq + ( 1638, + [ Prim + ( 1639, + I_DUP, + [], + [] ); + Prim + ( 1640, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1641, + I_DIP, + [ Seq + ( 1642, + [ Prim + ( 1643, + I_DUP, + [], + [] ); + Prim + ( 1644, + I_DIP, + [ Seq + ( 1645, + [ + Prim + ( + 1646, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1647, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1648, + I_DIP, + [ Seq + ( 1649, + [ Prim + ( 1650, + I_DUP, + [], + [] ); + Prim + ( 1651, + I_DIP, + [ Seq + ( 1652, + [ + Prim + ( + 1653, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1654, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1655, + I_DIP, + [ Seq + ( 1656, + [ Prim + ( 1657, + I_DUP, + [], + [] ); + Prim + ( 1658, + I_DIP, + [ Seq + ( 1659, + [ + Prim + ( + 1660, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1661, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (1662, I_SWAP, [], []); + Prim + (1663, I_DROP, [], []); + Prim + (1664, I_SWAP, [], []); + Prim + (1665, I_PAIR, [], []); + Prim + (1666, I_SWAP, [], []); + Prim + (1667, I_PAIR, [], []); + Prim + (1668, I_SWAP, [], []); + Prim + (1669, I_PAIR, [], []); + Prim + ( 1670, + I_DIP, + [ Seq + ( 1671, + [ Prim + ( 1672, + I_DUP, + [], + [] ); + Prim + ( 1673, + I_DIP, + [ Seq + ( 1674, + [ + Prim + ( + 1675, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1676, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (1677, I_SWAP, [], []); + Prim + (1678, I_DROP, [], []); + Prim + (1679, I_SWAP, [], []); + Prim + (1680, I_PAIR, [], []); + Prim + ( 1681, + I_DIP, + [ Int + ( 1682, + Z.of_int 3 ); + Seq + ( 1683, + [ Prim + ( 1684, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1685, + I_DIG, + [ Int + ( 1686, + Z.of_int 3 ) + ], + [] ); + Prim + (1687, I_CAR, [], []); + Prim + (1688, I_CDR, [], []); + Prim + (1689, I_CAR, [], []); + Prim + ( 1690, + I_CONTRACT, + [ Prim + ( 1691, + T_unit, + [], + [] ) ], + [] ); + Prim + ( 1692, + I_IF_NONE, + [ Seq + ( 1693, + [ Prim + ( 1694, + I_PUSH, + [ Prim + ( 1695, + T_string, + [], + [] + ); + String + ( 1696, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] ); + Prim + ( 1697, + I_FAILWITH, + [], + [] ) ] + ); + Seq (1698, []) ], + [] ); + Prim + ( 1699, + I_DIG, + [ Int + ( 1700, + Z.of_int 3 ) + ], + [] ); + Prim + (1701, I_UNIT, [], []); + Prim + ( 1702, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + ( 1703, + I_DIP, + [ Seq + ( 1704, + [ Prim + ( 1705, + I_DIP, + [ Seq + ( 1706, + [ + Prim + ( + 1707, + I_DIP, + [ + Seq + ( + 1708, + [ + Prim + ( + 1709, + I_CAR, + [], + [] + ); + Prim + ( + 1710, + I_CDR, + [], + [] + ); + Prim + ( + 1711, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1712, + I_DUP, + [], + [] ); + Prim + ( 1713, + I_CDR, + [], + [] ); + Prim + ( 1714, + I_CDR, + [], + [] ); + Prim + ( 1715, + I_CAR, + [], + [] ); + Prim + ( 1716, + I_CONTRACT, + [ Prim + ( 1717, + T_pair, + [ + Prim + ( + 1718, + T_address, + [], + [] + ); + Prim + ( + 1719, + T_pair, + [ + Prim + ( + 1720, + T_address, + [], + [] + ); + Prim + ( + 1721, + T_nat, + [], + [] + ) + ], + [] + ) + ], + [] + ) + ], + [ "%transfer" + ] ); + Prim + ( 1722, + I_IF_NONE, + [ Seq + ( 1723, + [ + Prim + ( + 1724, + I_PUSH, + [ + Prim + ( + 1725, + T_string, + [], + [] + ); + String + ( + 1726, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] + ); + Prim + ( + 1727, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 1728, + [] + ) + ], + [] ); + Prim + ( 1729, + I_PUSH, + [ Prim + ( 1730, + T_mutez, + [], + [] + ); + Int + ( 1731, + Z + .zero + ) + ], + [] ); + Prim + ( 1732, + I_DIG, + [ Int + ( 1733, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1734, + I_DIG, + [ Int + ( 1735, + Z + .of_int + 4 + ) + ], + [] ); + Prim + ( 1736, + I_PAIR, + [], + [] ); + Prim + ( 1737, + I_SELF, + [], + [] ); + Prim + ( 1738, + I_ADDRESS, + [], + [] ); + Prim + ( 1739, + I_PAIR, + [], + [] ); + Prim + ( 1740, + I_TRANSFER_TOKENS, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1741, + I_NIL, + [ Prim + ( 1742, + T_operation, + [], + [] ) ], + [] ); + Prim + (1743, I_SWAP, [], []); + Prim + (1744, I_CONS, [], []); + Prim + (1745, I_SWAP, [], []); + Prim + (1746, I_CONS, [], []); + Prim + (1747, I_PAIR, [], []) + ] ); + Seq + ( 1748, + [ Prim + ( 1749, + I_DIP, + [ Seq + ( 1750, + [ Prim + ( 1751, + I_DUP, + [], + [] ); + Prim + ( 1752, + I_CDR, + [], + [] ); + Prim + ( 1753, + I_CAR, + [], + [] ); + Prim + ( 1754, + I_CAR, + [], + [] ); + Prim + ( 1755, + I_IF, + [ Seq + ( 1756, + [ + Prim + ( + 1757, + I_PUSH, + [ + Prim + ( + 1758, + T_string, + [], + [] + ); + String + ( + 1759, + "selfIsUpdatingToken \ + must \ + be \ + false." + ) + ], + [] + ); + Prim + ( + 1760, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 1761, + [] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (1762, I_DUP, [], []); + Prim + (1763, I_CDR, [], []); + Prim + (1764, I_CDR, [], []); + Prim + (1765, I_NOW, [], []); + Prim + ( 1766, + I_COMPARE, + [], + [] ); + Prim + (1767, I_LT, [], []); + Prim + ( 1768, + I_IF, + [ Seq (1769, []); + Seq + ( 1770, + [ Prim + ( 1771, + I_PUSH, + [ Prim + ( 1772, + T_string, + [], + [] + ); + String + ( 1773, + "NOW \ + is \ + greater \ + than \ + deadline." + ) + ], + [] ); + Prim + ( 1774, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1775, + I_PUSH, + [ Prim + ( 1776, + T_mutez, + [], + [] ); + Int (1777, Z.zero) + ], + [] ); + Prim + ( 1778, + I_AMOUNT, + [], + [] ); + Prim + ( 1779, + I_COMPARE, + [], + [] ); + Prim + (1780, I_GT, [], []); + Prim + ( 1781, + I_IF, + [ Seq (1782, []); + Seq + ( 1783, + [ Prim + ( 1784, + I_PUSH, + [ Prim + ( 1785, + T_string, + [], + [] + ); + String + ( 1786, + "Amount \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 1787, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (1788, I_DUP, [], []); + Prim + (1789, I_CDR, [], []); + Prim + (1790, I_CAR, [], []); + Prim + ( 1791, + I_PUSH, + [ Prim + ( 1792, + T_nat, + [], + [] ); + Int (1793, Z.zero) + ], + [] ); + Prim + ( 1794, + I_COMPARE, + [], + [] ); + Prim + (1795, I_LT, [], []); + Prim + ( 1796, + I_IF, + [ Seq (1797, []); + Seq + ( 1798, + [ Prim + ( 1799, + I_PUSH, + [ Prim + ( 1800, + T_string, + [], + [] + ); + String + ( 1801, + "minTokensBought \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 1802, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1803, + I_DIP, + [ Seq + ( 1804, + [ Prim + ( 1805, + I_DUP, + [], + [] ); + Prim + ( 1806, + I_CDR, + [], + [] ); + Prim + ( 1807, + I_CDR, + [], + [] ); + Prim + ( 1808, + I_CDR, + [], + [] ); + Prim + ( 1809, + I_CDR, + [], + [] ); + Prim + ( 1810, + I_PUSH, + [ Prim + ( 1811, + T_mutez, + [], + [] + ); + Int + ( 1812, + Z + .zero + ) + ], + [] ); + Prim + ( 1813, + I_COMPARE, + [], + [] ); + Prim + ( 1814, + I_LT, + [], + [] ); + Prim + ( 1815, + I_IF, + [ Seq + ( 1816, + [] + ); + Seq + ( 1817, + [ + Prim + ( + 1818, + I_PUSH, + [ + Prim + ( + 1819, + T_string, + [], + [] + ); + String + ( + 1820, + "xtzPool \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] + ); + Prim + ( + 1821, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + ( 1822, + I_DIP, + [ Seq + ( 1823, + [ Prim + ( 1824, + I_DUP, + [], + [] ); + Prim + ( 1825, + I_CDR, + [], + [] ); + Prim + ( 1826, + I_CDR, + [], + [] ); + Prim + ( 1827, + I_CDR, + [], + [] ); + Prim + ( 1828, + I_CAR, + [], + [] ); + Prim + ( 1829, + I_PUSH, + [ Prim + ( 1830, + T_nat, + [], + [] + ); + Int + ( 1831, + Z + .zero + ) + ], + [] ); + Prim + ( 1832, + I_COMPARE, + [], + [] ); + Prim + ( 1833, + I_LT, + [], + [] ); + Prim + ( 1834, + I_IF, + [ Seq + ( 1835, + [] + ); + Seq + ( 1836, + [ + Prim + ( + 1837, + I_PUSH, + [ + Prim + ( + 1838, + T_string, + [], + [] + ); + String + ( + 1839, + "tokenPool \ + must \ + be \ + greater \ + than \ + zero" + ) + ], + [] + ); + Prim + ( + 1840, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + ( 1841, + I_DIP, + [ Seq + ( 1842, + [ Prim + ( 1843, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + (1844, I_SWAP, [], []); + Prim + (1845, I_CDR, [], []); + Prim + (1846, I_CDR, [], []); + Prim + (1847, I_CDR, [], []); + Prim + (1848, I_CDR, [], []); + Prim + ( 1849, + I_DIP, + [ Seq + ( 1850, + [ Prim + ( 1851, + I_PUSH, + [ Prim + ( 1852, + T_mutez, + [], + [] + ); + Int + ( 1853, + Z + .one + ) + ], + [] ) ] + ) ], + [] ); + Prim + (1854, I_EDIV, [], []); + Prim + ( 1855, + I_IF_NONE, + [ Seq + ( 1856, + [ Prim + ( 1857, + I_PUSH, + [ Prim + ( 1858, + T_string, + [], + [] + ); + String + ( 1859, + "" + ) + ], + [] ); + Prim + ( 1860, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 1861, + [ Prim + ( 1862, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1863, + I_PUSH, + [ Prim + ( 1864, + T_nat, + [], + [] ); + Int + ( 1865, + Z.of_int 1000 + ) ], + [] ); + Prim + (1866, I_MUL, [], []); + Prim + ( 1867, + I_AMOUNT, + [], + [] ); + Prim + ( 1868, + I_DIP, + [ Seq + ( 1869, + [ Prim + ( 1870, + I_PUSH, + [ Prim + ( 1871, + T_mutez, + [], + [] + ); + Int + ( 1872, + Z + .one + ) + ], + [] ) ] + ) ], + [] ); + Prim + (1873, I_EDIV, [], []); + Prim + ( 1874, + I_IF_NONE, + [ Seq + ( 1875, + [ Prim + ( 1876, + I_PUSH, + [ Prim + ( 1877, + T_string, + [], + [] + ); + String + ( 1878, + "" + ) + ], + [] ); + Prim + ( 1879, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 1880, + [ Prim + ( 1881, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1882, I_DUP, [], []); + Prim + ( 1883, + I_DIP, + [ Seq + ( 1884, + [ Prim + ( 1885, + I_PUSH, + [ Prim + ( 1886, + T_nat, + [], + [] + ); + Int + ( 1887, + Z + .of_int + 999 + ) + ], + [] ); + Prim + ( 1888, + I_MUL, + [], + [] ); + Prim + ( 1889, + I_ADD, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1890, + I_PUSH, + [ Prim + ( 1891, + T_nat, + [], + [] ); + Int + ( 1892, + Z.of_int 999 + ) ], + [] ); + Prim + (1893, I_MUL, [], []); + Prim + ( 1894, + I_DIP, + [ Int + ( 1895, + Z.of_int 3 ); + Seq + ( 1896, + [ Prim + ( 1897, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1898, + I_DIG, + [ Int + ( 1899, + Z.of_int 3 ) + ], + [] ); + Prim + (1900, I_CDR, [], []); + Prim + (1901, I_CDR, [], []); + Prim + (1902, I_CDR, [], []); + Prim + (1903, I_CAR, [], []); + Prim + (1904, I_MUL, [], []); + Prim + (1905, I_EDIV, [], []); + Prim + ( 1906, + I_IF_NONE, + [ Seq + ( 1907, + [ Prim + ( 1908, + I_PUSH, + [ Prim + ( 1909, + T_string, + [], + [] + ); + String + ( 1910, + "divByZero." + ) + ], + [] ); + Prim + ( 1911, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 1912, + [ Prim + ( 1913, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1914, I_DUP, [], []); + Prim + ( 1915, + I_DIP, + [ Seq + ( 1916, + [ Prim + ( 1917, + I_DIP, + [ Seq + ( 1918, + [ + Prim + ( + 1919, + I_DUP, + [], + [] + ); + Prim + ( + 1920, + I_CDR, + [], + [] + ); + Prim + ( + 1921, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1922, + I_COMPARE, + [], + [] ); + Prim + ( 1923, + I_GE, + [], + [] ); + Prim + ( 1924, + I_IF, + [ Seq + ( 1925, + [] + ); + Seq + ( 1926, + [ + Prim + ( + 1927, + I_PUSH, + [ + Prim + ( + 1928, + T_string, + [], + [] + ); + String + ( + 1929, + "tokensBought \ + is \ + less \ + than \ + minTokensBought." + ) + ], + [] + ); + Prim + ( + 1930, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (1931, I_DUP, [], []); + Prim + ( 1932, + I_DIP, + [ Int + ( 1933, + Z.of_int 3 ); + Seq + ( 1934, + [ Prim + ( 1935, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1936, + I_DIG, + [ Int + ( 1937, + Z.of_int 3 ) + ], + [] ); + Prim + (1938, I_CDR, [], []); + Prim + (1939, I_CDR, [], []); + Prim + (1940, I_CDR, [], []); + Prim + (1941, I_CAR, [], []); + Prim + (1942, I_SUB, [], []); + Prim + (1943, I_DUP, [], []); + Prim + ( 1944, + I_PUSH, + [ Prim + ( 1945, + T_int, + [], + [] ); + Int (1946, Z.zero) + ], + [] ); + Prim + ( 1947, + I_COMPARE, + [], + [] ); + Prim + (1948, I_LE, [], []); + Prim + ( 1949, + I_IF, + [ Seq + ( 1950, + [ Prim + ( 1951, + I_ABS, + [], + [] ) ] + ); + Seq + ( 1952, + [ Prim + ( 1953, + I_PUSH, + [ Prim + ( 1954, + T_string, + [], + [] + ); + String + ( 1955, + "" + ) + ], + [] ); + Prim + ( 1956, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1957, + I_DIP, + [ Seq + ( 1958, + [ Prim + ( 1959, + I_DIG, + [ Int + ( 1960, + Z + .of_int + 2 + ) + ], + [] ) ] + ) ], + [] ); + Prim + ( 1961, + I_DIP, + [ Seq + ( 1962, + [ Prim + ( 1963, + I_DUP, + [], + [] ); + Prim + ( 1964, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1965, + I_DIP, + [ Seq + ( 1966, + [ Prim + ( 1967, + I_DUP, + [], + [] ); + Prim + ( 1968, + I_DIP, + [ Seq + ( 1969, + [ + Prim + ( + 1970, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1971, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1972, + I_DIP, + [ Seq + ( 1973, + [ Prim + ( 1974, + I_DUP, + [], + [] ); + Prim + ( 1975, + I_DIP, + [ Seq + ( 1976, + [ + Prim + ( + 1977, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1978, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 1979, + I_DIP, + [ Seq + ( 1980, + [ Prim + ( 1981, + I_DUP, + [], + [] ); + Prim + ( 1982, + I_DIP, + [ Seq + ( 1983, + [ + Prim + ( + 1984, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1985, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (1986, I_SWAP, [], []); + Prim + (1987, I_DROP, [], []); + Prim + (1988, I_PAIR, [], []); + Prim + (1989, I_SWAP, [], []); + Prim + (1990, I_PAIR, [], []); + Prim + (1991, I_SWAP, [], []); + Prim + (1992, I_PAIR, [], []); + Prim + ( 1993, + I_DIP, + [ Seq + ( 1994, + [ Prim + ( 1995, + I_DUP, + [], + [] ); + Prim + ( 1996, + I_DIP, + [ Seq + ( 1997, + [ + Prim + ( + 1998, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 1999, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2000, I_SWAP, [], []); + Prim + (2001, I_DROP, [], []); + Prim + (2002, I_SWAP, [], []); + Prim + (2003, I_PAIR, [], []); + Prim + (2004, I_DUP, [], []); + Prim + (2005, I_CDR, [], []); + Prim + (2006, I_CDR, [], []); + Prim + (2007, I_CDR, [], []); + Prim + (2008, I_CDR, [], []); + Prim + ( 2009, + I_AMOUNT, + [], + [] ); + Prim + (2010, I_ADD, [], []); + Prim + ( 2011, + I_DIP, + [ Seq + ( 2012, + [ Prim + ( 2013, + I_DUP, + [], + [] ); + Prim + ( 2014, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2015, + I_DIP, + [ Seq + ( 2016, + [ Prim + ( 2017, + I_DUP, + [], + [] ); + Prim + ( 2018, + I_DIP, + [ Seq + ( 2019, + [ + Prim + ( + 2020, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2021, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2022, + I_DIP, + [ Seq + ( 2023, + [ Prim + ( 2024, + I_DUP, + [], + [] ); + Prim + ( 2025, + I_DIP, + [ Seq + ( 2026, + [ + Prim + ( + 2027, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2028, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2029, + I_DIP, + [ Seq + ( 2030, + [ Prim + ( 2031, + I_DUP, + [], + [] ); + Prim + ( 2032, + I_DIP, + [ Seq + ( 2033, + [ + Prim + ( + 2034, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2035, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2036, I_SWAP, [], []); + Prim + (2037, I_DROP, [], []); + Prim + (2038, I_SWAP, [], []); + Prim + (2039, I_PAIR, [], []); + Prim + (2040, I_SWAP, [], []); + Prim + (2041, I_PAIR, [], []); + Prim + (2042, I_SWAP, [], []); + Prim + (2043, I_PAIR, [], []); + Prim + ( 2044, + I_DIP, + [ Seq + ( 2045, + [ Prim + ( 2046, + I_DUP, + [], + [] ); + Prim + ( 2047, + I_DIP, + [ Seq + ( 2048, + [ + Prim + ( + 2049, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2050, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2051, I_SWAP, [], []); + Prim + (2052, I_DROP, [], []); + Prim + (2053, I_SWAP, [], []); + Prim + (2054, I_PAIR, [], []); + Prim + ( 2055, + I_DIP, + [ Seq + ( 2056, + [ Prim + ( 2057, + I_DIP, + [ Seq + ( 2058, + [ + Prim + ( + 2059, + I_CAR, + [], + [] + ); + Prim + ( + 2060, + I_SELF, + [], + [] + ); + Prim + ( + 2061, + I_ADDRESS, + [], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (2062, I_DUP, [], []); + Prim + (2063, I_CDR, [], []); + Prim + (2064, I_CDR, [], []); + Prim + (2065, I_CAR, [], []); + Prim + ( 2066, + I_CONTRACT, + [ Prim + ( 2067, + T_pair, + [ Prim + ( 2068, + T_address, + [], + [] ); + Prim + ( 2069, + T_pair, + [ Prim + ( 2070, + T_address, + [], + [] + ); + Prim + ( 2071, + T_nat, + [], + [] + ) + ], + [] ) ], + [] ) ], + ["%transfer"] ); + Prim + ( 2072, + I_IF_NONE, + [ Seq + ( 2073, + [ Prim + ( 2074, + I_PUSH, + [ Prim + ( 2075, + T_string, + [], + [] + ); + String + ( 2076, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] ); + Prim + ( 2077, + I_FAILWITH, + [], + [] ) ] + ); + Seq (2078, []) ], + [] ); + Prim + ( 2079, + I_PUSH, + [ Prim + ( 2080, + T_mutez, + [], + [] ); + Int (2081, Z.zero) + ], + [] ); + Prim + ( 2082, + I_DIG, + [ Int + ( 2083, + Z.of_int 3 ) + ], + [] ); + Prim + ( 2084, + I_DIG, + [ Int + ( 2085, + Z.of_int 5 ) + ], + [] ); + Prim + ( 2086, + I_DIG, + [ Int + ( 2087, + Z.of_int 5 ) + ], + [] ); + Prim + ( 2088, + I_DIP, + [ Seq + ( 2089, + [ Prim + ( 2090, + I_PAIR, + [], + [] ) ] + ) ], + [] ); + Prim + (2091, I_PAIR, [], []); + Prim + ( 2092, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + ( 2093, + I_DIP, + [ Seq + ( 2094, + [ Prim + ( 2095, + I_NIL, + [ Prim + ( 2096, + T_operation, + [], + [] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (2097, I_CONS, [], []); + Prim + (2098, I_PAIR, [], []) + ] ) ], + [] ) ] ) ], + [] ) ] ); + Seq + ( 2099, + [ Prim + ( 2100, + I_IF_LEFT, + [ Seq + ( 2101, + [ Prim + ( 2102, + I_IF_LEFT, + [ Seq + ( 2103, + [ Prim + ( 2104, + I_DIP, + [ Seq + ( 2105, + [ Prim + ( 2106, + I_DUP, + [], + [] ); + Prim + ( 2107, + I_CDR, + [], + [] ); + Prim + ( 2108, + I_CAR, + [], + [] ); + Prim + ( 2109, + I_CAR, + [], + [] ); + Prim + ( 2110, + I_IF, + [ Seq + ( 2111, + [ + Prim + ( + 2112, + I_PUSH, + [ + Prim + ( + 2113, + T_string, + [], + [] + ); + String + ( + 2114, + "selfIsUpdatingToken \ + must \ + be \ + false." + ) + ], + [] + ); + Prim + ( + 2115, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 2116, + [] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (2117, I_DUP, [], []); + Prim + (2118, I_CDR, [], []); + Prim + (2119, I_CDR, [], []); + Prim + (2120, I_CDR, [], []); + Prim + (2121, I_NOW, [], []); + Prim + ( 2122, + I_COMPARE, + [], + [] ); + Prim + (2123, I_LT, [], []); + Prim + ( 2124, + I_IF, + [ Seq (2125, []); + Seq + ( 2126, + [ Prim + ( 2127, + I_PUSH, + [ Prim + ( 2128, + T_string, + [], + [] + ); + String + ( 2129, + "NOW \ + is \ + greater \ + than \ + deadline." + ) + ], + [] ); + Prim + ( 2130, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2131, + I_PUSH, + [ Prim + ( 2132, + T_mutez, + [], + [] ); + Int (2133, Z.zero) + ], + [] ); + Prim + ( 2134, + I_AMOUNT, + [], + [] ); + Prim + ( 2135, + I_COMPARE, + [], + [] ); + Prim + (2136, I_EQ, [], []); + Prim + ( 2137, + I_IF, + [ Seq (2138, []); + Seq + ( 2139, + [ Prim + ( 2140, + I_PUSH, + [ Prim + ( 2141, + T_string, + [], + [] + ); + String + ( 2142, + "Amount \ + must \ + be \ + zero." + ) + ], + [] ); + Prim + ( 2143, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2144, + I_DIP, + [ Seq + ( 2145, + [ Prim + ( 2146, + I_DUP, + [], + [] ); + Prim + ( 2147, + I_CDR, + [], + [] ); + Prim + ( 2148, + I_CDR, + [], + [] ); + Prim + ( 2149, + I_CDR, + [], + [] ); + Prim + ( 2150, + I_CDR, + [], + [] ); + Prim + ( 2151, + I_PUSH, + [ Prim + ( 2152, + T_mutez, + [], + [] + ); + Int + ( 2153, + Z + .zero + ) + ], + [] ); + Prim + ( 2154, + I_COMPARE, + [], + [] ); + Prim + ( 2155, + I_LT, + [], + [] ); + Prim + ( 2156, + I_IF, + [ Seq + ( 2157, + [] + ); + Seq + ( 2158, + [ + Prim + ( + 2159, + I_PUSH, + [ + Prim + ( + 2160, + T_string, + [], + [] + ); + String + ( + 2161, + "xtzPool \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] + ); + Prim + ( + 2162, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + ( 2163, + I_DIP, + [ Seq + ( 2164, + [ Prim + ( 2165, + I_DUP, + [], + [] ); + Prim + ( 2166, + I_CDR, + [], + [] ); + Prim + ( 2167, + I_CDR, + [], + [] ); + Prim + ( 2168, + I_CDR, + [], + [] ); + Prim + ( 2169, + I_CAR, + [], + [] ); + Prim + ( 2170, + I_PUSH, + [ Prim + ( 2171, + T_nat, + [], + [] + ); + Int + ( 2172, + Z + .zero + ) + ], + [] ); + Prim + ( 2173, + I_COMPARE, + [], + [] ); + Prim + ( 2174, + I_LT, + [], + [] ); + Prim + ( 2175, + I_IF, + [ Seq + ( 2176, + [] + ); + Seq + ( 2177, + [ + Prim + ( + 2178, + I_PUSH, + [ + Prim + ( + 2179, + T_string, + [], + [] + ); + String + ( + 2180, + "tokenPool \ + must \ + be \ + greater \ + than \ + zero" + ) + ], + [] + ); + Prim + ( + 2181, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (2182, I_DUP, [], []); + Prim + (2183, I_CDR, [], []); + Prim + (2184, I_CAR, [], []); + Prim + ( 2185, + I_PUSH, + [ Prim + ( 2186, + T_nat, + [], + [] ); + Int (2187, Z.zero) + ], + [] ); + Prim + ( 2188, + I_COMPARE, + [], + [] ); + Prim + (2189, I_LT, [], []); + Prim + ( 2190, + I_IF, + [ Seq (2191, []); + Seq + ( 2192, + [ Prim + ( 2193, + I_PUSH, + [ Prim + ( 2194, + T_string, + [], + [] + ); + String + ( 2195, + "tokensSold \ + is \ + zero" + ) + ], + [] ); + Prim + ( 2196, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (2197, I_DUP, [], []); + Prim + (2198, I_CDR, [], []); + Prim + (2199, I_CDR, [], []); + Prim + (2200, I_CAR, [], []); + Prim + ( 2201, + I_PUSH, + [ Prim + ( 2202, + T_mutez, + [], + [] ); + Int (2203, Z.zero) + ], + [] ); + Prim + ( 2204, + I_COMPARE, + [], + [] ); + Prim + (2205, I_LT, [], []); + Prim + ( 2206, + I_IF, + [ Seq (2207, []); + Seq + ( 2208, + [ Prim + ( 2209, + I_PUSH, + [ Prim + ( 2210, + T_string, + [], + [] + ); + String + ( 2211, + "minXtzBought \ + must \ + be \ + greater \ + than \ + zero." + ) + ], + [] ); + Prim + ( 2212, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (2213, I_DUP, [], []); + Prim + (2214, I_CDR, [], []); + Prim + (2215, I_CAR, [], []); + Prim + ( 2216, + I_PUSH, + [ Prim + ( 2217, + T_nat, + [], + [] ); + Int + ( 2218, + Z.of_int 999 + ) ], + [] ); + Prim + (2219, I_MUL, [], []); + Prim + ( 2220, + I_DIP, + [ Int + ( 2221, + Z.of_int 2 ); + Seq + ( 2222, + [ Prim + ( 2223, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2224, + I_DIG, + [ Int + ( 2225, + Z.of_int 2 ) + ], + [] ); + Prim + (2226, I_CDR, [], []); + Prim + (2227, I_CDR, [], []); + Prim + (2228, I_CDR, [], []); + Prim + (2229, I_CAR, [], []); + Prim + ( 2230, + I_PUSH, + [ Prim + ( 2231, + T_nat, + [], + [] ); + Int + ( 2232, + Z.of_int 1000 + ) ], + [] ); + Prim + (2233, I_MUL, [], []); + Prim + (2234, I_ADD, [], []); + Prim + ( 2235, + I_DIP, + [ Seq + ( 2236, + [ Prim + ( 2237, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + (2238, I_SWAP, [], []); + Prim + (2239, I_CDR, [], []); + Prim + (2240, I_CAR, [], []); + Prim + ( 2241, + I_PUSH, + [ Prim + ( 2242, + T_nat, + [], + [] ); + Int + ( 2243, + Z.of_int 999 + ) ], + [] ); + Prim + (2244, I_MUL, [], []); + Prim + ( 2245, + I_DIP, + [ Int + ( 2246, + Z.of_int 3 ); + Seq + ( 2247, + [ Prim + ( 2248, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2249, + I_DIG, + [ Int + ( 2250, + Z.of_int 3 ) + ], + [] ); + Prim + (2251, I_CDR, [], []); + Prim + (2252, I_CDR, [], []); + Prim + (2253, I_CDR, [], []); + Prim + (2254, I_CDR, [], []); + Prim + ( 2255, + I_DIP, + [ Seq + ( 2256, + [ Prim + ( 2257, + I_PUSH, + [ Prim + ( 2258, + T_mutez, + [], + [] + ); + Int + ( 2259, + Z + .one + ) + ], + [] ) ] + ) ], + [] ); + Prim + (2260, I_EDIV, [], []); + Prim + ( 2261, + I_IF_NONE, + [ Seq + ( 2262, + [ Prim + ( 2263, + I_PUSH, + [ Prim + ( 2264, + T_string, + [], + [] + ); + String + ( 2265, + "" + ) + ], + [] ); + Prim + ( 2266, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 2267, + [ Prim + ( 2268, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (2269, I_MUL, [], []); + Prim + (2270, I_EDIV, [], []); + Prim + ( 2271, + I_IF_NONE, + [ Seq + ( 2272, + [ Prim + ( 2273, + I_PUSH, + [ Prim + ( 2274, + T_string, + [], + [] + ); + String + ( 2275, + "divByZero." + ) + ], + [] ); + Prim + ( 2276, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 2277, + [ Prim + ( 2278, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2279, + I_PUSH, + [ Prim + ( 2280, + T_mutez, + [], + [] ); + Int (2281, Z.one) + ], + [] ); + Prim + (2282, I_MUL, [], []); + Prim + (2283, I_DUP, [], []); + Prim + ( 2284, + I_DIP, + [ Seq + ( 2285, + [ Prim + ( 2286, + I_DIP, + [ Seq + ( 2287, + [ + Prim + ( + 2288, + I_DUP, + [], + [] + ); + Prim + ( + 2289, + I_CDR, + [], + [] + ); + Prim + ( + 2290, + I_CDR, + [], + [] + ); + Prim + ( + 2291, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2292, + I_COMPARE, + [], + [] ); + Prim + ( 2293, + I_GE, + [], + [] ); + Prim + ( 2294, + I_IF, + [ Seq + ( 2295, + [] + ); + Seq + ( 2296, + [ + Prim + ( + 2297, + I_PUSH, + [ + Prim + ( + 2298, + T_string, + [], + [] + ); + String + ( + 2299, + "xtzBought \ + is \ + less \ + than \ + minXtzBought." + ) + ], + [] + ); + Prim + ( + 2300, + I_FAILWITH, + [], + [] + ) + ] + ) + ], + [] ) ] + ) ], + [] ); + Prim + ( 2301, + I_DIP, + [ Seq + ( 2302, + [ Prim + ( 2303, + I_SWAP, + [], + [] ); + Prim + ( 2304, + I_DUP, + [], + [] ); + Prim + ( 2305, + I_CDR, + [], + [] ); + Prim + ( 2306, + I_CDR, + [], + [] ); + Prim + ( 2307, + I_CDR, + [], + [] ); + Prim + ( 2308, + I_CAR, + [], + [] ); + Prim + ( 2309, + I_DIP, + [ Int + ( 2310, + Z + .of_int + 2 + ); + Seq + ( 2311, + [ + Prim + ( + 2312, + I_DUP, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2313, + I_DIG, + [ Int + ( 2314, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 2315, + I_CDR, + [], + [] ); + Prim + ( 2316, + I_CAR, + [], + [] ); + Prim + ( 2317, + I_ADD, + [], + [] ); + Prim + ( 2318, + I_DIP, + [ Seq + ( 2319, + [ + Prim + ( + 2320, + I_DUP, + [], + [] + ); + Prim + ( + 2321, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2322, + I_DIP, + [ Seq + ( 2323, + [ + Prim + ( + 2324, + I_DUP, + [], + [] + ); + Prim + ( + 2325, + I_DIP, + [ + Seq + ( + 2326, + [ + Prim + ( + 2327, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2328, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2329, + I_DIP, + [ Seq + ( 2330, + [ + Prim + ( + 2331, + I_DUP, + [], + [] + ); + Prim + ( + 2332, + I_DIP, + [ + Seq + ( + 2333, + [ + Prim + ( + 2334, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2335, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2336, + I_DIP, + [ Seq + ( 2337, + [ + Prim + ( + 2338, + I_DUP, + [], + [] + ); + Prim + ( + 2339, + I_DIP, + [ + Seq + ( + 2340, + [ + Prim + ( + 2341, + I_CDR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2342, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2343, + I_SWAP, + [], + [] ); + Prim + ( 2344, + I_DROP, + [], + [] ); + Prim + ( 2345, + I_PAIR, + [], + [] ); + Prim + ( 2346, + I_SWAP, + [], + [] ); + Prim + ( 2347, + I_PAIR, + [], + [] ); + Prim + ( 2348, + I_SWAP, + [], + [] ); + Prim + ( 2349, + I_PAIR, + [], + [] ); + Prim + ( 2350, + I_DIP, + [ Seq + ( 2351, + [ + Prim + ( + 2352, + I_DUP, + [], + [] + ); + Prim + ( + 2353, + I_DIP, + [ + Seq + ( + 2354, + [ + Prim + ( + 2355, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2356, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2357, + I_SWAP, + [], + [] ); + Prim + ( 2358, + I_DROP, + [], + [] ); + Prim + ( 2359, + I_SWAP, + [], + [] ); + Prim + ( 2360, + I_PAIR, + [], + [] ) ] + ) ], + [] ); + Prim + (2361, I_DUP, [], []); + Prim + ( 2362, + I_DIP, + [ Seq + ( 2363, + [ Prim + ( 2364, + I_DIP, + [ Seq + ( 2365, + [ + Prim + ( + 2366, + I_DUP, + [], + [] + ); + Prim + ( + 2367, + I_CDR, + [], + [] + ); + Prim + ( + 2368, + I_CDR, + [], + [] + ); + Prim + ( + 2369, + I_CDR, + [], + [] + ); + Prim + ( + 2370, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2371, + I_SWAP, + [], + [] ); + Prim + ( 2372, + I_SUB, + [], + [] ); + Prim + ( 2373, + I_DIP, + [ Seq + ( 2374, + [ + Prim + ( + 2375, + I_DUP, + [], + [] + ); + Prim + ( + 2376, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2377, + I_DIP, + [ Seq + ( 2378, + [ + Prim + ( + 2379, + I_DUP, + [], + [] + ); + Prim + ( + 2380, + I_DIP, + [ + Seq + ( + 2381, + [ + Prim + ( + 2382, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2383, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2384, + I_DIP, + [ Seq + ( 2385, + [ + Prim + ( + 2386, + I_DUP, + [], + [] + ); + Prim + ( + 2387, + I_DIP, + [ + Seq + ( + 2388, + [ + Prim + ( + 2389, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2390, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2391, + I_DIP, + [ Seq + ( 2392, + [ + Prim + ( + 2393, + I_DUP, + [], + [] + ); + Prim + ( + 2394, + I_DIP, + [ + Seq + ( + 2395, + [ + Prim + ( + 2396, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2397, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2398, + I_SWAP, + [], + [] ); + Prim + ( 2399, + I_DROP, + [], + [] ); + Prim + ( 2400, + I_SWAP, + [], + [] ); + Prim + ( 2401, + I_PAIR, + [], + [] ); + Prim + ( 2402, + I_SWAP, + [], + [] ); + Prim + ( 2403, + I_PAIR, + [], + [] ); + Prim + ( 2404, + I_SWAP, + [], + [] ); + Prim + ( 2405, + I_PAIR, + [], + [] ); + Prim + ( 2406, + I_DIP, + [ Seq + ( 2407, + [ + Prim + ( + 2408, + I_DUP, + [], + [] + ); + Prim + ( + 2409, + I_DIP, + [ + Seq + ( + 2410, + [ + Prim + ( + 2411, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ); + Prim + ( + 2412, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2413, + I_SWAP, + [], + [] ); + Prim + ( 2414, + I_DROP, + [], + [] ); + Prim + ( 2415, + I_SWAP, + [], + [] ); + Prim + ( 2416, + I_PAIR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2417, + I_DIP, + [ Int + ( 2418, + Z.of_int 2 ); + Seq + ( 2419, + [ Prim + ( 2420, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2421, + I_DIG, + [ Int + ( 2422, + Z.of_int 2 ) + ], + [] ); + Prim + (2423, I_CAR, [], []); + Prim + (2424, I_CDR, [], []); + Prim + ( 2425, + I_CONTRACT, + [ Prim + ( 2426, + T_unit, + [], + [] ) ], + [] ); + Prim + ( 2427, + I_IF_NONE, + [ Seq + ( 2428, + [ Prim + ( 2429, + I_PUSH, + [ Prim + ( 2430, + T_string, + [], + [] + ); + String + ( 2431, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] ); + Prim + ( 2432, + I_FAILWITH, + [], + [] ) ] + ); + Seq (2433, []) ], + [] ); + Prim + ( 2434, + I_DIG, + [Int (2435, Z.one)], + [] ); + Prim + (2436, I_UNIT, [], []); + Prim + ( 2437, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + ( 2438, + I_DIP, + [ Seq + ( 2439, + [ Prim + ( 2440, + I_DIP, + [ Seq + ( 2441, + [ + Prim + ( + 2442, + I_DUP, + [], + [] + ); + Prim + ( + 2443, + I_CDR, + [], + [] + ); + Prim + ( + 2444, + I_CAR, + [], + [] + ); + Prim + ( + 2445, + I_DIP, + [ + Seq + ( + 2446, + [ + Prim + ( + 2447, + I_CAR, + [], + [] + ); + Prim + ( + 2448, + I_CAR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2449, + I_DUP, + [], + [] ); + Prim + ( 2450, + I_CDR, + [], + [] ); + Prim + ( 2451, + I_CDR, + [], + [] ); + Prim + ( 2452, + I_CAR, + [], + [] ); + Prim + ( 2453, + I_CONTRACT, + [ Prim + ( 2454, + T_pair, + [ + Prim + ( + 2455, + T_address, + [], + [] + ); + Prim + ( + 2456, + T_pair, + [ + Prim + ( + 2457, + T_address, + [], + [] + ); + Prim + ( + 2458, + T_nat, + [], + [] + ) + ], + [] + ) + ], + [] + ) + ], + [ "%transfer" + ] ); + Prim + ( 2459, + I_IF_NONE, + [ Seq + ( 2460, + [ + Prim + ( + 2461, + I_PUSH, + [ + Prim + ( + 2462, + T_string, + [], + [] + ); + String + ( + 2463, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] + ); + Prim + ( + 2464, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 2465, + [] + ) + ], + [] ); + Prim + ( 2466, + I_PUSH, + [ Prim + ( 2467, + T_mutez, + [], + [] + ); + Int + ( 2468, + Z + .zero + ) + ], + [] ); + Prim + ( 2469, + I_DIG, + [ Int + ( 2470, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 2471, + I_SELF, + [], + [] ); + Prim + ( 2472, + I_ADDRESS, + [], + [] ); + Prim + ( 2473, + I_DIG, + [ Int + ( 2474, + Z + .of_int + 5 + ) + ], + [] ); + Prim + ( 2475, + I_DIP, + [ Seq + ( 2476, + [ + Prim + ( + 2477, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2478, + I_PAIR, + [], + [] ); + Prim + ( 2479, + I_TRANSFER_TOKENS, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2480, + I_NIL, + [ Prim + ( 2481, + T_operation, + [], + [] ) ], + [] ); + Prim + ( 2482, + I_DIG, + [ Int + ( 2483, + Z.of_int 2 ) + ], + [] ); + Prim + (2484, I_CONS, [], []); + Prim + (2485, I_SWAP, [], []); + Prim + (2486, I_CONS, [], []); + Prim + (2487, I_PAIR, [], []) + ] ); + Seq + ( 2488, + [ Prim + ( 2489, + I_PUSH, + [ Prim + ( 2490, + T_mutez, + [], + [] ); + Int (2491, Z.zero) + ], + [] ); + Prim + ( 2492, + I_AMOUNT, + [], + [] ); + Prim + ( 2493, + I_COMPARE, + [], + [] ); + Prim + (2494, I_EQ, [], []); + Prim + ( 2495, + I_IF, + [ Seq (2496, []); + Seq + ( 2497, + [ Prim + ( 2498, + I_PUSH, + [ Prim + ( 2499, + T_string, + [], + [] + ); + String + ( 2500, + "Amount \ + must \ + be \ + zero." + ) + ], + [] ); + Prim + ( 2501, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2502, + I_IMPLICIT_ACCOUNT, + [], + [] ); + Prim + ( 2503, + I_ADDRESS, + [], + [] ); + Prim + ( 2504, + I_SENDER, + [], + [] ); + Prim + ( 2505, + I_COMPARE, + [], + [] ); + Prim + (2506, I_EQ, [], []); + Prim + ( 2507, + I_IF, + [ Seq (2508, []); + Seq + ( 2509, + [ Prim + ( 2510, + I_PUSH, + [ Prim + ( 2511, + T_string, + [], + [] + ); + String + ( 2512, + "unsafeUpdateTokenPool" + ) + ], + [] ); + Prim + ( 2513, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + (2514, I_DUP, [], []); + Prim + (2515, I_CDR, [], []); + Prim + (2516, I_CAR, [], []); + Prim + (2517, I_CAR, [], []); + Prim + ( 2518, + I_IF, + [ Seq + ( 2519, + [ Prim + ( 2520, + I_PUSH, + [ Prim + ( 2521, + T_string, + [], + [] + ); + String + ( 2522, + "selfIsUpdatingToken \ + must \ + be \ + false." + ) + ], + [] ); + Prim + ( 2523, + I_FAILWITH, + [], + [] ) ] + ); + Seq (2524, []) ], + [] ); + Prim + (2525, I_DUP, [], []); + Prim + (2526, I_CDR, [], []); + Prim + ( 2527, + I_PUSH, + [ Prim + ( 2528, + T_bool, + [], + [] ); + Prim + ( 2529, + D_True, + [], + [] ) ], + [] ); + Prim + ( 2530, + I_DIP, + [ Seq + ( 2531, + [ Prim + ( 2532, + I_DUP, + [], + [] ); + Prim + ( 2533, + I_DIP, + [ Seq + ( 2534, + [ + Prim + ( + 2535, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2536, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2537, + I_DIP, + [ Seq + ( 2538, + [ Prim + ( 2539, + I_DUP, + [], + [] ); + Prim + ( 2540, + I_DIP, + [ Seq + ( 2541, + [ + Prim + ( + 2542, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2543, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (2544, I_SWAP, [], []); + Prim + (2545, I_DROP, [], []); + Prim + (2546, I_PAIR, [], []); + Prim + (2547, I_PAIR, [], []); + Prim + ( 2548, + I_DIP, + [ Seq + ( 2549, + [ Prim + ( 2550, + I_DUP, + [], + [] ); + Prim + ( 2551, + I_DIP, + [ Seq + ( 2552, + [ + Prim + ( + 2553, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2554, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2555, I_SWAP, [], []); + Prim + (2556, I_DROP, [], []); + Prim + (2557, I_SWAP, [], []); + Prim + (2558, I_PAIR, [], []); + Prim + (2559, I_DUP, [], []); + Prim + (2560, I_CDR, [], []); + Prim + (2561, I_CDR, [], []); + Prim + (2562, I_CAR, [], []); + Prim + ( 2563, + I_CONTRACT, + [ Prim + ( 2564, + T_pair, + [ Prim + ( 2565, + T_address, + [], + [] ); + Prim + ( 2566, + T_contract, + [ Prim + ( 2567, + T_nat, + [], + [] + ) + ], + [] ) ], + [] ) ], + ["%getBalance"] ); + Prim + ( 2568, + I_IF_NONE, + [ Seq + ( 2569, + [ Prim + ( 2570, + I_PUSH, + [ Prim + ( 2571, + T_string, + [], + [] + ); + String + ( 2572, + "bad \ + address \ + for \ + get_entrypoint" + ) + ], + [] ); + Prim + ( 2573, + I_FAILWITH, + [], + [] ) ] + ); + Seq (2574, []) ], + [] ); + Prim + ( 2575, + I_PUSH, + [ Prim + ( 2576, + T_mutez, + [], + [] ); + Int (2577, Z.zero) + ], + [] ); + Prim + ( 2578, + I_SELF, + [], + [ "%updateTokenPoolInternal" + ] ); + Prim + (2579, I_SELF, [], []); + Prim + ( 2580, + I_ADDRESS, + [], + [] ); + Prim + (2581, I_PAIR, [], []); + Prim + ( 2582, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + ( 2583, + I_DIP, + [ Seq + ( 2584, + [ Prim + ( 2585, + I_NIL, + [ Prim + ( 2586, + T_operation, + [], + [] + ) + ], + [] ) ] + ) ], + [] ); + Prim + (2587, I_CONS, [], []); + Prim + (2588, I_PAIR, [], []) + ] ) ], + [] ) ] ); + Seq + ( 2589, + [ Prim + ( 2590, + I_IF_LEFT, + [ Seq + ( 2591, + [ Prim + ( 2592, + I_PUSH, + [ Prim + ( 2593, + T_mutez, + [], + [] ); + Int (2594, Z.zero) + ], + [] ); + Prim + ( 2595, + I_AMOUNT, + [], + [] ); + Prim + ( 2596, + I_COMPARE, + [], + [] ); + Prim + (2597, I_EQ, [], []); + Prim + ( 2598, + I_IF, + [ Seq (2599, []); + Seq + ( 2600, + [ Prim + ( 2601, + I_PUSH, + [ Prim + ( 2602, + T_string, + [], + [] + ); + String + ( 2603, + "Amount \ + must \ + be \ + zero." + ) + ], + [] ); + Prim + ( 2604, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2605, + I_DIP, + [ Seq + ( 2606, + [ Prim + ( 2607, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + (2608, I_SWAP, [], []); + Prim + (2609, I_CDR, [], []); + Prim + (2610, I_CAR, [], []); + Prim + (2611, I_CAR, [], []); + Prim + ( 2612, + I_IF, + [ Seq (2613, []); + Seq + ( 2614, + [ Prim + ( 2615, + I_PUSH, + [ Prim + ( 2616, + T_string, + [], + [] + ); + String + ( 2617, + "Dexter \ + did \ + not \ + initiate \ + this \ + operation." + ) + ], + [] ); + Prim + ( 2618, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2619, + I_DIP, + [ Seq + ( 2620, + [ Prim + ( 2621, + I_DUP, + [], + [] ) ] + ) ], + [] ); + Prim + (2622, I_SWAP, [], []); + Prim + (2623, I_CDR, [], []); + Prim + (2624, I_CDR, [], []); + Prim + (2625, I_CAR, [], []); + Prim + ( 2626, + I_SENDER, + [], + [] ); + Prim + ( 2627, + I_COMPARE, + [], + [] ); + Prim + (2628, I_EQ, [], []); + Prim + ( 2629, + I_IF, + [ Seq (2630, []); + Seq + ( 2631, + [ Prim + ( 2632, + I_PUSH, + [ Prim + ( 2633, + T_string, + [], + [] + ); + String + ( 2634, + "The \ + sender \ + is \ + not \ + the \ + token \ + contract \ + associated \ + with \ + this \ + contract." + ) + ], + [] ); + Prim + ( 2635, + I_FAILWITH, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2636, + I_DIP, + [ Seq + ( 2637, + [ Prim + ( 2638, + I_DUP, + [], + [] ); + Prim + ( 2639, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2640, + I_DIP, + [ Seq + ( 2641, + [ Prim + ( 2642, + I_DUP, + [], + [] ); + Prim + ( 2643, + I_DIP, + [ Seq + ( 2644, + [ + Prim + ( + 2645, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2646, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2647, + I_DIP, + [ Seq + ( 2648, + [ Prim + ( 2649, + I_DUP, + [], + [] ); + Prim + ( 2650, + I_DIP, + [ Seq + ( 2651, + [ + Prim + ( + 2652, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2653, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2654, + I_DIP, + [ Seq + ( 2655, + [ Prim + ( 2656, + I_DUP, + [], + [] ); + Prim + ( 2657, + I_DIP, + [ Seq + ( 2658, + [ + Prim + ( + 2659, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2660, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (2661, I_SWAP, [], []); + Prim + (2662, I_DROP, [], []); + Prim + (2663, I_PAIR, [], []); + Prim + (2664, I_SWAP, [], []); + Prim + (2665, I_PAIR, [], []); + Prim + (2666, I_SWAP, [], []); + Prim + (2667, I_PAIR, [], []); + Prim + ( 2668, + I_DIP, + [ Seq + ( 2669, + [ Prim + ( 2670, + I_DUP, + [], + [] ); + Prim + ( 2671, + I_DIP, + [ Seq + ( 2672, + [ + Prim + ( + 2673, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2674, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2675, I_SWAP, [], []); + Prim + (2676, I_DROP, [], []); + Prim + (2677, I_SWAP, [], []); + Prim + (2678, I_PAIR, [], []); + Prim + (2679, I_DUP, [], []); + Prim + (2680, I_CDR, [], []); + Prim + ( 2681, + I_PUSH, + [ Prim + ( 2682, + T_bool, + [], + [] ); + Prim + ( 2683, + D_False, + [], + [] ) ], + [] ); + Prim + ( 2684, + I_DIP, + [ Seq + ( 2685, + [ Prim + ( 2686, + I_DUP, + [], + [] ); + Prim + ( 2687, + I_DIP, + [ Seq + ( 2688, + [ + Prim + ( + 2689, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2690, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2691, + I_DIP, + [ Seq + ( 2692, + [ Prim + ( 2693, + I_DUP, + [], + [] ); + Prim + ( 2694, + I_DIP, + [ Seq + ( 2695, + [ + Prim + ( + 2696, + I_CDR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2697, + I_CAR, + [], + [] ) ] + ) ], + [] ); + Prim + (2698, I_SWAP, [], []); + Prim + (2699, I_DROP, [], []); + Prim + (2700, I_PAIR, [], []); + Prim + (2701, I_PAIR, [], []); + Prim + ( 2702, + I_DIP, + [ Seq + ( 2703, + [ Prim + ( 2704, + I_DUP, + [], + [] ); + Prim + ( 2705, + I_DIP, + [ Seq + ( 2706, + [ + Prim + ( + 2707, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2708, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2709, I_SWAP, [], []); + Prim + (2710, I_DROP, [], []); + Prim + (2711, I_SWAP, [], []); + Prim + (2712, I_PAIR, [], []); + Prim + ( 2713, + I_NIL, + [ Prim + ( 2714, + T_operation, + [], + [] ) ], + [] ); + Prim + (2715, I_PAIR, [], []) + ] ); + Seq + ( 2716, + [ Prim + (2717, I_DROP, [], []); + Prim + (2718, I_DUP, [], []); + Prim + (2719, I_CDR, [], []); + Prim + (2720, I_CAR, [], []); + Prim + (2721, I_CAR, [], []); + Prim + ( 2722, + I_IF, + [ Seq + ( 2723, + [ Prim + ( 2724, + I_PUSH, + [ Prim + ( 2725, + T_string, + [], + [] + ); + String + ( 2726, + "selfIsUpdatingToken \ + must \ + be \ + false." + ) + ], + [] ); + Prim + ( 2727, + I_FAILWITH, + [], + [] ) ] + ); + Seq (2728, []) ], + [] ); + Prim + (2729, I_DUP, [], []); + Prim + (2730, I_CDR, [], []); + Prim + (2731, I_CDR, [], []); + Prim + (2732, I_CDR, [], []); + Prim + (2733, I_CDR, [], []); + Prim + ( 2734, + I_AMOUNT, + [], + [] ); + Prim + (2735, I_ADD, [], []); + Prim + ( 2736, + I_DIP, + [ Seq + ( 2737, + [ Prim + ( 2738, + I_DUP, + [], + [] ); + Prim + ( 2739, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2740, + I_DIP, + [ Seq + ( 2741, + [ Prim + ( 2742, + I_DUP, + [], + [] ); + Prim + ( 2743, + I_DIP, + [ Seq + ( 2744, + [ + Prim + ( + 2745, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2746, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2747, + I_DIP, + [ Seq + ( 2748, + [ Prim + ( 2749, + I_DUP, + [], + [] ); + Prim + ( 2750, + I_DIP, + [ Seq + ( 2751, + [ + Prim + ( + 2752, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2753, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + ( 2754, + I_DIP, + [ Seq + ( 2755, + [ Prim + ( 2756, + I_DUP, + [], + [] ); + Prim + ( 2757, + I_DIP, + [ Seq + ( 2758, + [ + Prim + ( + 2759, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2760, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2761, I_SWAP, [], []); + Prim + (2762, I_DROP, [], []); + Prim + (2763, I_SWAP, [], []); + Prim + (2764, I_PAIR, [], []); + Prim + (2765, I_SWAP, [], []); + Prim + (2766, I_PAIR, [], []); + Prim + (2767, I_SWAP, [], []); + Prim + (2768, I_PAIR, [], []); + Prim + ( 2769, + I_DIP, + [ Seq + ( 2770, + [ Prim + ( 2771, + I_DUP, + [], + [] ); + Prim + ( 2772, + I_DIP, + [ Seq + ( 2773, + [ + Prim + ( + 2774, + I_CAR, + [], + [] + ) + ] + ) + ], + [] ); + Prim + ( 2775, + I_CDR, + [], + [] ) ] + ) ], + [] ); + Prim + (2776, I_SWAP, [], []); + Prim + (2777, I_DROP, [], []); + Prim + (2778, I_SWAP, [], []); + Prim + (2779, I_PAIR, [], []); + Prim + ( 2780, + I_NIL, + [ Prim + ( 2781, + T_operation, + [], + [] ) ], + [] ); + Prim + (2782, I_PAIR, [], []) + ] ) ], + [] ) ] ) ], + [] ) ] ) ], + [] ) ] ) ], + [] ) ] ) diff --git a/src/proto_alpha/lib_parameters/test_fa12.ml b/src/proto_alpha/lib_parameters/test_fa12.ml new file mode 100644 index 000000000000..40ee39d8cac7 --- /dev/null +++ b/src/proto_alpha/lib_parameters/test_fa12.ml @@ -0,0 +1,1249 @@ +open Protocol.Alpha_context.Script +open Micheline + +let script = + Seq + ( 0, + [ Prim + ( 1, + K_parameter, + [ Prim + ( 2, + T_or, + [ Prim + ( 3, + T_or, + [ Prim + ( 4, + T_or, + [ Prim + ( 5, + T_pair, + [ Prim (6, T_address, [], ["%spender"]); + Prim (7, T_nat, [], ["%value"]) ], + ["%approve"] ); + Prim + ( 8, + T_pair, + [ Prim + ( 9, + T_pair, + [ Prim (10, T_address, [], ["%owner"]); + Prim + (11, T_address, [], ["%spender"]) + ], + [] ); + Prim + ( 12, + T_contract, + [Prim (13, T_nat, [], [])], + [] ) ], + ["%getAllowance"] ) ], + [] ); + Prim + ( 14, + T_or, + [ Prim + ( 15, + T_pair, + [ Prim (16, T_address, [], ["%owner"]); + Prim + ( 17, + T_contract, + [Prim (18, T_nat, [], [])], + [] ) ], + ["%getBalance"] ); + Prim + ( 19, + T_pair, + [ Prim (20, T_unit, [], []); + Prim + ( 21, + T_contract, + [Prim (22, T_nat, [], [])], + [] ) ], + ["%getTotalSupply"] ) ], + [] ) ], + [] ); + Prim + ( 23, + T_pair, + [ Prim (24, T_address, [], ["%from"]); + Prim + ( 25, + T_pair, + [ Prim (26, T_address, [], ["%to"]); + Prim (27, T_nat, [], ["%value"]) ], + [] ) ], + ["%transfer"] ) ], + [] ) ], + [] ); + Prim + ( 28, + K_storage, + [ Prim + ( 29, + T_pair, + [ Prim + ( 30, + T_big_map, + [ Prim (31, T_address, [], []); + Prim + ( 32, + T_pair, + [ Prim + ( 33, + T_map, + [ Prim (34, T_address, [], []); + Prim (35, T_nat, [], []) ], + ["%allowances"] ); + Prim (36, T_nat, [], ["%balance"]) ], + [] ) ], + ["%ledger"] ); + Prim (37, T_nat, [], ["%totalSupply"]) ], + [] ) ], + [] ); + Prim + ( 38, + K_code, + [ Seq + ( 39, + [ Prim (40, I_NIL, [Prim (41, T_operation, [], [])], []); + Prim + ( 42, + I_LAMBDA, + [ Prim + ( 43, + T_pair, + [ Prim (44, T_address, [], []); + Prim + ( 45, + T_pair, + [ Prim + ( 46, + T_big_map, + [ Prim (47, T_address, [], []); + Prim + ( 48, + T_pair, + [ Prim + ( 49, + T_map, + [ Prim + ( 50, + T_address, + [], + [] ); + Prim (51, T_nat, [], []) + ], + [] ); + Prim (52, T_nat, [], []) ], + [] ) ], + [] ); + Prim (53, T_nat, [], []) ], + [] ) ], + [] ); + Prim + ( 54, + T_pair, + [ Prim + ( 55, + T_map, + [ Prim (56, T_address, [], []); + Prim (57, T_nat, [], []) ], + [] ); + Prim (58, T_nat, [], []) ], + [] ); + Seq + ( 59, + [ Prim (60, I_DUP, [], []); + Prim (61, I_CDR, [], []); + Prim (62, I_SWAP, [], []); + Prim (63, I_CAR, [], []); + Prim (64, I_SWAP, [], []); + Prim (65, I_CAR, [], []); + Prim (66, I_SWAP, [], []); + Prim (67, I_GET, [], []); + Prim + ( 68, + I_IF_NONE, + [ Seq + ( 69, + [ Prim + ( 70, + I_PUSH, + [ Prim (71, T_nat, [], []); + Int (72, Z.zero) ], + [] ); + Prim + ( 73, + I_EMPTY_MAP, + [ Prim (74, T_address, [], []); + Prim (75, T_nat, [], []) ], + [] ); + Prim (76, I_PAIR, [], []) ] ); + Seq (77, []) ], + [] ) ] ) ], + [] ); + Prim + ( 78, + I_LAMBDA, + [ Prim + ( 79, + T_pair, + [ Prim + ( 80, + T_pair, + [ Prim + ( 81, + T_pair, + [ Prim + ( 82, + T_map, + [ Prim (83, T_address, [], []); + Prim (84, T_nat, [], []) ], + [] ); + Prim (85, T_nat, [], []) ], + [] ); + Prim (86, T_address, [], []) ], + [] ); + Prim + ( 87, + T_pair, + [ Prim + ( 88, + T_big_map, + [ Prim (89, T_address, [], []); + Prim + ( 90, + T_pair, + [ Prim + ( 91, + T_map, + [ Prim + ( 92, + T_address, + [], + [] ); + Prim (93, T_nat, [], []) + ], + [] ); + Prim (94, T_nat, [], []) ], + [] ) ], + [] ); + Prim (95, T_nat, [], []) ], + [] ) ], + [] ); + Prim (96, T_nat, [], []); + Seq + ( 97, + [ Prim (98, I_DUP, [], []); + Prim (99, I_CDR, [], []); + Prim (100, I_SWAP, [], []); + Prim (101, I_CAR, [], []); + Prim (102, I_SWAP, [], []); + Prim (103, I_DROP, [], []); + Prim (104, I_DUP, [], []); + Prim (105, I_CDR, [], []); + Prim (106, I_SWAP, [], []); + Prim (107, I_CAR, [], []); + Prim (108, I_CAR, [], []); + Prim (109, I_SWAP, [], []); + Prim (110, I_GET, [], []); + Prim + ( 111, + I_IF_NONE, + [ Seq + ( 112, + [ Prim + ( 113, + I_PUSH, + [ Prim (114, T_nat, [], []); + Int (115, Z.zero) ], + [] ) ] ); + Seq (116, []) ], + [] ) ] ) ], + [] ); + Prim (117, I_DIG, [Int (118, Z.of_int 3)], []); + Prim (119, I_DUP, [], []); + Prim (120, I_CDR, [], []); + Prim (121, I_SWAP, [], []); + Prim (122, I_CAR, [], []); + Prim + ( 123, + I_IF_LEFT, + [ Seq + ( 124, + [ Prim + ( 125, + I_IF_LEFT, + [ Seq + ( 126, + [ Prim + ( 127, + I_IF_LEFT, + [ Seq + ( 128, + [ Prim + (129, I_DUP, [], []); + Prim + (130, I_CDR, [], []); + Prim + (131, I_SWAP, [], []); + Prim + (132, I_CAR, [], []); + Prim + ( 133, + I_DIG, + [ Int + ( 134, + Z.of_int 2 ) + ], + [] ); + Prim + (135, I_DUP, [], []); + Prim + ( 136, + I_DUG, + [ Int + ( 137, + Z.of_int 3 ) + ], + [] ); + Prim + ( 138, + I_SENDER, + [], + [] ); + Prim + (139, I_PAIR, [], []); + Prim + ( 140, + I_DIG, + [ Int + ( 141, + Z.of_int 5 ) + ], + [] ); + Prim + (142, I_SWAP, [], []); + Prim + (143, I_EXEC, [], []); + Prim + ( 144, + I_DIG, + [ Int + ( 145, + Z.of_int 3 ) + ], + [] ); + Prim + (146, I_DUP, [], []); + Prim + ( 147, + I_DUG, + [ Int + ( 148, + Z.of_int 4 ) + ], + [] ); + Prim + ( 149, + I_DIG, + [ Int + ( 150, + Z.of_int 2 ) + ], + [] ); + Prim + (151, I_DUP, [], []); + Prim + ( 152, + I_DUG, + [ Int + ( 153, + Z.of_int 3 ) + ], + [] ); + Prim + ( 154, + I_DIG, + [ Int + ( 155, + Z.of_int 2 ) + ], + [] ); + Prim + (156, I_DUP, [], []); + Prim + ( 157, + I_DUG, + [ Int + ( 158, + Z.of_int 3 ) + ], + [] ); + Prim + (159, I_PAIR, [], []); + Prim + (160, I_PAIR, [], []); + Prim + ( 161, + I_DIG, + [ Int + ( 162, + Z.of_int 5 ) + ], + [] ); + Prim + (163, I_SWAP, [], []); + Prim + (164, I_EXEC, [], []); + Prim + ( 165, + I_PUSH, + [ Prim + ( 166, + T_nat, + [], + [] ); + Int (167, Z.zero) + ], + [] ); + Prim + ( 168, + I_DIG, + [ Int + ( 169, + Z.of_int 4 ) + ], + [] ); + Prim + (170, I_DUP, [], []); + Prim + ( 171, + I_DUG, + [ Int + ( 172, + Z.of_int 5 ) + ], + [] ); + Prim + ( 173, + I_COMPARE, + [], + [] ); + Prim (174, I_GT, [], []); + Prim + ( 175, + I_PUSH, + [ Prim + ( 176, + T_nat, + [], + [] ); + Int (177, Z.zero) + ], + [] ); + Prim + ( 178, + I_DIG, + [ Int + ( 179, + Z.of_int 2 ) + ], + [] ); + Prim + ( 180, + I_COMPARE, + [], + [] ); + Prim (181, I_GT, [], []); + Prim + (182, I_AND, [], []); + Prim + ( 183, + I_IF, + [ Seq + ( 184, + [ Prim + ( 185, + I_PUSH, + [ Prim + ( 186, + T_string, + [], + [] + ); + String + ( 187, + "UnsafeAllowanceChange" + ) + ], + [] ); + Prim + ( 188, + I_FAILWITH, + [], + [] ) ] + ); + Seq (189, []) ], + [] ); + Prim + ( 190, + I_DIG, + [ Int + ( 191, + Z.of_int 3 ) + ], + [] ); + Prim + (192, I_DUP, [], []); + Prim + ( 193, + I_DUG, + [ Int + ( 194, + Z.of_int 4 ) + ], + [] ); + Prim + (195, I_CDR, [], []); + Prim + ( 196, + I_DIG, + [ Int + ( 197, + Z.of_int 4 ) + ], + [] ); + Prim + (198, I_CAR, [], []); + Prim + ( 199, + I_DIG, + [ Int + ( 200, + Z.of_int 2 ) + ], + [] ); + Prim + (201, I_DUP, [], []); + Prim + ( 202, + I_DUG, + [ Int + ( 203, + Z.of_int 3 ) + ], + [] ); + Prim + (204, I_CDR, [], []); + Prim + ( 205, + I_DIG, + [ Int + ( 206, + Z.of_int 3 ) + ], + [] ); + Prim + (207, I_CAR, [], []); + Prim + ( 208, + I_DIG, + [ Int + ( 209, + Z.of_int 5 ) + ], + [] ); + Prim + ( 210, + I_DIG, + [ Int + ( 211, + Z.of_int 5 ) + ], + [] ); + Prim + (212, I_SWAP, [], []); + Prim + (213, I_SOME, [], []); + Prim + (214, I_SWAP, [], []); + Prim + ( 215, + I_UPDATE, + [], + [] ); + Prim + (216, I_PAIR, [], []); + Prim + (217, I_SOME, [], []); + Prim + ( 218, + I_SENDER, + [], + [] ); + Prim + ( 219, + I_UPDATE, + [], + [] ); + Prim + (220, I_PAIR, [], []); + Prim + (221, I_SWAP, [], []); + Prim + (222, I_PAIR, [], []) + ] ); + Seq + ( 223, + [ Prim + ( 224, + I_DIG, + [ Int + ( 225, + Z.of_int 4 ) + ], + [] ); + Prim + (226, I_DROP, [], []); + Prim + (227, I_DUP, [], []); + Prim + ( 228, + I_DUG, + [ Int + ( 229, + Z.of_int 2 ) + ], + [] ); + Prim + (230, I_CDR, [], []); + Prim + (231, I_PAIR, [], []); + Prim + (232, I_SWAP, [], []); + Prim + (233, I_DUP, [], []); + Prim + ( 234, + I_DUG, + [ Int + ( 235, + Z.of_int 2 ) + ], + [] ); + Prim + (236, I_CAR, [], []); + Prim + (237, I_CDR, [], []); + Prim + ( 238, + I_DIG, + [ Int + ( 239, + Z.of_int 2 ) + ], + [] ); + Prim + (240, I_CAR, [], []); + Prim + (241, I_CAR, [], []); + Prim + ( 242, + I_DIG, + [ Int + ( 243, + Z.of_int 2 ) + ], + [] ); + Prim + (244, I_DUP, [], []); + Prim + (245, I_CDR, [], []); + Prim + (246, I_SWAP, [], []); + Prim + (247, I_CAR, [], []); + Prim + (248, I_SWAP, [], []); + Prim + (249, I_DUP, [], []); + Prim + ( 250, + I_DUG, + [ Int + ( 251, + Z.of_int 2 ) + ], + [] ); + Prim + ( 252, + I_DIG, + [ Int + ( 253, + Z.of_int 3 ) + ], + [] ); + Prim + (254, I_PAIR, [], []); + Prim + ( 255, + I_DIG, + [ Int + ( 256, + Z.of_int 5 ) + ], + [] ); + Prim + (257, I_SWAP, [], []); + Prim + (258, I_EXEC, [], []); + Prim + ( 259, + I_DIG, + [ Int + ( 260, + Z.of_int 2 ) + ], + [] ); + Prim + (261, I_DUP, [], []); + Prim + ( 262, + I_DUG, + [ Int + ( 263, + Z.of_int 3 ) + ], + [] ); + Prim + ( 264, + I_DIG, + [ Int + ( 265, + Z.of_int 4 ) + ], + [] ); + Prim + ( 266, + I_DIG, + [ Int + ( 267, + Z.of_int 2 ) + ], + [] ); + Prim + (268, I_PAIR, [], []); + Prim + (269, I_PAIR, [], []); + Prim + ( 270, + I_DIG, + [ Int + ( 271, + Z.of_int 3 ) + ], + [] ); + Prim + (272, I_SWAP, [], []); + Prim + (273, I_EXEC, [], []); + Prim + ( 274, + I_DIG, + [ Int + ( 275, + Z.of_int 2 ) + ], + [] ); + Prim + ( 276, + I_NIL, + [ Prim + ( 277, + T_operation, + [], + [] ) ], + [] ); + Prim + ( 278, + I_DIG, + [ Int + ( 279, + Z.of_int 3 ) + ], + [] ); + Prim + ( 280, + I_PUSH, + [ Prim + ( 281, + T_mutez, + [], + [] ); + Int (282, Z.zero) + ], + [] ); + Prim + ( 283, + I_DIG, + [ Int + ( 284, + Z.of_int 4 ) + ], + [] ); + Prim + ( 285, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + (286, I_CONS, [], []); + Prim + (287, I_PAIR, [], []) + ] ) ], + [] ) ] ); + Seq + ( 288, + [ Prim + ( 289, + I_DIG, + [Int (290, Z.of_int 2)], + [] ); + Prim (291, I_DROP, [], []); + Prim + ( 292, + I_DIG, + [Int (293, Z.of_int 3)], + [] ); + Prim (294, I_DROP, [], []); + Prim + ( 295, + I_IF_LEFT, + [ Seq + ( 296, + [ Prim + (297, I_DUP, [], []); + Prim + (298, I_CDR, [], []); + Prim + (299, I_SWAP, [], []); + Prim + (300, I_CAR, [], []); + Prim + ( 301, + I_DIG, + [ Int + ( 302, + Z.of_int 2 ) + ], + [] ); + Prim + (303, I_DUP, [], []); + Prim + ( 304, + I_DUG, + [ Int + ( 305, + Z.of_int 3 ) + ], + [] ); + Prim + (306, I_SWAP, [], []); + Prim + (307, I_PAIR, [], []); + Prim + ( 308, + I_DIG, + [ Int + ( 309, + Z.of_int 3 ) + ], + [] ); + Prim + (310, I_SWAP, [], []); + Prim + (311, I_EXEC, [], []); + Prim + ( 312, + I_DIG, + [ Int + ( 313, + Z.of_int 2 ) + ], + [] ); + Prim + ( 314, + I_NIL, + [ Prim + ( 315, + T_operation, + [], + [] ) ], + [] ); + Prim + ( 316, + I_DIG, + [ Int + ( 317, + Z.of_int 3 ) + ], + [] ); + Prim + ( 318, + I_PUSH, + [ Prim + ( 319, + T_mutez, + [], + [] ); + Int (320, Z.zero) + ], + [] ); + Prim + ( 321, + I_DIG, + [ Int + ( 322, + Z.of_int 4 ) + ], + [] ); + Prim + (323, I_CDR, [], []); + Prim + ( 324, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + (325, I_CONS, [], []); + Prim + (326, I_PAIR, [], []) + ] ); + Seq + ( 327, + [ Prim + ( 328, + I_DIG, + [ Int + ( 329, + Z.of_int 2 ) + ], + [] ); + Prim + (330, I_DROP, [], []); + Prim + (331, I_CDR, [], []); + Prim + (332, I_SWAP, [], []); + Prim + (333, I_DUP, [], []); + Prim + ( 334, + I_DUG, + [ Int + ( 335, + Z.of_int 2 ) + ], + [] ); + Prim + ( 336, + I_NIL, + [ Prim + ( 337, + T_operation, + [], + [] ) ], + [] ); + Prim + ( 338, + I_DIG, + [ Int + ( 339, + Z.of_int 2 ) + ], + [] ); + Prim + ( 340, + I_PUSH, + [ Prim + ( 341, + T_mutez, + [], + [] ); + Int (342, Z.zero) + ], + [] ); + Prim + ( 343, + I_DIG, + [ Int + ( 344, + Z.of_int 4 ) + ], + [] ); + Prim + (345, I_CDR, [], []); + Prim + ( 346, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + (347, I_CONS, [], []); + Prim + (348, I_PAIR, [], []) + ] ) ], + [] ) ] ) ], + [] ) ] ); + Seq + ( 349, + [ Prim (350, I_DUP, [], []); + Prim (351, I_DUG, [Int (352, Z.of_int 2)], []); + Prim (353, I_CDR, [], []); + Prim (354, I_CDR, [], []); + Prim (355, I_PAIR, [], []); + Prim (356, I_SWAP, [], []); + Prim (357, I_DUP, [], []); + Prim (358, I_DUG, [Int (359, Z.of_int 2)], []); + Prim (360, I_CDR, [], []); + Prim (361, I_CAR, [], []); + Prim (362, I_DIG, [Int (363, Z.of_int 2)], []); + Prim (364, I_CAR, [], []); + Prim (365, I_DIG, [Int (366, Z.of_int 2)], []); + Prim (367, I_DUP, [], []); + Prim (368, I_CDR, [], []); + Prim (369, I_SWAP, [], []); + Prim (370, I_CAR, [], []); + Prim (371, I_SWAP, [], []); + Prim (372, I_DUP, [], []); + Prim (373, I_DUG, [Int (374, Z.of_int 2)], []); + Prim (375, I_DIG, [Int (376, Z.of_int 3)], []); + Prim (377, I_DUP, [], []); + Prim (378, I_DUG, [Int (379, Z.of_int 4)], []); + Prim (380, I_PAIR, [], []); + Prim (381, I_DIG, [Int (382, Z.of_int 6)], []); + Prim (383, I_DUP, [], []); + Prim (384, I_DUG, [Int (385, Z.of_int 7)], []); + Prim (386, I_SWAP, [], []); + Prim (387, I_EXEC, [], []); + Prim (388, I_SWAP, [], []); + Prim (389, I_DUP, [], []); + Prim (390, I_DUG, [Int (391, Z.of_int 2)], []); + Prim (392, I_SWAP, [], []); + Prim (393, I_DUP, [], []); + Prim (394, I_DUG, [Int (395, Z.of_int 2)], []); + Prim (396, I_CDR, [], []); + Prim (397, I_COMPARE, [], []); + Prim (398, I_LT, [], []); + Prim + ( 399, + I_IF, + [ Seq + ( 400, + [ Prim + ( 401, + I_PUSH, + [ Prim (402, T_string, [], []); + String + (403, "NotEnoughBalance") + ], + [] ); + Prim (404, I_FAILWITH, [], []) ] ); + Seq (405, []) ], + [] ); + Prim (406, I_SENDER, [], []); + Prim (407, I_DIG, [Int (408, Z.of_int 4)], []); + Prim (409, I_DUP, [], []); + Prim (410, I_DUG, [Int (411, Z.of_int 5)], []); + Prim (412, I_COMPARE, [], []); + Prim (413, I_NEQ, [], []); + Prim + ( 414, + I_IF, + [ Seq + ( 415, + [ Prim + ( 416, + I_DIG, + [Int (417, Z.of_int 2)], + [] ); + Prim (418, I_DUP, [], []); + Prim + ( 419, + I_DUG, + [Int (420, Z.of_int 3)], + [] ); + Prim (421, I_SENDER, [], []); + Prim + ( 422, + I_DIG, + [Int (423, Z.of_int 2)], + [] ); + Prim (424, I_DUP, [], []); + Prim + ( 425, + I_DUG, + [Int (426, Z.of_int 3)], + [] ); + Prim (427, I_PAIR, [], []); + Prim (428, I_PAIR, [], []); + Prim + ( 429, + I_DIG, + [Int (430, Z.of_int 6)], + [] ); + Prim (431, I_SWAP, [], []); + Prim (432, I_EXEC, [], []); + Prim + ( 433, + I_DIG, + [Int (434, Z.of_int 2)], + [] ); + Prim (435, I_DUP, [], []); + Prim + ( 436, + I_DUG, + [Int (437, Z.of_int 3)], + [] ); + Prim (438, I_SWAP, [], []); + Prim (439, I_DUP, [], []); + Prim + ( 440, + I_DUG, + [Int (441, Z.of_int 2)], + [] ); + Prim (442, I_COMPARE, [], []); + Prim (443, I_LT, [], []); + Prim + ( 444, + I_IF, + [ Seq + ( 445, + [ Prim + ( 446, + I_PUSH, + [ Prim + ( 447, + T_string, + [], + [] ); + String + ( 448, + "NotEnoughAllowance" + ) ], + [] ); + Prim + ( 449, + I_FAILWITH, + [], + [] ) ] ); + Seq (450, []) ], + [] ); + Prim (451, I_SWAP, [], []); + Prim (452, I_DUP, [], []); + Prim + ( 453, + I_DUG, + [Int (454, Z.of_int 2)], + [] ); + Prim (455, I_CDR, [], []); + Prim + ( 456, + I_DIG, + [Int (457, Z.of_int 2)], + [] ); + Prim (458, I_CAR, [], []); + Prim + ( 459, + I_DIG, + [Int (460, Z.of_int 3)], + [] ); + Prim (461, I_DUP, [], []); + Prim + ( 462, + I_DUG, + [Int (463, Z.of_int 4)], + [] ); + Prim + ( 464, + I_DIG, + [Int (465, Z.of_int 3)], + [] ); + Prim (466, I_SUB, [], []); + Prim (467, I_ABS, [], []); + Prim (468, I_SOME, [], []); + Prim (469, I_SENDER, [], []); + Prim (470, I_UPDATE, [], []); + Prim (471, I_PAIR, [], []) ] ); + Seq + ( 472, + [ Prim + ( 473, + I_DIG, + [Int (474, Z.of_int 5)], + [] ); + Prim (475, I_DROP, [], []) ] ) ], + [] ); + Prim (476, I_SWAP, [], []); + Prim (477, I_DUP, [], []); + Prim (478, I_DUG, [Int (479, Z.of_int 2)], []); + Prim (480, I_SWAP, [], []); + Prim (481, I_DUP, [], []); + Prim (482, I_DUG, [Int (483, Z.of_int 2)], []); + Prim (484, I_CDR, [], []); + Prim (485, I_SUB, [], []); + Prim (486, I_ABS, [], []); + Prim (487, I_SWAP, [], []); + Prim (488, I_CAR, [], []); + Prim (489, I_PAIR, [], []); + Prim (490, I_DIG, [Int (491, Z.of_int 2)], []); + Prim (492, I_DUP, [], []); + Prim (493, I_DUG, [Int (494, Z.of_int 3)], []); + Prim (495, I_CDR, [], []); + Prim (496, I_DIG, [Int (497, Z.of_int 3)], []); + Prim (498, I_CAR, [], []); + Prim (499, I_DIG, [Int (500, Z.of_int 2)], []); + Prim (501, I_DIG, [Int (502, Z.of_int 4)], []); + Prim (503, I_SWAP, [], []); + Prim (504, I_SOME, [], []); + Prim (505, I_SWAP, [], []); + Prim (506, I_UPDATE, [], []); + Prim (507, I_PAIR, [], []); + Prim (508, I_DUP, [], []); + Prim (509, I_DIG, [Int (510, Z.of_int 3)], []); + Prim (511, I_DUP, [], []); + Prim (512, I_DUG, [Int (513, Z.of_int 4)], []); + Prim (514, I_PAIR, [], []); + Prim (515, I_DIG, [Int (516, Z.of_int 4)], []); + Prim (517, I_SWAP, [], []); + Prim (518, I_EXEC, [], []); + Prim (519, I_DIG, [Int (520, Z.of_int 2)], []); + Prim (521, I_SWAP, [], []); + Prim (522, I_DUP, [], []); + Prim (523, I_DUG, [Int (524, Z.of_int 2)], []); + Prim (525, I_CDR, [], []); + Prim (526, I_ADD, [], []); + Prim (527, I_SWAP, [], []); + Prim (528, I_CAR, [], []); + Prim (529, I_PAIR, [], []); + Prim (530, I_SWAP, [], []); + Prim (531, I_DUP, [], []); + Prim (532, I_DUG, [Int (533, Z.of_int 2)], []); + Prim (534, I_CDR, [], []); + Prim (535, I_DIG, [Int (536, Z.of_int 2)], []); + Prim (537, I_CAR, [], []); + Prim (538, I_DIG, [Int (539, Z.of_int 2)], []); + Prim (540, I_DIG, [Int (541, Z.of_int 3)], []); + Prim (542, I_SWAP, [], []); + Prim (543, I_SOME, [], []); + Prim (544, I_SWAP, [], []); + Prim (545, I_UPDATE, [], []); + Prim (546, I_PAIR, [], []); + Prim (547, I_SWAP, [], []); + Prim (548, I_PAIR, [], []) ] ) ], + [] ) ] ) ], + [] ) ] ) diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 1e4272bd0e0d..8ed529c1640b 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -301,7 +301,7 @@ module Parameters = Parameters_repr module Liquidity_baking = struct let get_escape_ema = Storage.Liquidity_baking.Escape_ema.get - let set_escape_ema ctxt flag = + let update_escape_ema ctxt ~escape_vote = Storage.Liquidity_baking.Escape_ema.get ctxt >>=? fun old_ema -> (* if ema is over threshold, we don't update it because liquidity baking is permanently off *) @@ -310,7 +310,8 @@ module Liquidity_baking = struct old_ema < Constants.liquidity_baking_escape_ema_threshold ctxt) then let new_ema = - Int32.(add (div (mul 999l old_ema) 1000l) (if flag then 1000l else 0l)) + Int32.( + add (div (mul 999l old_ema) 1000l) (if escape_vote then 1000l else 0l)) in Storage.Liquidity_baking.Escape_ema.set ctxt new_ema >|=? fun ctxt -> (ctxt, new_ema) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 13506588cb19..2c43fbc6ff5e 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -463,119 +463,6 @@ module Script : sig val strip_locations_cost : node -> Gas.cost end -module Constants : sig - (** Fixed constants *) - type fixed = { - proof_of_work_nonce_size : int; - nonce_length : int; - max_anon_ops_per_block : int; - max_operation_data_length : int; - max_proposals_per_delegate : int; - } - - val fixed_encoding : fixed Data_encoding.t - - val fixed : fixed - - val proof_of_work_nonce_size : int - - val nonce_length : int - - val max_anon_ops_per_block : int - - val max_operation_data_length : int - - val max_proposals_per_delegate : int - - (** Constants parameterized by context *) - type parametric = { - preserved_cycles : int; - blocks_per_cycle : int32; - blocks_per_commitment : int32; - blocks_per_roll_snapshot : int32; - blocks_per_voting_period : int32; - time_between_blocks : Period.t list; - endorsers_per_block : int; - hard_gas_limit_per_operation : Gas.Arith.integral; - hard_gas_limit_per_block : Gas.Arith.integral; - proof_of_work_threshold : int64; - tokens_per_roll : Tez.t; - michelson_maximum_type_size : int; - seed_nonce_revelation_tip : Tez.t; - origination_size : int; - block_security_deposit : Tez.t; - endorsement_security_deposit : Tez.t; - baking_reward_per_endorsement : Tez.t list; - endorsement_reward : Tez.t list; - cost_per_byte : Tez.t; - hard_storage_limit_per_operation : Z.t; - quorum_min : int32; - quorum_max : int32; - min_proposal_quorum : int32; - initial_endorsers : int; - delay_per_missing_endorsement : Period.t; - } - - val parametric_encoding : parametric Data_encoding.t - - val parametric : context -> parametric - - val preserved_cycles : context -> int - - val blocks_per_cycle : context -> int32 - - val blocks_per_commitment : context -> int32 - - val blocks_per_roll_snapshot : context -> int32 - - val blocks_per_voting_period : context -> int32 - - val time_between_blocks : context -> Period.t list - - val endorsers_per_block : context -> int - - val initial_endorsers : context -> int - - val delay_per_missing_endorsement : context -> Period.t - - val hard_gas_limit_per_operation : context -> Gas.Arith.integral - - val hard_gas_limit_per_block : context -> Gas.Arith.integral - - val cost_per_byte : context -> Tez.t - - val hard_storage_limit_per_operation : context -> Z.t - - val proof_of_work_threshold : context -> int64 - - val tokens_per_roll : context -> Tez.t - - val michelson_maximum_type_size : context -> int - - val baking_reward_per_endorsement : context -> Tez.t list - - val endorsement_reward : context -> Tez.t list - - val seed_nonce_revelation_tip : context -> Tez.t - - val origination_size : context -> int - - val block_security_deposit : context -> Tez.t - - val endorsement_security_deposit : context -> Tez.t - - val quorum_min : context -> int32 - - val quorum_max : context -> int32 - - val min_proposal_quorum : context -> int32 - - (** All constants: fixed and parametric *) - type t = {fixed : fixed; parametric : parametric} - - val encoding : t Data_encoding.t -end - module Level : sig type t = private { level : Raw_level.t; @@ -1021,14 +908,13 @@ module Constants : sig endorsement_reward : Tez.t list; cost_per_byte : Tez.t; hard_storage_limit_per_operation : Z.t; - test_chain_duration : int64; quorum_min : int32; quorum_max : int32; min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period.t; - liquidity_baking_cpmm_origination_nonce : Contract.origination_nonce; - liquidity_baking_reward : Tez.t; + liquidity_baking_cpmm_address : Contract.t; + liquidity_baking_subsidy : Tez.t; liquidity_baking_sunset_duration : int32; liquidity_baking_escape_ema_threshold : int32; } @@ -1081,18 +967,15 @@ module Constants : sig val endorsement_security_deposit : context -> Tez.t - val test_chain_duration : context -> int64 - val quorum_min : context -> int32 val quorum_max : context -> int32 val min_proposal_quorum : context -> int32 - val liquidity_baking_cpmm_origination_nonce : - context -> Contract.origination_nonce + val liquidity_baking_cpmm_address : context -> Contract.t - val liquidity_baking_reward : context -> Tez.t + val liquidity_baking_subsidy : context -> Tez.t val liquidity_baking_sunset_duration : context -> int32 @@ -1308,7 +1191,7 @@ module Block_header : sig priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baking_escape_flag : bool; + liquidity_baking_escape_vote : bool; } type protocol_data = {contents : contents; signature : Signature.t} @@ -1757,7 +1640,6 @@ module Parameters : sig delegate : public_key_hash option; amount : Tez.t; script : Script.t; - origination_nonce : Contract.origination_nonce option; } type t = { @@ -1776,9 +1658,10 @@ module Liquidity_baking : sig val get_escape_ema : context -> Int32.t tzresult Lwt.t (** ema starts at zero - ema[n+1] = (999 * ema[n] // 1000) + (1000 if flag[n] else 0) - where flag is protocol_data.contents.liquidity_baking_escape_flag **) - val set_escape_ema : context -> bool -> (context * Int32.t) tzresult Lwt.t + ema[n+1] = (999 * ema[n] // 1000) + (1000 if escape_vote[n] else 0) + where escape_vote is protocol_data.contents.liquidity_baking_escape_vote **) + val update_escape_ema : + context -> escape_vote:bool -> (context * Int32.t) tzresult Lwt.t val get_sunset_level : context -> Int32.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 8e29bdbf6261..917d84e0f336 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1574,9 +1574,9 @@ let apply_liquidity_baking_subsidy ctxt (* don't set or get ema if past sunset *) return (ctxt, noop_balance_update, 0l) else - Liquidity_baking.set_escape_ema + Liquidity_baking.update_escape_ema ctxt - protocol_data.liquidity_baking_escape_flag + ~escape_vote:protocol_data.liquidity_baking_escape_vote >>=? fun (ctxt, liquidity_baking_escape_ema) -> (* liquidity baking permanently shuts off if threshold is reached once *) if @@ -1586,63 +1586,69 @@ let apply_liquidity_baking_subsidy ctxt then return (ctxt, noop_balance_update, liquidity_baking_escape_ema) else let liquidity_baking_cpmm_contract = - Contract.originated_contract - (Constants.liquidity_baking_cpmm_origination_nonce ctxt) + Constants.liquidity_baking_cpmm_address ctxt in - let liquidity_baking_subsidy = Constants.liquidity_baking_reward ctxt in - (* credit liquidity baking subsidy to CPMM contract *) - Contract.credit - ctxt - liquidity_baking_cpmm_contract - liquidity_baking_subsidy - >>=? fun ctxt -> - Contract.get_script ctxt liquidity_baking_cpmm_contract - >>=? fun (ctxt, script) -> - match script with - | None -> - Lwt.return (error (Script_tc_errors.No_such_entrypoint "default")) - | Some script -> - let step_constants = - let open Script_interpreter in - { - source = liquidity_baking_cpmm_contract; - payer = liquidity_baking_cpmm_contract; - self = liquidity_baking_cpmm_contract; - amount = liquidity_baking_subsidy; - chain_id = Chain_id.zero; - } - in - let parameter = - Micheline.strip_locations - Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) - in - (* call CPPM default entrypoint with parameter Unit *) - (* this is necessary for the CPMM's xtz_pool in storage to + (* fail gracefully if the cpmm is not found *) + Contract.exists ctxt liquidity_baking_cpmm_contract + >>=? fun liquidity_baking_cpmm_contract_exists -> + if liquidity_baking_cpmm_contract_exists then + let liquidity_baking_subsidy = + Constants.liquidity_baking_subsidy ctxt + in + (* credit liquidity baking subsidy to CPMM contract *) + Contract.credit + ctxt + liquidity_baking_cpmm_contract + liquidity_baking_subsidy + >>=? fun ctxt -> + Contract.get_script ctxt liquidity_baking_cpmm_contract + >>=? fun (ctxt, script) -> + match script with + | None -> + Lwt.return (error (Script_tc_errors.No_such_entrypoint "default")) + | Some script -> + let step_constants = + let open Script_interpreter in + { + source = liquidity_baking_cpmm_contract; + payer = liquidity_baking_cpmm_contract; + self = liquidity_baking_cpmm_contract; + amount = liquidity_baking_subsidy; + chain_id = Chain_id.zero; + } + in + let parameter = + Micheline.strip_locations + Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) + in + (* call CPPM default entrypoint with parameter Unit *) + (* this is necessary for the CPMM's xtz_pool in storage to increase since it cannot use BALANCE due to a transfer attack *) - Script_interpreter.execute - ctxt - Optimized - step_constants - ~script - ~parameter - ~entrypoint:"default" - ~internal:true - >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> - let _operations = operations in - (* update CPMM storage *) - Contract.update_script_storage - ctxt - liquidity_baking_cpmm_contract - storage - lazy_storage_diff - >>=? fun ctxt -> - let balance_update = - Receipt. - ( Contract liquidity_baking_cpmm_contract, - Credited liquidity_baking_subsidy, - Subsidy ) - in - return (ctxt, balance_update, liquidity_baking_escape_ema) + Script_interpreter.execute + ctxt + Optimized + step_constants + ~script + ~parameter + ~entrypoint:"default" + ~internal:true + >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> + let _operations = operations in + (* update CPMM storage *) + Contract.update_script_storage + ctxt + liquidity_baking_cpmm_contract + storage + lazy_storage_diff + >>=? fun ctxt -> + let balance_update = + Receipt. + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_subsidy, + Subsidy ) + in + return (ctxt, balance_update, liquidity_baking_escape_ema) + else return (ctxt, noop_balance_update, liquidity_baking_escape_ema) let finalize_application ctxt protocol_data delegate ~block_delay migration_balance_updates = diff --git a/src/proto_alpha/lib_protocol/block_header_repr.ml b/src/proto_alpha/lib_protocol/block_header_repr.ml index 387a9465b546..72363616a0fd 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.ml +++ b/src/proto_alpha/lib_protocol/block_header_repr.ml @@ -29,7 +29,7 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baking_escape_flag : bool; + liquidity_baking_escape_vote : bool; } type protocol_data = {contents : contents; signature : Signature.t} @@ -53,20 +53,20 @@ let contents_encoding = (fun { priority; seed_nonce_hash; proof_of_work_nonce; - liquidity_baking_escape_flag } -> + liquidity_baking_escape_vote } -> ( priority, proof_of_work_nonce, seed_nonce_hash, - liquidity_baking_escape_flag )) + liquidity_baking_escape_vote )) (fun ( priority, proof_of_work_nonce, seed_nonce_hash, - liquidity_baking_escape_flag ) -> + liquidity_baking_escape_vote ) -> { priority; seed_nonce_hash; proof_of_work_nonce; - liquidity_baking_escape_flag; + liquidity_baking_escape_vote; }) (obj4 (req "priority" uint16) @@ -74,7 +74,7 @@ let contents_encoding = "proof_of_work_nonce" (Fixed.bytes Constants_repr.proof_of_work_nonce_size)) (opt "seed_nonce_hash" Nonce_hash.encoding) - (req "liquidity_baking_escape_flag" Data_encoding.bool)) + (req "liquidity_baking_escape_vote" Data_encoding.bool)) let protocol_data_encoding = let open Data_encoding in @@ -124,7 +124,7 @@ let max_header_length = proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '0'; seed_nonce_hash = Some Nonce_hash.zero; - liquidity_baking_escape_flag = false; + liquidity_baking_escape_vote = false; } in Data_encoding.Binary.length diff --git a/src/proto_alpha/lib_protocol/block_header_repr.mli b/src/proto_alpha/lib_protocol/block_header_repr.mli index 6b2639a5d665..65526cef8109 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.mli +++ b/src/proto_alpha/lib_protocol/block_header_repr.mli @@ -27,7 +27,7 @@ type contents = { priority : int; seed_nonce_hash : Nonce_hash.t option; proof_of_work_nonce : bytes; - liquidity_baking_escape_flag : bool; + liquidity_baking_escape_vote : bool; (* set by baker to vote in favor of permanently disabling liquidity baking *) } diff --git a/src/proto_alpha/lib_protocol/bootstrap_storage.ml b/src/proto_alpha/lib_protocol/bootstrap_storage.ml index c30d9c67bec8..34e670b7aeec 100644 --- a/src/proto_alpha/lib_protocol/bootstrap_storage.ml +++ b/src/proto_alpha/lib_protocol/bootstrap_storage.ml @@ -40,32 +40,18 @@ let init_account ctxt return ctxt let init_contract ~typecheck ctxt - ({delegate; amount; script; origination_nonce} : - Parameters_repr.bootstrap_contract) = - match origination_nonce with - | None -> - Contract_storage.fresh_contract_from_current_nonce ctxt - >>?= fun (ctxt, contract) -> - typecheck ctxt script - >>=? fun (script, ctxt) -> - Contract_storage.raw_originate - ctxt - contract - ~balance:amount - ~prepaid_bootstrap_storage:true - ~script - ~delegate - | Some origination_nonce -> - let contract = Contract_repr.originated_contract origination_nonce in - typecheck ctxt script - >>=? fun (script, ctxt) -> - Contract_storage.raw_originate - ctxt - contract - ~balance:amount - ~prepaid_bootstrap_storage:true - ~script - ~delegate + ({delegate; amount; script} : Parameters_repr.bootstrap_contract) = + Contract_storage.fresh_contract_from_current_nonce ctxt + >>?= fun (ctxt, contract) -> + typecheck ctxt script + >>=? fun (script, ctxt) -> + Contract_storage.raw_originate + ctxt + contract + ~balance:amount + ~prepaid_bootstrap_storage:true + ~script + ~delegate let init ctxt ~typecheck ?ramp_up_cycles ?no_reward_cycles accounts contracts = let nonce = diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index d411c93f3a1e..615fee4f39e1 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -115,8 +115,8 @@ type parametric = { min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; - liquidity_baking_cpmm_origination_nonce : Contract_repr.origination_nonce; - liquidity_baking_reward : Tez_repr.t; + liquidity_baking_cpmm_address : Contract_repr.t; + liquidity_baking_subsidy : Tez_repr.t; liquidity_baking_sunset_duration : int32; liquidity_baking_escape_ema_threshold : int32; } @@ -156,8 +156,8 @@ let parametric_encoding = c.min_proposal_quorum, c.initial_endorsers, c.delay_per_missing_endorsement, - c.liquidity_baking_cpmm_origination_nonce, - c.liquidity_baking_reward, + c.liquidity_baking_cpmm_address, + c.liquidity_baking_subsidy, c.liquidity_baking_sunset_duration, c.liquidity_baking_escape_ema_threshold ) ) )) (fun ( ( preserved_cycles, @@ -186,8 +186,8 @@ let parametric_encoding = min_proposal_quorum, initial_endorsers, delay_per_missing_endorsement, - liquidity_baking_cpmm_origination_nonce, - liquidity_baking_reward, + liquidity_baking_cpmm_address, + liquidity_baking_subsidy, liquidity_baking_sunset_duration, liquidity_baking_escape_ema_threshold ) ) ) -> { @@ -216,8 +216,8 @@ let parametric_encoding = min_proposal_quorum; initial_endorsers; delay_per_missing_endorsement; - liquidity_baking_cpmm_origination_nonce; - liquidity_baking_reward; + liquidity_baking_cpmm_address; + liquidity_baking_subsidy; liquidity_baking_sunset_duration; liquidity_baking_escape_ema_threshold; }) @@ -256,10 +256,8 @@ let parametric_encoding = (req "min_proposal_quorum" int32) (req "initial_endorsers" uint16) (req "delay_per_missing_endorsement" Period_repr.encoding) - (req - "liquidity_baking_cpmm_origination_nonce" - Contract_repr.origination_nonce_encoding) - (req "liquidity_baking_reward" Tez_repr.encoding) + (req "liquidity_baking_cpmm_address" Contract_repr.encoding) + (req "liquidity_baking_subsidy" Tez_repr.encoding) (req "liquidity_baking_sunset_duration" int32) (req "liquidity_baking_escape_ema_threshold" int32)))) diff --git a/src/proto_alpha/lib_protocol/constants_repr.mli b/src/proto_alpha/lib_protocol/constants_repr.mli index 3d560ee1ba7a..b4d0b9c8a12f 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_repr.mli @@ -77,6 +77,10 @@ type parametric = { min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; + liquidity_baking_cpmm_address : Contract_repr.t; + liquidity_baking_subsidy : Tez_repr.t; + liquidity_baking_sunset_duration : int32; + liquidity_baking_escape_ema_threshold : int32; } val parametric_encoding : parametric Data_encoding.encoding @@ -84,3 +88,37 @@ val parametric_encoding : parametric Data_encoding.encoding type t = {fixed : fixed; parametric : parametric} val encoding : t Data_encoding.encoding + +module Proto_previous : sig + type parametric = { + preserved_cycles : int; + blocks_per_cycle : int32; + blocks_per_commitment : int32; + blocks_per_roll_snapshot : int32; + blocks_per_voting_period : int32; + time_between_blocks : Period_repr.t list; + endorsers_per_block : int; + hard_gas_limit_per_operation : Gas_limit_repr.Arith.integral; + hard_gas_limit_per_block : Gas_limit_repr.Arith.integral; + proof_of_work_threshold : int64; + tokens_per_roll : Tez_repr.t; + michelson_maximum_type_size : int; + seed_nonce_revelation_tip : Tez_repr.t; + origination_size : int; + block_security_deposit : Tez_repr.t; + endorsement_security_deposit : Tez_repr.t; + baking_reward_per_endorsement : Tez_repr.t list; + endorsement_reward : Tez_repr.t list; + cost_per_byte : Tez_repr.t; + hard_storage_limit_per_operation : Z.t; + test_chain_duration : int64; + (* in seconds *) + quorum_min : int32; + quorum_max : int32; + min_proposal_quorum : int32; + initial_endorsers : int; + delay_per_missing_endorsement : Period_repr.t; + } + + val parametric_encoding : parametric Data_encoding.encoding +end diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index b6f9b13a79fd..342b7700774c 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -123,13 +123,13 @@ let min_proposal_quorum c = let constants = Raw_context.constants c in constants.min_proposal_quorum -let liquidity_baking_cpmm_origination_nonce c = +let liquidity_baking_cpmm_address c = let constants = Raw_context.constants c in - constants.liquidity_baking_cpmm_origination_nonce + constants.liquidity_baking_cpmm_address -let liquidity_baking_reward c = +let liquidity_baking_subsidy c = let constants = Raw_context.constants c in - constants.liquidity_baking_reward + constants.liquidity_baking_subsidy let liquidity_baking_sunset_duration c = let constants = Raw_context.constants c in diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 34fa2f6228b1..228137515863 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -75,4 +75,12 @@ val quorum_max : Raw_context.t -> int32 val min_proposal_quorum : Raw_context.t -> int32 +val liquidity_baking_cpmm_address : Raw_context.t -> Contract_repr.t + +val liquidity_baking_subsidy : Raw_context.t -> Tez_repr.t + +val liquidity_baking_sunset_duration : Raw_context.t -> int32 + +val liquidity_baking_escape_ema_threshold : Raw_context.t -> int32 + val parametric : Raw_context.t -> Constants_repr.parametric diff --git a/src/proto_alpha/lib_protocol/dune.inc b/src/proto_alpha/lib_protocol/dune.inc index ee57405d369c..1621c34e8075 100644 --- a/src/proto_alpha/lib_protocol/dune.inc +++ b/src/proto_alpha/lib_protocol/dune.inc @@ -32,14 +32,9 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end fixed_point_repr.mli fixed_point_repr.ml saturation_repr.mli saturation_repr.ml gas_limit_repr.mli gas_limit_repr.ml -<<<<<<< HEAD + contract_repr.mli contract_repr.ml constants_repr.mli constants_repr.ml fitness_repr.mli fitness_repr.ml -======= - contract_repr.mli contract_repr.ml - constants_repr.ml - fitness_repr.ml ->>>>>>> liquidity baking: initial commit raw_level_repr.mli raw_level_repr.ml cycle_repr.mli cycle_repr.ml level_repr.mli level_repr.ml @@ -124,14 +119,9 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end fixed_point_repr.mli fixed_point_repr.ml saturation_repr.mli saturation_repr.ml gas_limit_repr.mli gas_limit_repr.ml -<<<<<<< HEAD + contract_repr.mli contract_repr.ml constants_repr.mli constants_repr.ml fitness_repr.mli fitness_repr.ml -======= - contract_repr.mli contract_repr.ml - constants_repr.ml - fitness_repr.ml ->>>>>>> liquidity baking: initial commit raw_level_repr.mli raw_level_repr.ml cycle_repr.mli cycle_repr.ml level_repr.mli level_repr.ml @@ -216,14 +206,9 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end fixed_point_repr.mli fixed_point_repr.ml saturation_repr.mli saturation_repr.ml gas_limit_repr.mli gas_limit_repr.ml -<<<<<<< HEAD + contract_repr.mli contract_repr.ml constants_repr.mli constants_repr.ml fitness_repr.mli fitness_repr.ml -======= - contract_repr.mli contract_repr.ml - constants_repr.ml - fitness_repr.ml ->>>>>>> liquidity baking: initial commit raw_level_repr.mli raw_level_repr.ml cycle_repr.mli cycle_repr.ml level_repr.mli level_repr.ml diff --git a/src/proto_alpha/lib_protocol/helpers_services.ml b/src/proto_alpha/lib_protocol/helpers_services.ml index 247907804147..12147317a92a 100644 --- a/src/proto_alpha/lib_protocol/helpers_services.ml +++ b/src/proto_alpha/lib_protocol/helpers_services.ml @@ -859,17 +859,9 @@ module Forge = struct "proof_of_work_nonce" (Fixed.bytes Alpha_context.Constants.proof_of_work_nonce_size) empty_proof_of_work_nonce) - (req "liquidity_baking_escape_flag" bool)) + (req "liquidity_baking_escape_vote" bool)) ~output:(obj1 (req "protocol_data" bytes)) RPC_path.(path / "protocol_data") - - (* let flags = - * RPC_service.post_service - * ~description:"Set block flags" - * ~query:RPC_query.empty - * ~input:bool - * ~output:int32 - * RPC_path.(path / "flags") *) end let register () = @@ -885,7 +877,7 @@ module Forge = struct ( priority, seed_nonce_hash, proof_of_work_nonce, - liquidity_baking_escape_flag ) + liquidity_baking_escape_vote ) -> return (Data_encoding.Binary.to_bytes_exn @@ -894,7 +886,7 @@ module Forge = struct priority; seed_nonce_hash; proof_of_work_nonce; - liquidity_baking_escape_flag; + liquidity_baking_escape_vote; })) module Manager = struct @@ -1050,7 +1042,7 @@ module Forge = struct let protocol_data ctxt block ~priority ?seed_nonce_hash ?(proof_of_work_nonce = empty_proof_of_work_nonce) - ~liquidity_baking_escape_flag () = + ~liquidity_baking_escape_vote () = RPC_context.make_call0 S.protocol_data ctxt @@ -1059,12 +1051,7 @@ module Forge = struct ( priority, seed_nonce_hash, proof_of_work_nonce, - liquidity_baking_escape_flag ) - - (* let set_liquidity_baking_escape_ema ctxt block flag = - * (\* Alpha_context.set_liquidity_baking_escape_ema ctxt flag - * * >>=? fun (ctxt, new_ema) - *\) - * RPC_context.make_call0 S.flags ctxt block () flag *) + liquidity_baking_escape_vote ) end module Parse = struct diff --git a/src/proto_alpha/lib_protocol/helpers_services.mli b/src/proto_alpha/lib_protocol/helpers_services.mli index 34e55825ae7a..de50450bc82e 100644 --- a/src/proto_alpha/lib_protocol/helpers_services.mli +++ b/src/proto_alpha/lib_protocol/helpers_services.mli @@ -289,7 +289,7 @@ module Forge : sig priority:int -> ?seed_nonce_hash:Nonce_hash.t -> ?proof_of_work_nonce:bytes -> - liquidity_baking_escape_flag:bool -> + liquidity_baking_escape_vote:bool -> unit -> bytes shell_tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index d916ba5f5d31..9c2199e45cde 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -96,6 +96,15 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = ~amount_mutez:100_000_000L >>= fun (ctxt, balance_updates) -> Storage.Pending_migration_balance_updates.init ctxt balance_updates + >>=? fun ctxt -> + Storage.Liquidity_baking.Escape_ema.init ctxt 0l + >>=? fun ctxt -> + Storage.Liquidity_baking.Sunset_level.init + ctxt + Int32.( + add + (Raw_level_repr.to_int32 (Level_storage.current ctxt).level) + (Constants_storage.liquidity_baking_sunset_duration ctxt)) let prepare ctxt ~level ~predecessor_timestamp ~timestamp ~fitness = Raw_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt diff --git a/src/proto_alpha/lib_protocol/parameters_repr.ml b/src/proto_alpha/lib_protocol/parameters_repr.ml index e5c9aae07568..61ac59ab5aab 100644 --- a/src/proto_alpha/lib_protocol/parameters_repr.ml +++ b/src/proto_alpha/lib_protocol/parameters_repr.ml @@ -33,8 +33,6 @@ type bootstrap_contract = { delegate : Signature.Public_key_hash.t option; amount : Tez_repr.t; script : Script_repr.t; - origination_nonce : Contract_repr.origination_nonce option; - (* to test inflationary in sandbox, otherwise should be None *) } type t = { @@ -83,19 +81,14 @@ let bootstrap_account_encoding = let bootstrap_contract_encoding = let open Data_encoding in conv - (fun {delegate; amount; script; origination_nonce} -> - (delegate, amount, script, origination_nonce)) - (fun (delegate, amount, script, origination_nonce) -> - {delegate; amount; script; origination_nonce}) - (obj4 + (fun {delegate; amount; script} -> (delegate, amount, script)) + (fun (delegate, amount, script) -> {delegate; amount; script}) + (obj3 (req "delegate" (Data_encoding.option Signature.Public_key_hash.encoding)) (req "amount" Tez_repr.encoding) - (req "script" Script_repr.encoding) - (req - "origination nonce" - (Data_encoding.option Contract_repr.origination_nonce_encoding))) + (req "script" Script_repr.encoding)) let encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/parameters_repr.mli b/src/proto_alpha/lib_protocol/parameters_repr.mli index 56df3d258471..14cdb0d67515 100644 --- a/src/proto_alpha/lib_protocol/parameters_repr.mli +++ b/src/proto_alpha/lib_protocol/parameters_repr.mli @@ -33,7 +33,6 @@ type bootstrap_contract = { delegate : Signature.Public_key_hash.t option; amount : Tez_repr.t; script : Script_repr.t; - origination_nonce : Contract_repr.origination_nonce option; } type t = { diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 887512bd21e5..93d92c0feacc 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -829,32 +829,31 @@ let prepare_first_block ~level ~timestamp ~fitness ctxt = time_between_blocks = c.time_between_blocks; endorsers_per_block = c.endorsers_per_block; hard_gas_limit_per_operation = c.hard_gas_limit_per_operation; - hard_gas_limit_per_block = - Gas_limit_repr.Arith.(integral_of_int_exn 5_200_000); + hard_gas_limit_per_block = c.hard_gas_limit_per_block; proof_of_work_threshold = c.proof_of_work_threshold; tokens_per_roll = c.tokens_per_roll; michelson_maximum_type_size = c.michelson_maximum_type_size; seed_nonce_revelation_tip = c.seed_nonce_revelation_tip; origination_size = c.origination_size; - block_security_deposit = Tez_repr.(mul_exn one 640); - endorsement_security_deposit = Tez_repr.(mul_exn one_cent 250); - baking_reward_per_endorsement = - Tez_repr.[of_mutez_exn 78_125L; of_mutez_exn 11_719L]; - endorsement_reward = - Tez_repr.[of_mutez_exn 78_125L; of_mutez_exn 52_083L]; + block_security_deposit = c.block_security_deposit; + endorsement_security_deposit = c.endorsement_security_deposit; + baking_reward_per_endorsement = c.baking_reward_per_endorsement; + endorsement_reward = c.endorsement_reward; hard_storage_limit_per_operation = c.hard_storage_limit_per_operation; cost_per_byte = c.cost_per_byte; - test_chain_duration = c.test_chain_duration; quorum_min = c.quorum_min; quorum_max = c.quorum_max; min_proposal_quorum = c.min_proposal_quorum; initial_endorsers = c.initial_endorsers; delay_per_missing_endorsement = c.delay_per_missing_endorsement; - liquidity_baking_cpmm_origination_nonce = + liquidity_baking_cpmm_address = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) - Contract_repr.initial_origination_nonce Operation_hash.zero; - liquidity_baking_reward = Tez_repr.of_mutez_exn 5_000_000L; + Contract_repr.originated_contract + (Contract_repr.initial_origination_nonce + (Operation_hash.hash_bytes + [Bytes.of_string "Un festival de GADT."])); + liquidity_baking_subsidy = Tez_repr.of_mutez_exn 5_000_000L; liquidity_baking_sunset_duration = 262800l; liquidity_baking_escape_ema_threshold = 500_000l; } diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 6af73b50e6ca..c1679b5e0dcc 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -496,7 +496,7 @@ module Liquidity_baking : sig Single_data_storage with type t := Raw_context.t and type value = Int32.t (** Level at which liquidity baking automatically shuts off. - Set in stitching to six months from activation of Florence. **) + Set in stitching to six months from activation of proto 009. **) module Sunset_level : Single_data_storage with type t := Raw_context.t and type value = Int32.t end diff --git a/src/proto_alpha/lib_protocol/test/dune b/src/proto_alpha/lib_protocol/test/dune index 4b492e108ac7..498ad10ce330 100644 --- a/src/proto_alpha/lib_protocol/test/dune +++ b/src/proto_alpha/lib_protocol/test/dune @@ -26,20 +26,10 @@ (deps main.exe) (action (progn))) -(rule - (alias fa12.json) - (action (copy %{lib:tezos-protocol-alpha-parameters:fa12.json} - fa12.json))) - -(rule - (alias cpmm.json) - (action (copy %{lib:tezos-protocol-alpha-parameters:cpmm.json} - cpmm.json))) - ; runs only the `Quick tests (rule (alias runtest_proto_alpha) - (deps (glob_files contracts/*) fa12.json cpmm.json) + (deps (glob_files contracts/*)) (package tezos-protocol-alpha-tests) (action (run %{exe:main.exe} -v -q))) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 3b4a0009eaf2..d6fc926317f0 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -145,13 +145,13 @@ module Forge = struct Bytes.create Constants.proof_of_work_nonce_size let make_contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ?(liquidity_baking_escape_flag = false) ~priority ~seed_nonce_hash () = + ?(liquidity_baking_escape_vote = false) ~priority ~seed_nonce_hash () = Block_header. { priority; proof_of_work_nonce; seed_nonce_hash; - liquidity_baking_escape_flag; + liquidity_baking_escape_vote; } let make_shell ~level ~predecessor ~timestamp ~fitness ~operations_hash = @@ -190,7 +190,7 @@ module Forge = struct Block_header.{shell; protocol_data = {contents; signature}} let forge_header ?(policy = By_priority 0) ?timestamp ?(operations = []) - ?liquidity_baking_escape_flag pred = + ?liquidity_baking_escape_vote pred = dispatch_policy policy pred >>=? fun (pkh, priority, _timestamp) -> Alpha_services.Delegate.Minimal_valid_time.get rpc_ctxt pred priority 0 @@ -223,19 +223,19 @@ module Forge = struct ~operations_hash in let contents = - make_contents ~priority ~seed_nonce_hash ?liquidity_baking_escape_flag () + make_contents ~priority ~seed_nonce_hash ?liquidity_baking_escape_vote () in {baker = pkh; shell; contents} (* compatibility only, needed by incremental *) let contents ?(proof_of_work_nonce = default_proof_of_work_nonce) - ?(priority = 0) ?seed_nonce_hash ?(liquidity_baking_escape_flag = false) + ?(priority = 0) ?seed_nonce_hash ?(liquidity_baking_escape_vote = false) () = { Block_header.priority; proof_of_work_nonce; seed_nonce_hash; - liquidity_baking_escape_flag; + liquidity_baking_escape_vote; } end @@ -271,9 +271,7 @@ let initial_context ?(with_commitments = false) constants header let parameters = Default_parameters.parameters_of_constants ~bootstrap_accounts - ~bootstrap_contracts: - Default_parameters.( - build_bootstrap_contracts bootstrap_contracts_filepaths) + ~bootstrap_contracts:Default_parameters.test_bootstrap_contracts ~with_commitments constants in @@ -432,7 +430,7 @@ let apply_with_metadata header ?(operations = []) pred = ({hash; header; operations; context}, result) let bake ?policy ?timestamp ?operation ?operations - ?liquidity_baking_escape_flag pred = + ?liquidity_baking_escape_vote pred = let operations = match (operation, operations) with | (Some op, Some ops) -> @@ -448,13 +446,13 @@ let bake ?policy ?timestamp ?operation ?operations ?timestamp ?policy ?operations - ?liquidity_baking_escape_flag + ?liquidity_baking_escape_vote pred >>=? fun header -> Forge.sign_header header >>=? fun header -> apply header ?operations pred let bake_with_metadata ?policy ?timestamp ?operation ?operations - ?liquidity_baking_escape_flag pred = + ?liquidity_baking_escape_vote pred = let operations = match (operation, operations) with | (Some op, Some ops) -> @@ -470,7 +468,7 @@ let bake_with_metadata ?policy ?timestamp ?operation ?operations ?timestamp ?policy ?operations - ?liquidity_baking_escape_flag + ?liquidity_baking_escape_vote pred >>=? fun header -> Forge.sign_header header @@ -481,16 +479,16 @@ let bake_with_metadata ?policy ?timestamp ?operation ?operations (* This function is duplicated from Context to avoid a cyclic dependency *) let get_constants b = Alpha_services.Constants.all rpc_ctxt b -let bake_n ?policy ?liquidity_baking_escape_flag n b = +let bake_n ?policy ?liquidity_baking_escape_vote n b = List.fold_left_es - (fun b _ -> bake ?policy ?liquidity_baking_escape_flag b) + (fun b _ -> bake ?policy ?liquidity_baking_escape_vote b) b (1 -- n) -let bake_n_with_balance_updates ?policy ?liquidity_baking_escape_flag n b = +let bake_n_with_balance_updates ?policy ?liquidity_baking_escape_vote n b = List.fold_left_es (fun (b, balance_updates_list) _ -> - bake_with_metadata ?policy ?liquidity_baking_escape_flag b + bake_with_metadata ?policy ?liquidity_baking_escape_vote b >>=? fun (b, metadata) -> return (b, metadata.balance_updates @ balance_updates_list)) (b, []) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 0de1fd906150..7f8aaf901068 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -62,7 +62,7 @@ module Forge : sig ?proof_of_work_nonce:Bytes.t -> ?priority:int -> ?seed_nonce_hash:Nonce_hash.t -> - ?liquidity_baking_escape_flag:bool -> + ?liquidity_baking_escape_vote:bool -> unit -> Block_header.contents @@ -74,7 +74,7 @@ module Forge : sig ?policy:baker_policy -> ?timestamp:Timestamp.time -> ?operations:Operation.packed list -> - ?liquidity_baking_escape_flag:bool -> + ?liquidity_baking_escape_vote:bool -> t -> header tzresult Lwt.t @@ -124,14 +124,14 @@ val bake : ?timestamp:Timestamp.time -> ?operation:Operation.packed -> ?operations:Operation.packed list -> - ?liquidity_baking_escape_flag:bool -> + ?liquidity_baking_escape_vote:bool -> t -> t tzresult Lwt.t (** Bakes [n] blocks. *) val bake_n : ?policy:baker_policy -> - ?liquidity_baking_escape_flag:bool -> + ?liquidity_baking_escape_vote:bool -> int -> t -> block tzresult Lwt.t @@ -140,7 +140,7 @@ val bake_n : in the metadata of baked blocks. **) val bake_n_with_balance_updates : ?policy:baker_policy -> - ?liquidity_baking_escape_flag:bool -> + ?liquidity_baking_escape_vote:bool -> int -> t -> (block * Alpha_context.Receipt.balance_updates) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 90f93a0cd39e..232470ce6be3 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -173,10 +173,10 @@ let get_endorsing_reward ctxt ~priority ~endorsing_power = (Environment.wrap_tzresult Tez.(reward_per_endorsement *? Int64.of_int endorsing_power)) -let get_liquidity_baking_reward ctxt = +let get_liquidity_baking_subsidy ctxt = get_constants ctxt - >>=? fun {Constants.parametric = {liquidity_baking_reward; _}; _} -> - return liquidity_baking_reward + >>=? fun {Constants.parametric = {liquidity_baking_subsidy; _}; _} -> + return liquidity_baking_subsidy (* Voting *) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 9f0cf2100ffa..29e18ba61457 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -63,7 +63,7 @@ val get_baking_reward : val get_endorsing_reward : t -> priority:int -> endorsing_power:int -> Tez.t tzresult Lwt.t -val get_liquidity_baking_reward : t -> Tez.t tzresult Lwt.t +val get_liquidity_baking_subsidy : t -> Tez.t tzresult Lwt.t module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index cb2bb5f09a12..96d6d45d53e5 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -27,22 +27,19 @@ open Protocol open Test_tez open Micheline_printer -let liquidity_baking_rewards n () = +let liquidity_baking_subsidys n () = Context.init 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n n blk >>=? fun blk -> - Context.get_liquidity_baking_reward (B blk) - >>=? fun liquidity_baking_reward -> - Tez.(liquidity_baking_reward *? Int64.(of_int n)) + Context.get_liquidity_baking_subsidy (B blk) + >>=? fun liquidity_baking_subsidy -> + Tez.(liquidity_baking_subsidy *? Int64.(of_int n)) >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ @@ -57,18 +54,15 @@ let liquidity_baking_sunset_level () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in let sunset = csts.parametric.liquidity_baking_sunset_duration in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n Int32.(to_int (add sunset 100l)) blk >>=? fun blk -> - Context.get_liquidity_baking_reward (B blk) - >>=? fun liquidity_baking_reward -> - Tez.(liquidity_baking_reward *? Int64.(sub (of_int32 sunset) 1L)) + Context.get_liquidity_baking_subsidy (B blk) + >>=? fun liquidity_baking_subsidy -> + Tez.(liquidity_baking_subsidy *? Int64.(sub (of_int32 sunset) 1L)) >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ @@ -83,21 +77,18 @@ let liquidity_baking_escape_hatch_100 () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in (* log(1-1/2) / log(0.999) *) let escape_level = 694 in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> - Block.bake_n ~liquidity_baking_escape_flag:true escape_level blk + Block.bake_n ~liquidity_baking_escape_vote:true escape_level blk >>=? fun blk -> Block.bake_n 100 blk >>=? fun blk -> - Context.get_liquidity_baking_reward (B blk) - >>=? fun liquidity_baking_reward -> - Tez.(liquidity_baking_reward *? Int64.(sub (of_int escape_level) 1L)) + Context.get_liquidity_baking_subsidy (B blk) + >>=? fun liquidity_baking_subsidy -> + Tez.(liquidity_baking_subsidy *? Int64.(sub (of_int escape_level) 1L)) >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ @@ -112,10 +103,7 @@ let liquidity_baking_escape_hatch_80 () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in (* log(1-1/(2*.8)) / log(0.999) *) let escape_level = 983 in Context.Contract.balance (B blk) liquidity_baking @@ -124,7 +112,7 @@ let liquidity_baking_escape_hatch_80 () = if i < escape_level then Block.bake blk >>=? fun blk -> - Block.bake_n ~liquidity_baking_escape_flag:true 4 blk + Block.bake_n ~liquidity_baking_escape_vote:true 4 blk >>=? fun blk -> bake_80_percent_escaping blk (i + 5) else return blk in @@ -132,9 +120,9 @@ let liquidity_baking_escape_hatch_80 () = >>=? fun blk -> Block.bake_n 100 blk >>=? fun blk -> - Context.get_liquidity_baking_reward (B blk) - >>=? fun liquidity_baking_reward -> - Tez.(liquidity_baking_reward *? Int64.(sub (of_int escape_level) 1L)) + Context.get_liquidity_baking_subsidy (B blk) + >>=? fun liquidity_baking_subsidy -> + Tez.(liquidity_baking_subsidy *? Int64.(sub (of_int escape_level) 1L)) >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ @@ -149,10 +137,7 @@ let liquidity_baking_escape_hatch_60 () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in (* log(1-1/(2*.6)) / log(0.999) *) let escape_level = 1790 in Context.Contract.balance (B blk) liquidity_baking @@ -161,7 +146,7 @@ let liquidity_baking_escape_hatch_60 () = if i < escape_level then Block.bake_n 2 blk >>=? fun blk -> - Block.bake_n ~liquidity_baking_escape_flag:true 3 blk + Block.bake_n ~liquidity_baking_escape_vote:true 3 blk >>=? fun blk -> bake_80_percent_escaping blk (i + 5) else return blk in @@ -169,9 +154,9 @@ let liquidity_baking_escape_hatch_60 () = >>=? fun blk -> Block.bake_n 100 blk >>=? fun blk -> - Context.get_liquidity_baking_reward (B blk) - >>=? fun liquidity_baking_reward -> - Tez.(liquidity_baking_reward *? Int64.(sub (of_int escape_level) 1L)) + Context.get_liquidity_baking_subsidy (B blk) + >>=? fun liquidity_baking_subsidy -> + Tez.(liquidity_baking_subsidy *? Int64.(sub (of_int escape_level) 1L)) >>?= fun expected_balance -> Assert.balance_was_credited ~loc:__LOC__ @@ -186,15 +171,12 @@ let liquidity_baking_storage n () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in let expected_storage = Expr.from_string (Printf.sprintf - "Pair 1 (Pair False 4000000000000) \ - \"KT1HuJge9aGSi62pa4LdEMg43r4nHzscZqDP\" 2000000000000 %d" + "Pair 0 (Pair False 4000000000000) \ + \"KT1CSKPf2jeLpMmrgKquN2bCjBTkAcAdRVDy\" 2000000000000 %d" (2000000000000 + (n * 5000000))) in Block.bake_n n blk @@ -220,10 +202,7 @@ let liquidity_baking_balance_update () = >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = - Alpha_context.Contract.originated_contract - csts.parametric.liquidity_baking_cpmm_origination_nonce - in + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in let sunset = csts.parametric.liquidity_baking_sunset_duration in Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk >>=? fun (_blk, balance_updates) -> @@ -240,7 +219,7 @@ let liquidity_baking_balance_update () = false) balance_updates in - let rewards = + let credits = List.fold_left (fun accum (_, update, _) -> match update with @@ -257,36 +236,36 @@ let liquidity_baking_balance_update () = in Assert.equal_tez ~loc:__LOC__ - rewards + credits (Tez.of_int ((Int32.to_int sunset - 1) * 5)) >>=? fun () -> return_unit let tests = - [ Test.tztest - "test liquidity baking rewards are correct" + [ Test_services.tztest + "test liquidity baking subsidy is correct" `Quick - (liquidity_baking_rewards 64); - Test.tztest + (liquidity_baking_subsidys 64); + Test_services.tztest "test liquidity baking shuts off at sunset level" `Quick liquidity_baking_sunset_level; - Test.tztest + Test_services.tztest "test liquidity baking escape hatch with 100% of bakers flagging" `Quick liquidity_baking_escape_hatch_100; - Test.tztest + Test_services.tztest "test liquidity baking escape hatch with 80% of bakers flagging" `Quick liquidity_baking_escape_hatch_80; - Test.tztest + Test_services.tztest "test liquidity baking escape hatch with 60% of bakers flagging" `Quick liquidity_baking_escape_hatch_60; - Test.tztest + Test_services.tztest "test liquidity baking storage is updated" `Quick (liquidity_baking_storage 64); - Test.tztest + Test_services.tztest "test liquidity baking balance updates" `Quick liquidity_baking_balance_update ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out index 20af84e5b4fb..8f0c3f4a240c 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out @@ -33,8 +33,8 @@ This sequence of operations was run: [CONTRACT_HASH] Storage size: 146 bytes Updated big_maps: - New map(0) of type (big_map int int) - Set map(0)[0] to 0 + New map(2) of type (big_map int int) + Set map(2)[0] to 0 Paid storage size diff: 146 bytes Consumed gas: 1899.428 Balance updates: diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" new file mode 100644 index 000000000000..8a586f2700ff --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" @@ -0,0 +1,42 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-"hello"-(Pair None 2)-big_map_diff10] + +storage + (Pair None 2) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["hello"] to 4 +trace + - location: 11 (remaining gas: 1039988.651 units remaining) + [ (Pair "hello" (Some 4) {}) ] + - location: 13 (remaining gas: 1039988.451 units remaining) + [ "hello" @parameter + (Pair (Some 4) {}) @storage ] + - location: 16 (remaining gas: 1039988.151 units remaining) + [ (Some 4) + {} ] + - location: 15 (remaining gas: 1039988.081 units remaining) + [ (Some 4) + {} ] + - location: 14 (remaining gas: 1039988.081 units remaining) + [ "hello" @parameter + (Some 4) + {} ] + - location: -1 (remaining gas: 1039988.011 units remaining) + [ "hello" @parameter + (Some 4) + {} ] + - location: 17 (remaining gas: 1039987.791 units remaining) + [ None + { Elt "hello" 4 } ] + - location: 18 (remaining gas: 1039987.651 units remaining) + [ (Pair None { Elt "hello" 4 }) ] + - location: 19 (remaining gas: 1039987.511 units remaining) + [ {} + (Pair None { Elt "hello" 4 }) ] + - location: 21 (remaining gas: 1039987.371 units remaining) + [ (Pair {} None { Elt "hello" 4 }) ] + - location: -1 (remaining gas: 1039987.301 units remaining) + [ (Pair {} None { Elt "hello" 4 }) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" new file mode 100644 index 000000000000..58ae004bc132 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" @@ -0,0 +1,42 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt "hello" 4 })-"hello"-(Pair (Some 4) 2)-big_map_diff12] + +storage + (Pair (Some 4) 2) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["hello"] to 5 +trace + - location: 11 (remaining gas: 1039988.027 units remaining) + [ (Pair "hello" (Some 5) { Elt "hello" 4 }) ] + - location: 13 (remaining gas: 1039987.827 units remaining) + [ "hello" @parameter + (Pair (Some 5) { Elt "hello" 4 }) @storage ] + - location: 16 (remaining gas: 1039987.527 units remaining) + [ (Some 5) + { Elt "hello" 4 } ] + - location: 15 (remaining gas: 1039987.457 units remaining) + [ (Some 5) + { Elt "hello" 4 } ] + - location: 14 (remaining gas: 1039987.457 units remaining) + [ "hello" @parameter + (Some 5) + { Elt "hello" 4 } ] + - location: -1 (remaining gas: 1039987.387 units remaining) + [ "hello" @parameter + (Some 5) + { Elt "hello" 4 } ] + - location: 17 (remaining gas: 1039987.167 units remaining) + [ (Some 4) + { Elt "hello" 5 } ] + - location: 18 (remaining gas: 1039987.027 units remaining) + [ (Pair (Some 4) { Elt "hello" 5 }) ] + - location: 19 (remaining gas: 1039986.887 units remaining) + [ {} + (Pair (Some 4) { Elt "hello" 5 }) ] + - location: 21 (remaining gas: 1039986.747 units remaining) + [ (Pair {} (Some 4) { Elt "hello" 5 }) ] + - location: -1 (remaining gas: 1039986.677 units remaining) + [ (Pair {} (Some 4) { Elt "hello" 5 }) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" new file mode 100644 index 000000000000..6705d52730c4 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" @@ -0,0 +1,43 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt "hello" 4 })-"hi"-(Pair None 2)-big_map_diff13] + +storage + (Pair None 2) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["hello"] to 4 + Set map(2)["hi"] to 5 +trace + - location: 11 (remaining gas: 1039988.057 units remaining) + [ (Pair "hi" (Some 5) { Elt "hello" 4 }) ] + - location: 13 (remaining gas: 1039987.857 units remaining) + [ "hi" @parameter + (Pair (Some 5) { Elt "hello" 4 }) @storage ] + - location: 16 (remaining gas: 1039987.557 units remaining) + [ (Some 5) + { Elt "hello" 4 } ] + - location: 15 (remaining gas: 1039987.487 units remaining) + [ (Some 5) + { Elt "hello" 4 } ] + - location: 14 (remaining gas: 1039987.487 units remaining) + [ "hi" @parameter + (Some 5) + { Elt "hello" 4 } ] + - location: -1 (remaining gas: 1039987.417 units remaining) + [ "hi" @parameter + (Some 5) + { Elt "hello" 4 } ] + - location: 17 (remaining gas: 1039987.197 units remaining) + [ None + { Elt "hello" 4 ; Elt "hi" 5 } ] + - location: 18 (remaining gas: 1039987.057 units remaining) + [ (Pair None { Elt "hello" 4 ; Elt "hi" 5 }) ] + - location: 19 (remaining gas: 1039986.917 units remaining) + [ {} + (Pair None { Elt "hello" 4 ; Elt "hi" 5 }) ] + - location: 21 (remaining gas: 1039986.777 units remaining) + [ (Pair {} None { Elt "hello" 4 ; Elt "hi" 5 }) ] + - location: -1 (remaining gas: 1039986.707 units remaining) + [ (Pair {} None { Elt "hello" 4 ; Elt "hi" 5 }) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" new file mode 100644 index 000000000000..2eadf0fa1023 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" @@ -0,0 +1,43 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt "1" 1 ; Elt "2" 2 })-"1"-(Pair (Some 1) 2)-big_map_diff14] + +storage + (Pair (Some 1) 2) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Unset map(2)["1"] + Set map(2)["2"] to 2 +trace + - location: 11 (remaining gas: 1039987.643 units remaining) + [ (Pair "1" None { Elt "1" 1 ; Elt "2" 2 }) ] + - location: 13 (remaining gas: 1039987.443 units remaining) + [ "1" @parameter + (Pair None { Elt "1" 1 ; Elt "2" 2 }) @storage ] + - location: 16 (remaining gas: 1039987.143 units remaining) + [ None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: 15 (remaining gas: 1039987.073 units remaining) + [ None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: 14 (remaining gas: 1039987.073 units remaining) + [ "1" @parameter + None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: -1 (remaining gas: 1039987.003 units remaining) + [ "1" @parameter + None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: 17 (remaining gas: 1039986.783 units remaining) + [ (Some 1) + { Elt "2" 2 } ] + - location: 18 (remaining gas: 1039986.643 units remaining) + [ (Pair (Some 1) { Elt "2" 2 }) ] + - location: 19 (remaining gas: 1039986.503 units remaining) + [ {} + (Pair (Some 1) { Elt "2" 2 }) ] + - location: 21 (remaining gas: 1039986.363 units remaining) + [ (Pair {} (Some 1) { Elt "2" 2 }) ] + - location: -1 (remaining gas: 1039986.293 units remaining) + [ (Pair {} (Some 1) { Elt "2" 2 }) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" new file mode 100644 index 000000000000..3982a72aa928 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" @@ -0,0 +1,43 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt "1" 1 ; Elt "2" 2 })-"1"-(Pair (Some 1) 2)-big_map_diff15] + +storage + (Pair (Some 1) 2) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Unset map(2)["1"] + Set map(2)["2"] to 2 +trace + - location: 11 (remaining gas: 1039987.643 units remaining) + [ (Pair "1" None { Elt "1" 1 ; Elt "2" 2 }) ] + - location: 13 (remaining gas: 1039987.443 units remaining) + [ "1" @parameter + (Pair None { Elt "1" 1 ; Elt "2" 2 }) @storage ] + - location: 16 (remaining gas: 1039987.143 units remaining) + [ None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: 15 (remaining gas: 1039987.073 units remaining) + [ None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: 14 (remaining gas: 1039987.073 units remaining) + [ "1" @parameter + None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: -1 (remaining gas: 1039987.003 units remaining) + [ "1" @parameter + None + { Elt "1" 1 ; Elt "2" 2 } ] + - location: 17 (remaining gas: 1039986.783 units remaining) + [ (Some 1) + { Elt "2" 2 } ] + - location: 18 (remaining gas: 1039986.643 units remaining) + [ (Pair (Some 1) { Elt "2" 2 }) ] + - location: 19 (remaining gas: 1039986.503 units remaining) + [ {} + (Pair (Some 1) { Elt "2" 2 }) ] + - location: 21 (remaining gas: 1039986.363 units remaining) + [ (Pair {} (Some 1) { Elt "2" 2 }) ] + - location: -1 (remaining gas: 1039986.293 units remaining) + [ (Pair {} (Some 1) { Elt "2" 2 }) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" new file mode 100644 index 000000000000..9c0bbdff2930 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" @@ -0,0 +1,42 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt "hello" 4 })-"hello"-(Pair (Some 4) 2)-big_map_diff11] + +storage + (Pair (Some 4) 2) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Unset map(2)["hello"] +trace + - location: 11 (remaining gas: 1039988.267 units remaining) + [ (Pair "hello" None { Elt "hello" 4 }) ] + - location: 13 (remaining gas: 1039988.067 units remaining) + [ "hello" @parameter + (Pair None { Elt "hello" 4 }) @storage ] + - location: 16 (remaining gas: 1039987.767 units remaining) + [ None + { Elt "hello" 4 } ] + - location: 15 (remaining gas: 1039987.697 units remaining) + [ None + { Elt "hello" 4 } ] + - location: 14 (remaining gas: 1039987.697 units remaining) + [ "hello" @parameter + None + { Elt "hello" 4 } ] + - location: -1 (remaining gas: 1039987.627 units remaining) + [ "hello" @parameter + None + { Elt "hello" 4 } ] + - location: 17 (remaining gas: 1039987.407 units remaining) + [ (Some 4) + {} ] + - location: 18 (remaining gas: 1039987.267 units remaining) + [ (Pair (Some 4) {}) ] + - location: 19 (remaining gas: 1039987.127 units remaining) + [ {} + (Pair (Some 4) {}) ] + - location: 21 (remaining gas: 1039986.987 units remaining) + [ (Pair {} (Some 4) {}) ] + - location: -1 (remaining gas: 1039986.917 units remaining) + [ (Pair {} (Some 4) {}) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" new file mode 100644 index 000000000000..0faab32663bf --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" @@ -0,0 +1,42 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-"hello"-(Pair None 2)-big_map_diff9] + +storage + (Pair None 2) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Unset map(2)["hello"] +trace + - location: 11 (remaining gas: 1039988.891 units remaining) + [ (Pair "hello" None {}) ] + - location: 13 (remaining gas: 1039988.691 units remaining) + [ "hello" @parameter + (Pair None {}) @storage ] + - location: 16 (remaining gas: 1039988.391 units remaining) + [ None + {} ] + - location: 15 (remaining gas: 1039988.321 units remaining) + [ None + {} ] + - location: 14 (remaining gas: 1039988.321 units remaining) + [ "hello" @parameter + None + {} ] + - location: -1 (remaining gas: 1039988.251 units remaining) + [ "hello" @parameter + None + {} ] + - location: 17 (remaining gas: 1039988.031 units remaining) + [ None + {} ] + - location: 18 (remaining gas: 1039987.891 units remaining) + [ (Pair None {}) ] + - location: 19 (remaining gas: 1039987.751 units remaining) + [ {} + (Pair None {}) ] + - location: 21 (remaining gas: 1039987.611 units remaining) + [ (Pair {} None {}) ] + - location: -1 (remaining gas: 1039987.541 units remaining) + [ (Pair {} None {}) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" new file mode 100644 index 000000000000..bc090f905c36 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" @@ -0,0 +1,51 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt "1" "one" ; Elt "2" "two" } None)-"1"-(Pair 2 (Some "one"))-big_map_diff2] + +storage + (Pair 2 (Some "one")) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["1"] to "one" + Set map(2)["2"] to "two" +trace + - location: 11 (remaining gas: 1039982.525 units remaining) + [ (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) ] + - location: 12 (remaining gas: 1039982.385 units remaining) + [ (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) + (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) ] + - location: 13 (remaining gas: 1039982.245 units remaining) + [ "1" @parameter + (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) ] + - location: 17 (remaining gas: 1039981.885 units remaining) + [ (Pair { Elt "1" "one" ; Elt "2" "two" } None) @storage ] + - location: 18 (remaining gas: 1039981.745 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } ] + - location: -1 (remaining gas: 1039981.675 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } ] + - location: 19 (remaining gas: 1039981.535 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + { Elt "1" "one" ; Elt "2" "two" } ] + - location: -1 (remaining gas: 1039981.465 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + { Elt "1" "one" ; Elt "2" "two" } ] + - location: 14 (remaining gas: 1039981.465 units remaining) + [ "1" @parameter + { Elt "1" "one" ; Elt "2" "two" } + { Elt "1" "one" ; Elt "2" "two" } ] + - location: 20 (remaining gas: 1039981.325 units remaining) + [ (Some "one") + { Elt "1" "one" ; Elt "2" "two" } ] + - location: 21 (remaining gas: 1039981.195 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + (Some "one") ] + - location: 22 (remaining gas: 1039981.055 units remaining) + [ (Pair { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] + - location: 23 (remaining gas: 1039980.915 units remaining) + [ {} + (Pair { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] + - location: 25 (remaining gas: 1039980.775 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] + - location: -1 (remaining gas: 1039980.705 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" new file mode 100644 index 000000000000..d290e4c0cc2b --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" @@ -0,0 +1,50 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt "hello" "hi" } None)-""-(Pair 2 None)-big_map_diff1] + +storage + (Pair 2 None) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["hello"] to "hi" +trace + - location: 11 (remaining gas: 1039983.253 units remaining) + [ (Pair "" { Elt "hello" "hi" } None) ] + - location: 12 (remaining gas: 1039983.113 units remaining) + [ (Pair "" { Elt "hello" "hi" } None) + (Pair "" { Elt "hello" "hi" } None) ] + - location: 13 (remaining gas: 1039982.973 units remaining) + [ "" @parameter + (Pair "" { Elt "hello" "hi" } None) ] + - location: 17 (remaining gas: 1039982.613 units remaining) + [ (Pair { Elt "hello" "hi" } None) @storage ] + - location: 18 (remaining gas: 1039982.473 units remaining) + [ { Elt "hello" "hi" } ] + - location: -1 (remaining gas: 1039982.403 units remaining) + [ { Elt "hello" "hi" } ] + - location: 19 (remaining gas: 1039982.263 units remaining) + [ { Elt "hello" "hi" } + { Elt "hello" "hi" } ] + - location: -1 (remaining gas: 1039982.193 units remaining) + [ { Elt "hello" "hi" } + { Elt "hello" "hi" } ] + - location: 14 (remaining gas: 1039982.193 units remaining) + [ "" @parameter + { Elt "hello" "hi" } + { Elt "hello" "hi" } ] + - location: 20 (remaining gas: 1039982.053 units remaining) + [ None + { Elt "hello" "hi" } ] + - location: 21 (remaining gas: 1039981.923 units remaining) + [ { Elt "hello" "hi" } + None ] + - location: 22 (remaining gas: 1039981.783 units remaining) + [ (Pair { Elt "hello" "hi" } None) ] + - location: 23 (remaining gas: 1039981.643 units remaining) + [ {} + (Pair { Elt "hello" "hi" } None) ] + - location: 25 (remaining gas: 1039981.503 units remaining) + [ (Pair {} { Elt "hello" "hi" } None) ] + - location: -1 (remaining gas: 1039981.433 units remaining) + [ (Pair {} { Elt "hello" "hi" } None) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" new file mode 100644 index 000000000000..4566dc427fc2 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" @@ -0,0 +1,50 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt "hello" "hi" } None)-"hello"-(Pair 2 (Some "hi"))-big_map_diff0] + +storage + (Pair 2 (Some "hi")) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["hello"] to "hi" +trace + - location: 11 (remaining gas: 1039983.203 units remaining) + [ (Pair "hello" { Elt "hello" "hi" } None) ] + - location: 12 (remaining gas: 1039983.063 units remaining) + [ (Pair "hello" { Elt "hello" "hi" } None) + (Pair "hello" { Elt "hello" "hi" } None) ] + - location: 13 (remaining gas: 1039982.923 units remaining) + [ "hello" @parameter + (Pair "hello" { Elt "hello" "hi" } None) ] + - location: 17 (remaining gas: 1039982.563 units remaining) + [ (Pair { Elt "hello" "hi" } None) @storage ] + - location: 18 (remaining gas: 1039982.423 units remaining) + [ { Elt "hello" "hi" } ] + - location: -1 (remaining gas: 1039982.353 units remaining) + [ { Elt "hello" "hi" } ] + - location: 19 (remaining gas: 1039982.213 units remaining) + [ { Elt "hello" "hi" } + { Elt "hello" "hi" } ] + - location: -1 (remaining gas: 1039982.143 units remaining) + [ { Elt "hello" "hi" } + { Elt "hello" "hi" } ] + - location: 14 (remaining gas: 1039982.143 units remaining) + [ "hello" @parameter + { Elt "hello" "hi" } + { Elt "hello" "hi" } ] + - location: 20 (remaining gas: 1039982.003 units remaining) + [ (Some "hi") + { Elt "hello" "hi" } ] + - location: 21 (remaining gas: 1039981.873 units remaining) + [ { Elt "hello" "hi" } + (Some "hi") ] + - location: 22 (remaining gas: 1039981.733 units remaining) + [ (Pair { Elt "hello" "hi" } (Some "hi")) ] + - location: 23 (remaining gas: 1039981.593 units remaining) + [ {} + (Pair { Elt "hello" "hi" } (Some "hi")) ] + - location: 25 (remaining gas: 1039981.453 units remaining) + [ (Pair {} { Elt "hello" "hi" } (Some "hi")) ] + - location: -1 (remaining gas: 1039981.383 units remaining) + [ (Pair {} { Elt "hello" "hi" } (Some "hi")) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" new file mode 100644 index 000000000000..6033bee05579 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" @@ -0,0 +1,54 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)-{ Elt "1" (Some "two") }-(Pair 2 Unit)-big_map_diff4] + +storage + (Pair 2 Unit) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["1"] to "two" + Set map(2)["2"] to "two" +trace + - location: 13 (remaining gas: 1039984.481 units remaining) + [ (Pair { Elt "1" (Some "two") } { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 15 (remaining gas: 1039984.281 units remaining) + [ { Elt "1" (Some "two") } @parameter + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] + - location: 18 (remaining gas: 1039983.981 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 17 (remaining gas: 1039983.911 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 16 (remaining gas: 1039983.911 units remaining) + [ { Elt "1" (Some "two") } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039983.841 units remaining) + [ { Elt "1" (Some "two") } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 21 (remaining gas: 1039983.521 units remaining) + [ "1" @key + (Some "two") @elt + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 22 (remaining gas: 1039983.381 units remaining) + [ { Elt "1" "two" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039983.311 units remaining) + [ { Elt "1" "two" ; Elt "2" "two" } + Unit ] + - location: 19 (remaining gas: 1039983.311 units remaining) + [ { Elt "1" "two" ; Elt "2" "two" } + Unit ] + - location: 23 (remaining gas: 1039983.171 units remaining) + [ (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] + - location: 24 (remaining gas: 1039983.031 units remaining) + [ {} + (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] + - location: 26 (remaining gas: 1039982.891 units remaining) + [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] + - location: -1 (remaining gas: 1039982.821 units remaining) + [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" new file mode 100644 index 000000000000..1f69ec8b8406 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" @@ -0,0 +1,54 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)-{ Elt "1" (Some "two") }-(Pair 2 Unit)-big_map_diff8] + +storage + (Pair 2 Unit) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["1"] to "two" + Set map(2)["2"] to "two" +trace + - location: 13 (remaining gas: 1039984.481 units remaining) + [ (Pair { Elt "1" (Some "two") } { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 15 (remaining gas: 1039984.281 units remaining) + [ { Elt "1" (Some "two") } @parameter + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] + - location: 18 (remaining gas: 1039983.981 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 17 (remaining gas: 1039983.911 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 16 (remaining gas: 1039983.911 units remaining) + [ { Elt "1" (Some "two") } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039983.841 units remaining) + [ { Elt "1" (Some "two") } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 21 (remaining gas: 1039983.521 units remaining) + [ "1" @key + (Some "two") @elt + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 22 (remaining gas: 1039983.381 units remaining) + [ { Elt "1" "two" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039983.311 units remaining) + [ { Elt "1" "two" ; Elt "2" "two" } + Unit ] + - location: 19 (remaining gas: 1039983.311 units remaining) + [ { Elt "1" "two" ; Elt "2" "two" } + Unit ] + - location: 23 (remaining gas: 1039983.171 units remaining) + [ (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] + - location: 24 (remaining gas: 1039983.031 units remaining) + [ {} + (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] + - location: 26 (remaining gas: 1039982.891 units remaining) + [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] + - location: -1 (remaining gas: 1039982.821 units remaining) + [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" new file mode 100644 index 000000000000..9c1f5a190693 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" @@ -0,0 +1,55 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)-{ Elt "3" None }-(Pair 2 Unit)-big_map_diff6] + +storage + (Pair 2 Unit) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["1"] to "one" + Set map(2)["2"] to "two" + Unset map(2)["3"] +trace + - location: 13 (remaining gas: 1039984.765 units remaining) + [ (Pair { Elt "3" None } { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 15 (remaining gas: 1039984.565 units remaining) + [ { Elt "3" None } @parameter + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] + - location: 18 (remaining gas: 1039984.265 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 17 (remaining gas: 1039984.195 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 16 (remaining gas: 1039984.195 units remaining) + [ { Elt "3" None } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039984.125 units remaining) + [ { Elt "3" None } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 21 (remaining gas: 1039983.805 units remaining) + [ "3" @key + None @elt + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 22 (remaining gas: 1039983.665 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039983.595 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 19 (remaining gas: 1039983.595 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 23 (remaining gas: 1039983.455 units remaining) + [ (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 24 (remaining gas: 1039983.315 units remaining) + [ {} + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 26 (remaining gas: 1039983.175 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: -1 (remaining gas: 1039983.105 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" new file mode 100644 index 000000000000..20d0ab72edd1 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" @@ -0,0 +1,54 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)-{ Elt "2" None }-(Pair 2 Unit)-big_map_diff7] + +storage + (Pair 2 Unit) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["1"] to "one" + Unset map(2)["2"] +trace + - location: 13 (remaining gas: 1039984.765 units remaining) + [ (Pair { Elt "2" None } { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 15 (remaining gas: 1039984.565 units remaining) + [ { Elt "2" None } @parameter + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] + - location: 18 (remaining gas: 1039984.265 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 17 (remaining gas: 1039984.195 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 16 (remaining gas: 1039984.195 units remaining) + [ { Elt "2" None } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039984.125 units remaining) + [ { Elt "2" None } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 21 (remaining gas: 1039983.805 units remaining) + [ "2" @key + None @elt + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 22 (remaining gas: 1039983.665 units remaining) + [ { Elt "1" "one" } + Unit ] + - location: -1 (remaining gas: 1039983.595 units remaining) + [ { Elt "1" "one" } + Unit ] + - location: 19 (remaining gas: 1039983.595 units remaining) + [ { Elt "1" "one" } + Unit ] + - location: 23 (remaining gas: 1039983.455 units remaining) + [ (Pair { Elt "1" "one" } Unit) ] + - location: 24 (remaining gas: 1039983.315 units remaining) + [ {} + (Pair { Elt "1" "one" } Unit) ] + - location: 26 (remaining gas: 1039983.175 units remaining) + [ (Pair {} { Elt "1" "one" } Unit) ] + - location: -1 (remaining gas: 1039983.105 units remaining) + [ (Pair {} { Elt "1" "one" } Unit) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" new file mode 100644 index 000000000000..a7f394d8fe2c --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" @@ -0,0 +1,43 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)-{}-(Pair 2 Unit)-big_map_diff3] + +storage + (Pair 2 Unit) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["1"] to "one" + Set map(2)["2"] to "two" +trace + - location: 13 (remaining gas: 1039985.349 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 15 (remaining gas: 1039985.149 units remaining) + [ {} @parameter + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] + - location: 18 (remaining gas: 1039984.849 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 17 (remaining gas: 1039984.779 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 16 (remaining gas: 1039984.779 units remaining) + [ {} @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039984.709 units remaining) + [ {} @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 19 (remaining gas: 1039984.569 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 23 (remaining gas: 1039984.429 units remaining) + [ (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 24 (remaining gas: 1039984.289 units remaining) + [ {} + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 26 (remaining gas: 1039984.149 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: -1 (remaining gas: 1039984.079 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" new file mode 100644 index 000000000000..6b4a90a25ea2 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" @@ -0,0 +1,55 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)-{ Elt "3" (Some "three") }-(Pair 2 Unit)-big_map_diff5] + +storage + (Pair 2 Unit) +emitted operations + +big_map diff + New map(2) of type (big_map string string) + Set map(2)["1"] to "one" + Set map(2)["2"] to "two" + Set map(2)["3"] to "three" +trace + - location: 13 (remaining gas: 1039984.461 units remaining) + [ (Pair { Elt "3" (Some "three") } { Elt "1" "one" ; Elt "2" "two" } Unit) ] + - location: 15 (remaining gas: 1039984.261 units remaining) + [ { Elt "3" (Some "three") } @parameter + (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] + - location: 18 (remaining gas: 1039983.961 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 17 (remaining gas: 1039983.891 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 16 (remaining gas: 1039983.891 units remaining) + [ { Elt "3" (Some "three") } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: -1 (remaining gas: 1039983.821 units remaining) + [ { Elt "3" (Some "three") } @parameter + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 21 (remaining gas: 1039983.501 units remaining) + [ "3" @key + (Some "three") @elt + { Elt "1" "one" ; Elt "2" "two" } + Unit ] + - location: 22 (remaining gas: 1039983.361 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } + Unit ] + - location: -1 (remaining gas: 1039983.291 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } + Unit ] + - location: 19 (remaining gas: 1039983.291 units remaining) + [ { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } + Unit ] + - location: 23 (remaining gas: 1039983.151 units remaining) + [ (Pair { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] + - location: 24 (remaining gas: 1039983.011 units remaining) + [ {} + (Pair { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] + - location: 26 (remaining gas: 1039982.871 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] + - location: -1 (remaining gas: 1039982.801 units remaining) + [ (Pair {} { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" new file mode 100644 index 000000000000..7e0bbd7f4a8e --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" @@ -0,0 +1,80 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt "1" "one" } { Elt "2" "two" }) )-(Right (Right (Right (Left { Pair "3" "three" }))))-(Left (Pair 2 3))-big_map_diff4] + +storage + (Left (Pair 2 3)) +emitted operations + +big_map diff + New map(3) of type (big_map string string) + Set map(3)["2"] to "two" + New map(2) of type (big_map string string) + Set map(2)["1"] to "one" + Set map(2)["3"] to "three" +trace + - location: 42 (remaining gas: 1039921.281 units remaining) + [ (Pair (Right (Right (Right (Left { Pair "3" "three" })))) + (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] + - location: 43 (remaining gas: 1039921.141 units remaining) + [ (Right (Right (Right (Left { Pair "3" "three" })))) @parameter + (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] + - location: 114 (remaining gas: 1039920.101 units remaining) + [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] + - location: 112 (remaining gas: 1039920.031 units remaining) + [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] + - location: 119 (remaining gas: 1039919.891 units remaining) + [ { Elt "1" "one" } + { Elt "2" "two" } ] + - location: -1 (remaining gas: 1039919.821 units remaining) + [ { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 110 (remaining gas: 1039919.821 units remaining) + [ { Pair "3" "three" } @parameter.right.right.right.add + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 122 (remaining gas: 1039919.114 units remaining) + [ "3" + "three" + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 125 (remaining gas: 1039918.814 units remaining) + [ (Some "three") + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 124 (remaining gas: 1039918.744 units remaining) + [ (Some "three") + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 123 (remaining gas: 1039918.744 units remaining) + [ "3" + (Some "three") + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 126 (remaining gas: 1039918.604 units remaining) + [ { Elt "1" "one" ; Elt "3" "three" } + { Elt "2" "two" } ] + - location: -1 (remaining gas: 1039918.534 units remaining) + [ { Elt "1" "one" ; Elt "3" "three" } + { Elt "2" "two" } ] + - location: 120 (remaining gas: 1039918.534 units remaining) + [ { Elt "1" "one" ; Elt "3" "three" } + { Elt "2" "two" } ] + - location: 127 (remaining gas: 1039918.394 units remaining) + [ (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" }) ] + - location: 128 (remaining gas: 1039918.254 units remaining) + [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] + - location: -1 (remaining gas: 1039918.184 units remaining) + [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] + - location: 107 (remaining gas: 1039918.114 units remaining) + [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] + - location: 64 (remaining gas: 1039918.044 units remaining) + [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] + - location: 59 (remaining gas: 1039917.974 units remaining) + [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] + - location: 151 (remaining gas: 1039917.834 units remaining) + [ {} + (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] + - location: 153 (remaining gas: 1039917.694 units remaining) + [ (Pair {} (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" }))) ] + - location: -1 (remaining gas: 1039917.624 units remaining) + [ (Pair {} (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" }))) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" new file mode 100644 index 000000000000..9538d38c832d --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" @@ -0,0 +1,43 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))-(Left Unit)-(Left (Pair 2 3))-big_map_diff0] + +storage + (Left (Pair 2 3)) +emitted operations + +big_map diff + New map(3) of type (big_map string string) + Set map(3)["1"] to "one" + New map(2) of type (big_map string string) + Set map(2)["2"] to "two" +trace + - location: 42 (remaining gas: 1039923.184 units remaining) + [ (Pair (Left Unit) (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] + - location: 43 (remaining gas: 1039923.044 units remaining) + [ (Left Unit) @parameter + (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] + - location: 46 (remaining gas: 1039922.754 units remaining) + [ (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] + - location: 49 (remaining gas: 1039922.474 units remaining) + [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] + - location: 47 (remaining gas: 1039922.404 units remaining) + [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] + - location: 54 (remaining gas: 1039922.264 units remaining) + [ { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 55 (remaining gas: 1039922.134 units remaining) + [ { Elt "2" "two" } + { Elt "1" "one" } ] + - location: 56 (remaining gas: 1039921.994 units remaining) + [ (Pair { Elt "2" "two" } { Elt "1" "one" }) ] + - location: 57 (remaining gas: 1039921.854 units remaining) + [ (Left (Pair { Elt "2" "two" } { Elt "1" "one" })) ] + - location: -1 (remaining gas: 1039921.784 units remaining) + [ (Left (Pair { Elt "2" "two" } { Elt "1" "one" })) ] + - location: 151 (remaining gas: 1039921.644 units remaining) + [ {} + (Left (Pair { Elt "2" "two" } { Elt "1" "one" })) ] + - location: 153 (remaining gas: 1039921.504 units remaining) + [ (Pair {} (Left (Pair { Elt "2" "two" } { Elt "1" "one" }))) ] + - location: -1 (remaining gas: 1039921.434 units remaining) + [ (Pair {} (Left (Pair { Elt "2" "two" } { Elt "1" "one" }))) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" new file mode 100644 index 000000000000..eedb7586ecd5 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" @@ -0,0 +1,35 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))-(Right (Left (Left (Pair { Elt "3" "three" } { Elt "4" "four" }))))-(Left (Pair 2 3))-big_map_diff1] + +storage + (Left (Pair 2 3)) +emitted operations + +big_map diff + New map(3) of type (big_map string string) + Set map(3)["4"] to "four" + New map(2) of type (big_map string string) + Set map(2)["3"] to "three" +trace + - location: 42 (remaining gas: 1039919.438 units remaining) + [ (Pair (Right (Left (Left (Pair { Elt "3" "three" } { Elt "4" "four" })))) + (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] + - location: 43 (remaining gas: 1039919.298 units remaining) + [ (Right (Left (Left (Pair { Elt "3" "three" } { Elt "4" "four" })))) @parameter + (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] + - location: 62 (remaining gas: 1039918.868 units remaining) + [ (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage + (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) @parameter.right.reset ] + - location: 63 (remaining gas: 1039918.728 units remaining) + [ (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) @parameter.right.reset ] + - location: -1 (remaining gas: 1039918.658 units remaining) + [ (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) @parameter.right.reset ] + - location: 59 (remaining gas: 1039918.588 units remaining) + [ (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) ] + - location: 151 (remaining gas: 1039918.448 units remaining) + [ {} + (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) ] + - location: 153 (remaining gas: 1039918.308 units remaining) + [ (Pair {} (Left (Pair { Elt "3" "three" } { Elt "4" "four" }))) ] + - location: -1 (remaining gas: 1039918.238 units remaining) + [ (Pair {} (Left (Pair { Elt "3" "three" } { Elt "4" "four" }))) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" new file mode 100644 index 000000000000..1e8254ad6a0f --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" @@ -0,0 +1,74 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))-(Right (Right (Right (Right { "1" }))))-(Left (Pair 2 3))-big_map_diff5] + +storage + (Left (Pair 2 3)) +emitted operations + +big_map diff + New map(3) of type (big_map string string) + Set map(3)["2"] to "two" + New map(2) of type (big_map string string) + Unset map(2)["1"] +trace + - location: 42 (remaining gas: 1039921.825 units remaining) + [ (Pair (Right (Right (Right (Right { "1" })))) + (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] + - location: 43 (remaining gas: 1039921.685 units remaining) + [ (Right (Right (Right (Right { "1" })))) @parameter + (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] + - location: 135 (remaining gas: 1039920.645 units remaining) + [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] + - location: 133 (remaining gas: 1039920.575 units remaining) + [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] + - location: 140 (remaining gas: 1039920.435 units remaining) + [ { Elt "1" "one" } + { Elt "2" "two" } ] + - location: -1 (remaining gas: 1039920.365 units remaining) + [ { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 131 (remaining gas: 1039920.365 units remaining) + [ { "1" } @parameter.right.right.right.rem + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 145 (remaining gas: 1039919.498 units remaining) + [ None + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 144 (remaining gas: 1039919.428 units remaining) + [ None + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 143 (remaining gas: 1039919.428 units remaining) + [ "1" @parameter.right.right.right.rem.elt + None + { Elt "1" "one" } + { Elt "2" "two" } ] + - location: 147 (remaining gas: 1039919.288 units remaining) + [ {} + { Elt "2" "two" } ] + - location: -1 (remaining gas: 1039919.218 units remaining) + [ {} + { Elt "2" "two" } ] + - location: 141 (remaining gas: 1039919.218 units remaining) + [ {} + { Elt "2" "two" } ] + - location: 148 (remaining gas: 1039919.078 units remaining) + [ (Pair {} { Elt "2" "two" }) ] + - location: 149 (remaining gas: 1039918.938 units remaining) + [ (Left (Pair {} { Elt "2" "two" })) ] + - location: -1 (remaining gas: 1039918.868 units remaining) + [ (Left (Pair {} { Elt "2" "two" })) ] + - location: 107 (remaining gas: 1039918.798 units remaining) + [ (Left (Pair {} { Elt "2" "two" })) ] + - location: 64 (remaining gas: 1039918.728 units remaining) + [ (Left (Pair {} { Elt "2" "two" })) ] + - location: 59 (remaining gas: 1039918.658 units remaining) + [ (Left (Pair {} { Elt "2" "two" })) ] + - location: 151 (remaining gas: 1039918.518 units remaining) + [ {} + (Left (Pair {} { Elt "2" "two" })) ] + - location: 153 (remaining gas: 1039918.378 units remaining) + [ (Pair {} (Left (Pair {} { Elt "2" "two" }))) ] + - location: -1 (remaining gas: 1039918.308 units remaining) + [ (Pair {} (Left (Pair {} { Elt "2" "two" }))) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" new file mode 100644 index 000000000000..367d8cf8d3d6 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" @@ -0,0 +1,128 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" }) )))-(Left (Pair 2 3))-big_map_diff3] + +storage + (Left (Pair 2 3)) +emitted operations + +big_map diff + New map(3) of type (big_map string string) + Set map(3)["gaz"] to "baz" + New map(2) of type (big_map string string) + Set map(2)["foo"] to "bar" +trace + - location: 42 (remaining gas: 1039922.719 units remaining) + [ (Pair (Right (Right (Left (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" })))) (Right Unit)) ] + - location: 43 (remaining gas: 1039922.579 units remaining) + [ (Right (Right (Left (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" })))) @parameter + (Right Unit) @storage ] + - location: 75 (remaining gas: 1039921.689 units remaining) + [ Unit @storage.right ] + - location: 69 (remaining gas: 1039921.619 units remaining) + [ Unit @storage.right ] + - location: 76 (remaining gas: 1039921.479 units remaining) + [ ] + - location: -1 (remaining gas: 1039921.409 units remaining) + [ ] + - location: 67 (remaining gas: 1039921.409 units remaining) + [ (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" }) @parameter.right.right.import ] + - location: 77 (remaining gas: 1039921.269 units remaining) + [ { Pair "foo" "bar" } + { Pair "gaz" "baz" } ] + - location: 80 (remaining gas: 1039920.809 units remaining) + [ {} + { Pair "gaz" "baz" } ] + - location: 79 (remaining gas: 1039920.739 units remaining) + [ {} + { Pair "gaz" "baz" } ] + - location: 78 (remaining gas: 1039920.739 units remaining) + [ { Pair "foo" "bar" } + {} + { Pair "gaz" "baz" } ] + - location: 85 (remaining gas: 1039920.032 units remaining) + [ "foo" + "bar" + {} + { Pair "gaz" "baz" } ] + - location: 88 (remaining gas: 1039919.732 units remaining) + [ (Some "bar") + {} + { Pair "gaz" "baz" } ] + - location: 87 (remaining gas: 1039919.662 units remaining) + [ (Some "bar") + {} + { Pair "gaz" "baz" } ] + - location: 86 (remaining gas: 1039919.662 units remaining) + [ "foo" + (Some "bar") + {} + { Pair "gaz" "baz" } ] + - location: 89 (remaining gas: 1039919.522 units remaining) + [ { Elt "foo" "bar" } + { Pair "gaz" "baz" } ] + - location: -1 (remaining gas: 1039919.452 units remaining) + [ { Elt "foo" "bar" } + { Pair "gaz" "baz" } ] + - location: 83 (remaining gas: 1039919.452 units remaining) + [ { Elt "foo" "bar" } + { Pair "gaz" "baz" } ] + - location: 90 (remaining gas: 1039919.322 units remaining) + [ { Pair "gaz" "baz" } + { Elt "foo" "bar" } ] + - location: 93 (remaining gas: 1039918.862 units remaining) + [ {} + { Elt "foo" "bar" } ] + - location: 92 (remaining gas: 1039918.792 units remaining) + [ {} + { Elt "foo" "bar" } ] + - location: 91 (remaining gas: 1039918.792 units remaining) + [ { Pair "gaz" "baz" } + {} + { Elt "foo" "bar" } ] + - location: 98 (remaining gas: 1039918.085 units remaining) + [ "gaz" + "baz" + {} + { Elt "foo" "bar" } ] + - location: 101 (remaining gas: 1039917.785 units remaining) + [ (Some "baz") + {} + { Elt "foo" "bar" } ] + - location: 100 (remaining gas: 1039917.715 units remaining) + [ (Some "baz") + {} + { Elt "foo" "bar" } ] + - location: 99 (remaining gas: 1039917.715 units remaining) + [ "gaz" + (Some "baz") + {} + { Elt "foo" "bar" } ] + - location: 102 (remaining gas: 1039917.575 units remaining) + [ { Elt "gaz" "baz" } + { Elt "foo" "bar" } ] + - location: -1 (remaining gas: 1039917.505 units remaining) + [ { Elt "gaz" "baz" } + { Elt "foo" "bar" } ] + - location: 96 (remaining gas: 1039917.505 units remaining) + [ { Elt "gaz" "baz" } + { Elt "foo" "bar" } ] + - location: 103 (remaining gas: 1039917.375 units remaining) + [ { Elt "foo" "bar" } + { Elt "gaz" "baz" } ] + - location: 104 (remaining gas: 1039917.235 units remaining) + [ (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" }) ] + - location: 105 (remaining gas: 1039917.095 units remaining) + [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] + - location: -1 (remaining gas: 1039917.025 units remaining) + [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] + - location: 64 (remaining gas: 1039916.955 units remaining) + [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] + - location: 59 (remaining gas: 1039916.885 units remaining) + [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] + - location: 151 (remaining gas: 1039916.745 units remaining) + [ {} + (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] + - location: 153 (remaining gas: 1039916.605 units remaining) + [ (Pair {} (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" }))) ] + - location: -1 (remaining gas: 1039916.535 units remaining) + [ (Pair {} (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" }))) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out new file mode 100644 index 000000000000..d2d64637dc02 --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out @@ -0,0 +1,46 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (Some False))0] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[0] to 1 +trace + - location: 11 (remaining gas: 1039986.170 units remaining) + [ (Pair 1 { Elt 0 1 } None) ] + - location: 12 (remaining gas: 1039986.030 units remaining) + [ 1 @parameter + (Pair { Elt 0 1 } None) @storage ] + - location: 15 (remaining gas: 1039985.730 units remaining) + [ { Elt 0 1 } ] + - location: 16 (remaining gas: 1039985.590 units remaining) + [ { Elt 0 1 } + { Elt 0 1 } ] + - location: -1 (remaining gas: 1039985.520 units remaining) + [ { Elt 0 1 } + { Elt 0 1 } ] + - location: 13 (remaining gas: 1039985.520 units remaining) + [ 1 @parameter + { Elt 0 1 } + { Elt 0 1 } ] + - location: 17 (remaining gas: 1039985.380 units remaining) + [ False + { Elt 0 1 } ] + - location: 18 (remaining gas: 1039985.240 units remaining) + [ (Some False) + { Elt 0 1 } ] + - location: 19 (remaining gas: 1039985.110 units remaining) + [ { Elt 0 1 } + (Some False) ] + - location: 20 (remaining gas: 1039984.970 units remaining) + [ (Pair { Elt 0 1 } (Some False)) ] + - location: 21 (remaining gas: 1039984.830 units remaining) + [ {} + (Pair { Elt 0 1 } (Some False)) ] + - location: 23 (remaining gas: 1039984.690 units remaining) + [ (Pair {} { Elt 0 1 } (Some False)) ] + - location: -1 (remaining gas: 1039984.620 units remaining) + [ (Pair {} { Elt 0 1 } (Some False)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out new file mode 100644 index 000000000000..db1d692ded9e --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out @@ -0,0 +1,46 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (Some False))1] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[0] to 1 +trace + - location: 11 (remaining gas: 1039986.170 units remaining) + [ (Pair 1 { Elt 0 1 } None) ] + - location: 12 (remaining gas: 1039986.030 units remaining) + [ 1 @parameter + (Pair { Elt 0 1 } None) @storage ] + - location: 15 (remaining gas: 1039985.730 units remaining) + [ { Elt 0 1 } ] + - location: 16 (remaining gas: 1039985.590 units remaining) + [ { Elt 0 1 } + { Elt 0 1 } ] + - location: -1 (remaining gas: 1039985.520 units remaining) + [ { Elt 0 1 } + { Elt 0 1 } ] + - location: 13 (remaining gas: 1039985.520 units remaining) + [ 1 @parameter + { Elt 0 1 } + { Elt 0 1 } ] + - location: 17 (remaining gas: 1039985.380 units remaining) + [ False + { Elt 0 1 } ] + - location: 18 (remaining gas: 1039985.240 units remaining) + [ (Some False) + { Elt 0 1 } ] + - location: 19 (remaining gas: 1039985.110 units remaining) + [ { Elt 0 1 } + (Some False) ] + - location: 20 (remaining gas: 1039984.970 units remaining) + [ (Pair { Elt 0 1 } (Some False)) ] + - location: 21 (remaining gas: 1039984.830 units remaining) + [ {} + (Pair { Elt 0 1 } (Some False)) ] + - location: 23 (remaining gas: 1039984.690 units remaining) + [ (Pair {} { Elt 0 1 } (Some False)) ] + - location: -1 (remaining gas: 1039984.620 units remaining) + [ (Pair {} { Elt 0 1 } (Some False)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out new file mode 100644 index 000000000000..417b6cfb9ddb --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out @@ -0,0 +1,46 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (Some True))1] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 0 +trace + - location: 11 (remaining gas: 1039986.170 units remaining) + [ (Pair 1 { Elt 1 0 } None) ] + - location: 12 (remaining gas: 1039986.030 units remaining) + [ 1 @parameter + (Pair { Elt 1 0 } None) @storage ] + - location: 15 (remaining gas: 1039985.730 units remaining) + [ { Elt 1 0 } ] + - location: 16 (remaining gas: 1039985.590 units remaining) + [ { Elt 1 0 } + { Elt 1 0 } ] + - location: -1 (remaining gas: 1039985.520 units remaining) + [ { Elt 1 0 } + { Elt 1 0 } ] + - location: 13 (remaining gas: 1039985.520 units remaining) + [ 1 @parameter + { Elt 1 0 } + { Elt 1 0 } ] + - location: 17 (remaining gas: 1039985.380 units remaining) + [ True + { Elt 1 0 } ] + - location: 18 (remaining gas: 1039985.240 units remaining) + [ (Some True) + { Elt 1 0 } ] + - location: 19 (remaining gas: 1039985.110 units remaining) + [ { Elt 1 0 } + (Some True) ] + - location: 20 (remaining gas: 1039984.970 units remaining) + [ (Pair { Elt 1 0 } (Some True)) ] + - location: 21 (remaining gas: 1039984.830 units remaining) + [ {} + (Pair { Elt 1 0 } (Some True)) ] + - location: 23 (remaining gas: 1039984.690 units remaining) + [ (Pair {} { Elt 1 0 } (Some True)) ] + - location: -1 (remaining gas: 1039984.620 units remaining) + [ (Pair {} { Elt 1 0 } (Some True)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out new file mode 100644 index 000000000000..ec0b98789664 --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out @@ -0,0 +1,46 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (Some True))0] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 0 +trace + - location: 11 (remaining gas: 1039986.170 units remaining) + [ (Pair 1 { Elt 1 0 } None) ] + - location: 12 (remaining gas: 1039986.030 units remaining) + [ 1 @parameter + (Pair { Elt 1 0 } None) @storage ] + - location: 15 (remaining gas: 1039985.730 units remaining) + [ { Elt 1 0 } ] + - location: 16 (remaining gas: 1039985.590 units remaining) + [ { Elt 1 0 } + { Elt 1 0 } ] + - location: -1 (remaining gas: 1039985.520 units remaining) + [ { Elt 1 0 } + { Elt 1 0 } ] + - location: 13 (remaining gas: 1039985.520 units remaining) + [ 1 @parameter + { Elt 1 0 } + { Elt 1 0 } ] + - location: 17 (remaining gas: 1039985.380 units remaining) + [ True + { Elt 1 0 } ] + - location: 18 (remaining gas: 1039985.240 units remaining) + [ (Some True) + { Elt 1 0 } ] + - location: 19 (remaining gas: 1039985.110 units remaining) + [ { Elt 1 0 } + (Some True) ] + - location: 20 (remaining gas: 1039984.970 units remaining) + [ (Pair { Elt 1 0 } (Some True)) ] + - location: 21 (remaining gas: 1039984.830 units remaining) + [ {} + (Pair { Elt 1 0 } (Some True)) ] + - location: 23 (remaining gas: 1039984.690 units remaining) + [ (Pair {} { Elt 1 0 } (Some True)) ] + - location: -1 (remaining gas: 1039984.620 units remaining) + [ (Pair {} { Elt 1 0 } (Some True)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out new file mode 100644 index 000000000000..f3076a12414f --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1-(Pair 2 (Some True))1] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 4 + Set map(2)[2] to 11 +trace + - location: 11 (remaining gas: 1039985.460 units remaining) + [ (Pair 1 { Elt 1 4 ; Elt 2 11 } None) ] + - location: 12 (remaining gas: 1039985.320 units remaining) + [ 1 @parameter + (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] + - location: 15 (remaining gas: 1039985.020 units remaining) + [ { Elt 1 4 ; Elt 2 11 } ] + - location: 16 (remaining gas: 1039984.880 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: -1 (remaining gas: 1039984.810 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 13 (remaining gas: 1039984.810 units remaining) + [ 1 @parameter + { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 17 (remaining gas: 1039984.670 units remaining) + [ True + { Elt 1 4 ; Elt 2 11 } ] + - location: 18 (remaining gas: 1039984.530 units remaining) + [ (Some True) + { Elt 1 4 ; Elt 2 11 } ] + - location: 19 (remaining gas: 1039984.400 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + (Some True) ] + - location: 20 (remaining gas: 1039984.260 units remaining) + [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 21 (remaining gas: 1039984.120 units remaining) + [ {} + (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 23 (remaining gas: 1039983.980 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: -1 (remaining gas: 1039983.910 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out new file mode 100644 index 000000000000..e7848d3aafbe --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1-(Pair 2 (Some True))0] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 4 + Set map(2)[2] to 11 +trace + - location: 11 (remaining gas: 1039985.460 units remaining) + [ (Pair 1 { Elt 1 4 ; Elt 2 11 } None) ] + - location: 12 (remaining gas: 1039985.320 units remaining) + [ 1 @parameter + (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] + - location: 15 (remaining gas: 1039985.020 units remaining) + [ { Elt 1 4 ; Elt 2 11 } ] + - location: 16 (remaining gas: 1039984.880 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: -1 (remaining gas: 1039984.810 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 13 (remaining gas: 1039984.810 units remaining) + [ 1 @parameter + { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 17 (remaining gas: 1039984.670 units remaining) + [ True + { Elt 1 4 ; Elt 2 11 } ] + - location: 18 (remaining gas: 1039984.530 units remaining) + [ (Some True) + { Elt 1 4 ; Elt 2 11 } ] + - location: 19 (remaining gas: 1039984.400 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + (Some True) ] + - location: 20 (remaining gas: 1039984.260 units remaining) + [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 21 (remaining gas: 1039984.120 units remaining) + [ {} + (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 23 (remaining gas: 1039983.980 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: -1 (remaining gas: 1039983.910 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out new file mode 100644 index 000000000000..fdbe6c8df07b --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2-(Pair 2 (Some True))1] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 4 + Set map(2)[2] to 11 +trace + - location: 11 (remaining gas: 1039985.460 units remaining) + [ (Pair 2 { Elt 1 4 ; Elt 2 11 } None) ] + - location: 12 (remaining gas: 1039985.320 units remaining) + [ 2 @parameter + (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] + - location: 15 (remaining gas: 1039985.020 units remaining) + [ { Elt 1 4 ; Elt 2 11 } ] + - location: 16 (remaining gas: 1039984.880 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: -1 (remaining gas: 1039984.810 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 13 (remaining gas: 1039984.810 units remaining) + [ 2 @parameter + { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 17 (remaining gas: 1039984.670 units remaining) + [ True + { Elt 1 4 ; Elt 2 11 } ] + - location: 18 (remaining gas: 1039984.530 units remaining) + [ (Some True) + { Elt 1 4 ; Elt 2 11 } ] + - location: 19 (remaining gas: 1039984.400 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + (Some True) ] + - location: 20 (remaining gas: 1039984.260 units remaining) + [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 21 (remaining gas: 1039984.120 units remaining) + [ {} + (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 23 (remaining gas: 1039983.980 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: -1 (remaining gas: 1039983.910 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out new file mode 100644 index 000000000000..30ce7828ebd8 --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2-(Pair 2 (Some True))0] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 4 + Set map(2)[2] to 11 +trace + - location: 11 (remaining gas: 1039985.460 units remaining) + [ (Pair 2 { Elt 1 4 ; Elt 2 11 } None) ] + - location: 12 (remaining gas: 1039985.320 units remaining) + [ 2 @parameter + (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] + - location: 15 (remaining gas: 1039985.020 units remaining) + [ { Elt 1 4 ; Elt 2 11 } ] + - location: 16 (remaining gas: 1039984.880 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: -1 (remaining gas: 1039984.810 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 13 (remaining gas: 1039984.810 units remaining) + [ 2 @parameter + { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 17 (remaining gas: 1039984.670 units remaining) + [ True + { Elt 1 4 ; Elt 2 11 } ] + - location: 18 (remaining gas: 1039984.530 units remaining) + [ (Some True) + { Elt 1 4 ; Elt 2 11 } ] + - location: 19 (remaining gas: 1039984.400 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + (Some True) ] + - location: 20 (remaining gas: 1039984.260 units remaining) + [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 21 (remaining gas: 1039984.120 units remaining) + [ {} + (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: 23 (remaining gas: 1039983.980 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + - location: -1 (remaining gas: 1039983.910 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out new file mode 100644 index 000000000000..02daf08e37de --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3-(Pair 2 (Some False))0] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 4 + Set map(2)[2] to 11 +trace + - location: 11 (remaining gas: 1039985.460 units remaining) + [ (Pair 3 { Elt 1 4 ; Elt 2 11 } None) ] + - location: 12 (remaining gas: 1039985.320 units remaining) + [ 3 @parameter + (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] + - location: 15 (remaining gas: 1039985.020 units remaining) + [ { Elt 1 4 ; Elt 2 11 } ] + - location: 16 (remaining gas: 1039984.880 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: -1 (remaining gas: 1039984.810 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 13 (remaining gas: 1039984.810 units remaining) + [ 3 @parameter + { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 17 (remaining gas: 1039984.670 units remaining) + [ False + { Elt 1 4 ; Elt 2 11 } ] + - location: 18 (remaining gas: 1039984.530 units remaining) + [ (Some False) + { Elt 1 4 ; Elt 2 11 } ] + - location: 19 (remaining gas: 1039984.400 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + (Some False) ] + - location: 20 (remaining gas: 1039984.260 units remaining) + [ (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] + - location: 21 (remaining gas: 1039984.120 units remaining) + [ {} + (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] + - location: 23 (remaining gas: 1039983.980 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] + - location: -1 (remaining gas: 1039983.910 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out new file mode 100644 index 000000000000..8981825b7569 --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3-(Pair 2 (Some False))1] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) + Set map(2)[1] to 4 + Set map(2)[2] to 11 +trace + - location: 11 (remaining gas: 1039985.460 units remaining) + [ (Pair 3 { Elt 1 4 ; Elt 2 11 } None) ] + - location: 12 (remaining gas: 1039985.320 units remaining) + [ 3 @parameter + (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] + - location: 15 (remaining gas: 1039985.020 units remaining) + [ { Elt 1 4 ; Elt 2 11 } ] + - location: 16 (remaining gas: 1039984.880 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: -1 (remaining gas: 1039984.810 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 13 (remaining gas: 1039984.810 units remaining) + [ 3 @parameter + { Elt 1 4 ; Elt 2 11 } + { Elt 1 4 ; Elt 2 11 } ] + - location: 17 (remaining gas: 1039984.670 units remaining) + [ False + { Elt 1 4 ; Elt 2 11 } ] + - location: 18 (remaining gas: 1039984.530 units remaining) + [ (Some False) + { Elt 1 4 ; Elt 2 11 } ] + - location: 19 (remaining gas: 1039984.400 units remaining) + [ { Elt 1 4 ; Elt 2 11 } + (Some False) ] + - location: 20 (remaining gas: 1039984.260 units remaining) + [ (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] + - location: 21 (remaining gas: 1039984.120 units remaining) + [ {} + (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] + - location: 23 (remaining gas: 1039983.980 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] + - location: -1 (remaining gas: 1039983.910 units remaining) + [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out new file mode 100644 index 000000000000..833013aef0e6 --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out @@ -0,0 +1,45 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) +trace + - location: 11 (remaining gas: 1039986.730 units remaining) + [ (Pair 1 {} None) ] + - location: 12 (remaining gas: 1039986.590 units remaining) + [ 1 @parameter + (Pair {} None) @storage ] + - location: 15 (remaining gas: 1039986.290 units remaining) + [ {} ] + - location: 16 (remaining gas: 1039986.150 units remaining) + [ {} + {} ] + - location: -1 (remaining gas: 1039986.080 units remaining) + [ {} + {} ] + - location: 13 (remaining gas: 1039986.080 units remaining) + [ 1 @parameter + {} + {} ] + - location: 17 (remaining gas: 1039985.940 units remaining) + [ False + {} ] + - location: 18 (remaining gas: 1039985.800 units remaining) + [ (Some False) + {} ] + - location: 19 (remaining gas: 1039985.670 units remaining) + [ {} + (Some False) ] + - location: 20 (remaining gas: 1039985.530 units remaining) + [ (Pair {} (Some False)) ] + - location: 21 (remaining gas: 1039985.390 units remaining) + [ {} + (Pair {} (Some False)) ] + - location: 23 (remaining gas: 1039985.250 units remaining) + [ (Pair {} {} (Some False)) ] + - location: -1 (remaining gas: 1039985.180 units remaining) + [ (Pair {} {} (Some False)) ] + diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out new file mode 100644 index 000000000000..d67e6cca78d2 --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out @@ -0,0 +1,45 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map nat nat) +trace + - location: 11 (remaining gas: 1039986.730 units remaining) + [ (Pair 1 {} None) ] + - location: 12 (remaining gas: 1039986.590 units remaining) + [ 1 @parameter + (Pair {} None) @storage ] + - location: 15 (remaining gas: 1039986.290 units remaining) + [ {} ] + - location: 16 (remaining gas: 1039986.150 units remaining) + [ {} + {} ] + - location: -1 (remaining gas: 1039986.080 units remaining) + [ {} + {} ] + - location: 13 (remaining gas: 1039986.080 units remaining) + [ 1 @parameter + {} + {} ] + - location: 17 (remaining gas: 1039985.940 units remaining) + [ False + {} ] + - location: 18 (remaining gas: 1039985.800 units remaining) + [ (Some False) + {} ] + - location: 19 (remaining gas: 1039985.670 units remaining) + [ {} + (Some False) ] + - location: 20 (remaining gas: 1039985.530 units remaining) + [ (Pair {} (Some False)) ] + - location: 21 (remaining gas: 1039985.390 units remaining) + [ {} + (Pair {} (Some False)) ] + - location: 23 (remaining gas: 1039985.250 units remaining) + [ (Pair {} {} (Some False)) ] + - location: -1 (remaining gas: 1039985.180 units remaining) + [ (Pair {} {} (Some False)) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" new file mode 100644 index 000000000000..2f4b4e3f7e39 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)-"baz"-(Pair 2 (Some False))] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["bar"] to 4 + Set map(2)["foo"] to 11 +trace + - location: 11 (remaining gas: 1039985.358 units remaining) + [ (Pair "baz" { Elt "bar" 4 ; Elt "foo" 11 } None) ] + - location: 12 (remaining gas: 1039985.218 units remaining) + [ "baz" @parameter + (Pair { Elt "bar" 4 ; Elt "foo" 11 } None) @storage ] + - location: 15 (remaining gas: 1039984.918 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 16 (remaining gas: 1039984.778 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: -1 (remaining gas: 1039984.708 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 13 (remaining gas: 1039984.708 units remaining) + [ "baz" @parameter + { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 17 (remaining gas: 1039984.568 units remaining) + [ False + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 18 (remaining gas: 1039984.428 units remaining) + [ (Some False) + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 19 (remaining gas: 1039984.298 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + (Some False) ] + - location: 20 (remaining gas: 1039984.158 units remaining) + [ (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] + - location: 21 (remaining gas: 1039984.018 units remaining) + [ {} + (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] + - location: 23 (remaining gas: 1039983.878 units remaining) + [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] + - location: -1 (remaining gas: 1039983.808 units remaining) + [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" new file mode 100644 index 000000000000..f7775c8764a4 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)-"bar"-(Pair 2 (Some True))] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["bar"] to 4 + Set map(2)["foo"] to 11 +trace + - location: 11 (remaining gas: 1039985.358 units remaining) + [ (Pair "bar" { Elt "bar" 4 ; Elt "foo" 11 } None) ] + - location: 12 (remaining gas: 1039985.218 units remaining) + [ "bar" @parameter + (Pair { Elt "bar" 4 ; Elt "foo" 11 } None) @storage ] + - location: 15 (remaining gas: 1039984.918 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 16 (remaining gas: 1039984.778 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: -1 (remaining gas: 1039984.708 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 13 (remaining gas: 1039984.708 units remaining) + [ "bar" @parameter + { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 17 (remaining gas: 1039984.568 units remaining) + [ True + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 18 (remaining gas: 1039984.428 units remaining) + [ (Some True) + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 19 (remaining gas: 1039984.298 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + (Some True) ] + - location: 20 (remaining gas: 1039984.158 units remaining) + [ (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + - location: 21 (remaining gas: 1039984.018 units remaining) + [ {} + (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + - location: 23 (remaining gas: 1039983.878 units remaining) + [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + - location: -1 (remaining gas: 1039983.808 units remaining) + [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" new file mode 100644 index 000000000000..f57effbfe4c3 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" @@ -0,0 +1,47 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)-"foo"-(Pair 2 (Some True))] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["bar"] to 4 + Set map(2)["foo"] to 11 +trace + - location: 11 (remaining gas: 1039985.358 units remaining) + [ (Pair "foo" { Elt "bar" 4 ; Elt "foo" 11 } None) ] + - location: 12 (remaining gas: 1039985.218 units remaining) + [ "foo" @parameter + (Pair { Elt "bar" 4 ; Elt "foo" 11 } None) @storage ] + - location: 15 (remaining gas: 1039984.918 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 16 (remaining gas: 1039984.778 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: -1 (remaining gas: 1039984.708 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 13 (remaining gas: 1039984.708 units remaining) + [ "foo" @parameter + { Elt "bar" 4 ; Elt "foo" 11 } + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 17 (remaining gas: 1039984.568 units remaining) + [ True + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 18 (remaining gas: 1039984.428 units remaining) + [ (Some True) + { Elt "bar" 4 ; Elt "foo" 11 } ] + - location: 19 (remaining gas: 1039984.298 units remaining) + [ { Elt "bar" 4 ; Elt "foo" 11 } + (Some True) ] + - location: 20 (remaining gas: 1039984.158 units remaining) + [ (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + - location: 21 (remaining gas: 1039984.018 units remaining) + [ {} + (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + - location: 23 (remaining gas: 1039983.878 units remaining) + [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + - location: -1 (remaining gas: 1039983.808 units remaining) + [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" new file mode 100644 index 000000000000..55180a94d561 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" @@ -0,0 +1,46 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt "foo" 0 } None)-"foo"-(Pair 2 (Some True))] + +storage + (Pair 2 (Some True)) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["foo"] to 0 +trace + - location: 11 (remaining gas: 1039986.082 units remaining) + [ (Pair "foo" { Elt "foo" 0 } None) ] + - location: 12 (remaining gas: 1039985.942 units remaining) + [ "foo" @parameter + (Pair { Elt "foo" 0 } None) @storage ] + - location: 15 (remaining gas: 1039985.642 units remaining) + [ { Elt "foo" 0 } ] + - location: 16 (remaining gas: 1039985.502 units remaining) + [ { Elt "foo" 0 } + { Elt "foo" 0 } ] + - location: -1 (remaining gas: 1039985.432 units remaining) + [ { Elt "foo" 0 } + { Elt "foo" 0 } ] + - location: 13 (remaining gas: 1039985.432 units remaining) + [ "foo" @parameter + { Elt "foo" 0 } + { Elt "foo" 0 } ] + - location: 17 (remaining gas: 1039985.292 units remaining) + [ True + { Elt "foo" 0 } ] + - location: 18 (remaining gas: 1039985.152 units remaining) + [ (Some True) + { Elt "foo" 0 } ] + - location: 19 (remaining gas: 1039985.022 units remaining) + [ { Elt "foo" 0 } + (Some True) ] + - location: 20 (remaining gas: 1039984.882 units remaining) + [ (Pair { Elt "foo" 0 } (Some True)) ] + - location: 21 (remaining gas: 1039984.742 units remaining) + [ {} + (Pair { Elt "foo" 0 } (Some True)) ] + - location: 23 (remaining gas: 1039984.602 units remaining) + [ (Pair {} { Elt "foo" 0 } (Some True)) ] + - location: -1 (remaining gas: 1039984.532 units remaining) + [ (Pair {} { Elt "foo" 0 } (Some True)) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" new file mode 100644 index 000000000000..08985432813d --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" @@ -0,0 +1,46 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt "foo" 1 } None)-"bar"-(Pair 2 (Some False))] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) + Set map(2)["foo"] to 1 +trace + - location: 11 (remaining gas: 1039986.082 units remaining) + [ (Pair "bar" { Elt "foo" 1 } None) ] + - location: 12 (remaining gas: 1039985.942 units remaining) + [ "bar" @parameter + (Pair { Elt "foo" 1 } None) @storage ] + - location: 15 (remaining gas: 1039985.642 units remaining) + [ { Elt "foo" 1 } ] + - location: 16 (remaining gas: 1039985.502 units remaining) + [ { Elt "foo" 1 } + { Elt "foo" 1 } ] + - location: -1 (remaining gas: 1039985.432 units remaining) + [ { Elt "foo" 1 } + { Elt "foo" 1 } ] + - location: 13 (remaining gas: 1039985.432 units remaining) + [ "bar" @parameter + { Elt "foo" 1 } + { Elt "foo" 1 } ] + - location: 17 (remaining gas: 1039985.292 units remaining) + [ False + { Elt "foo" 1 } ] + - location: 18 (remaining gas: 1039985.152 units remaining) + [ (Some False) + { Elt "foo" 1 } ] + - location: 19 (remaining gas: 1039985.022 units remaining) + [ { Elt "foo" 1 } + (Some False) ] + - location: 20 (remaining gas: 1039984.882 units remaining) + [ (Pair { Elt "foo" 1 } (Some False)) ] + - location: 21 (remaining gas: 1039984.742 units remaining) + [ {} + (Pair { Elt "foo" 1 } (Some False)) ] + - location: 23 (remaining gas: 1039984.602 units remaining) + [ (Pair {} { Elt "foo" 1 } (Some False)) ] + - location: -1 (remaining gas: 1039984.532 units remaining) + [ (Pair {} { Elt "foo" 1 } (Some False)) ] + diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" new file mode 100644 index 000000000000..ad1d5bbcf781 --- /dev/null +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" @@ -0,0 +1,45 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-"bar"-(Pair 2 (Some False))] + +storage + (Pair 2 (Some False)) +emitted operations + +big_map diff + New map(2) of type (big_map string nat) +trace + - location: 11 (remaining gas: 1039986.686 units remaining) + [ (Pair "bar" {} None) ] + - location: 12 (remaining gas: 1039986.546 units remaining) + [ "bar" @parameter + (Pair {} None) @storage ] + - location: 15 (remaining gas: 1039986.246 units remaining) + [ {} ] + - location: 16 (remaining gas: 1039986.106 units remaining) + [ {} + {} ] + - location: -1 (remaining gas: 1039986.036 units remaining) + [ {} + {} ] + - location: 13 (remaining gas: 1039986.036 units remaining) + [ "bar" @parameter + {} + {} ] + - location: 17 (remaining gas: 1039985.896 units remaining) + [ False + {} ] + - location: 18 (remaining gas: 1039985.756 units remaining) + [ (Some False) + {} ] + - location: 19 (remaining gas: 1039985.626 units remaining) + [ {} + (Some False) ] + - location: 20 (remaining gas: 1039985.486 units remaining) + [ (Pair {} (Some False)) ] + - location: 21 (remaining gas: 1039985.346 units remaining) + [ {} + (Pair {} (Some False)) ] + - location: 23 (remaining gas: 1039985.206 units remaining) + [ (Pair {} {} (Some False)) ] + - location: -1 (remaining gas: 1039985.136 units remaining) + [ (Pair {} {} (Some False)) ] + diff --git a/tests_python/tests_alpha/test_contract_opcodes.py b/tests_python/tests_alpha/test_contract_opcodes.py index edd625c21b3f..218ac7d1af94 100644 --- a/tests_python/tests_alpha/test_contract_opcodes.py +++ b/tests_python/tests_alpha/test_contract_opcodes.py @@ -324,110 +324,110 @@ class TestContractOpcodes: 'big_map_mem_nat.tz', '(Pair { Elt 0 1 } None)', '1', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair {} None)', '1', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 0 } None)', '1', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '1', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '2', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '3', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "foo" 1 } None)', '"bar"', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), ( 'big_map_mem_string.tz', '(Pair {} None)', '"bar"', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "foo" 0 } None)', '"foo"', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)', '"foo"', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)', '"bar"', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)', '"baz"', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), # Memberships in big maps ( 'big_map_mem_nat.tz', '(Pair { Elt 0 1 } None)', '1', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair {} None)', '1', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 0 } None)', '1', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '1', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '2', - '(Pair 0 (Some True))', + '(Pair 2 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '3', - '(Pair 0 (Some False))', + '(Pair 2 (Some False))', ), # Identity on sets ('set_id.tz', '{}', '{ "a" ; "b" ; "c" }', '{ "a" ; "b" ; "c" }'), @@ -1488,31 +1488,31 @@ class TestContractOpcodes: 'get_big_map_value.tz', '(Pair { Elt "hello" "hi" } None)', '"hello"', - '(Pair 0 (Some "hi"))', + '(Pair 2 (Some "hi"))', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["hello"] to "hi"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["hello"] to "hi"'], ], ), ( 'get_big_map_value.tz', '(Pair { Elt "hello" "hi" } None)', '""', - '(Pair 0 None)', + '(Pair 2 None)', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["hello"] to "hi"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["hello"] to "hi"'], ], ), ( 'get_big_map_value.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } None)', '"1"', - '(Pair 0 (Some "one"))', + '(Pair 2 (Some "one"))', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["2"] to "two"'], - ['Set map(0)["1"] to "one"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["1"] to "one"'], + ['Set map(2)["2"] to "two"'], ], ), # Test updating big maps @@ -1520,68 +1520,68 @@ class TestContractOpcodes: 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{}', - '(Pair 0 Unit)', + '(Pair 2 Unit)', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["2"] to "two"'], - ['Set map(0)["1"] to "one"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["1"] to "one"'], + ['Set map(2)["2"] to "two"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "1" (Some "two") }', - '(Pair 0 Unit)', + '(Pair 2 Unit)', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["2"] to "two"'], - ['Set map(0)["1"] to "two"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["1"] to "two"'], + ['Set map(2)["2"] to "two"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "3" (Some "three") }', - '(Pair 0 Unit)', + '(Pair 2 Unit)', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["2"] to "two"'], - ['Set map(0)["3"] to "three"'], - ['Set map(0)["1"] to "one"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["1"] to "one"'], + ['Set map(2)["2"] to "two"'], + ['Set map(2)["3"] to "three"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "3" None }', - '(Pair 0 Unit)', + '(Pair 2 Unit)', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["2"] to "two"'], - ['Unset map(0)["3"]'], - ['Set map(0)["1"] to "one"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["1"] to "one"'], + ['Set map(2)["2"] to "two"'], + ['Unset map(2)["3"]'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "2" None }', - '(Pair 0 Unit)', + '(Pair 2 Unit)', [ - ["New map(0) of type (big_map string string)"], - ['Unset map(0)["2"]'], - ['Set map(0)["1"] to "one"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["1"] to "one"'], + ['Unset map(2)["2"]'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "1" (Some "two") }', - '(Pair 0 Unit)', + '(Pair 2 Unit)', [ - ["New map(0) of type (big_map string string)"], - ['Set map(0)["2"] to "two"'], - ['Set map(0)["1"] to "two"'], + ["New map(2) of type (big_map string string)"], + ['Set map(2)["1"] to "two"'], + ['Set map(2)["2"] to "two"'], ], ), # test the GET_AND_UPDATE instruction on big maps @@ -1590,51 +1590,51 @@ class TestContractOpcodes: 'get_and_update_big_map.tz', '(Pair None {})', '"hello"', - '(Pair None 0)', + '(Pair None 2)', [ - ["New map(0) of type (big_map string nat)"], - ['Unset map(0)["hello"]'], + ["New map(2) of type (big_map string nat)"], + ['Unset map(2)["hello"]'], ], ), ( 'get_and_update_big_map.tz', '(Pair (Some 4) {})', '"hello"', - '(Pair None 0)', + '(Pair None 2)', [ - ["New map(0) of type (big_map string nat)"], - ['Set map(0)["hello"] to 4'], + ["New map(2) of type (big_map string nat)"], + ['Set map(2)["hello"] to 4'], ], ), ( 'get_and_update_big_map.tz', '(Pair None { Elt "hello" 4 })', '"hello"', - '(Pair (Some 4) 0)', + '(Pair (Some 4) 2)', [ - ["New map(0) of type (big_map string nat)"], - ['Unset map(0)["hello"]'], + ["New map(2) of type (big_map string nat)"], + ['Unset map(2)["hello"]'], ], ), ( 'get_and_update_big_map.tz', '(Pair (Some 5) { Elt "hello" 4 })', '"hello"', - '(Pair (Some 4) 0)', + '(Pair (Some 4) 2)', [ - ["New map(0) of type (big_map string nat)"], - ['Set map(0)["hello"] to 5'], + ["New map(2) of type (big_map string nat)"], + ['Set map(2)["hello"] to 5'], ], ), ( 'get_and_update_big_map.tz', '(Pair (Some 5) { Elt "hello" 4 })', '"hi"', - '(Pair None 0)', + '(Pair None 2)', [ - ["New map(0) of type (big_map string nat)"], - ['Set map(0)["hello"] to 4'], - ['Set map(0)["hi"] to 5'], + ["New map(2) of type (big_map string nat)"], + ['Set map(2)["hello"] to 4'], + ['Set map(2)["hi"] to 5'], ], ), ( @@ -1642,11 +1642,11 @@ class TestContractOpcodes: '(Pair None { Elt "1" 1 ; \ Elt "2" 2 })', '"1"', - '(Pair (Some 1) 0)', + '(Pair (Some 1) 2)', [ - ["New map(0) of type (big_map string nat)"], - ['Set map(0)["2"] to 2'], - ['Unset map(0)["1"]'], + ["New map(2) of type (big_map string nat)"], + ['Unset map(2)["1"]'], + ['Set map(2)["2"] to 2'], ], ), ( @@ -1654,11 +1654,11 @@ class TestContractOpcodes: '(Pair None { Elt "1" 1 ; \ Elt "2" 2 })', '"1"', - '(Pair (Some 1) 0)', + '(Pair (Some 1) 2)', [ - ["New map(0) of type (big_map string nat)"], - ['Set map(0)["2"] to 2'], - ['Unset map(0)["1"]'], + ["New map(2) of type (big_map string nat)"], + ['Unset map(2)["1"]'], + ['Set map(2)["2"] to 2'], ], ), ], @@ -1686,12 +1686,12 @@ class TestContractOpcodes: ( '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))', '(Left Unit)', - '(Left (Pair 0 1))', + '(Left (Pair 2 3))', [ - ['New map(1) of type (big_map string string)'], - ['Set map(1)["1"] to "one"'], - ['New map(0) of type (big_map string string)'], - ['Set map(0)["2"] to "two"'], + ['New map(3) of type (big_map string string)'], + ['Set map(3)["1"] to "one"'], + ['New map(2) of type (big_map string string)'], + ['Set map(2)["2"] to "two"'], ], ), # test reset with new map @@ -1699,12 +1699,12 @@ class TestContractOpcodes: '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))', '(Right (Left (Left (Pair { Elt "3" "three" } ' + '{ Elt "4" "four" }))))', - '(Left (Pair 0 1))', + '(Left (Pair 2 3))', [ - ['New map(1) of type (big_map string string)'], - ['Set map(1)["4"] to "four"'], - ['New map(0) of type (big_map string string)'], - ['Set map(0)["3"] to "three"'], + ['New map(3) of type (big_map string string)'], + ['Set map(3)["4"] to "four"'], + ['New map(2) of type (big_map string string)'], + ['Set map(2)["3"] to "three"'], ], ), # test reset to unit @@ -1719,37 +1719,37 @@ class TestContractOpcodes: '(Right Unit)', '(Right (Right (Left (Pair { Pair "foo" "bar" } ' + '{ Pair "gaz" "baz" }) )))', - '(Left (Pair 0 1))', + '(Left (Pair 2 3))', [ - ['New map(1) of type (big_map string string)'], - ['Set map(1)["gaz"] to "baz"'], - ['New map(0) of type (big_map string string)'], - ['Set map(0)["foo"] to "bar"'], + ['New map(3) of type (big_map string string)'], + ['Set map(3)["gaz"] to "baz"'], + ['New map(2) of type (big_map string string)'], + ['Set map(2)["foo"] to "bar"'], ], ), # test add to big_map ( '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }) )', '(Right (Right (Right (Left { Pair "3" "three" }))))', - '(Left (Pair 0 1))', + '(Left (Pair 2 3))', [ - ['New map(1) of type (big_map string string)'], - ['Set map(1)["2"] to "two"'], - ['New map(0) of type (big_map string string)'], - ['Set map(0)["3"] to "three"'], - ['Set map(0)["1"] to "one"'], + ['New map(3) of type (big_map string string)'], + ['Set map(3)["2"] to "two"'], + ['New map(2) of type (big_map string string)'], + ['Set map(2)["1"] to "one"'], + ['Set map(2)["3"] to "three"'], ], ), # test remove from big_map ( '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))', '(Right (Right (Right (Right { "1" }))))', - '(Left (Pair 0 1))', + '(Left (Pair 2 3))', [ - ['New map(1) of type (big_map string string)'], - ['Set map(1)["2"] to "two"'], - ['New map(0) of type (big_map string string)'], - ['Unset map(0)["1"]'], + ['New map(3) of type (big_map string string)'], + ['Set map(3)["2"] to "two"'], + ['New map(2) of type (big_map string string)'], + ['Unset map(2)["1"]'], ], ), ], diff --git a/tests_python/tests_alpha/test_voting_full.py b/tests_python/tests_alpha/test_voting_full.py index fff8707c4a5c..2b1e14903359 100644 --- a/tests_python/tests_alpha/test_voting_full.py +++ b/tests_python/tests_alpha/test_voting_full.py @@ -1,3 +1,9 @@ +""" +This tests the migration from PROTO_A to PROTO_B. +""" + +import json +import os import time import pytest @@ -79,6 +85,23 @@ class TestVotingFull: new dummy protocol """ + def test_add_tmp_bootstrap_node(self, sandbox: Sandbox): + """ launch tmp nodes just to bootstrap all other ones """ + sandbox.add_node(10, params=node_params(0)) + sandbox.add_node(11, params=node_params(0)) + + def test_activate_proto_a(self, sandbox: Sandbox): + sandbox.client(10).activate_protocol_json(PROTO_A, PARAMETERS) + + def test_add_tmp_bootstrap_baker(self, sandbox: Sandbox): + """Launch a temporary baker so that 10 and 11 keep broadcasting + heads to the future joining nodes and help them bootstrap""" + # note we use 'bootstrap1' for all baking, this avoids the issue + # of a delegate becoming inactive. For instance, if we want + # to bake with 'bootstrap2' later in the test, it may have became + # inactive + sandbox.add_baker(10, 'bootstrap1', proto=PROTO_A_DAEMON) + def test_add_initial_nodes(self, sandbox: Sandbox): for i in range(NUM_NODES): sandbox.add_node(i, params=constants.NODE_PARAMS) diff --git a/tezt/_regressions/encoding/alpha.block_header.out b/tezt/_regressions/encoding/alpha.block_header.out index 3460e449da98..d75487b4d94e 100644 --- a/tezt/_regressions/encoding/alpha.block_header.out +++ b/tezt/_regressions/encoding/alpha.block_header.out @@ -15,7 +15,7 @@ tezt/_regressions/encoding/alpha.block_header.out "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }' 00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d5580066804fe735e06e97e26da8236b6341b91c625d5e82b3524ec0a88cc982365e70f8a5b9bc65df2ea6d21ee244cc3a96fb33031c394c78b1179ff1b8a44237740c @@ -29,6 +29,6 @@ tezt/_regressions/encoding/alpha.block_header.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } diff --git a/tezt/_regressions/encoding/alpha.block_header.unsigned.out b/tezt/_regressions/encoding/alpha.block_header.unsigned.out index 2c7f681f0c7c..ac43c090ceb7 100644 --- a/tezt/_regressions/encoding/alpha.block_header.unsigned.out +++ b/tezt/_regressions/encoding/alpha.block_header.unsigned.out @@ -15,7 +15,7 @@ tezt/_regressions/encoding/alpha.block_header.unsigned.out "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", - "liquidity_baking_escape_flag": false + "liquidity_baking_escape_vote": false }' 00000533010e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8000000005e9dcbb00242e9bc4583d4f9fa6ba422733f45d3a44397141a953d2237bf8df62e5046eef700000011000000010100000008000000000000000a4c7319284b55068bb7c4e0b9f8585729db7fb27ab4ca9cff2038a1fc324f650c521d101895ca00000000ff043691f53c02ca1ac6f1a0c1586bf77973e04c2d9b618a8309e79651daf0d55800 @@ -28,4 +28,4 @@ tezt/_regressions/encoding/alpha.block_header.unsigned.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", - "liquidity_baking_escape_flag": false } + "liquidity_baking_escape_vote": false } diff --git a/tezt/_regressions/encoding/alpha.operation.out b/tezt/_regressions/encoding/alpha.operation.out index 3cfa05c156cb..d7577433f2e0 100644 --- a/tezt/_regressions/encoding/alpha.operation.out +++ b/tezt/_regressions/encoding/alpha.operation.out @@ -120,7 +120,7 @@ tezt/_regressions/encoding/alpha.operation.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -137,7 +137,7 @@ tezt/_regressions/encoding/alpha.operation.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } @@ -160,7 +160,7 @@ tezt/_regressions/encoding/alpha.operation.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": @@ -173,7 +173,7 @@ tezt/_regressions/encoding/alpha.operation.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } ], "signature": diff --git a/tezt/_regressions/encoding/alpha.operation.unsigned.out b/tezt/_regressions/encoding/alpha.operation.unsigned.out index 39ac60fe2d58..a8d479ad345b 100644 --- a/tezt/_regressions/encoding/alpha.operation.unsigned.out +++ b/tezt/_regressions/encoding/alpha.operation.unsigned.out @@ -108,7 +108,7 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -125,7 +125,7 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } @@ -147,7 +147,7 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": @@ -160,7 +160,7 @@ tezt/_regressions/encoding/alpha.operation.unsigned.out "fitness": [ "01", "000000000000000a" ], "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } } ] } diff --git a/tezt/_regressions/rpc/alpha.client.contracts.out b/tezt/_regressions/rpc/alpha.client.contracts.out index c8134cad0a5c..5e83c931a820 100644 --- a/tezt/_regressions/rpc/alpha.client.contracts.out +++ b/tezt/_regressions/rpc/alpha.client.contracts.out @@ -3,10 +3,10 @@ tezt/_regressions/rpc/alpha.client.contracts.out ./tezos-client rpc get /chains/main/blocks/head/context/contracts [ "[PUBLIC_KEY_HASH]", "[CONTRACT_HASH]", - "[PUBLIC_KEY_HASH]", "[CONTRACT_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", + "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]" ] ./tezos-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]' diff --git a/tezt/_regressions/rpc/current.client.others.out b/tezt/_regressions/rpc/current.client.others.out index 0036e92b60de..3b5a20f9479f 100644 --- a/tezt/_regressions/rpc/current.client.others.out +++ b/tezt/_regressions/rpc/current.client.others.out @@ -11,17 +11,15 @@ tezt/_regressions/rpc/current.client.others.out "hard_gas_limit_per_block": "10400000", "proof_of_work_threshold": "-1", "tokens_per_roll": "8000000000", "michelson_maximum_type_size": 1000, "seed_nonce_revelation_tip": "125000", "origination_size": 257, - "block_security_deposit": "544000000", + "block_security_deposit": "512000000", "endorsement_security_deposit": "64000000", "baking_reward_per_endorsement": [ "1250000", "187500" ], "endorsement_reward": [ "1250000", "833333" ], "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", - "test_chain_duration": "0", "quorum_min": 2000, "quorum_max": 7000, - "min_proposal_quorum": 500, "initial_endorsers": 1, - "delay_per_missing_endorsement": "1", - "liquidity_baking_cpmm_origination_nonce": - { "operation": "oneDGhZacw99EEFaYDTtWfz5QEhUW3PPVFsHa7GShnLPuDn7gSd" }, - "liquidity_baking_reward": "5000000", + "hard_storage_limit_per_operation": "60000", "test_chain_duration": "0", + "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, + "initial_endorsers": 1, "delay_per_missing_endorsement": "1", + "liquidity_baking_cpmm_address": "[CONTRACT_HASH]", + "liquidity_baking_subsidy": "5000000", "liquidity_baking_sunset_duration": 1024, "liquidity_baking_escape_ema_threshold": 500000 } diff --git a/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json b/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json index d8fffaea03d5..067f6ab46d9e 100644 --- a/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json +++ b/tezt/tests/encoding_samples/alpha/block_header.unsigned/block_header.unsigned.sample.json @@ -10,5 +10,5 @@ "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", - "liquidity_baking_escape_flag": false + "liquidity_baking_escape_vote": false } diff --git a/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json b/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json index a84e53347abc..e7ea5355ffab 100644 --- a/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json +++ b/tezt/tests/encoding_samples/alpha/block_header/block_header.sample.json @@ -10,6 +10,6 @@ "priority": 21021, "proof_of_work_nonce": "101895ca00000000", "seed_nonce_hash": "nceUFoeQDgkJCmzdMWh19ZjBYqQD3N9fe6bXQ1ZsUKKvMn7iun5Z3", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } diff --git a/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json b/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json index c0cb6c57b1a4..3e2066e129c2 100644 --- a/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json +++ b/tezt/tests/encoding_samples/alpha/operation.unsigned/operation.unsigned-double-baking-evidence.sample.json @@ -13,7 +13,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -27,7 +27,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } }] diff --git a/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json b/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json index d2f06895d9d3..63ae234307a4 100644 --- a/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json +++ b/tezt/tests/encoding_samples/alpha/operation/operation-double-baking-evidence.sample.json @@ -13,7 +13,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" }, "bh2": { @@ -27,7 +27,7 @@ "context": "CoVDyf9y9gHfAkPWofBJffo4X4bWjmehH2LeVonDcCKKzyQYwqdk", "priority": 0, "proof_of_work_nonce": "101895ca00000000", - "liquidity_baking_escape_flag": false, + "liquidity_baking_escape_vote": false, "signature": "sigbQ5ZNvkjvGssJgoAnUAfY4Wvvg3QZqawBYB1j1VDBNTMBAALnCzRHWzer34bnfmzgHg3EvwdzQKdxgSghB897cono6gbQ" } }], diff --git a/vendors/flextesa-lib/tezos_protocol.ml b/vendors/flextesa-lib/tezos_protocol.ml index 0e6195327b5f..eb2c497ff768 100644 --- a/vendors/flextesa-lib/tezos_protocol.ml +++ b/vendors/flextesa-lib/tezos_protocol.ml @@ -150,6 +150,18 @@ let protocol_parameters_json t : Ezjsonm.t = (* `src/proto_005_PsBabyM1/lib_protocol/parameters_repr.ml` `src/proto_006_PsCARTHA/lib_parameters/default_parameters.ml` `src/proto_007_PsDELPH1/lib_parameters/default_parameters.ml` *) + let alpha_specific_parameters = + match subkind with + | `Alpha -> + [ ( "liquidity_baking_cpmm_address" + , string "KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG"); + ( "liquidity_baking_subsidy" + , string "5000000" ); + ( "liquidity_baking_sunset_duration" + , int 262800 ); + ( "liquidity_baking_escape_ema_threshold" + , int 500000 ); ] + | _ -> [] in let op_gas_limit, block_gas_limit = match subkind with | `Babylon -> (800_000, 8_000_000) @@ -157,33 +169,34 @@ let protocol_parameters_json t : Ezjsonm.t = | `Delphi | `Edo | `Florence | `Alpha -> (1_040_000, 10_400_000) in let open Ezjsonm in let list_of_zs = list (fun i -> string (Int.to_string i)) in - [ ("blocks_per_commitment", int 4); ("endorsers_per_block", int 32) - ; ("hard_gas_limit_per_operation", string (Int.to_string op_gas_limit)) - ; ("hard_gas_limit_per_block", string (Int.to_string block_gas_limit)) - ; ("tokens_per_roll", string (Int.to_string 8_000_000_000)) - ; ("michelson_maximum_type_size", int 1_000) - ; ("seed_nonce_revelation_tip", string (Int.to_string 125_000)) - ; ("origination_size", int 257) - ; ("block_security_deposit", string (Int.to_string 512_000_000)) - ; ("endorsement_security_deposit", string (Int.to_string 64_000_000)) - ; ( match subkind with - | `Babylon -> ("block_reward", string (Int.to_string 16_000_000)) - | `Carthage | `Delphi | `Edo | `Florence | `Alpha -> - ( "baking_reward_per_endorsement" - , list_of_zs t.baking_reward_per_endorsement ) ) - ; ( "endorsement_reward" - , match subkind with - | `Babylon -> string (Int.to_string 2_000_000) - | `Carthage | `Delphi | `Edo | `Florence | `Alpha -> list_of_zs t.endorsement_reward - ); ("hard_storage_limit_per_operation", string (Int.to_string 60_000)) - ; ( "cost_per_byte" - , match subkind with - | `Babylon | `Carthage -> string (Int.to_string 1_000) - | `Delphi | `Edo | `Florence | `Alpha -> string (Int.to_string 250) ) - ; ("test_chain_duration", string (Int.to_string 1_966_080)) - ; ("quorum_min", int 3_000); ("quorum_max", int 7_000) - ; ("min_proposal_quorum", int 500); ("initial_endorsers", int 1) - ; ("delay_per_missing_endorsement", string (Int.to_string 1)) ] in + alpha_specific_parameters + @ [ ("blocks_per_commitment", int 4); ("endorsers_per_block", int 32) + ; ("hard_gas_limit_per_operation", string (Int.to_string op_gas_limit)) + ; ("hard_gas_limit_per_block", string (Int.to_string block_gas_limit)) + ; ("tokens_per_roll", string (Int.to_string 8_000_000_000)) + ; ("michelson_maximum_type_size", int 1_000) + ; ("seed_nonce_revelation_tip", string (Int.to_string 125_000)) + ; ("origination_size", int 257) + ; ("block_security_deposit", string (Int.to_string 512_000_000)) + ; ("endorsement_security_deposit", string (Int.to_string 64_000_000)) + ; ( match subkind with + | `Babylon -> ("block_reward", string (Int.to_string 16_000_000)) + | `Carthage | `Delphi | `Edo | `Florence | `Alpha -> + ( "baking_reward_per_endorsement" + , list_of_zs t.baking_reward_per_endorsement ) ) + ; ( "endorsement_reward" + , match subkind with + | `Babylon -> string (Int.to_string 2_000_000) + | `Carthage | `Delphi | `Edo | `Florence | `Alpha -> list_of_zs t.endorsement_reward + ); ("hard_storage_limit_per_operation", string (Int.to_string 60_000)) + ; ( "cost_per_byte" + , match subkind with + | `Babylon | `Carthage -> string (Int.to_string 1_000) + | `Delphi | `Edo | `Florence | `Alpha -> string (Int.to_string 250) ) + ; ("test_chain_duration", string (Int.to_string 1_966_080)) + ; ("quorum_min", int 3_000); ("quorum_max", int 7_000) + ; ("min_proposal_quorum", int 500); ("initial_endorsers", int 1) + ; ("delay_per_missing_endorsement", string (Int.to_string 1)) ] in let common = [ ( "bootstrap_accounts" , list make_account (t.bootstrap_accounts @ [(t.dictator, 10_000_000L)]) -- GitLab From b46d3c1a91224bb61d5efa9d0203de5cdfbef001 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Wed, 3 Feb 2021 23:43:57 -0500 Subject: [PATCH 37/62] liquidity baking: add more unit tests --- .../lib_protocol/test/helpers/block.ml | 74 +++----- .../lib_protocol/test/helpers/block.mli | 1 + .../lib_protocol/test/helpers/context.ml | 3 +- .../lib_protocol/test/helpers/context.mli | 1 + .../test/test_liquidity_baking.ml | 160 ++++++++++++++---- 5 files changed, 161 insertions(+), 78 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index d6fc926317f0..f1e4975942d7 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -259,8 +259,8 @@ let check_constants_consistency constants = "Inconsistent constants : blocks per cycle must be superior than \ blocks per roll snapshot") -let initial_context ?(with_commitments = false) constants header - initial_accounts = +let initial_context ?(with_commitments = false) ?bootstrap_contracts constants + header initial_accounts = let open Tezos_protocol_alpha_parameters in let bootstrap_accounts = List.map @@ -271,7 +271,7 @@ let initial_context ?(with_commitments = false) constants header let parameters = Default_parameters.parameters_of_constants ~bootstrap_accounts - ~bootstrap_contracts:Default_parameters.test_bootstrap_contracts + ?bootstrap_contracts ~with_commitments constants in @@ -323,7 +323,8 @@ let genesis_with_parameters parameters = (* if no parameter file is passed we check in the current directory where the test is run *) let genesis ?with_commitments ?endorsers_per_block ?initial_endorsers - ?min_proposal_quorum (initial_accounts : (Account.t * Tez.t) list) = + ?min_proposal_quorum ?bootstrap_contracts + (initial_accounts : (Account.t * Tez.t) list) = if initial_accounts = [] then Stdlib.failwith "Must have one account with a roll to bake" ; let open Tezos_protocol_alpha_parameters in @@ -374,7 +375,12 @@ let genesis ?with_commitments ?endorsers_per_block ?initial_endorsers ~operations_hash:Operation_list_list_hash.zero in let contents = Forge.make_contents ~priority:0 ~seed_nonce_hash:None () in - initial_context ?with_commitments constants shell initial_accounts + initial_context + ?with_commitments + ?bootstrap_contracts + constants + shell + initial_accounts >|=? fun context -> { hash; @@ -385,28 +391,6 @@ let genesis ?with_commitments ?endorsers_per_block ?initial_endorsers (********* Baking *************) -let apply header ?(operations = []) pred = - (let open Environment.Error_monad in - Main.begin_application - ~chain_id:Chain_id.zero - ~predecessor_context:pred.context - ~predecessor_fitness:pred.header.shell.fitness - ~predecessor_timestamp:pred.header.shell.timestamp - header - >>=? fun vstate -> - List.fold_left_es - (fun vstate op -> - apply_operation vstate op >|=? fun (state, _result) -> state) - vstate - operations - >>=? fun vstate -> - Main.finalize_block vstate - >|=? fun (validation, _result) -> validation.context) - >|= Environment.wrap_tzresult - >|=? fun context -> - let hash = Block_header.hash header in - {hash; header; operations; context} - let apply_with_metadata header ?(operations = []) pred = (let open Environment.Error_monad in Main.begin_application @@ -424,12 +408,16 @@ let apply_with_metadata header ?(operations = []) pred = >>=? fun vstate -> Main.finalize_block vstate >|=? fun (validation, result) -> (validation.context, result)) - >|= Environment.wrap_error + >|= Environment.wrap_tzresult >|=? fun (context, result) -> let hash = Block_header.hash header in ({hash; header; operations; context}, result) -let bake ?policy ?timestamp ?operation ?operations +let apply header ?(operations = []) pred = + apply_with_metadata header ~operations pred + >>=? fun (t, _metadata) -> return t + +let bake_with_metadata ?policy ?timestamp ?operation ?operations ?liquidity_baking_escape_vote pred = let operations = match (operation, operations) with @@ -449,30 +437,19 @@ let bake ?policy ?timestamp ?operation ?operations ?liquidity_baking_escape_vote pred >>=? fun header -> - Forge.sign_header header >>=? fun header -> apply header ?operations pred + Forge.sign_header header + >>=? fun header -> apply_with_metadata header ?operations pred -let bake_with_metadata ?policy ?timestamp ?operation ?operations +let bake ?policy ?timestamp ?operation ?operations ?liquidity_baking_escape_vote pred = - let operations = - match (operation, operations) with - | (Some op, Some ops) -> - Some (op :: ops) - | (Some op, None) -> - Some [op] - | (None, Some ops) -> - Some ops - | (None, None) -> - None - in - Forge.forge_header - ?timestamp + bake_with_metadata ?policy + ?timestamp + ?operation ?operations ?liquidity_baking_escape_vote pred - >>=? fun header -> - Forge.sign_header header - >>=? fun header -> apply_with_metadata header ?operations pred + >>=? fun (t, _metadata) -> return t (********** Cycles ****************) @@ -490,9 +467,10 @@ let bake_n_with_balance_updates ?policy ?liquidity_baking_escape_vote n b = (fun (b, balance_updates_list) _ -> bake_with_metadata ?policy ?liquidity_baking_escape_vote b >>=? fun (b, metadata) -> - return (b, metadata.balance_updates @ balance_updates_list)) + return (b, List.rev_append metadata.balance_updates balance_updates_list)) (b, []) (1 -- n) + >>=? fun (b, balance_updates) -> return (b, List.rev balance_updates) let bake_until_cycle_end ?policy b = get_constants b diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 7f8aaf901068..00cbac7c1fce 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -98,6 +98,7 @@ val genesis : ?endorsers_per_block:int -> ?initial_endorsers:int -> ?min_proposal_quorum:int32 -> + ?bootstrap_contracts:Parameters.bootstrap_contract list -> (Account.t * Tez.tez) list -> block tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 232470ce6be3..1da55bca4796 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -301,7 +301,7 @@ module Delegate = struct end let init ?endorsers_per_block ?with_commitments ?(initial_balances = []) - ?initial_endorsers ?min_proposal_quorum n = + ?initial_endorsers ?min_proposal_quorum ?bootstrap_contracts n = let accounts = Account.generate_accounts ~initial_balances n in let contracts = List.map @@ -313,5 +313,6 @@ let init ?endorsers_per_block ?with_commitments ?(initial_balances = []) ?with_commitments ?initial_endorsers ?min_proposal_quorum + ?bootstrap_contracts accounts >|=? fun blk -> (blk, contracts) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 29e18ba61457..73bedad60a26 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -138,5 +138,6 @@ val init : ?initial_balances:int64 list -> ?initial_endorsers:int -> ?min_proposal_quorum:int32 -> + ?bootstrap_contracts:Parameters.bootstrap_contract list -> int -> (Block.t * Alpha_context.Contract.t list) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 96d6d45d53e5..840c8c30f9ea 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -1,7 +1,7 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2020 Tocqueville Group, Inc. *) +(* Copyright (c) 2020 Tocqueville Group, Inc. *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -23,12 +23,23 @@ (* *) (*****************************************************************************) +(** Testing + ------- + Component: liquidity baking + Invocation: dune exec src/proto_alpha/lib_protocol/test/main.exe -- test "^liquidity baking$" + Subject: Test liquidity baking subsidies, CPMM storage updates, + sunset shut off, and escape hatch shut off. +*) + open Protocol open Test_tez open Micheline_printer -let liquidity_baking_subsidys n () = - Context.init 1 +let bootstrap_contracts = + Tezos_protocol_alpha_parameters.Default_parameters.test_bootstrap_contracts + +let liquidity_baking_subsidies n () = + Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -49,8 +60,8 @@ let liquidity_baking_subsidys n () = expected_balance >>=? fun () -> return_unit -let liquidity_baking_sunset_level () = - Context.init 1 +let liquidity_baking_sunset_level n () = + Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -58,7 +69,7 @@ let liquidity_baking_sunset_level () = let sunset = csts.parametric.liquidity_baking_sunset_duration in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> - Block.bake_n Int32.(to_int (add sunset 100l)) blk + Block.bake_n (Int32.to_int sunset + n) blk >>=? fun blk -> Context.get_liquidity_baking_subsidy (B blk) >>=? fun liquidity_baking_subsidy -> @@ -72,8 +83,8 @@ let liquidity_baking_sunset_level () = expected_balance >>=? fun () -> return_unit -let liquidity_baking_escape_hatch_100 () = - Context.init 1 +let liquidity_baking_escape_hatch_100 n () = + Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -84,7 +95,7 @@ let liquidity_baking_escape_hatch_100 () = >>=? fun old_balance -> Block.bake_n ~liquidity_baking_escape_vote:true escape_level blk >>=? fun blk -> - Block.bake_n 100 blk + Block.bake_n n blk >>=? fun blk -> Context.get_liquidity_baking_subsidy (B blk) >>=? fun liquidity_baking_subsidy -> @@ -98,8 +109,8 @@ let liquidity_baking_escape_hatch_100 () = expected_balance >>=? fun () -> return_unit -let liquidity_baking_escape_hatch_80 () = - Context.init 1 +let liquidity_baking_escape_hatch_80 n () = + Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -118,7 +129,7 @@ let liquidity_baking_escape_hatch_80 () = in bake_80_percent_escaping blk 0 >>=? fun blk -> - Block.bake_n 100 blk + Block.bake_n n blk >>=? fun blk -> Context.get_liquidity_baking_subsidy (B blk) >>=? fun liquidity_baking_subsidy -> @@ -132,8 +143,8 @@ let liquidity_baking_escape_hatch_80 () = expected_balance >>=? fun () -> return_unit -let liquidity_baking_escape_hatch_60 () = - Context.init 1 +let liquidity_baking_escape_hatch_60 n () = + Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -142,17 +153,17 @@ let liquidity_baking_escape_hatch_60 () = let escape_level = 1790 in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> - let rec bake_80_percent_escaping blk i = + let rec bake_60_percent_escaping blk i = if i < escape_level then Block.bake_n 2 blk >>=? fun blk -> Block.bake_n ~liquidity_baking_escape_vote:true 3 blk - >>=? fun blk -> bake_80_percent_escaping blk (i + 5) + >>=? fun blk -> bake_60_percent_escaping blk (i + 5) else return blk in - bake_80_percent_escaping blk 0 + bake_60_percent_escaping blk 0 >>=? fun blk -> - Block.bake_n 100 blk + Block.bake_n n blk >>=? fun blk -> Context.get_liquidity_baking_subsidy (B blk) >>=? fun liquidity_baking_subsidy -> @@ -166,8 +177,40 @@ let liquidity_baking_escape_hatch_60 () = expected_balance >>=? fun () -> return_unit +let liquidity_baking_escape_hatch_50 n () = + Context.init ~bootstrap_contracts 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in + (* log(1-1/(2*.6)) / log(0.999) *) + let sunset = csts.parametric.liquidity_baking_sunset_duration in + Context.Contract.balance (B blk) liquidity_baking + >>=? fun old_balance -> + let rec bake_50_percent_escaping blk i = + if i < Int32.to_int sunset + n then + Block.bake blk + >>=? fun blk -> + Block.bake ~liquidity_baking_escape_vote:true blk + >>=? fun blk -> bake_50_percent_escaping blk (i + 2) + else return blk + in + bake_50_percent_escaping blk 0 + >>=? fun blk -> + Context.get_liquidity_baking_subsidy (B blk) + >>=? fun liquidity_baking_subsidy -> + Tez.(liquidity_baking_subsidy *? Int64.(sub (of_int32 sunset) 1L)) + >>?= fun expected_balance -> + Assert.balance_was_credited + ~loc:__LOC__ + (B blk) + liquidity_baking + old_balance + expected_balance + >>=? fun () -> return_unit + let liquidity_baking_storage n () = - Context.init 1 + Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -198,7 +241,7 @@ let liquidity_baking_storage n () = >>=? fun () -> return_unit let liquidity_baking_balance_update () = - Context.init 1 + Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -244,23 +287,82 @@ let tests = [ Test_services.tztest "test liquidity baking subsidy is correct" `Quick - (liquidity_baking_subsidys 64); + (liquidity_baking_subsidies 64); + Test_services.tztest + "test liquidity baking shuts off at sunset level when baking one block \ + longer" + `Quick + (liquidity_baking_sunset_level 1); + Test_services.tztest + "test liquidity baking shuts off at sunset level when baking two blocks \ + longer" + `Quick + (liquidity_baking_sunset_level 2); + Test_services.tztest + "test liquidity baking shuts off at sunset level when baking 100 blocks \ + longer" + `Quick + (liquidity_baking_sunset_level 100); + Test_services.tztest + "test liquidity baking escape hatch with 100% of bakers flagging when \ + baking one block longer" + `Quick + (liquidity_baking_escape_hatch_100 1); + Test_services.tztest + "test liquidity baking escape hatch with 100% of bakers flagging\n\ + \ when baking two blocks longer" + `Quick + (liquidity_baking_escape_hatch_100 2); + Test_services.tztest + "test liquidity baking escape hatch with 100% of bakers flagging when \ + baking 100 blocks longer" + `Quick + (liquidity_baking_escape_hatch_100 100); + Test_services.tztest + "test liquidity baking escape hatch with 80% of bakers flagging when \ + baking one block longer" + `Quick + (liquidity_baking_escape_hatch_80 1); + Test_services.tztest + "test liquidity baking escape hatch with 80% of bakers flagging\n\ + \ when baking two blocks longer" + `Quick + (liquidity_baking_escape_hatch_80 2); + Test_services.tztest + "test liquidity baking escape hatch with 80% of bakers flagging when \ + baking 100 blocks longer" + `Quick + (liquidity_baking_escape_hatch_80 100); + Test_services.tztest + "test liquidity baking escape hatch with 60% of bakers flagging when \ + baking one block longer" + `Quick + (liquidity_baking_escape_hatch_60 1); + Test_services.tztest + "test liquidity baking escape hatch with 60% of bakers flagging\n\ + \ when baking two blocks longer" + `Quick + (liquidity_baking_escape_hatch_60 2); Test_services.tztest - "test liquidity baking shuts off at sunset level" + "test liquidity baking escape hatch with 60% of bakers flagging when \ + baking 100 blocks longer" `Quick - liquidity_baking_sunset_level; + (liquidity_baking_escape_hatch_60 100); Test_services.tztest - "test liquidity baking escape hatch with 100% of bakers flagging" + "test liquidity baking shuts off at sunset level with escape hatch at \ + 50% and baking one block longer" `Quick - liquidity_baking_escape_hatch_100; + (liquidity_baking_escape_hatch_50 1); Test_services.tztest - "test liquidity baking escape hatch with 80% of bakers flagging" + "test liquidity baking shuts off at sunset level with escape hatch at \ + 50% and baking two blocks longer" `Quick - liquidity_baking_escape_hatch_80; + (liquidity_baking_escape_hatch_50 2); Test_services.tztest - "test liquidity baking escape hatch with 60% of bakers flagging" + "test liquidity baking shuts off at sunset level with escape hatch at \ + 50% and baking 100 blocks longer" `Quick - liquidity_baking_escape_hatch_60; + (liquidity_baking_escape_hatch_50 100); Test_services.tztest "test liquidity baking storage is updated" `Quick -- GitLab From dfa34d622612e6d7378e7f802d4fe784ec2a2b8b Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 4 Feb 2021 00:10:23 -0500 Subject: [PATCH 38/62] liquidity baking: calculate liquidity_baking_subsidy from total rewards --- .../lib_parameters/default_parameters.ml | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 0d8e1e37b0ea..9b8626d12713 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -26,7 +26,7 @@ open Protocol.Alpha_context open Micheline -let constants_mainnet = +let constants_mainnet_without_liquidity_baking_subsidy = Constants. { preserved_cycles = 5; @@ -72,6 +72,46 @@ let constants_mainnet = liquidity_baking_escape_ema_threshold = 500_000l; } +(* liquidity_baking_subsidy is 1/16th of total rewards *) +let constants_mainnet = + let baking_reward_per_endorsement = + match + List.hd + constants_mainnet_without_liquidity_baking_subsidy + .baking_reward_per_endorsement + with + | None -> + assert false + | Some c -> + c + in + let endorsement_reward = + match + List.hd + constants_mainnet_without_liquidity_baking_subsidy.endorsement_reward + with + | None -> + assert false + | Some c -> + c + in + let endorsers_per_block = + constants_mainnet_without_liquidity_baking_subsidy.endorsers_per_block + in + { + constants_mainnet_without_liquidity_baking_subsidy with + liquidity_baking_subsidy = + ( match Tez.(baking_reward_per_endorsement +? endorsement_reward) with + | Error _ -> + assert false + | Ok c -> ( + match Tez.(mul_exn c endorsers_per_block /? 16L) with + | Error _ -> + assert false + | Ok c -> + c ) ); + } + let constants_sandbox = Constants. { -- GitLab From e9b3117ca8158e3f88c09c78b8a175939986e530 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 4 Feb 2021 00:52:03 -0500 Subject: [PATCH 39/62] liquidity baking: update docs --- docs/alpha/liquidity_baking.rst | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/alpha/liquidity_baking.rst b/docs/alpha/liquidity_baking.rst index e354ed9c285e..22a51bbbc448 100644 --- a/docs/alpha/liquidity_baking.rst +++ b/docs/alpha/liquidity_baking.rst @@ -1,30 +1,32 @@ +.. _liquidity_baking_009: + Liquidity Baking ================ Liquidity baking incentivizes large amounts of decentralized liquidity provision between tez and tzBTC by minting a small amount of tez every block and depositing it inside of a constant product market making smart-contract. It includes an escape hatch mechanism as a contingency. Contract -~~~~~~~~~~~~ +~~~~~~~~ -A constant product market making (CPMM) Michelson contract is first deployed on the chain. This contract maintains a balance of ``a`` tez and ``b`` tzBTC, where tzBTC is the FA1.2 token found at address KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn. The smart contract accepts deposits of ``da`` tez and returns ``db`` tzBTC (or vice versa) where the invariant ``(a + da * (1 - f)) * (b - db) = a b`` is preserved, and ``f`` is a fee, set at 0.1%. +A constant product market making (CPMM) Michelson contract is first deployed on the chain. This contract maintains a balance of ``a`` tez and ``b`` `tzBTC`_, where tzBTC is the `FA1.2 token`_ found at address KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn. The smart contract accepts deposits of ``da`` tez and returns ``db`` tzBTC (or vice versa) where the invariant ``(a + da * (1 - f)) * (b - db) = a b`` is preserved, and ``f`` is a fee, set at 0.1%. -To implement this contract, we use a fork of the open source code base used by the "Dexter" project. The implementation of this contract has been `formally verified`_ against its functional specification. The contract code is modified in the following way: - -1. The fee is set to 0.1% only. Rationale: given the subsidy it is not necessary to charge a large fee and better to improve liquidity. -2. The ability to set a manager has been removed. -3. The ability to set a delegate and receive rewards has been removed. Rationale: the subsidy means there is no need for a baker for that contract and having one would create an imbalance. +To implement this contract, we use a fork of the open source code base used by the "Dexter" project. The implementation of this contract has been `formally verified`_ against its functional specification and `audited by Trail of Bits`_. The contract code is modified in the following way: +1. The fee is set to 0.1% as compared to 0.3% in Dexter. Rationale: given the subsidy it is not necessary to charge a large fee and better to improve liquidity. +2. The ability to set a delegate and receive rewards has been removed. Rationale: the subsidy means there is no need for a baker for that contract and having one would create an imbalance. +3. The ability to set a manager has been removed since it is only used in Dexter to set the delegate. + Subsidy -~~~~~~~~~~~ +~~~~~~~ -At every block in the chain, 5 tez are minted and credited to the CPMM contract, and the CPMM's ``%default`` entrypoint is called to update the ``xtz_pool`` balance in its storage. This corresponds to 1/16th of 80 tez which is the typical block reward and endorsement reward for a block of priority 0 with all endorsements. If for any reason this constant changes, the amount of 5 tez should also be changed adequately. +At every block in the chain, a small amount of tez is minted and credited to the CPMM contract, and the CPMM's ``%default`` entrypoint is called to update the ``xtz_pool`` balance in its storage. The amount that is minted and sent to the CPMM contract is 1/16th of the rewards for a block of priority 0 with all endorsements; currently the rewards are 80 tez per block so the amount that is sent to the CPMM contract is 5 tez per block. So the credits to the CPMM contract can be accounted for by indexers, they are included in block metadata as a balance update with a new constructor for ``update_origin``, ``Subsidy``. As a safety precaution, the subsidy expires automatically after 6 months but it can be renewed periodically by protocol amendment. Escape hatch -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~ In addition to the 6 months sunset, an escape hatch is included. At every block, a baker can choose to include a flag that requests ending the subsidy. The context maintains an exponential moving average of that flag calculated as such with integer arithmetic: -- GitLab From c2a0fe642936a9bad6fe45a417fef1159b083452 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 4 Feb 2021 20:04:13 -0500 Subject: [PATCH 40/62] liquidity baking: read per_block_vote_file at beginning of every block --- .../lib_delegate/client_baking_forge.ml | 44 +++++++++--- .../lib_delegate/client_baking_forge.mli | 2 +- src/proto_alpha/lib_delegate/client_daemon.ml | 5 +- .../lib_delegate/client_daemon.mli | 2 +- .../lib_delegate/delegate_commands.ml | 69 ++++--------------- 5 files changed, 51 insertions(+), 71 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index f51ab1d46ac6..b4d80e9d5e5e 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -1377,11 +1377,40 @@ let build_block cctxt ~user_activated_upgrades state seed_nonce_hash operations slot ) +type per_block_votes = {liquidity_baking_escape_vote : bool option} + +let per_block_votes_encoding = + let open Data_encoding in + def "per_block_votes.alpha" + @@ conv + (fun {liquidity_baking_escape_vote} -> liquidity_baking_escape_vote) + (fun liquidity_baking_escape_vote -> {liquidity_baking_escape_vote}) + (obj1 (opt "liquidity_baking_escape_vote" Data_encoding.bool)) + +let read_liquidity_baking_escape_vote per_block_vote_file = + match per_block_vote_file with + | None -> + return false + | Some vote_file -> ( + Lwt_utils_unix.Json.read_file vote_file + >>=? fun votes_json -> + match + Data_encoding.Json.destruct per_block_votes_encoding votes_json + with + | exception e -> + Lwt.return (error_exn e) + | votes -> ( + match votes.liquidity_baking_escape_vote with + | None -> + return false + | Some liquidity_baking_escape_vote -> + return liquidity_baking_escape_vote ) ) + (** [bake cctxt state] create a single block when woken up to do so. All the necessary information is available in the [state.best_slot]. *) -let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades - ~chain state ~liquidity_baking_escape_vote = +let bake ?per_block_vote_file (cctxt : #Protocol_client_context.full) + ~user_activated_upgrades ~chain state = ( match state.best_slot with | None -> assert false (* unreachable *) @@ -1390,6 +1419,8 @@ let bake (cctxt : #Protocol_client_context.full) ~user_activated_upgrades >>=? fun slot -> let seed_nonce = generate_seed_nonce () in let seed_nonce_hash = Nonce.hash seed_nonce in + read_liquidity_baking_escape_vote per_block_vote_file + >>=? fun liquidity_baking_escape_vote -> build_block cctxt ~user_activated_upgrades @@ -1621,7 +1652,7 @@ let reveal_potential_nonces (cctxt : #Client_context.full) constants ~chain the [delegates] *) let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?max_priority ~liquidity_baking_escape_vote ~chain ~context_path delegates + ?max_priority ?per_block_vote_file ~chain ~context_path delegates block_stream = let state_maker bi = Alpha_services.Constants.all cctxt (chain, `Head 0) @@ -1672,12 +1703,7 @@ let create (cctxt : #Protocol_client_context.full) ~user_activated_upgrades timeout ) in let timeout_k cctxt state () = - bake - cctxt - ~user_activated_upgrades - ~chain - state - ~liquidity_baking_escape_vote + bake ?per_block_vote_file cctxt ~user_activated_upgrades ~chain state >>= function | Error err -> if state.retry_counter = 0 then ( diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.mli b/src/proto_alpha/lib_delegate/client_baking_forge.mli index 4e89408f5269..28bd86c529b5 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.mli +++ b/src/proto_alpha/lib_delegate/client_baking_forge.mli @@ -102,7 +102,7 @@ val create : ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> - liquidity_baking_escape_vote:bool -> + ?per_block_vote_file:string -> chain:Chain_services.chain -> context_path:string -> public_key_hash list -> diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index eb73d4530976..d3391fe6c954 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -94,8 +94,7 @@ end module Baker = struct let run (cctxt : #Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~liquidity_baking_escape_vote ~chain ~context_path ~keep_alive delegates - = + ?per_block_vote_file ~chain ~context_path ~keep_alive delegates = let process () = Config_services.user_activated_upgrades cctxt >>=? fun user_activated_upgrades -> @@ -113,7 +112,7 @@ module Baker = struct ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?max_priority - ~liquidity_baking_escape_vote + ?per_block_vote_file ~chain ~context_path delegates diff --git a/src/proto_alpha/lib_delegate/client_daemon.mli b/src/proto_alpha/lib_delegate/client_daemon.mli index 6473cb5adc80..06ef103ca5b9 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.mli +++ b/src/proto_alpha/lib_delegate/client_daemon.mli @@ -43,7 +43,7 @@ module Baker : sig ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?max_priority:int -> - liquidity_baking_escape_vote:bool -> + ?per_block_vote_file:string -> chain:Chain_services.chain -> context_path:string -> keep_alive:bool -> diff --git a/src/proto_alpha/lib_delegate/delegate_commands.ml b/src/proto_alpha/lib_delegate/delegate_commands.ml index 68eb11864d7a..ae166e62c1af 100644 --- a/src/proto_alpha/lib_delegate/delegate_commands.ml +++ b/src/proto_alpha/lib_delegate/delegate_commands.ml @@ -86,59 +86,20 @@ let keep_alive_arg = ~long:"keep-alive" () -type per_block_votes = {liquidity_baking_escape_vote : bool option} - -let per_block_votes_encoding = - let open Data_encoding in - def "per_block_votes.alpha" - @@ conv - (fun {liquidity_baking_escape_vote} -> liquidity_baking_escape_vote) - (fun liquidity_baking_escape_vote -> {liquidity_baking_escape_vote}) - (obj1 (opt "liquidity_baking_escape_vote" Data_encoding.bool)) - -let json_file_or_text_parameter = - Clic.parameter (fun _ p -> - match String.split ~limit:1 ':' p with - | ["text"; text] -> - return (Ezjsonm.from_string text) - | ["file"; path] -> - Lwt_utils_unix.Json.read_file path - | _ -> ( - if Sys.file_exists p then Lwt_utils_unix.Json.read_file p - else - try return (Ezjsonm.from_string p) - with Ezjsonm.Parse_error _ -> - failwith "Neither an existing file nor valid JSON: '%s'" p )) - -let per_block_votes_arg = +let per_block_vote_file_arg = Clic.arg - ~doc:"read per block votes as json or json file" + ~doc:"read per block votes as json file" ~short:'V' - ~long:"votes" - ~placeholder:"per block votes" - json_file_or_text_parameter - -let liquidity_baking_escape_vote per_block_votes = - match per_block_votes with - | None -> - return false - | Some votes -> ( - match Data_encoding.Json.destruct per_block_votes_encoding votes with - | exception e -> - Lwt.return (error_exn e) - | votes -> ( - match votes.liquidity_baking_escape_vote with - | None -> - return false - | Some escape_vote -> - return escape_vote ) ) + ~long:"votefile" + ~placeholder:"filename" + (Clic.parameter (fun _ s -> return s)) let delegate_commands () = let open Clic in [ command ~group ~desc:"Forge and inject block using the delegate rights." - (args9 + (args8 max_priority_arg minimal_fees_arg minimal_nanotez_per_gas_unit_arg @@ -146,8 +107,7 @@ let delegate_commands () = force_switch minimal_timestamp_switch mempool_arg - context_path_arg - per_block_votes_arg) + context_path_arg) ( prefixes ["bake"; "for"] @@ Client_keys.Public_key_hash.source_param ~name:"baker" @@ -160,12 +120,9 @@ let delegate_commands () = force, minimal_timestamp, mempool, - context_path, - per_block_votes ) + context_path ) delegate cctxt -> - liquidity_baking_escape_vote per_block_votes - >>=? fun liquidity_baking_escape_vote -> bake_block cctxt ~minimal_fees @@ -176,7 +133,7 @@ let delegate_commands () = ~minimal_timestamp ?mempool ?context_path - ~liquidity_baking_escape_vote + ~liquidity_baking_escape_vote:false ~chain:cctxt#chain ~head:cctxt#block delegate); @@ -306,7 +263,7 @@ let baker_commands () = minimal_nanotez_per_gas_unit_arg minimal_nanotez_per_byte_arg keep_alive_arg - per_block_votes_arg) + per_block_vote_file_arg) ( prefixes ["run"; "with"; "local"; "node"] @@ param ~name:"context_path" @@ -319,14 +276,12 @@ let baker_commands () = minimal_nanotez_per_gas_unit, minimal_nanotez_per_byte, keep_alive, - per_block_votes ) + per_block_vote_file ) node_path delegates cctxt -> may_lock_pidfile pidfile >>=? fun () -> - liquidity_baking_escape_vote per_block_votes - >>=? fun liquidity_baking_escape_vote -> Tezos_signer_backends.Encrypted.decrypt_list cctxt (List.map fst delegates) @@ -338,7 +293,7 @@ let baker_commands () = ~minimal_nanotez_per_gas_unit ~minimal_nanotez_per_byte ?max_priority - ~liquidity_baking_escape_vote + ?per_block_vote_file ~context_path:(Filename.concat node_path "context") ~keep_alive (List.map snd delegates)) ] -- GitLab From 78d34f8245b731e9707deb8bfdf459cb0786c87b Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 5 Feb 2021 00:38:20 -0500 Subject: [PATCH 41/62] liquidity baking: add unit test that subsidy param 1/6th of total rewards --- .../lib_parameters/default_parameters.ml | 43 +------------------ .../test/test_liquidity_baking.ml | 38 ++++++++++++++++ 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 9b8626d12713..8da3e0c28e95 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -26,7 +26,7 @@ open Protocol.Alpha_context open Micheline -let constants_mainnet_without_liquidity_baking_subsidy = +let constants_mainnet = Constants. { preserved_cycles = 5; @@ -64,6 +64,7 @@ let constants_mainnet_without_liquidity_baking_subsidy = (initial_origination_nonce (Operation_hash.hash_bytes [Bytes.of_string "Un festival de GADT."]))); + (* liquidity_baking_subsidy is 1/16th of total rewards *) liquidity_baking_subsidy = Tez.of_mutez_exn 5_000_000L; (* level after protocol activation when liquidity baking shuts off *) (* set to six months *) @@ -72,46 +73,6 @@ let constants_mainnet_without_liquidity_baking_subsidy = liquidity_baking_escape_ema_threshold = 500_000l; } -(* liquidity_baking_subsidy is 1/16th of total rewards *) -let constants_mainnet = - let baking_reward_per_endorsement = - match - List.hd - constants_mainnet_without_liquidity_baking_subsidy - .baking_reward_per_endorsement - with - | None -> - assert false - | Some c -> - c - in - let endorsement_reward = - match - List.hd - constants_mainnet_without_liquidity_baking_subsidy.endorsement_reward - with - | None -> - assert false - | Some c -> - c - in - let endorsers_per_block = - constants_mainnet_without_liquidity_baking_subsidy.endorsers_per_block - in - { - constants_mainnet_without_liquidity_baking_subsidy with - liquidity_baking_subsidy = - ( match Tez.(baking_reward_per_endorsement +? endorsement_reward) with - | Error _ -> - assert false - | Ok c -> ( - match Tez.(mul_exn c endorsers_per_block /? 16L) with - | Error _ -> - assert false - | Ok c -> - c ) ); - } - let constants_sandbox = Constants. { diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 840c8c30f9ea..0fe1e151e705 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -38,6 +38,40 @@ open Micheline_printer let bootstrap_contracts = Tezos_protocol_alpha_parameters.Default_parameters.test_bootstrap_contracts +let liquidity_baking_subsidy_param () = + Context.init ~bootstrap_contracts 1 + >>=? fun (blk, _contracts) -> + Context.get_constants (B blk) + >>=? fun csts -> + let baking_reward_per_endorsement = + match List.hd csts.parametric.baking_reward_per_endorsement with + | None -> + assert false + | Some c -> + c + in + let endorsement_reward = + match List.hd csts.parametric.endorsement_reward with + | None -> + assert false + | Some c -> + c + in + let endorsers_per_block = csts.parametric.endorsers_per_block in + let actual_subsidy = csts.parametric.liquidity_baking_subsidy in + let expected_subsidy = + match Tez.(baking_reward_per_endorsement +? endorsement_reward) with + | Error _ -> + assert false + | Ok c -> ( + match Tez.(mul_exn c endorsers_per_block /? 16L) with + | Error _ -> + assert false + | Ok c -> + c ) + in + Assert.equal_tez ~loc:__LOC__ actual_subsidy expected_subsidy + let liquidity_baking_subsidies n () = Context.init ~bootstrap_contracts 1 >>=? fun (blk, _contracts) -> @@ -285,6 +319,10 @@ let liquidity_baking_balance_update () = let tests = [ Test_services.tztest + "test liquidity_baking_subsidy parameter is 1/6th of total baking rewards" + `Quick + liquidity_baking_subsidy_param; + Test_services.tztest "test liquidity baking subsidy is correct" `Quick (liquidity_baking_subsidies 64); -- GitLab From 5413e5aac47925bea85a581123c2d28882cad9a0 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 5 Feb 2021 00:40:32 -0500 Subject: [PATCH 42/62] liquidity baking: fix errors in docs and remove dead code --- docs/alpha/liquidity_baking.rst | 2 +- docs/protocols/alpha.rst | 4 +--- src/proto_alpha/lib_protocol/alpha_context.mli | 2 -- src/proto_alpha/lib_protocol/storage.mli | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/alpha/liquidity_baking.rst b/docs/alpha/liquidity_baking.rst index 22a51bbbc448..b394d5aebe9f 100644 --- a/docs/alpha/liquidity_baking.rst +++ b/docs/alpha/liquidity_baking.rst @@ -8,7 +8,7 @@ Liquidity baking incentivizes large amounts of decentralized liquidity provision Contract ~~~~~~~~ -A constant product market making (CPMM) Michelson contract is first deployed on the chain. This contract maintains a balance of ``a`` tez and ``b`` `tzBTC`_, where tzBTC is the `FA1.2 token`_ found at address KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn. The smart contract accepts deposits of ``da`` tez and returns ``db`` tzBTC (or vice versa) where the invariant ``(a + da * (1 - f)) * (b - db) = a b`` is preserved, and ``f`` is a fee, set at 0.1%. +A constant product market making (CPMM) Michelson contract is first deployed on the chain. This contract maintains a balance of ``a`` tez and ``b`` `tzBTC`_, where tzBTC is the `FA1.2 token`_ found at address KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn. The smart contract accepts deposits of ``da`` tez and returns ``db`` tzBTC (or vice versa) where the invariant ``(a + da * (1 - f)) * (b - db) = a * b`` is preserved, and ``f`` is a fee, set at 0.1%. To implement this contract, we use a fork of the open source code base used by the "Dexter" project. The implementation of this contract has been `formally verified`_ against its functional specification and `audited by Trail of Bits`_. The contract code is modified in the following way: diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index c1274e2a4790..aca973f8e94b 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -28,10 +28,8 @@ The liquidity baking subsidy shuts off automatically at six months from protocol At any time bakers can vote to shut off the liquidity baking subsidy by setting a boolean flag in protocol_data. An exponential moving average (ema) of this escape flag is calculated with a window size of 1000 blocks and the subsidy permanently shuts off if the ema is ever over a threshold included in constants (half the window size with precision of 1000 added for integer computation). -The block security deposit is increased by 1/16th to 544. - - `TZIP `_ - MR: :gl:`tezos!2473` -More detailed docs for liquidity baking can be found `here<../alpha/liquidity_baking.rst>`_ +More information can be found on the :ref:`liquidity baking reference page`. diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 2c43fbc6ff5e..6773054b8f90 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -855,8 +855,6 @@ module Contract : sig (* Only for testing *) type origination_nonce - val origination_nonce_encoding : origination_nonce Data_encoding.t - val initial_origination_nonce : Operation_hash.t -> origination_nonce val originated_contract : origination_nonce -> contract diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index c1679b5e0dcc..7446f8ed5428 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -490,7 +490,7 @@ module Pending_migration_balance_updates : module Liquidity_baking : sig (** Exponential moving average (ema) of flags set in protocol_data.contents. - If at any block it's above half the window size set in constants, + If at any block it's above half the threshold set in constants, liquidity baking permanently shuts off. **) module Escape_ema : Single_data_storage with type t := Raw_context.t and type value = Int32.t -- GitLab From 051ad44703941befcf93ce0643f6129c1e6e1161 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 5 Feb 2021 01:48:06 -0500 Subject: [PATCH 43/62] liquidity baking: remove test_chain_duration from constants --- src/proto_alpha/lib_protocol/constants_repr.ml | 14 +++----------- tezt/_regressions/rpc/current.client.others.out | 6 +++--- vendors/flextesa-lib/tezos_protocol.ml | 8 +++++++- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index 615fee4f39e1..b3bf2de24a7b 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -145,13 +145,7 @@ let parametric_encoding = c.endorsement_reward, c.cost_per_byte, c.hard_storage_limit_per_operation ), - ( 0L, - (* At this position in the encoding we used to have a test - chain duration but it is not used anymore and should be - removed when this encoding is updated. When the test - chain was removed, we did not want to change the - encoding for retrocompatibility. *) - c.quorum_min, + ( c.quorum_min, c.quorum_max, c.min_proposal_quorum, c.initial_endorsers, @@ -180,8 +174,7 @@ let parametric_encoding = endorsement_reward, cost_per_byte, hard_storage_limit_per_operation ), - ( _test_chain_duration, - quorum_min, + ( quorum_min, quorum_max, min_proposal_quorum, initial_endorsers, @@ -249,8 +242,7 @@ let parametric_encoding = (req "endorsement_reward" (list Tez_repr.encoding)) (req "cost_per_byte" Tez_repr.encoding) (req "hard_storage_limit_per_operation" z)) - (obj10 - (req "test_chain_duration" int64) + (obj9 (req "quorum_min" int32) (req "quorum_max" int32) (req "min_proposal_quorum" int32) diff --git a/tezt/_regressions/rpc/current.client.others.out b/tezt/_regressions/rpc/current.client.others.out index 3b5a20f9479f..a0fc43637fd1 100644 --- a/tezt/_regressions/rpc/current.client.others.out +++ b/tezt/_regressions/rpc/current.client.others.out @@ -15,9 +15,9 @@ tezt/_regressions/rpc/current.client.others.out "endorsement_security_deposit": "64000000", "baking_reward_per_endorsement": [ "1250000", "187500" ], "endorsement_reward": [ "1250000", "833333" ], "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "test_chain_duration": "0", - "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, - "initial_endorsers": 1, "delay_per_missing_endorsement": "1", + "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, + "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 1, + "delay_per_missing_endorsement": "1", "liquidity_baking_cpmm_address": "[CONTRACT_HASH]", "liquidity_baking_subsidy": "5000000", "liquidity_baking_sunset_duration": 1024, diff --git a/vendors/flextesa-lib/tezos_protocol.ml b/vendors/flextesa-lib/tezos_protocol.ml index eb2c497ff768..9760d28c42f5 100644 --- a/vendors/flextesa-lib/tezos_protocol.ml +++ b/vendors/flextesa-lib/tezos_protocol.ml @@ -162,6 +162,12 @@ let protocol_parameters_json t : Ezjsonm.t = ( "liquidity_baking_escape_ema_threshold" , int 500000 ); ] | _ -> [] in + let legacy_parameters = + match subkind with + | `Babylon | `Carthage | `Delphi | `Edo -> + [ ("test_chain_duration", string (Int.to_string 1_966_080)) ] + | `Alpha -> [] + in let op_gas_limit, block_gas_limit = match subkind with | `Babylon -> (800_000, 8_000_000) @@ -170,6 +176,7 @@ let protocol_parameters_json t : Ezjsonm.t = let open Ezjsonm in let list_of_zs = list (fun i -> string (Int.to_string i)) in alpha_specific_parameters + @ legacy_parameters @ [ ("blocks_per_commitment", int 4); ("endorsers_per_block", int 32) ; ("hard_gas_limit_per_operation", string (Int.to_string op_gas_limit)) ; ("hard_gas_limit_per_block", string (Int.to_string block_gas_limit)) @@ -193,7 +200,6 @@ let protocol_parameters_json t : Ezjsonm.t = , match subkind with | `Babylon | `Carthage -> string (Int.to_string 1_000) | `Delphi | `Edo | `Florence | `Alpha -> string (Int.to_string 250) ) - ; ("test_chain_duration", string (Int.to_string 1_966_080)) ; ("quorum_min", int 3_000); ("quorum_max", int 7_000) ; ("min_proposal_quorum", int 500); ("initial_endorsers", int 1) ; ("delay_per_missing_endorsement", string (Int.to_string 1)) ] in -- GitLab From c03399292771cefe313edcd7c26441211fa9000a Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 5 Feb 2021 17:50:51 -0500 Subject: [PATCH 44/62] liquidity baking: update docs --- docs/index.rst | 1 + docs/protocols/alpha.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 30661e2222a6..6bc273b8f213 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -159,6 +159,7 @@ in the :ref:`introduction `. alpha/glossary alpha/cli-commands alpha/rpc + alpha/liquidity_baking .. toctree:: :maxdepth: 2 diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index aca973f8e94b..7913ff239504 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -32,4 +32,4 @@ At any time bakers can vote to shut off the liquidity baking subsidy by setting - MR: :gl:`tezos!2473` -More information can be found on the :ref:`liquidity baking reference page`. +More information can be found on the :ref:`liquidity baking reference page`. -- GitLab From bd4e82cf2393597fb381e3614ac29d06f1cbc21c Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 10:32:08 +0100 Subject: [PATCH 45/62] Simplify balance updates --- src/proto_alpha/lib_protocol/apply.ml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 917d84e0f336..c19ecad33dbe 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1563,16 +1563,9 @@ let apply_liquidity_baking_subsidy ctxt Liquidity_baking.get_sunset_level ctxt >>=? fun sunset_level -> let level = Raw_level.to_int32 (Level.current ctxt).level in - (* zero credit will be filtered out by cleanup_balance_updates *) - let noop_balance_update = - Receipt. - ( Rewards (Ed25519 Ed25519.Public_key_hash.zero, Cycle.root), - Credited Tez.zero, - Subsidy ) - in if Compare.Int32.(level >= sunset_level) then (* don't set or get ema if past sunset *) - return (ctxt, noop_balance_update, 0l) + return (ctxt, [], 0l) else Liquidity_baking.update_escape_ema ctxt @@ -1583,7 +1576,7 @@ let apply_liquidity_baking_subsidy ctxt Compare.Int32.( liquidity_baking_escape_ema >= Constants.liquidity_baking_escape_ema_threshold ctxt) - then return (ctxt, noop_balance_update, liquidity_baking_escape_ema) + then return (ctxt, [], liquidity_baking_escape_ema) else let liquidity_baking_cpmm_contract = Constants.liquidity_baking_cpmm_address ctxt @@ -1647,8 +1640,8 @@ let apply_liquidity_baking_subsidy ctxt Credited liquidity_baking_subsidy, Subsidy ) in - return (ctxt, balance_update, liquidity_baking_escape_ema) - else return (ctxt, noop_balance_update, liquidity_baking_escape_ema) + return (ctxt, [balance_update], liquidity_baking_escape_ema) + else return (ctxt, [], liquidity_baking_escape_ema) let finalize_application ctxt protocol_data delegate ~block_delay migration_balance_updates = @@ -1689,7 +1682,8 @@ let finalize_application ctxt protocol_data delegate ~block_delay Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> apply_liquidity_baking_subsidy ctxt protocol_data - >>=? fun (ctxt, liquidity_baking_balance_update, liquidity_baking_escape_ema) -> + >>=? fun (ctxt, liquidity_baking_balance_updates, liquidity_baking_escape_ema) + -> (* end of cycle *) may_snapshot_roll ctxt >>=? fun ctxt -> @@ -1706,9 +1700,8 @@ let finalize_application ctxt protocol_data delegate ~block_delay Debited deposit, Block_application ); (Deposits (delegate, cycle), Credited deposit, Block_application); - (Rewards (delegate, cycle), Credited reward, Block_application); - liquidity_baking_balance_update ] - @ balance_updates )) + (Rewards (delegate, cycle), Credited reward, Block_application) ] + @ liquidity_baking_balance_updates @ balance_updates )) in let consumed_gas = Gas.Arith.sub -- GitLab From 4bbd3635277c77b944686e20819b63f52df3467c Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 10:34:03 +0100 Subject: [PATCH 46/62] Minor refactor --- src/proto_alpha/lib_protocol/apply.ml | 120 +++++++++++++------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index c19ecad33dbe..156f095e0f34 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1581,67 +1581,69 @@ let apply_liquidity_baking_subsidy ctxt let liquidity_baking_cpmm_contract = Constants.liquidity_baking_cpmm_address ctxt in - (* fail gracefully if the cpmm is not found *) Contract.exists ctxt liquidity_baking_cpmm_contract - >>=? fun liquidity_baking_cpmm_contract_exists -> - if liquidity_baking_cpmm_contract_exists then - let liquidity_baking_subsidy = - Constants.liquidity_baking_subsidy ctxt - in - (* credit liquidity baking subsidy to CPMM contract *) - Contract.credit - ctxt - liquidity_baking_cpmm_contract - liquidity_baking_subsidy - >>=? fun ctxt -> - Contract.get_script ctxt liquidity_baking_cpmm_contract - >>=? fun (ctxt, script) -> - match script with - | None -> - Lwt.return (error (Script_tc_errors.No_such_entrypoint "default")) - | Some script -> - let step_constants = - let open Script_interpreter in - { - source = liquidity_baking_cpmm_contract; - payer = liquidity_baking_cpmm_contract; - self = liquidity_baking_cpmm_contract; - amount = liquidity_baking_subsidy; - chain_id = Chain_id.zero; - } - in - let parameter = - Micheline.strip_locations - Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) - in - (* call CPPM default entrypoint with parameter Unit *) - (* this is necessary for the CPMM's xtz_pool in storage to + >>=? function + | false -> + (* fail gracefully if the cpmm is not found *) + return (ctxt, [], liquidity_baking_escape_ema) + | true -> ( + let liquidity_baking_subsidy = + Constants.liquidity_baking_subsidy ctxt + in + (* credit liquidity baking subsidy to CPMM contract *) + Contract.credit + ctxt + liquidity_baking_cpmm_contract + liquidity_baking_subsidy + >>=? fun ctxt -> + Contract.get_script ctxt liquidity_baking_cpmm_contract + >>=? fun (ctxt, script) -> + match script with + | None -> + Lwt.return + (error (Script_tc_errors.No_such_entrypoint "default")) + | Some script -> + let step_constants = + let open Script_interpreter in + { + source = liquidity_baking_cpmm_contract; + payer = liquidity_baking_cpmm_contract; + self = liquidity_baking_cpmm_contract; + amount = liquidity_baking_subsidy; + chain_id = Chain_id.zero; + } + in + let parameter = + Micheline.strip_locations + Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) + in + (* call CPPM default entrypoint with parameter Unit *) + (* this is necessary for the CPMM's xtz_pool in storage to increase since it cannot use BALANCE due to a transfer attack *) - Script_interpreter.execute - ctxt - Optimized - step_constants - ~script - ~parameter - ~entrypoint:"default" - ~internal:true - >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> - let _operations = operations in - (* update CPMM storage *) - Contract.update_script_storage - ctxt - liquidity_baking_cpmm_contract - storage - lazy_storage_diff - >>=? fun ctxt -> - let balance_update = - Receipt. - ( Contract liquidity_baking_cpmm_contract, - Credited liquidity_baking_subsidy, - Subsidy ) - in - return (ctxt, [balance_update], liquidity_baking_escape_ema) - else return (ctxt, [], liquidity_baking_escape_ema) + Script_interpreter.execute + ctxt + Optimized + step_constants + ~script + ~parameter + ~entrypoint:"default" + ~internal:true + >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> + let _operations = operations in + (* update CPMM storage *) + Contract.update_script_storage + ctxt + liquidity_baking_cpmm_contract + storage + lazy_storage_diff + >>=? fun ctxt -> + let balance_update = + Receipt. + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_subsidy, + Subsidy ) + in + return (ctxt, [balance_update], liquidity_baking_escape_ema) ) let finalize_application ctxt protocol_data delegate ~block_delay migration_balance_updates = -- GitLab From 864f68a690f86980e45fe4ab13f01be8d08a187f Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 10:40:47 +0100 Subject: [PATCH 47/62] Some comments --- src/proto_alpha/lib_protocol/apply.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 156f095e0f34..f5e546ff3987 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1605,6 +1605,9 @@ let apply_liquidity_baking_subsidy ctxt | Some script -> let step_constants = let open Script_interpreter in + (* + Using dummy values since they are not used within the CPMM default entrypoint. + *) { source = liquidity_baking_cpmm_contract; payer = liquidity_baking_cpmm_contract; @@ -1617,9 +1620,11 @@ let apply_liquidity_baking_subsidy ctxt Micheline.strip_locations Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) in - (* call CPPM default entrypoint with parameter Unit *) - (* this is necessary for the CPMM's xtz_pool in storage to - increase since it cannot use BALANCE due to a transfer attack *) + (* + Call CPPM default entrypoint with parameter Unit. + This is necessary for the CPMM's xtz_pool in storage to + increase since it cannot use BALANCE due to a transfer attack. + *) Script_interpreter.execute ctxt Optimized -- GitLab From 07f31b671687733967ebcdd28524abd0fc121f70 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 11:01:00 +0100 Subject: [PATCH 48/62] Do not fail if something bad happens in CPMM contract --- src/proto_alpha/lib_protocol/apply.ml | 122 ++++++++++++++------------ 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index f5e546ff3987..8dc85016176f 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1587,68 +1587,78 @@ let apply_liquidity_baking_subsidy ctxt (* fail gracefully if the cpmm is not found *) return (ctxt, [], liquidity_baking_escape_ema) | true -> ( - let liquidity_baking_subsidy = - Constants.liquidity_baking_subsidy ctxt - in - (* credit liquidity baking subsidy to CPMM contract *) - Contract.credit - ctxt - liquidity_baking_cpmm_contract - liquidity_baking_subsidy - >>=? fun ctxt -> - Contract.get_script ctxt liquidity_baking_cpmm_contract - >>=? fun (ctxt, script) -> - match script with - | None -> - Lwt.return - (error (Script_tc_errors.No_such_entrypoint "default")) - | Some script -> - let step_constants = - let open Script_interpreter in - (* + let backtracking_ctxt = ctxt in + (let liquidity_baking_subsidy = + Constants.liquidity_baking_subsidy ctxt + in + (* credit liquidity baking subsidy to CPMM contract *) + Contract.credit + ctxt + liquidity_baking_cpmm_contract + liquidity_baking_subsidy + >>=? fun ctxt -> + Contract.get_script ctxt liquidity_baking_cpmm_contract + >>=? fun (ctxt, script) -> + match script with + | None -> + fail (Script_tc_errors.No_such_entrypoint "default") + | Some script -> ( + let step_constants = + let open Script_interpreter in + (* Using dummy values since they are not used within the CPMM default entrypoint. *) - { - source = liquidity_baking_cpmm_contract; - payer = liquidity_baking_cpmm_contract; - self = liquidity_baking_cpmm_contract; - amount = liquidity_baking_subsidy; - chain_id = Chain_id.zero; - } - in - let parameter = - Micheline.strip_locations - Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) - in - (* + { + source = liquidity_baking_cpmm_contract; + payer = liquidity_baking_cpmm_contract; + self = liquidity_baking_cpmm_contract; + amount = liquidity_baking_subsidy; + chain_id = Chain_id.zero; + } + in + let parameter = + Micheline.strip_locations + Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) + in + (* Call CPPM default entrypoint with parameter Unit. This is necessary for the CPMM's xtz_pool in storage to increase since it cannot use BALANCE due to a transfer attack. *) - Script_interpreter.execute - ctxt - Optimized - step_constants - ~script - ~parameter - ~entrypoint:"default" - ~internal:true - >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> - let _operations = operations in - (* update CPMM storage *) - Contract.update_script_storage - ctxt - liquidity_baking_cpmm_contract - storage - lazy_storage_diff - >>=? fun ctxt -> - let balance_update = - Receipt. - ( Contract liquidity_baking_cpmm_contract, - Credited liquidity_baking_subsidy, - Subsidy ) - in - return (ctxt, [balance_update], liquidity_baking_escape_ema) ) + Script_interpreter.execute + ctxt + Optimized + step_constants + ~script + ~parameter + ~entrypoint:"default" + ~internal:true + >>=? fun {ctxt; storage; lazy_storage_diff; operations} -> + match operations with + | _ :: _ -> + (* No internal operations are expected here. Something bad may be happening. *) + return (backtracking_ctxt, []) + | [] -> + (* update CPMM storage *) + Contract.update_script_storage + ctxt + liquidity_baking_cpmm_contract + storage + lazy_storage_diff + >>=? fun ctxt -> + let balance_update = + Receipt. + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_subsidy, + Subsidy ) + in + return (ctxt, [balance_update]) )) + >|= function + | Ok (ctxt, balance_updates) -> + Ok (ctxt, balance_updates, liquidity_baking_escape_ema) + | Error _ -> + (* Do not fail if something bad happens during CPMM contract call. *) + Ok (backtracking_ctxt, [], liquidity_baking_escape_ema) ) let finalize_application ctxt protocol_data delegate ~block_delay migration_balance_updates = -- GitLab From 494eb79a21ab0d824a28d847349642bf1d623048 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 15:54:10 +0100 Subject: [PATCH 49/62] Pass vote rather than whole protocol_data --- src/proto_alpha/lib_protocol/apply.ml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 8dc85016176f..bc97f7aa1430 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1557,8 +1557,7 @@ let check_minimum_endorsements ctxt protocol_data block_delay timestamp; }) -let apply_liquidity_baking_subsidy ctxt - (protocol_data : Alpha_context.Block_header.contents) = +let apply_liquidity_baking_subsidy ctxt ~escape_vote = (* check level is below sunset *) Liquidity_baking.get_sunset_level ctxt >>=? fun sunset_level -> @@ -1567,9 +1566,7 @@ let apply_liquidity_baking_subsidy ctxt (* don't set or get ema if past sunset *) return (ctxt, [], 0l) else - Liquidity_baking.update_escape_ema - ctxt - ~escape_vote:protocol_data.liquidity_baking_escape_vote + Liquidity_baking.update_escape_ema ctxt ~escape_vote >>=? fun (ctxt, liquidity_baking_escape_ema) -> (* liquidity baking permanently shuts off if threshold is reached once *) if @@ -1698,7 +1695,8 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some nonce_hash -> Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> - apply_liquidity_baking_subsidy ctxt protocol_data + let escape_vote = protocol_data.liquidity_baking_escape_vote in + apply_liquidity_baking_subsidy ctxt ~escape_vote >>=? fun (ctxt, liquidity_baking_balance_updates, liquidity_baking_escape_ema) -> (* end of cycle *) -- GitLab From ac66af216826b734c83855be8f44e4bcb1943e22 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 18:11:00 +0100 Subject: [PATCH 50/62] Add field in block receipts --- src/proto_alpha/lib_protocol/apply.ml | 1 + src/proto_alpha/lib_protocol/apply_results.ml | 114 ++++++++++++------ .../lib_protocol/apply_results.mli | 1 + src/proto_alpha/lib_protocol/main.ml | 2 + 4 files changed, 79 insertions(+), 39 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index bc97f7aa1430..05e2b69b9e39 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1748,6 +1748,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay deactivated; balance_updates; liquidity_baking_escape_ema; + implicit_operations_results = []; } in (ctxt, receipt) diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index fc517858aeab..493091b445bc 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -403,6 +403,32 @@ let internal_operation_result_encoding : make Manager_result.origination_case; make Manager_result.delegation_case ] +let successful_manager_operation_result_encoding : + packed_successful_manager_operation_result Data_encoding.t = + let make (type kind) + (Manager_result.MCase res_case : kind Manager_result.case) = + let (Operation.Encoding.Manager_operations.MCase op_case) = + res_case.op_case + in + case + (Tag op_case.tag) + ~title:op_case.name + (merge_objs (obj1 (req "kind" (constant op_case.name))) res_case.encoding) + (fun res -> + match res_case.select res with + | Some res -> + Some ((), res_case.proj res) + | None -> + None) + (fun ((), res) -> Successful_manager_result (res_case.inj res)) + in + def "operation.alpha.successful_manager_operation_result" + @@ union + [ make Manager_result.reveal_case; + make Manager_result.transaction_case; + make Manager_result.origination_case; + make Manager_result.delegation_case ] + type 'kind contents_result = | Endorsement_result : { balance_updates : Receipt.balance_updates; @@ -1238,6 +1264,7 @@ type block_metadata = { deactivated : Signature.Public_key_hash.t list; balance_updates : Receipt.balance_updates; liquidity_baking_escape_ema : int32; + implicit_operations_results : packed_successful_manager_operation_result list; } let block_metadata_encoding = @@ -1253,27 +1280,30 @@ let block_metadata_encoding = consumed_gas; deactivated; balance_updates; - liquidity_baking_escape_ema } -> - ( baker, - level, - level_info, - voting_period_kind, - voting_period_info, - nonce_hash, - consumed_gas, - deactivated, - balance_updates, - liquidity_baking_escape_ema )) - (fun ( baker, - level, - level_info, - voting_period_kind, - voting_period_info, - nonce_hash, - consumed_gas, - deactivated, - balance_updates, - liquidity_baking_escape_ema ) -> + liquidity_baking_escape_ema; + implicit_operations_results } -> + ( ( baker, + level, + level_info, + voting_period_kind, + voting_period_info, + nonce_hash, + consumed_gas, + deactivated, + balance_updates, + liquidity_baking_escape_ema ), + implicit_operations_results )) + (fun ( ( baker, + level, + level_info, + voting_period_kind, + voting_period_info, + nonce_hash, + consumed_gas, + deactivated, + balance_updates, + liquidity_baking_escape_ema ), + implicit_operations_results ) -> { baker; level; @@ -1285,22 +1315,28 @@ let block_metadata_encoding = deactivated; balance_updates; liquidity_baking_escape_ema; + implicit_operations_results; }) - (obj10 - (req "baker" Signature.Public_key_hash.encoding) - (req - ~description:"This field is DEPRECATED: use level_info instead" - "level" - Level.compat_encoding) - (req "level_info" Level.encoding) - (req - ~description: - "This field is DEPRECATED: use voting_period_info instead" - "voting_period_kind" - Voting_period.kind_encoding) - (req "voting_period_info" Voting_period.info_encoding) - (req "nonce_hash" (option Nonce_hash.encoding)) - (req "consumed_gas" Gas.Arith.n_fp_encoding) - (req "deactivated" (list Signature.Public_key_hash.encoding)) - (req "balance_updates" Receipt.balance_updates_encoding) - (req "liquidity_baking_escape_ema" int32)) + (merge_objs + (obj10 + (req "baker" Signature.Public_key_hash.encoding) + (req + ~description:"This field is DEPRECATED: use level_info instead" + "level" + Level.compat_encoding) + (req "level_info" Level.encoding) + (req + ~description: + "This field is DEPRECATED: use voting_period_info instead" + "voting_period_kind" + Voting_period.kind_encoding) + (req "voting_period_info" Voting_period.info_encoding) + (req "nonce_hash" (option Nonce_hash.encoding)) + (req "consumed_gas" Gas.Arith.n_fp_encoding) + (req "deactivated" (list Signature.Public_key_hash.encoding)) + (req "balance_updates" Receipt.balance_updates_encoding) + (req "liquidity_baking_escape_ema" int32)) + (obj1 + (req + "implicit_operations_results" + (list successful_manager_operation_result_encoding)))) diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index 94590f527cbf..f056a57cc59c 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -192,6 +192,7 @@ type block_metadata = { deactivated : Signature.Public_key_hash.t list; balance_updates : Receipt.balance_updates; liquidity_baking_escape_ema : int32; + implicit_operations_results : packed_successful_manager_operation_result list; } val block_metadata_encoding : block_metadata Data_encoding.encoding diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index cee86d00880e..741cafc132ac 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -250,6 +250,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = deactivated = []; balance_updates = migration_balance_updates; liquidity_baking_escape_ema; + implicit_operations_results = []; } ) | Partial_application {block_header; baker; block_delay} -> let included_endorsements = Alpha_context.included_endorsements ctxt in @@ -284,6 +285,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = deactivated = []; balance_updates = migration_balance_updates; liquidity_baking_escape_ema; + implicit_operations_results = []; } ) | Application { baker; -- GitLab From d6195d582fc4348f9c91967239d1b231a8de53ee Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 19:04:30 +0100 Subject: [PATCH 51/62] Produce a transaction receipt rather than just a balance receipt --- src/proto_alpha/lib_protocol/apply.ml | 79 +++++++++++++++++++++------ 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 05e2b69b9e39..4d5c47c2b2f0 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1618,10 +1618,21 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = Michelson_v1_primitives.(Prim (0, D_Unit, [], [])) in (* - Call CPPM default entrypoint with parameter Unit. - This is necessary for the CPMM's xtz_pool in storage to - increase since it cannot use BALANCE due to a transfer attack. - *) + Call CPPM default entrypoint with parameter Unit. + This is necessary for the CPMM's xtz_pool in storage to + increase since it cannot use BALANCE due to a transfer attack. + + Mimicks a transaction. + + Gas limit for the operation is unlimited but the gas is still + counted towards the block allowance. + + There is no: + - storage burn (extra storage is free) + - fees (the operation is mandatory) + - gas for manager operation application, deserializing arguments + (constant per block). + *) Script_interpreter.execute ctxt Optimized @@ -1635,7 +1646,7 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = | _ :: _ -> (* No internal operations are expected here. Something bad may be happening. *) return (backtracking_ctxt, []) - | [] -> + | [] -> ( (* update CPMM storage *) Contract.update_script_storage ctxt @@ -1643,16 +1654,47 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = storage lazy_storage_diff >>=? fun ctxt -> - let balance_update = - Receipt. - ( Contract liquidity_baking_cpmm_contract, - Credited liquidity_baking_subsidy, - Subsidy ) - in - return (ctxt, [balance_update]) )) + Contract.originated_from_current_nonce + ~since:backtracking_ctxt + ~until:ctxt + >>=? function + | _ :: _ -> + (* No contracts are expected to be originated here. Something bad may be happening. *) + return (backtracking_ctxt, []) + | [] as originated_contracts -> + Fees.record_paid_storage_space + ctxt + liquidity_baking_cpmm_contract + >>=? fun ( ctxt, + new_size, + paid_storage_size_diff, + _to_burn ) -> + let balance_updates = + [ Receipt. + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_subsidy, + Subsidy ) ] + in + let consumed_gas = + Gas.consumed ~since:backtracking_ctxt ~until:ctxt + in + let result = + Transaction_result + { + storage = Some storage; + lazy_storage_diff; + balance_updates; + originated_contracts; + consumed_gas; + storage_size = new_size; + paid_storage_size_diff; + allocated_destination_contract = false; + } + in + return (ctxt, [Successful_manager_result result]) ) )) >|= function - | Ok (ctxt, balance_updates) -> - Ok (ctxt, balance_updates, liquidity_baking_escape_ema) + | Ok (ctxt, results) -> + Ok (ctxt, results, liquidity_baking_escape_ema) | Error _ -> (* Do not fail if something bad happens during CPMM contract call. *) Ok (backtracking_ctxt, [], liquidity_baking_escape_ema) ) @@ -1697,8 +1739,9 @@ let finalize_application ctxt protocol_data delegate ~block_delay >>=? fun ctxt -> let escape_vote = protocol_data.liquidity_baking_escape_vote in apply_liquidity_baking_subsidy ctxt ~escape_vote - >>=? fun (ctxt, liquidity_baking_balance_updates, liquidity_baking_escape_ema) - -> + >>=? fun ( ctxt, + liquidity_baking_implicit_results, + liquidity_baking_escape_ema ) -> (* end of cycle *) may_snapshot_roll ctxt >>=? fun ctxt -> @@ -1716,7 +1759,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay Block_application ); (Deposits (delegate, cycle), Credited deposit, Block_application); (Rewards (delegate, cycle), Credited reward, Block_application) ] - @ liquidity_baking_balance_updates @ balance_updates )) + @ balance_updates )) in let consumed_gas = Gas.Arith.sub @@ -1748,7 +1791,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay deactivated; balance_updates; liquidity_baking_escape_ema; - implicit_operations_results = []; + implicit_operations_results = liquidity_baking_implicit_results; } in (ctxt, receipt) -- GitLab From 70b9cf8404fb04fd94da3afdbe133f195f6547e5 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 11:08:11 +0100 Subject: [PATCH 52/62] Expose apply_liquidity_baking_subsidy --- src/proto_alpha/lib_protocol/apply.mli | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/proto_alpha/lib_protocol/apply.mli b/src/proto_alpha/lib_protocol/apply.mli index fbac491292c2..9d825219936c 100644 --- a/src/proto_alpha/lib_protocol/apply.mli +++ b/src/proto_alpha/lib_protocol/apply.mli @@ -126,6 +126,12 @@ val apply_operation : 'a operation -> (t * 'a operation_metadata, error trace) result Lwt.t +val apply_liquidity_baking_subsidy : + t -> + escape_vote:bool -> + (t * packed_successful_manager_operation_result list * Int32.t) tzresult + Lwt.t + val finalize_application : t -> Block_header.contents -> -- GitLab From 002118d3cd22be25dde4ebc1f83e3241662a42fd Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Mon, 8 Feb 2021 15:59:21 +0100 Subject: [PATCH 53/62] Apply liquidity baking at beginning of block --- src/proto_alpha/lib_protocol/apply.ml | 10 +--- src/proto_alpha/lib_protocol/apply.mli | 2 + src/proto_alpha/lib_protocol/main.ml | 81 +++++++++++++++++++++----- src/proto_alpha/lib_protocol/main.mli | 3 + 4 files changed, 74 insertions(+), 22 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 4d5c47c2b2f0..f62712169981 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1700,7 +1700,8 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = Ok (backtracking_ctxt, [], liquidity_baking_escape_ema) ) let finalize_application ctxt protocol_data delegate ~block_delay - migration_balance_updates = + migration_balance_updates ~liquidity_baking_escape_ema + implicit_operations_results = let included_endorsements = included_endorsements ctxt in check_minimum_endorsements ctxt @@ -1737,11 +1738,6 @@ let finalize_application ctxt protocol_data delegate ~block_delay | Some nonce_hash -> Nonce.record_hash ctxt {nonce_hash; delegate; rewards; fees} ) >>=? fun ctxt -> - let escape_vote = protocol_data.liquidity_baking_escape_vote in - apply_liquidity_baking_subsidy ctxt ~escape_vote - >>=? fun ( ctxt, - liquidity_baking_implicit_results, - liquidity_baking_escape_ema ) -> (* end of cycle *) may_snapshot_roll ctxt >>=? fun ctxt -> @@ -1791,7 +1787,7 @@ let finalize_application ctxt protocol_data delegate ~block_delay deactivated; balance_updates; liquidity_baking_escape_ema; - implicit_operations_results = liquidity_baking_implicit_results; + implicit_operations_results; } in (ctxt, receipt) diff --git a/src/proto_alpha/lib_protocol/apply.mli b/src/proto_alpha/lib_protocol/apply.mli index 9d825219936c..8a17350a2a35 100644 --- a/src/proto_alpha/lib_protocol/apply.mli +++ b/src/proto_alpha/lib_protocol/apply.mli @@ -138,6 +138,8 @@ val finalize_application : public_key_hash -> block_delay:Period.t -> Receipt.balance_updates -> + liquidity_baking_escape_ema:Int32.t -> + packed_successful_manager_operation_result list -> (t * block_metadata, error trace) result Lwt.t val apply_manager_contents_list : diff --git a/src/proto_alpha/lib_protocol/main.ml b/src/proto_alpha/lib_protocol/main.ml index 741cafc132ac..9928972e0c9c 100644 --- a/src/proto_alpha/lib_protocol/main.ml +++ b/src/proto_alpha/lib_protocol/main.ml @@ -113,6 +113,9 @@ type validation_state = { ctxt : Alpha_context.t; op_count : int; migration_balance_updates : Alpha_context.Receipt.balance_updates; + liquidity_baking_escape_ema : Int32.t; + implicit_operations_results : + Apply_results.packed_successful_manager_operation_result list; } let current_context {ctxt; _} = return (Alpha_context.finalize ctxt).context @@ -126,12 +129,27 @@ let begin_partial_application ~chain_id ~ancestor_context:ctxt Alpha_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt >>=? fun (ctxt, migration_balance_updates) -> Apply.begin_application ctxt chain_id block_header predecessor_timestamp - >|=? fun (ctxt, baker, block_delay) -> + >>=? fun (ctxt, baker, block_delay) -> + let escape_vote = + block_header.protocol_data.contents.liquidity_baking_escape_vote + in + Apply.apply_liquidity_baking_subsidy ctxt ~escape_vote + >|=? fun ( ctxt, + liquidity_baking_operations_results, + liquidity_baking_escape_ema ) -> let mode = Partial_application {block_header; baker = Signature.Public_key.hash baker; block_delay} in - {mode; chain_id; ctxt; op_count = 0; migration_balance_updates} + { + mode; + chain_id; + ctxt; + op_count = 0; + migration_balance_updates; + liquidity_baking_escape_ema; + implicit_operations_results = liquidity_baking_operations_results; + } let begin_application ~chain_id ~predecessor_context:ctxt ~predecessor_timestamp ~predecessor_fitness @@ -142,12 +160,27 @@ let begin_application ~chain_id ~predecessor_context:ctxt Alpha_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt >>=? fun (ctxt, migration_balance_updates) -> Apply.begin_application ctxt chain_id block_header predecessor_timestamp - >|=? fun (ctxt, baker, block_delay) -> + >>=? fun (ctxt, baker, block_delay) -> + let escape_vote = + block_header.protocol_data.contents.liquidity_baking_escape_vote + in + Apply.apply_liquidity_baking_subsidy ctxt ~escape_vote + >|=? fun ( ctxt, + liquidity_baking_operations_results, + liquidity_baking_escape_ema ) -> let mode = Application {block_header; baker = Signature.Public_key.hash baker; block_delay} in - {mode; chain_id; ctxt; op_count = 0; migration_balance_updates} + { + mode; + chain_id; + ctxt; + op_count = 0; + migration_balance_updates; + liquidity_baking_escape_ema; + implicit_operations_results = liquidity_baking_operations_results; + } let begin_construction ~chain_id ~predecessor_context:ctxt ~predecessor_timestamp ~predecessor_level:pred_level @@ -162,7 +195,8 @@ let begin_construction ~chain_id ~predecessor_context:ctxt Apply.begin_partial_construction ctxt >|=? fun ctxt -> let mode = Partial_construction {predecessor} in - (mode, ctxt) + let escape_vote = false in + (mode, ctxt, escape_vote) | Some proto_header -> Apply.begin_full_construction ctxt @@ -173,9 +207,22 @@ let begin_construction ~chain_id ~predecessor_context:ctxt let baker = Signature.Public_key.hash baker in Full_construction {predecessor; baker; protocol_data; block_delay} in - (mode, ctxt) ) - >|=? fun (mode, ctxt) -> - {mode; chain_id; ctxt; op_count = 0; migration_balance_updates} + let escape_vote = protocol_data.liquidity_baking_escape_vote in + (mode, ctxt, escape_vote) ) + >>=? fun (mode, ctxt, escape_vote) -> + Apply.apply_liquidity_baking_subsidy ctxt ~escape_vote + >|=? fun ( ctxt, + liquidity_baking_operations_results, + liquidity_baking_escape_ema ) -> + { + mode; + chain_id; + ctxt; + op_count = 0; + migration_balance_updates; + liquidity_baking_escape_ema; + implicit_operations_results = liquidity_baking_operations_results; + } let apply_operation ({mode; chain_id; ctxt; op_count; _} as data) (operation : Alpha_context.packed_operation) = @@ -213,15 +260,19 @@ let apply_operation ({mode; chain_id; ctxt; op_count; _} as data) let op_count = op_count + 1 in ({data with ctxt; op_count}, Operation_metadata result) -let finalize_block {mode; ctxt; op_count; migration_balance_updates} = +let finalize_block + { mode; + ctxt; + op_count; + migration_balance_updates; + liquidity_baking_escape_ema; + implicit_operations_results } = match mode with | Partial_construction _ -> Alpha_context.Voting_period.get_current_info ctxt >>=? fun {voting_period = {kind; _}; _} -> Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt >>=? fun ({voting_period; position; _} as voting_period_info) -> - Alpha_context.Liquidity_baking.get_escape_ema ctxt - >>=? fun liquidity_baking_escape_ema -> let level_info = Alpha_context.Level.current ctxt in let baker = Signature.Public_key_hash.zero in Signature.Public_key_hash.Map.fold @@ -250,7 +301,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = deactivated = []; balance_updates = migration_balance_updates; liquidity_baking_escape_ema; - implicit_operations_results = []; + implicit_operations_results; } ) | Partial_application {block_header; baker; block_delay} -> let included_endorsements = Alpha_context.included_endorsements ctxt in @@ -262,8 +313,6 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = >>?= fun () -> Alpha_context.Voting_period.get_current_info ctxt >>=? fun {voting_period = {kind; _}; _} -> - Alpha_context.Liquidity_baking.get_escape_ema ctxt - >>=? fun liquidity_baking_escape_ema -> Alpha_context.Voting_period.get_rpc_fixed_current_info ctxt >|=? fun ({voting_period; position; _} as voting_period_info) -> let level_info = Alpha_context.Level.current ctxt in @@ -285,7 +334,7 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = deactivated = []; balance_updates = migration_balance_updates; liquidity_baking_escape_ema; - implicit_operations_results = []; + implicit_operations_results; } ) | Application { baker; @@ -298,6 +347,8 @@ let finalize_block {mode; ctxt; op_count; migration_balance_updates} = baker ~block_delay migration_balance_updates + ~liquidity_baking_escape_ema + implicit_operations_results >|=? fun (ctxt, receipt) -> let level = Alpha_context.Level.current ctxt in let priority = protocol_data.priority in diff --git a/src/proto_alpha/lib_protocol/main.mli b/src/proto_alpha/lib_protocol/main.mli index 2128db498b60..519c5f063023 100644 --- a/src/proto_alpha/lib_protocol/main.mli +++ b/src/proto_alpha/lib_protocol/main.mli @@ -50,6 +50,9 @@ type validation_state = { ctxt : Alpha_context.t; op_count : int; migration_balance_updates : Alpha_context.Receipt.balance_updates; + liquidity_baking_escape_ema : Int32.t; + implicit_operations_results : + Apply_results.packed_successful_manager_operation_result list; } type operation_data = Alpha_context.packed_protocol_data -- GitLab From 9bbcc1bdbbc1ecfaa51490b0f962baff182a0d4f Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 8 Feb 2021 18:29:51 -0500 Subject: [PATCH 54/62] liquidity baking: don't call originated_from_current_nonce or record_paid_storage_space when applying subsidy --- src/proto_alpha/lib_protocol/apply.ml | 67 +++++++++++---------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index f62712169981..9e5ef81a6649 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1646,7 +1646,7 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = | _ :: _ -> (* No internal operations are expected here. Something bad may be happening. *) return (backtracking_ctxt, []) - | [] -> ( + | [] -> (* update CPMM storage *) Contract.update_script_storage ctxt @@ -1654,44 +1654,33 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = storage lazy_storage_diff >>=? fun ctxt -> - Contract.originated_from_current_nonce - ~since:backtracking_ctxt - ~until:ctxt - >>=? function - | _ :: _ -> - (* No contracts are expected to be originated here. Something bad may be happening. *) - return (backtracking_ctxt, []) - | [] as originated_contracts -> - Fees.record_paid_storage_space - ctxt - liquidity_baking_cpmm_contract - >>=? fun ( ctxt, - new_size, - paid_storage_size_diff, - _to_burn ) -> - let balance_updates = - [ Receipt. - ( Contract liquidity_baking_cpmm_contract, - Credited liquidity_baking_subsidy, - Subsidy ) ] - in - let consumed_gas = - Gas.consumed ~since:backtracking_ctxt ~until:ctxt - in - let result = - Transaction_result - { - storage = Some storage; - lazy_storage_diff; - balance_updates; - originated_contracts; - consumed_gas; - storage_size = new_size; - paid_storage_size_diff; - allocated_destination_contract = false; - } - in - return (ctxt, [Successful_manager_result result]) ) )) + Contract.used_storage_space + ctxt + liquidity_baking_cpmm_contract + >>=? fun storage_size -> + let balance_updates = + [ Receipt. + ( Contract liquidity_baking_cpmm_contract, + Credited liquidity_baking_subsidy, + Subsidy ) ] + in + let consumed_gas = + Gas.consumed ~since:backtracking_ctxt ~until:ctxt + in + let result = + Transaction_result + { + storage = Some storage; + lazy_storage_diff; + balance_updates; + originated_contracts = []; + consumed_gas; + storage_size; + paid_storage_size_diff = Z.zero; + allocated_destination_contract = false; + } + in + return (ctxt, [Successful_manager_result result]) )) >|= function | Ok (ctxt, results) -> Ok (ctxt, results, liquidity_baking_escape_ema) -- GitLab From 39095fe0ff3e78614313c8753c5dc66ef77d52a6 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 8 Feb 2021 19:59:33 -0500 Subject: [PATCH 55/62] liquidity baking: don't fail if per_block_votes file is deleted or malformed --- .../lib_delegate/client_baking_forge.ml | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/lib_delegate/client_baking_forge.ml b/src/proto_alpha/lib_delegate/client_baking_forge.ml index b4d80e9d5e5e..e3287e99eafe 100644 --- a/src/proto_alpha/lib_delegate/client_baking_forge.ml +++ b/src/proto_alpha/lib_delegate/client_baking_forge.ml @@ -1392,19 +1392,30 @@ let read_liquidity_baking_escape_vote per_block_vote_file = | None -> return false | Some vote_file -> ( - Lwt_utils_unix.Json.read_file vote_file - >>=? fun votes_json -> - match - Data_encoding.Json.destruct per_block_votes_encoding votes_json - with - | exception e -> - Lwt.return (error_exn e) - | votes -> ( - match votes.liquidity_baking_escape_vote with - | None -> + Lwt.catch + (fun () -> + Lwt_utils_unix.Json.read_file vote_file + >>= function + | Ok votes_json -> + Lwt.return_some votes_json + | Error _ -> + Lwt.fail Not_found) + (fun _ -> Lwt.return_none) + >>= function + | Some votes_json -> ( + match + Data_encoding.Json.destruct per_block_votes_encoding votes_json + with + | exception _ -> return false - | Some liquidity_baking_escape_vote -> - return liquidity_baking_escape_vote ) ) + | votes -> ( + match votes.liquidity_baking_escape_vote with + | None -> + return false + | Some liquidity_baking_escape_vote -> + return liquidity_baking_escape_vote ) ) + | None -> + return false ) (** [bake cctxt state] create a single block when woken up to do so. All the necessary information is available in the -- GitLab From a3b1fa09b7253a7a74ccd4d257627035028e3615 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 9 Feb 2021 10:15:35 +0100 Subject: [PATCH 56/62] Also take into account implicit_operations_results in tests --- .../lib_protocol/test/helpers/block.ml | 27 ++++++++++++++++--- .../lib_protocol/test/helpers/block.mli | 2 +- .../test/test_liquidity_baking.ml | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index f1e4975942d7..62f32a4d84c9 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -462,15 +462,34 @@ let bake_n ?policy ?liquidity_baking_escape_vote n b = b (1 -- n) -let bake_n_with_balance_updates ?policy ?liquidity_baking_escape_vote n b = +let bake_n_with_all_balance_updates ?policy ?liquidity_baking_escape_vote n b = List.fold_left_es - (fun (b, balance_updates_list) _ -> + (fun (b, balance_updates_rev) _ -> bake_with_metadata ?policy ?liquidity_baking_escape_vote b >>=? fun (b, metadata) -> - return (b, List.rev_append metadata.balance_updates balance_updates_list)) + let balance_updates_rev = + List.rev_append metadata.balance_updates balance_updates_rev + in + let balance_updates_rev = + List.fold_left + (fun balance_updates_rev -> + let open Apply_results in + function + | Successful_manager_result (Reveal_result _) + | Successful_manager_result (Delegation_result _) -> + balance_updates_rev + | Successful_manager_result + (Transaction_result {balance_updates; _}) + | Successful_manager_result + (Origination_result {balance_updates; _}) -> + List.rev_append balance_updates balance_updates_rev) + balance_updates_rev + metadata.implicit_operations_results + in + return (b, balance_updates_rev)) (b, []) (1 -- n) - >>=? fun (b, balance_updates) -> return (b, List.rev balance_updates) + >|=? fun (b, balance_updates_rev) -> (b, List.rev balance_updates_rev) let bake_until_cycle_end ?policy b = get_constants b diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 00cbac7c1fce..1e428da59f58 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -139,7 +139,7 @@ val bake_n : (** Version of bake_n that returns a list of all balance updates included in the metadata of baked blocks. **) -val bake_n_with_balance_updates : +val bake_n_with_all_balance_updates : ?policy:baker_policy -> ?liquidity_baking_escape_vote:bool -> int -> diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 0fe1e151e705..681916ea69d4 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -281,7 +281,7 @@ let liquidity_baking_balance_update () = >>=? fun csts -> let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in let sunset = csts.parametric.liquidity_baking_sunset_duration in - Block.bake_n_with_balance_updates Int32.(to_int (add sunset 100l)) blk + Block.bake_n_with_all_balance_updates Int32.(to_int (add sunset 100l)) blk >>=? fun (_blk, balance_updates) -> let liquidity_baking_updates = List.filter -- GitLab From b75a97f5d47c46bcabf07873e424cfc08746c77d Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Mon, 15 Feb 2021 18:02:43 -0500 Subject: [PATCH 57/62] liquidity baking: add record_paid_storage_space_subsidy --- .../lib_parameters/default_parameters.ml | 8 +++----- src/proto_alpha/lib_protocol/alpha_context.mli | 3 +++ src/proto_alpha/lib_protocol/apply.ml | 9 +++++---- src/proto_alpha/lib_protocol/fees_storage.ml | 13 +++++++++++++ src/proto_alpha/lib_protocol/fees_storage.mli | 8 ++++++++ src/proto_alpha/lib_protocol/raw_context.ml | 7 +++---- src/proto_alpha/lib_protocol/raw_context.mli | 2 ++ 7 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 8da3e0c28e95..2f0583e40b69 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -59,11 +59,9 @@ let constants_mainnet = delay_per_missing_endorsement = Period.of_seconds_exn 8L; liquidity_baking_cpmm_address = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) - Contract.( - originated_contract - (initial_origination_nonce - (Operation_hash.hash_bytes - [Bytes.of_string "Un festival de GADT."]))); + Contract.implicit_contract + (Signature.Public_key_hash.of_b58check_exn + "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU"); (* liquidity_baking_subsidy is 1/16th of total rewards *) liquidity_baking_subsidy = Tez.of_mutez_exn 5_000_000L; (* level after protocol activation when liquidity baking shuts off *) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 6773054b8f90..cbe0b0a058c6 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1381,6 +1381,9 @@ module Fees : sig val record_paid_storage_space : context -> Contract.t -> (context * Z.t * Z.t * Tez.t) tzresult Lwt.t + val record_paid_storage_space_subsidy : + context -> Contract.t -> (context * Z.t * Z.t) tzresult Lwt.t + val start_counting_storage_fees : context -> context val burn_storage_fees : diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 9e5ef81a6649..74d9bd89381a 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1654,10 +1654,10 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = storage lazy_storage_diff >>=? fun ctxt -> - Contract.used_storage_space + Fees.record_paid_storage_space_subsidy ctxt liquidity_baking_cpmm_contract - >>=? fun storage_size -> + >>=? fun (ctxt, new_size, paid_storage_size_diff) -> let balance_updates = [ Receipt. ( Contract liquidity_baking_cpmm_contract, @@ -1673,10 +1673,11 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = storage = Some storage; lazy_storage_diff; balance_updates; + (* At this point in application the origination nonce has not been initialized so we assume no new contracts are originated. *) originated_contracts = []; consumed_gas; - storage_size; - paid_storage_size_diff = Z.zero; + storage_size = new_size; + paid_storage_size_diff; allocated_destination_contract = false; } in diff --git a/src/proto_alpha/lib_protocol/fees_storage.ml b/src/proto_alpha/lib_protocol/fees_storage.ml index ddd82707c321..3f6f855d61e6 100644 --- a/src/proto_alpha/lib_protocol/fees_storage.ml +++ b/src/proto_alpha/lib_protocol/fees_storage.ml @@ -81,6 +81,19 @@ let record_paid_storage_space c contract = ( Tez_repr.(cost_per_byte *? Z.to_int64 to_be_paid) >|? fun to_burn -> (c, size, to_be_paid, to_burn) ) +let record_paid_storage_space_subsidy c contract = + match Raw_context.storage_space_to_pay c with + | Some _ -> + assert false + | None -> + Contract_storage.used_storage_space c contract + >>=? fun size -> + Contract_storage.set_paid_storage_space_and_return_fees_to_pay + c + contract + size + >>=? fun (to_be_paid, c) -> return (c, size, to_be_paid) + let burn_storage_fees c ~storage_limit ~payer = let origination_size = Constants_storage.origination_size c in let (c, storage_space_to_pay, allocated_contracts) = diff --git a/src/proto_alpha/lib_protocol/fees_storage.mli b/src/proto_alpha/lib_protocol/fees_storage.mli index 8e6a417c6393..a4691c5ff21b 100644 --- a/src/proto_alpha/lib_protocol/fees_storage.mli +++ b/src/proto_alpha/lib_protocol/fees_storage.mli @@ -38,6 +38,14 @@ val record_paid_storage_space : Contract_repr.t -> (Raw_context.t * Z.t * Z.t * Tez_repr.t) tzresult Lwt.t +(** Record paid storage space for contract without burn. + For use only in subsidies. + Will fail if storage_space_to_pay has been initialized.*) +val record_paid_storage_space_subsidy : + Raw_context.t -> + Contract_repr.t -> + (Raw_context.t * Z.t * Z.t) tzresult Lwt.t + val check_storage_limit : Raw_context.t -> storage_limit:Z.t -> unit tzresult val start_counting_storage_fees : Raw_context.t -> Raw_context.t diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 93d92c0feacc..90ea1e9cbde0 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -849,10 +849,9 @@ let prepare_first_block ~level ~timestamp ~fitness ctxt = delay_per_missing_endorsement = c.delay_per_missing_endorsement; liquidity_baking_cpmm_address = (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) - Contract_repr.originated_contract - (Contract_repr.initial_origination_nonce - (Operation_hash.hash_bytes - [Bytes.of_string "Un festival de GADT."])); + Contract_repr.implicit_contract + (Signature.Public_key_hash.of_b58check_exn + "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU"); liquidity_baking_subsidy = Tez_repr.of_mutez_exn 5_000_000L; liquidity_baking_sunset_duration = 262800l; liquidity_baking_escape_ema_threshold = 500_000l; diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index 50e40c91793d..255af2811ac0 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -128,6 +128,8 @@ val gas_consumed : since:t -> until:t -> Gas_limit_repr.Arith.fp val block_gas_level : t -> Gas_limit_repr.Arith.fp +val storage_space_to_pay : t -> Z.t option + val init_storage_space_to_pay : t -> t val update_storage_space_to_pay : t -> Z.t -> t -- GitLab From 27ac073cdc89d54443d2217d046f36bcf2ec7346 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Sun, 14 Mar 2021 17:25:33 -0400 Subject: [PATCH 58/62] liquidity baking: fix after rebasing --- src/proto_alpha/lib_client/mockup.ml | 155 +++++++++++++----- src/proto_alpha/lib_protocol/alpha_context.ml | 4 +- .../lib_protocol/alpha_context.mli | 2 + src/proto_alpha/lib_protocol/raw_context.ml | 4 +- ...(Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" | 20 +-- ...(Some 5) { Elt \"hello\" 4.129664940f.out" | 22 +-- ...(Some 5) { Elt \"hello\" 4.7f9778b826.out" | 22 +-- ...None { Elt \"1\" 1 ; .a8fbd9ff17.out" | 24 +-- ...None { Elt \"1\" 1 ; .cfc446b130.out" | 24 +-- ...None { Elt \"hello\" 4 })-.54dc01b7ba.out" | 22 +-- ...None {})-\"hello\"-(Pair N.c793d810c2.out" | 20 +-- ..." \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" | 32 ++-- ...ello\" \"hi\" } None)-\"\".2fe16a2420.out" | 30 ++-- ...hello\" \"hi\" } None)-\"h.9de65c712d.out" | 30 ++-- ...one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" | 30 ++-- ...one\" ; Elt \"2\" \"two\" .590c060653.out" | 30 ++-- ...one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" | 30 ++-- ...one\" ; Elt \"2\" \"two\" .bc065fddfe.out" | 30 ++-- ...one\" ; Elt \"2\" \"two\" .c83cecb062.out" | 24 +-- ...one\" ; Elt \"2\" \"two\" .d78cba5123.out" | 30 ++-- ... \"two\" }) )-(Right (Righ.3789a260e7.out" | 48 +++--- ... \"two\" }))-(Left Unit)-(.1fc7748f5b.out" | 26 +-- ... \"two\" }))-(Right (Left .45ba7bbe6e.out" | 18 +- ... \"two\" }))-(Right (Right.b11b9d15f4.out" | 44 ++--- ...Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" | 74 ++++----- ...lt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out | 26 +-- ...lt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out | 26 +-- ...lt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out | 26 +-- ...lt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out | 26 +-- ...lt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out | 26 +-- ...lt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out | 26 +-- ...lt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out | 26 +-- ...lt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out | 26 +-- ...lt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out | 26 +-- ...lt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out | 26 +-- ...air {} None)-1-(Pair 2 (Some False))0].out | 24 +-- ...air {} None)-1-(Pair 2 (Some False))1].out | 24 +-- ... \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" | 26 +-- ... \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" | 26 +-- ... \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" | 26 +-- ... \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" | 26 +-- ... \"foo\" 1 } None)-\"bar\".68bbace451.out" | 26 +-- ... None)-\"bar\"-(Pair 2 (Some False))].out" | 24 +-- tests_python/tests_alpha/protocol.py | 6 +- .../tests_alpha/test_contract_opcodes.py | 20 +-- tests_python/tests_alpha/test_migration.py | 2 +- tests_python/tests_alpha/test_mockup.py | 8 + tests_python/tests_alpha/test_voting_full.py | 23 --- tezt/_regressions/rpc/alpha.client.others.out | 10 +- .../rpc/alpha.proxy.contracts.out | 8 +- tezt/_regressions/rpc/alpha.proxy.others.out | 10 +- .../rpc/current.client.others.out | 11 +- vendors/flextesa-lib/tezos_protocol.ml | 2 +- 53 files changed, 711 insertions(+), 646 deletions(-) diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index 3b92c8b18ad0..1468a48efa8a 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -59,6 +59,10 @@ module Protocol_constants_overrides = struct min_proposal_quorum : int32 option; initial_endorsers : int option; delay_per_missing_endorsement : Period.t option; + liquidity_baking_cpmm_address : Contract.t option; + liquidity_baking_subsidy : Tez.t option; + liquidity_baking_sunset_duration : int32 option; + liquidity_baking_escape_ema_threshold : int32 option; (* Additional, "bastard" parameters (they are not protocol constants but partially treated the same way). *) chain_id : Chain_id.t option; timestamp : Time.Protocol.t option; @@ -77,25 +81,28 @@ module Protocol_constants_overrides = struct c.time_between_blocks, c.endorsers_per_block, c.hard_gas_limit_per_operation, - c.hard_gas_limit_per_block ), - ( ( c.proof_of_work_threshold, - c.tokens_per_roll, + c.hard_gas_limit_per_block, + c.proof_of_work_threshold ), + ( ( c.tokens_per_roll, c.michelson_maximum_type_size, c.seed_nonce_revelation_tip, c.origination_size, c.block_security_deposit, c.endorsement_security_deposit, - c.baking_reward_per_endorsement ), - ( c.endorsement_reward, + c.baking_reward_per_endorsement, + c.endorsement_reward, c.cost_per_byte, - c.hard_storage_limit_per_operation, - c.quorum_min, - c.quorum_max, - c.min_proposal_quorum, - c.initial_endorsers, - c.delay_per_missing_endorsement, - c.chain_id, - c.timestamp ) ) )) + c.hard_storage_limit_per_operation ), + ( ( c.quorum_min, + c.quorum_max, + c.min_proposal_quorum, + c.initial_endorsers, + c.delay_per_missing_endorsement, + c.liquidity_baking_cpmm_address, + c.liquidity_baking_subsidy, + c.liquidity_baking_sunset_duration, + c.liquidity_baking_escape_ema_threshold ), + (c.chain_id, c.timestamp) ) ) )) (fun ( ( preserved_cycles, blocks_per_cycle, blocks_per_commitment, @@ -104,25 +111,28 @@ module Protocol_constants_overrides = struct time_between_blocks, endorsers_per_block, hard_gas_limit_per_operation, - hard_gas_limit_per_block ), - ( ( proof_of_work_threshold, - tokens_per_roll, + hard_gas_limit_per_block, + proof_of_work_threshold ), + ( ( tokens_per_roll, michelson_maximum_type_size, seed_nonce_revelation_tip, origination_size, block_security_deposit, endorsement_security_deposit, - baking_reward_per_endorsement ), - ( endorsement_reward, + baking_reward_per_endorsement, + endorsement_reward, cost_per_byte, - hard_storage_limit_per_operation, - quorum_min, - quorum_max, - min_proposal_quorum, - initial_endorsers, - delay_per_missing_endorsement, - chain_id, - timestamp ) ) ) -> + hard_storage_limit_per_operation ), + ( ( quorum_min, + quorum_max, + min_proposal_quorum, + initial_endorsers, + delay_per_missing_endorsement, + liquidity_baking_cpmm_address, + liquidity_baking_subsidy, + liquidity_baking_sunset_duration, + liquidity_baking_escape_ema_threshold ), + (chain_id, timestamp) ) ) ) -> { preserved_cycles; blocks_per_cycle; @@ -149,11 +159,15 @@ module Protocol_constants_overrides = struct min_proposal_quorum; initial_endorsers; delay_per_missing_endorsement; + liquidity_baking_cpmm_address; + liquidity_baking_subsidy; + liquidity_baking_sunset_duration; + liquidity_baking_escape_ema_threshold; chain_id; timestamp; }) (merge_objs - (obj9 + (obj10 (opt "preserved_cycles" uint8) (opt "blocks_per_cycle" int32) (opt "blocks_per_commitment" int32) @@ -162,28 +176,34 @@ module Protocol_constants_overrides = struct (opt "time_between_blocks" (list Period.encoding)) (opt "endorsers_per_block" uint16) (opt "hard_gas_limit_per_operation" Gas.Arith.z_integral_encoding) - (opt "hard_gas_limit_per_block" Gas.Arith.z_integral_encoding)) + (opt "hard_gas_limit_per_block" Gas.Arith.z_integral_encoding) + (opt "proof_of_work_threshold" int64)) (merge_objs - (obj8 - (opt "proof_of_work_threshold" int64) + (obj10 (opt "tokens_per_roll" Tez.encoding) (opt "michelson_maximum_type_size" uint16) (opt "seed_nonce_revelation_tip" Tez.encoding) (opt "origination_size" int31) (opt "block_security_deposit" Tez.encoding) (opt "endorsement_security_deposit" Tez.encoding) - (opt "baking_reward_per_endorsement" (list Tez.encoding))) - (obj10 + (opt "baking_reward_per_endorsement" (list Tez.encoding)) (opt "endorsement_reward" (list Tez.encoding)) (opt "cost_per_byte" Tez.encoding) - (opt "hard_storage_limit_per_operation" z) - (opt "quorum_min" int32) - (opt "quorum_max" int32) - (opt "min_proposal_quorum" int32) - (opt "initial_endorsers" uint16) - (opt "delay_per_missing_endorsement" Period.encoding) - (opt "chain_id" Chain_id.encoding) - (opt "initial_timestamp" Time.Protocol.encoding)))) + (opt "hard_storage_limit_per_operation" z)) + (merge_objs + (obj9 + (opt "quorum_min" int32) + (opt "quorum_max" int32) + (opt "min_proposal_quorum" int32) + (opt "initial_endorsers" uint16) + (opt "delay_per_missing_endorsement" Period.encoding) + (opt "liquidity_baking_cpmm_address" Contract.encoding) + (opt "liquidity_baking_subsidy" Tez.encoding) + (opt "liquidity_baking_sunset_duration" int32) + (opt "liquidity_baking_escape_ema_threshold" int32)) + (obj2 + (opt "chain_id" Chain_id.encoding) + (opt "initial_timestamp" Time.Protocol.encoding))))) let default_value (cctxt : Tezos_client_base.Client_context.full) : t tzresult Lwt.t = @@ -230,6 +250,13 @@ module Protocol_constants_overrides = struct initial_endorsers = Some parametric.initial_endorsers; delay_per_missing_endorsement = Some parametric.delay_per_missing_endorsement; + liquidity_baking_cpmm_address = + Some parametric.liquidity_baking_cpmm_address; + liquidity_baking_subsidy = Some parametric.liquidity_baking_subsidy; + liquidity_baking_sunset_duration = + Some parametric.liquidity_baking_sunset_duration; + liquidity_baking_escape_ema_threshold = + Some parametric.liquidity_baking_escape_ema_threshold; (* Bastard, additional parameters. *) chain_id = to_chain_id_opt cpctxt#chain; timestamp = Some header.timestamp; @@ -262,6 +289,10 @@ module Protocol_constants_overrides = struct min_proposal_quorum = None; initial_endorsers = None; delay_per_missing_endorsement = None; + liquidity_baking_cpmm_address = None; + liquidity_baking_subsidy = None; + liquidity_baking_sunset_duration = None; + liquidity_baking_escape_ema_threshold = None; chain_id = None; timestamp = None; } @@ -438,6 +469,30 @@ module Protocol_constants_overrides = struct override_value = o.delay_per_missing_endorsement; pp = Period.pp; }; + O + { + name = "liquidity_baking_cpmm_address"; + override_value = o.liquidity_baking_cpmm_address; + pp = Contract.pp; + }; + O + { + name = "liquidity_baking_subsidy"; + override_value = o.liquidity_baking_subsidy; + pp = Tez.pp; + }; + O + { + name = "liquidity_baking_sunset_duration"; + override_value = o.liquidity_baking_sunset_duration; + pp = pp_print_int32; + }; + O + { + name = "liquidity_baking_escape_ema_threshold"; + override_value = o.liquidity_baking_escape_ema_threshold; + pp = pp_print_int32; + }; O {name = "chain_id"; override_value = o.chain_id; pp = Chain_id.pp}; O { @@ -532,7 +587,23 @@ module Protocol_constants_overrides = struct delay_per_missing_endorsement = Option.value ~default:c.delay_per_missing_endorsement - o.delay_per_missing_endorsement + o.delay_per_missing_endorsement; + liquidity_baking_cpmm_address = + Option.value + ~default:c.liquidity_baking_cpmm_address + o.liquidity_baking_cpmm_address; + liquidity_baking_subsidy = + Option.value + ~default:c.liquidity_baking_subsidy + o.liquidity_baking_subsidy; + liquidity_baking_sunset_duration = + Option.value + ~default:c.liquidity_baking_sunset_duration + o.liquidity_baking_sunset_duration; + liquidity_baking_escape_ema_threshold = + Option.value + ~default:c.liquidity_baking_escape_ema_threshold + o.liquidity_baking_escape_ema_threshold (* Notice that the chain_id and the timestamp are not used here as they are not protocol constants... *); } : Constants.parametric ) @@ -643,7 +714,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (req "delegate" Signature.Public_key_hash.encoding) + (opt "delegate" Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 8ed529c1640b..d9e15ea32a50 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -313,11 +313,11 @@ module Liquidity_baking = struct Int32.( add (div (mul 999l old_ema) 1000l) (if escape_vote then 1000l else 0l)) in - Storage.Liquidity_baking.Escape_ema.set ctxt new_ema + Storage.Liquidity_baking.Escape_ema.update ctxt new_ema >|=? fun ctxt -> (ctxt, new_ema) else return (ctxt, old_ema) let get_sunset_level = Storage.Liquidity_baking.Sunset_level.get - let set_sunset_level = Storage.Liquidity_baking.Sunset_level.set + let set_sunset_level = Storage.Liquidity_baking.Sunset_level.update end diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index cbe0b0a058c6..4bc85c70a960 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -858,6 +858,8 @@ module Contract : sig val initial_origination_nonce : Operation_hash.t -> origination_nonce val originated_contract : origination_nonce -> contract + + val pp : Format.formatter -> contract -> unit end module Constants : sig diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 90ea1e9cbde0..7bf35bc3e867 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -789,7 +789,7 @@ let check_and_update_protocol_version ctxt = (* only for the migration *) let get_previous_protocol_constants ctxt = - Context.get ctxt constants_key + Context.find ctxt constants_key >>= function | None -> failwith @@ -857,7 +857,7 @@ let prepare_first_block ~level ~timestamp ~fitness ctxt = liquidity_baking_escape_ema_threshold = 500_000l; } in - set_constants ctxt constants >|= ok ) + add_constants ctxt constants >|= ok ) >>=? fun ctxt -> prepare ctxt ~level ~predecessor_timestamp:timestamp ~timestamp ~fitness >|=? fun ctxt -> (previous_proto, ctxt) diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" index 8a586f2700ff..7df889c6d2ae 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 4) {})-\"hello\"-(Pa.2a2f4be41d.out" @@ -10,33 +10,33 @@ big_map diff trace - location: 11 (remaining gas: 1039988.651 units remaining) [ (Pair "hello" (Some 4) {}) ] - - location: 13 (remaining gas: 1039988.451 units remaining) + - location: 13 (remaining gas: 1039988.541 units remaining) [ "hello" @parameter (Pair (Some 4) {}) @storage ] - - location: 16 (remaining gas: 1039988.151 units remaining) + - location: 16 (remaining gas: 1039988.386 units remaining) [ (Some 4) {} ] - - location: 15 (remaining gas: 1039988.081 units remaining) + - location: 15 (remaining gas: 1039988.341 units remaining) [ (Some 4) {} ] - - location: 14 (remaining gas: 1039988.081 units remaining) + - location: 14 (remaining gas: 1039988.341 units remaining) [ "hello" @parameter (Some 4) {} ] - - location: -1 (remaining gas: 1039988.011 units remaining) + - location: -1 (remaining gas: 1039988.296 units remaining) [ "hello" @parameter (Some 4) {} ] - - location: 17 (remaining gas: 1039987.791 units remaining) + - location: 17 (remaining gas: 1039975.349 units remaining) [ None { Elt "hello" 4 } ] - - location: 18 (remaining gas: 1039987.651 units remaining) + - location: 18 (remaining gas: 1039975.274 units remaining) [ (Pair None { Elt "hello" 4 }) ] - - location: 19 (remaining gas: 1039987.511 units remaining) + - location: 19 (remaining gas: 1039975.199 units remaining) [ {} (Pair None { Elt "hello" 4 }) ] - - location: 21 (remaining gas: 1039987.371 units remaining) + - location: 21 (remaining gas: 1039975.124 units remaining) [ (Pair {} None { Elt "hello" 4 }) ] - - location: -1 (remaining gas: 1039987.301 units remaining) + - location: -1 (remaining gas: 1039975.079 units remaining) [ (Pair {} None { Elt "hello" 4 }) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" index 58ae004bc132..38d432458050 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.129664940f.out" @@ -8,35 +8,35 @@ big_map diff New map(2) of type (big_map string nat) Set map(2)["hello"] to 5 trace - - location: 11 (remaining gas: 1039988.027 units remaining) + - location: 11 (remaining gas: 1039975.271 units remaining) [ (Pair "hello" (Some 5) { Elt "hello" 4 }) ] - - location: 13 (remaining gas: 1039987.827 units remaining) + - location: 13 (remaining gas: 1039975.161 units remaining) [ "hello" @parameter (Pair (Some 5) { Elt "hello" 4 }) @storage ] - - location: 16 (remaining gas: 1039987.527 units remaining) + - location: 16 (remaining gas: 1039975.006 units remaining) [ (Some 5) { Elt "hello" 4 } ] - - location: 15 (remaining gas: 1039987.457 units remaining) + - location: 15 (remaining gas: 1039974.961 units remaining) [ (Some 5) { Elt "hello" 4 } ] - - location: 14 (remaining gas: 1039987.457 units remaining) + - location: 14 (remaining gas: 1039974.961 units remaining) [ "hello" @parameter (Some 5) { Elt "hello" 4 } ] - - location: -1 (remaining gas: 1039987.387 units remaining) + - location: -1 (remaining gas: 1039974.916 units remaining) [ "hello" @parameter (Some 5) { Elt "hello" 4 } ] - - location: 17 (remaining gas: 1039987.167 units remaining) + - location: 17 (remaining gas: 1039961.963 units remaining) [ (Some 4) { Elt "hello" 5 } ] - - location: 18 (remaining gas: 1039987.027 units remaining) + - location: 18 (remaining gas: 1039961.888 units remaining) [ (Pair (Some 4) { Elt "hello" 5 }) ] - - location: 19 (remaining gas: 1039986.887 units remaining) + - location: 19 (remaining gas: 1039961.813 units remaining) [ {} (Pair (Some 4) { Elt "hello" 5 }) ] - - location: 21 (remaining gas: 1039986.747 units remaining) + - location: 21 (remaining gas: 1039961.738 units remaining) [ (Pair {} (Some 4) { Elt "hello" 5 }) ] - - location: -1 (remaining gas: 1039986.677 units remaining) + - location: -1 (remaining gas: 1039961.693 units remaining) [ (Pair {} (Some 4) { Elt "hello" 5 }) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" index 6705d52730c4..e1f193a0d89e 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair (Some 5) { Elt \"hello\" 4.7f9778b826.out" @@ -9,35 +9,35 @@ big_map diff Set map(2)["hello"] to 4 Set map(2)["hi"] to 5 trace - - location: 11 (remaining gas: 1039988.057 units remaining) + - location: 11 (remaining gas: 1039975.301 units remaining) [ (Pair "hi" (Some 5) { Elt "hello" 4 }) ] - - location: 13 (remaining gas: 1039987.857 units remaining) + - location: 13 (remaining gas: 1039975.191 units remaining) [ "hi" @parameter (Pair (Some 5) { Elt "hello" 4 }) @storage ] - - location: 16 (remaining gas: 1039987.557 units remaining) + - location: 16 (remaining gas: 1039975.036 units remaining) [ (Some 5) { Elt "hello" 4 } ] - - location: 15 (remaining gas: 1039987.487 units remaining) + - location: 15 (remaining gas: 1039974.991 units remaining) [ (Some 5) { Elt "hello" 4 } ] - - location: 14 (remaining gas: 1039987.487 units remaining) + - location: 14 (remaining gas: 1039974.991 units remaining) [ "hi" @parameter (Some 5) { Elt "hello" 4 } ] - - location: -1 (remaining gas: 1039987.417 units remaining) + - location: -1 (remaining gas: 1039974.946 units remaining) [ "hi" @parameter (Some 5) { Elt "hello" 4 } ] - - location: 17 (remaining gas: 1039987.197 units remaining) + - location: 17 (remaining gas: 1039965.996 units remaining) [ None { Elt "hello" 4 ; Elt "hi" 5 } ] - - location: 18 (remaining gas: 1039987.057 units remaining) + - location: 18 (remaining gas: 1039965.921 units remaining) [ (Pair None { Elt "hello" 4 ; Elt "hi" 5 }) ] - - location: 19 (remaining gas: 1039986.917 units remaining) + - location: 19 (remaining gas: 1039965.846 units remaining) [ {} (Pair None { Elt "hello" 4 ; Elt "hi" 5 }) ] - - location: 21 (remaining gas: 1039986.777 units remaining) + - location: 21 (remaining gas: 1039965.771 units remaining) [ (Pair {} None { Elt "hello" 4 ; Elt "hi" 5 }) ] - - location: -1 (remaining gas: 1039986.707 units remaining) + - location: -1 (remaining gas: 1039965.726 units remaining) [ (Pair {} None { Elt "hello" 4 ; Elt "hi" 5 }) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" index 2eadf0fa1023..0899ad1ca186 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .a8fbd9ff17.out" @@ -6,38 +6,38 @@ emitted operations big_map diff New map(2) of type (big_map string nat) - Unset map(2)["1"] Set map(2)["2"] to 2 + Unset map(2)["1"] trace - - location: 11 (remaining gas: 1039987.643 units remaining) + - location: 11 (remaining gas: 1039970.137 units remaining) [ (Pair "1" None { Elt "1" 1 ; Elt "2" 2 }) ] - - location: 13 (remaining gas: 1039987.443 units remaining) + - location: 13 (remaining gas: 1039970.027 units remaining) [ "1" @parameter (Pair None { Elt "1" 1 ; Elt "2" 2 }) @storage ] - - location: 16 (remaining gas: 1039987.143 units remaining) + - location: 16 (remaining gas: 1039969.872 units remaining) [ None { Elt "1" 1 ; Elt "2" 2 } ] - - location: 15 (remaining gas: 1039987.073 units remaining) + - location: 15 (remaining gas: 1039969.827 units remaining) [ None { Elt "1" 1 ; Elt "2" 2 } ] - - location: 14 (remaining gas: 1039987.073 units remaining) + - location: 14 (remaining gas: 1039969.827 units remaining) [ "1" @parameter None { Elt "1" 1 ; Elt "2" 2 } ] - - location: -1 (remaining gas: 1039987.003 units remaining) + - location: -1 (remaining gas: 1039969.782 units remaining) [ "1" @parameter None { Elt "1" 1 ; Elt "2" 2 } ] - - location: 17 (remaining gas: 1039986.783 units remaining) + - location: 17 (remaining gas: 1039960.830 units remaining) [ (Some 1) { Elt "2" 2 } ] - - location: 18 (remaining gas: 1039986.643 units remaining) + - location: 18 (remaining gas: 1039960.755 units remaining) [ (Pair (Some 1) { Elt "2" 2 }) ] - - location: 19 (remaining gas: 1039986.503 units remaining) + - location: 19 (remaining gas: 1039960.680 units remaining) [ {} (Pair (Some 1) { Elt "2" 2 }) ] - - location: 21 (remaining gas: 1039986.363 units remaining) + - location: 21 (remaining gas: 1039960.605 units remaining) [ (Pair {} (Some 1) { Elt "2" 2 }) ] - - location: -1 (remaining gas: 1039986.293 units remaining) + - location: -1 (remaining gas: 1039960.560 units remaining) [ (Pair {} (Some 1) { Elt "2" 2 }) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" index 3982a72aa928..ebfd3711cb57 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"1\" 1 ; .cfc446b130.out" @@ -6,38 +6,38 @@ emitted operations big_map diff New map(2) of type (big_map string nat) - Unset map(2)["1"] Set map(2)["2"] to 2 + Unset map(2)["1"] trace - - location: 11 (remaining gas: 1039987.643 units remaining) + - location: 11 (remaining gas: 1039970.137 units remaining) [ (Pair "1" None { Elt "1" 1 ; Elt "2" 2 }) ] - - location: 13 (remaining gas: 1039987.443 units remaining) + - location: 13 (remaining gas: 1039970.027 units remaining) [ "1" @parameter (Pair None { Elt "1" 1 ; Elt "2" 2 }) @storage ] - - location: 16 (remaining gas: 1039987.143 units remaining) + - location: 16 (remaining gas: 1039969.872 units remaining) [ None { Elt "1" 1 ; Elt "2" 2 } ] - - location: 15 (remaining gas: 1039987.073 units remaining) + - location: 15 (remaining gas: 1039969.827 units remaining) [ None { Elt "1" 1 ; Elt "2" 2 } ] - - location: 14 (remaining gas: 1039987.073 units remaining) + - location: 14 (remaining gas: 1039969.827 units remaining) [ "1" @parameter None { Elt "1" 1 ; Elt "2" 2 } ] - - location: -1 (remaining gas: 1039987.003 units remaining) + - location: -1 (remaining gas: 1039969.782 units remaining) [ "1" @parameter None { Elt "1" 1 ; Elt "2" 2 } ] - - location: 17 (remaining gas: 1039986.783 units remaining) + - location: 17 (remaining gas: 1039960.830 units remaining) [ (Some 1) { Elt "2" 2 } ] - - location: 18 (remaining gas: 1039986.643 units remaining) + - location: 18 (remaining gas: 1039960.755 units remaining) [ (Pair (Some 1) { Elt "2" 2 }) ] - - location: 19 (remaining gas: 1039986.503 units remaining) + - location: 19 (remaining gas: 1039960.680 units remaining) [ {} (Pair (Some 1) { Elt "2" 2 }) ] - - location: 21 (remaining gas: 1039986.363 units remaining) + - location: 21 (remaining gas: 1039960.605 units remaining) [ (Pair {} (Some 1) { Elt "2" 2 }) ] - - location: -1 (remaining gas: 1039986.293 units remaining) + - location: -1 (remaining gas: 1039960.560 units remaining) [ (Pair {} (Some 1) { Elt "2" 2 }) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" index 9c0bbdff2930..6a32b6abdacf 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None { Elt \"hello\" 4 })-.54dc01b7ba.out" @@ -8,35 +8,35 @@ big_map diff New map(2) of type (big_map string nat) Unset map(2)["hello"] trace - - location: 11 (remaining gas: 1039988.267 units remaining) + - location: 11 (remaining gas: 1039975.511 units remaining) [ (Pair "hello" None { Elt "hello" 4 }) ] - - location: 13 (remaining gas: 1039988.067 units remaining) + - location: 13 (remaining gas: 1039975.401 units remaining) [ "hello" @parameter (Pair None { Elt "hello" 4 }) @storage ] - - location: 16 (remaining gas: 1039987.767 units remaining) + - location: 16 (remaining gas: 1039975.246 units remaining) [ None { Elt "hello" 4 } ] - - location: 15 (remaining gas: 1039987.697 units remaining) + - location: 15 (remaining gas: 1039975.201 units remaining) [ None { Elt "hello" 4 } ] - - location: 14 (remaining gas: 1039987.697 units remaining) + - location: 14 (remaining gas: 1039975.201 units remaining) [ "hello" @parameter None { Elt "hello" 4 } ] - - location: -1 (remaining gas: 1039987.627 units remaining) + - location: -1 (remaining gas: 1039975.156 units remaining) [ "hello" @parameter None { Elt "hello" 4 } ] - - location: 17 (remaining gas: 1039987.407 units remaining) + - location: 17 (remaining gas: 1039962.203 units remaining) [ (Some 4) {} ] - - location: 18 (remaining gas: 1039987.267 units remaining) + - location: 18 (remaining gas: 1039962.128 units remaining) [ (Pair (Some 4) {}) ] - - location: 19 (remaining gas: 1039987.127 units remaining) + - location: 19 (remaining gas: 1039962.053 units remaining) [ {} (Pair (Some 4) {}) ] - - location: 21 (remaining gas: 1039986.987 units remaining) + - location: 21 (remaining gas: 1039961.978 units remaining) [ (Pair {} (Some 4) {}) ] - - location: -1 (remaining gas: 1039986.917 units remaining) + - location: -1 (remaining gas: 1039961.933 units remaining) [ (Pair {} (Some 4) {}) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" index 0faab32663bf..0464e82f91f5 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_and_update_big_map.tz-(Pair None {})-\"hello\"-(Pair N.c793d810c2.out" @@ -10,33 +10,33 @@ big_map diff trace - location: 11 (remaining gas: 1039988.891 units remaining) [ (Pair "hello" None {}) ] - - location: 13 (remaining gas: 1039988.691 units remaining) + - location: 13 (remaining gas: 1039988.781 units remaining) [ "hello" @parameter (Pair None {}) @storage ] - - location: 16 (remaining gas: 1039988.391 units remaining) + - location: 16 (remaining gas: 1039988.626 units remaining) [ None {} ] - - location: 15 (remaining gas: 1039988.321 units remaining) + - location: 15 (remaining gas: 1039988.581 units remaining) [ None {} ] - - location: 14 (remaining gas: 1039988.321 units remaining) + - location: 14 (remaining gas: 1039988.581 units remaining) [ "hello" @parameter None {} ] - - location: -1 (remaining gas: 1039988.251 units remaining) + - location: -1 (remaining gas: 1039988.536 units remaining) [ "hello" @parameter None {} ] - - location: 17 (remaining gas: 1039988.031 units remaining) + - location: 17 (remaining gas: 1039975.589 units remaining) [ None {} ] - - location: 18 (remaining gas: 1039987.891 units remaining) + - location: 18 (remaining gas: 1039975.514 units remaining) [ (Pair None {}) ] - - location: 19 (remaining gas: 1039987.751 units remaining) + - location: 19 (remaining gas: 1039975.439 units remaining) [ {} (Pair None {}) ] - - location: 21 (remaining gas: 1039987.611 units remaining) + - location: 21 (remaining gas: 1039975.364 units remaining) [ (Pair {} None {}) ] - - location: -1 (remaining gas: 1039987.541 units remaining) + - location: -1 (remaining gas: 1039975.319 units remaining) [ (Pair {} None {}) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" index bc090f905c36..c323c3392688 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"tw.5f65a574b4.out" @@ -6,46 +6,46 @@ emitted operations big_map diff New map(2) of type (big_map string string) - Set map(2)["1"] to "one" Set map(2)["2"] to "two" + Set map(2)["1"] to "one" trace - - location: 11 (remaining gas: 1039982.525 units remaining) + - location: 11 (remaining gas: 1039965.019 units remaining) [ (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) ] - - location: 12 (remaining gas: 1039982.385 units remaining) + - location: 12 (remaining gas: 1039964.939 units remaining) [ (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) ] - - location: 13 (remaining gas: 1039982.245 units remaining) + - location: 13 (remaining gas: 1039964.859 units remaining) [ "1" @parameter (Pair "1" { Elt "1" "one" ; Elt "2" "two" } None) ] - - location: 17 (remaining gas: 1039981.885 units remaining) + - location: 17 (remaining gas: 1039964.674 units remaining) [ (Pair { Elt "1" "one" ; Elt "2" "two" } None) @storage ] - - location: 18 (remaining gas: 1039981.745 units remaining) + - location: 18 (remaining gas: 1039964.594 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } ] - - location: -1 (remaining gas: 1039981.675 units remaining) + - location: -1 (remaining gas: 1039964.549 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } ] - - location: 19 (remaining gas: 1039981.535 units remaining) + - location: 19 (remaining gas: 1039964.469 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } { Elt "1" "one" ; Elt "2" "two" } ] - - location: -1 (remaining gas: 1039981.465 units remaining) + - location: -1 (remaining gas: 1039964.424 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } { Elt "1" "one" ; Elt "2" "two" } ] - - location: 14 (remaining gas: 1039981.465 units remaining) + - location: 14 (remaining gas: 1039964.424 units remaining) [ "1" @parameter { Elt "1" "one" ; Elt "2" "two" } { Elt "1" "one" ; Elt "2" "two" } ] - - location: 20 (remaining gas: 1039981.325 units remaining) + - location: 20 (remaining gas: 1039955.562 units remaining) [ (Some "one") { Elt "1" "one" ; Elt "2" "two" } ] - - location: 21 (remaining gas: 1039981.195 units remaining) + - location: 21 (remaining gas: 1039955.492 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } (Some "one") ] - - location: 22 (remaining gas: 1039981.055 units remaining) + - location: 22 (remaining gas: 1039955.417 units remaining) [ (Pair { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] - - location: 23 (remaining gas: 1039980.915 units remaining) + - location: 23 (remaining gas: 1039955.342 units remaining) [ {} (Pair { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] - - location: 25 (remaining gas: 1039980.775 units remaining) + - location: 25 (remaining gas: 1039955.267 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] - - location: -1 (remaining gas: 1039980.705 units remaining) + - location: -1 (remaining gas: 1039955.222 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } (Some "one")) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" index d290e4c0cc2b..e5790d757d2e 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"\".2fe16a2420.out" @@ -8,43 +8,43 @@ big_map diff New map(2) of type (big_map string string) Set map(2)["hello"] to "hi" trace - - location: 11 (remaining gas: 1039983.253 units remaining) + - location: 11 (remaining gas: 1039970.497 units remaining) [ (Pair "" { Elt "hello" "hi" } None) ] - - location: 12 (remaining gas: 1039983.113 units remaining) + - location: 12 (remaining gas: 1039970.417 units remaining) [ (Pair "" { Elt "hello" "hi" } None) (Pair "" { Elt "hello" "hi" } None) ] - - location: 13 (remaining gas: 1039982.973 units remaining) + - location: 13 (remaining gas: 1039970.337 units remaining) [ "" @parameter (Pair "" { Elt "hello" "hi" } None) ] - - location: 17 (remaining gas: 1039982.613 units remaining) + - location: 17 (remaining gas: 1039970.152 units remaining) [ (Pair { Elt "hello" "hi" } None) @storage ] - - location: 18 (remaining gas: 1039982.473 units remaining) + - location: 18 (remaining gas: 1039970.072 units remaining) [ { Elt "hello" "hi" } ] - - location: -1 (remaining gas: 1039982.403 units remaining) + - location: -1 (remaining gas: 1039970.027 units remaining) [ { Elt "hello" "hi" } ] - - location: 19 (remaining gas: 1039982.263 units remaining) + - location: 19 (remaining gas: 1039969.947 units remaining) [ { Elt "hello" "hi" } { Elt "hello" "hi" } ] - - location: -1 (remaining gas: 1039982.193 units remaining) + - location: -1 (remaining gas: 1039969.902 units remaining) [ { Elt "hello" "hi" } { Elt "hello" "hi" } ] - - location: 14 (remaining gas: 1039982.193 units remaining) + - location: 14 (remaining gas: 1039969.902 units remaining) [ "" @parameter { Elt "hello" "hi" } { Elt "hello" "hi" } ] - - location: 20 (remaining gas: 1039982.053 units remaining) + - location: 20 (remaining gas: 1039961.042 units remaining) [ None { Elt "hello" "hi" } ] - - location: 21 (remaining gas: 1039981.923 units remaining) + - location: 21 (remaining gas: 1039960.972 units remaining) [ { Elt "hello" "hi" } None ] - - location: 22 (remaining gas: 1039981.783 units remaining) + - location: 22 (remaining gas: 1039960.897 units remaining) [ (Pair { Elt "hello" "hi" } None) ] - - location: 23 (remaining gas: 1039981.643 units remaining) + - location: 23 (remaining gas: 1039960.822 units remaining) [ {} (Pair { Elt "hello" "hi" } None) ] - - location: 25 (remaining gas: 1039981.503 units remaining) + - location: 25 (remaining gas: 1039960.747 units remaining) [ (Pair {} { Elt "hello" "hi" } None) ] - - location: -1 (remaining gas: 1039981.433 units remaining) + - location: -1 (remaining gas: 1039960.702 units remaining) [ (Pair {} { Elt "hello" "hi" } None) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" index 4566dc427fc2..350698218027 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[get_big_map_value.tz-(Pair { Elt \"hello\" \"hi\" } None)-\"h.9de65c712d.out" @@ -8,43 +8,43 @@ big_map diff New map(2) of type (big_map string string) Set map(2)["hello"] to "hi" trace - - location: 11 (remaining gas: 1039983.203 units remaining) + - location: 11 (remaining gas: 1039970.447 units remaining) [ (Pair "hello" { Elt "hello" "hi" } None) ] - - location: 12 (remaining gas: 1039983.063 units remaining) + - location: 12 (remaining gas: 1039970.367 units remaining) [ (Pair "hello" { Elt "hello" "hi" } None) (Pair "hello" { Elt "hello" "hi" } None) ] - - location: 13 (remaining gas: 1039982.923 units remaining) + - location: 13 (remaining gas: 1039970.287 units remaining) [ "hello" @parameter (Pair "hello" { Elt "hello" "hi" } None) ] - - location: 17 (remaining gas: 1039982.563 units remaining) + - location: 17 (remaining gas: 1039970.102 units remaining) [ (Pair { Elt "hello" "hi" } None) @storage ] - - location: 18 (remaining gas: 1039982.423 units remaining) + - location: 18 (remaining gas: 1039970.022 units remaining) [ { Elt "hello" "hi" } ] - - location: -1 (remaining gas: 1039982.353 units remaining) + - location: -1 (remaining gas: 1039969.977 units remaining) [ { Elt "hello" "hi" } ] - - location: 19 (remaining gas: 1039982.213 units remaining) + - location: 19 (remaining gas: 1039969.897 units remaining) [ { Elt "hello" "hi" } { Elt "hello" "hi" } ] - - location: -1 (remaining gas: 1039982.143 units remaining) + - location: -1 (remaining gas: 1039969.852 units remaining) [ { Elt "hello" "hi" } { Elt "hello" "hi" } ] - - location: 14 (remaining gas: 1039982.143 units remaining) + - location: 14 (remaining gas: 1039969.852 units remaining) [ "hello" @parameter { Elt "hello" "hi" } { Elt "hello" "hi" } ] - - location: 20 (remaining gas: 1039982.003 units remaining) + - location: 20 (remaining gas: 1039956.986 units remaining) [ (Some "hi") { Elt "hello" "hi" } ] - - location: 21 (remaining gas: 1039981.873 units remaining) + - location: 21 (remaining gas: 1039956.916 units remaining) [ { Elt "hello" "hi" } (Some "hi") ] - - location: 22 (remaining gas: 1039981.733 units remaining) + - location: 22 (remaining gas: 1039956.841 units remaining) [ (Pair { Elt "hello" "hi" } (Some "hi")) ] - - location: 23 (remaining gas: 1039981.593 units remaining) + - location: 23 (remaining gas: 1039956.766 units remaining) [ {} (Pair { Elt "hello" "hi" } (Some "hi")) ] - - location: 25 (remaining gas: 1039981.453 units remaining) + - location: 25 (remaining gas: 1039956.691 units remaining) [ (Pair {} { Elt "hello" "hi" } (Some "hi")) ] - - location: -1 (remaining gas: 1039981.383 units remaining) + - location: -1 (remaining gas: 1039956.646 units remaining) [ (Pair {} { Elt "hello" "hi" } (Some "hi")) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" index 6033bee05579..68c555cd1f65 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .1dee6b3dbf.out" @@ -6,49 +6,49 @@ emitted operations big_map diff New map(2) of type (big_map string string) - Set map(2)["1"] to "two" Set map(2)["2"] to "two" + Set map(2)["1"] to "two" trace - - location: 13 (remaining gas: 1039984.481 units remaining) + - location: 13 (remaining gas: 1039966.975 units remaining) [ (Pair { Elt "1" (Some "two") } { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 15 (remaining gas: 1039984.281 units remaining) + - location: 15 (remaining gas: 1039966.865 units remaining) [ { Elt "1" (Some "two") } @parameter (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] - - location: 18 (remaining gas: 1039983.981 units remaining) + - location: 18 (remaining gas: 1039966.710 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 17 (remaining gas: 1039983.911 units remaining) + - location: 17 (remaining gas: 1039966.665 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 16 (remaining gas: 1039983.911 units remaining) + - location: 16 (remaining gas: 1039966.665 units remaining) [ { Elt "1" (Some "two") } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039983.841 units remaining) + - location: -1 (remaining gas: 1039966.620 units remaining) [ { Elt "1" (Some "two") } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 21 (remaining gas: 1039983.521 units remaining) + - location: 21 (remaining gas: 1039966.390 units remaining) [ "1" @key (Some "two") @elt { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 22 (remaining gas: 1039983.381 units remaining) + - location: 22 (remaining gas: 1039957.522 units remaining) [ { Elt "1" "two" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039983.311 units remaining) + - location: -1 (remaining gas: 1039957.477 units remaining) [ { Elt "1" "two" ; Elt "2" "two" } Unit ] - - location: 19 (remaining gas: 1039983.311 units remaining) + - location: 19 (remaining gas: 1039957.477 units remaining) [ { Elt "1" "two" ; Elt "2" "two" } Unit ] - - location: 23 (remaining gas: 1039983.171 units remaining) + - location: 23 (remaining gas: 1039957.402 units remaining) [ (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] - - location: 24 (remaining gas: 1039983.031 units remaining) + - location: 24 (remaining gas: 1039957.327 units remaining) [ {} (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] - - location: 26 (remaining gas: 1039982.891 units remaining) + - location: 26 (remaining gas: 1039957.252 units remaining) [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] - - location: -1 (remaining gas: 1039982.821 units remaining) + - location: -1 (remaining gas: 1039957.207 units remaining) [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" index 1f69ec8b8406..656550a8eed8 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .590c060653.out" @@ -6,49 +6,49 @@ emitted operations big_map diff New map(2) of type (big_map string string) - Set map(2)["1"] to "two" Set map(2)["2"] to "two" + Set map(2)["1"] to "two" trace - - location: 13 (remaining gas: 1039984.481 units remaining) + - location: 13 (remaining gas: 1039966.975 units remaining) [ (Pair { Elt "1" (Some "two") } { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 15 (remaining gas: 1039984.281 units remaining) + - location: 15 (remaining gas: 1039966.865 units remaining) [ { Elt "1" (Some "two") } @parameter (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] - - location: 18 (remaining gas: 1039983.981 units remaining) + - location: 18 (remaining gas: 1039966.710 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 17 (remaining gas: 1039983.911 units remaining) + - location: 17 (remaining gas: 1039966.665 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 16 (remaining gas: 1039983.911 units remaining) + - location: 16 (remaining gas: 1039966.665 units remaining) [ { Elt "1" (Some "two") } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039983.841 units remaining) + - location: -1 (remaining gas: 1039966.620 units remaining) [ { Elt "1" (Some "two") } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 21 (remaining gas: 1039983.521 units remaining) + - location: 21 (remaining gas: 1039966.390 units remaining) [ "1" @key (Some "two") @elt { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 22 (remaining gas: 1039983.381 units remaining) + - location: 22 (remaining gas: 1039957.522 units remaining) [ { Elt "1" "two" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039983.311 units remaining) + - location: -1 (remaining gas: 1039957.477 units remaining) [ { Elt "1" "two" ; Elt "2" "two" } Unit ] - - location: 19 (remaining gas: 1039983.311 units remaining) + - location: 19 (remaining gas: 1039957.477 units remaining) [ { Elt "1" "two" ; Elt "2" "two" } Unit ] - - location: 23 (remaining gas: 1039983.171 units remaining) + - location: 23 (remaining gas: 1039957.402 units remaining) [ (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] - - location: 24 (remaining gas: 1039983.031 units remaining) + - location: 24 (remaining gas: 1039957.327 units remaining) [ {} (Pair { Elt "1" "two" ; Elt "2" "two" } Unit) ] - - location: 26 (remaining gas: 1039982.891 units remaining) + - location: 26 (remaining gas: 1039957.252 units remaining) [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] - - location: -1 (remaining gas: 1039982.821 units remaining) + - location: -1 (remaining gas: 1039957.207 units remaining) [ (Pair {} { Elt "1" "two" ; Elt "2" "two" } Unit) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" index 9c1f5a190693..70366c8517e4 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .85f2ff1a40.out" @@ -6,50 +6,50 @@ emitted operations big_map diff New map(2) of type (big_map string string) - Set map(2)["1"] to "one" Set map(2)["2"] to "two" Unset map(2)["3"] + Set map(2)["1"] to "one" trace - - location: 13 (remaining gas: 1039984.765 units remaining) + - location: 13 (remaining gas: 1039967.259 units remaining) [ (Pair { Elt "3" None } { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 15 (remaining gas: 1039984.565 units remaining) + - location: 15 (remaining gas: 1039967.149 units remaining) [ { Elt "3" None } @parameter (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] - - location: 18 (remaining gas: 1039984.265 units remaining) + - location: 18 (remaining gas: 1039966.994 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 17 (remaining gas: 1039984.195 units remaining) + - location: 17 (remaining gas: 1039966.949 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 16 (remaining gas: 1039984.195 units remaining) + - location: 16 (remaining gas: 1039966.949 units remaining) [ { Elt "3" None } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039984.125 units remaining) + - location: -1 (remaining gas: 1039966.904 units remaining) [ { Elt "3" None } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 21 (remaining gas: 1039983.805 units remaining) + - location: 21 (remaining gas: 1039966.674 units remaining) [ "3" @key None @elt { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 22 (remaining gas: 1039983.665 units remaining) + - location: 22 (remaining gas: 1039957.806 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039983.595 units remaining) + - location: -1 (remaining gas: 1039957.761 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 19 (remaining gas: 1039983.595 units remaining) + - location: 19 (remaining gas: 1039957.761 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 23 (remaining gas: 1039983.455 units remaining) + - location: 23 (remaining gas: 1039957.686 units remaining) [ (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 24 (remaining gas: 1039983.315 units remaining) + - location: 24 (remaining gas: 1039957.611 units remaining) [ {} (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 26 (remaining gas: 1039983.175 units remaining) + - location: 26 (remaining gas: 1039957.536 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: -1 (remaining gas: 1039983.105 units remaining) + - location: -1 (remaining gas: 1039957.491 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" index 20d0ab72edd1..00810e4f533a 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .bc065fddfe.out" @@ -6,49 +6,49 @@ emitted operations big_map diff New map(2) of type (big_map string string) - Set map(2)["1"] to "one" Unset map(2)["2"] + Set map(2)["1"] to "one" trace - - location: 13 (remaining gas: 1039984.765 units remaining) + - location: 13 (remaining gas: 1039967.259 units remaining) [ (Pair { Elt "2" None } { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 15 (remaining gas: 1039984.565 units remaining) + - location: 15 (remaining gas: 1039967.149 units remaining) [ { Elt "2" None } @parameter (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] - - location: 18 (remaining gas: 1039984.265 units remaining) + - location: 18 (remaining gas: 1039966.994 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 17 (remaining gas: 1039984.195 units remaining) + - location: 17 (remaining gas: 1039966.949 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 16 (remaining gas: 1039984.195 units remaining) + - location: 16 (remaining gas: 1039966.949 units remaining) [ { Elt "2" None } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039984.125 units remaining) + - location: -1 (remaining gas: 1039966.904 units remaining) [ { Elt "2" None } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 21 (remaining gas: 1039983.805 units remaining) + - location: 21 (remaining gas: 1039966.674 units remaining) [ "2" @key None @elt { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 22 (remaining gas: 1039983.665 units remaining) + - location: 22 (remaining gas: 1039957.806 units remaining) [ { Elt "1" "one" } Unit ] - - location: -1 (remaining gas: 1039983.595 units remaining) + - location: -1 (remaining gas: 1039957.761 units remaining) [ { Elt "1" "one" } Unit ] - - location: 19 (remaining gas: 1039983.595 units remaining) + - location: 19 (remaining gas: 1039957.761 units remaining) [ { Elt "1" "one" } Unit ] - - location: 23 (remaining gas: 1039983.455 units remaining) + - location: 23 (remaining gas: 1039957.686 units remaining) [ (Pair { Elt "1" "one" } Unit) ] - - location: 24 (remaining gas: 1039983.315 units remaining) + - location: 24 (remaining gas: 1039957.611 units remaining) [ {} (Pair { Elt "1" "one" } Unit) ] - - location: 26 (remaining gas: 1039983.175 units remaining) + - location: 26 (remaining gas: 1039957.536 units remaining) [ (Pair {} { Elt "1" "one" } Unit) ] - - location: -1 (remaining gas: 1039983.105 units remaining) + - location: -1 (remaining gas: 1039957.491 units remaining) [ (Pair {} { Elt "1" "one" } Unit) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" index a7f394d8fe2c..d02a1b139c49 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .c83cecb062.out" @@ -6,38 +6,38 @@ emitted operations big_map diff New map(2) of type (big_map string string) - Set map(2)["1"] to "one" Set map(2)["2"] to "two" + Set map(2)["1"] to "one" trace - - location: 13 (remaining gas: 1039985.349 units remaining) + - location: 13 (remaining gas: 1039967.843 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 15 (remaining gas: 1039985.149 units remaining) + - location: 15 (remaining gas: 1039967.733 units remaining) [ {} @parameter (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] - - location: 18 (remaining gas: 1039984.849 units remaining) + - location: 18 (remaining gas: 1039967.578 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 17 (remaining gas: 1039984.779 units remaining) + - location: 17 (remaining gas: 1039967.533 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 16 (remaining gas: 1039984.779 units remaining) + - location: 16 (remaining gas: 1039967.533 units remaining) [ {} @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039984.709 units remaining) + - location: -1 (remaining gas: 1039967.488 units remaining) [ {} @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 19 (remaining gas: 1039984.569 units remaining) + - location: 19 (remaining gas: 1039967.378 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 23 (remaining gas: 1039984.429 units remaining) + - location: 23 (remaining gas: 1039967.303 units remaining) [ (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 24 (remaining gas: 1039984.289 units remaining) + - location: 24 (remaining gas: 1039967.228 units remaining) [ {} (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 26 (remaining gas: 1039984.149 units remaining) + - location: 26 (remaining gas: 1039967.153 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: -1 (remaining gas: 1039984.079 units remaining) + - location: -1 (remaining gas: 1039967.108 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" } Unit) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" index 6b4a90a25ea2..129892bb1202 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test__big_map_contract_io[update_big_map.tz-(Pair { Elt \"1\" \"one\" ; Elt \"2\" \"two\" .d78cba5123.out" @@ -6,50 +6,50 @@ emitted operations big_map diff New map(2) of type (big_map string string) - Set map(2)["1"] to "one" Set map(2)["2"] to "two" Set map(2)["3"] to "three" + Set map(2)["1"] to "one" trace - - location: 13 (remaining gas: 1039984.461 units remaining) + - location: 13 (remaining gas: 1039966.955 units remaining) [ (Pair { Elt "3" (Some "three") } { Elt "1" "one" ; Elt "2" "two" } Unit) ] - - location: 15 (remaining gas: 1039984.261 units remaining) + - location: 15 (remaining gas: 1039966.845 units remaining) [ { Elt "3" (Some "three") } @parameter (Pair { Elt "1" "one" ; Elt "2" "two" } Unit) @storage ] - - location: 18 (remaining gas: 1039983.961 units remaining) + - location: 18 (remaining gas: 1039966.690 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 17 (remaining gas: 1039983.891 units remaining) + - location: 17 (remaining gas: 1039966.645 units remaining) [ { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 16 (remaining gas: 1039983.891 units remaining) + - location: 16 (remaining gas: 1039966.645 units remaining) [ { Elt "3" (Some "three") } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: -1 (remaining gas: 1039983.821 units remaining) + - location: -1 (remaining gas: 1039966.600 units remaining) [ { Elt "3" (Some "three") } @parameter { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 21 (remaining gas: 1039983.501 units remaining) + - location: 21 (remaining gas: 1039966.370 units remaining) [ "3" @key (Some "three") @elt { Elt "1" "one" ; Elt "2" "two" } Unit ] - - location: 22 (remaining gas: 1039983.361 units remaining) + - location: 22 (remaining gas: 1039957.502 units remaining) [ { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit ] - - location: -1 (remaining gas: 1039983.291 units remaining) + - location: -1 (remaining gas: 1039957.457 units remaining) [ { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit ] - - location: 19 (remaining gas: 1039983.291 units remaining) + - location: 19 (remaining gas: 1039957.457 units remaining) [ { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit ] - - location: 23 (remaining gas: 1039983.151 units remaining) + - location: 23 (remaining gas: 1039957.382 units remaining) [ (Pair { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] - - location: 24 (remaining gas: 1039983.011 units remaining) + - location: 24 (remaining gas: 1039957.307 units remaining) [ {} (Pair { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] - - location: 26 (remaining gas: 1039982.871 units remaining) + - location: 26 (remaining gas: 1039957.232 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] - - location: -1 (remaining gas: 1039982.801 units remaining) + - location: -1 (remaining gas: 1039957.187 units remaining) [ (Pair {} { Elt "1" "one" ; Elt "2" "two" ; Elt "3" "three" } Unit) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" index 7e0bbd7f4a8e..222592f4c619 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }) )-(Right (Righ.3789a260e7.out" @@ -8,73 +8,73 @@ big_map diff New map(3) of type (big_map string string) Set map(3)["2"] to "two" New map(2) of type (big_map string string) - Set map(2)["1"] to "one" Set map(2)["3"] to "three" + Set map(2)["1"] to "one" trace - - location: 42 (remaining gas: 1039921.281 units remaining) + - location: 42 (remaining gas: 1039903.779 units remaining) [ (Pair (Right (Right (Right (Left { Pair "3" "three" })))) (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] - - location: 43 (remaining gas: 1039921.141 units remaining) + - location: 43 (remaining gas: 1039903.699 units remaining) [ (Right (Right (Right (Left { Pair "3" "three" })))) @parameter (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] - - location: 114 (remaining gas: 1039920.101 units remaining) + - location: 114 (remaining gas: 1039903.249 units remaining) [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] - - location: 112 (remaining gas: 1039920.031 units remaining) + - location: 112 (remaining gas: 1039903.204 units remaining) [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] - - location: 119 (remaining gas: 1039919.891 units remaining) + - location: 119 (remaining gas: 1039903.124 units remaining) [ { Elt "1" "one" } { Elt "2" "two" } ] - - location: -1 (remaining gas: 1039919.821 units remaining) + - location: -1 (remaining gas: 1039903.079 units remaining) [ { Elt "1" "one" } { Elt "2" "two" } ] - - location: 110 (remaining gas: 1039919.821 units remaining) + - location: 110 (remaining gas: 1039903.079 units remaining) [ { Pair "3" "three" } @parameter.right.right.right.add { Elt "1" "one" } { Elt "2" "two" } ] - - location: 122 (remaining gas: 1039919.114 units remaining) + - location: 122 (remaining gas: 1039902.462 units remaining) [ "3" "three" { Elt "1" "one" } { Elt "2" "two" } ] - - location: 125 (remaining gas: 1039918.814 units remaining) + - location: 125 (remaining gas: 1039902.312 units remaining) [ (Some "three") { Elt "1" "one" } { Elt "2" "two" } ] - - location: 124 (remaining gas: 1039918.744 units remaining) + - location: 124 (remaining gas: 1039902.267 units remaining) [ (Some "three") { Elt "1" "one" } { Elt "2" "two" } ] - - location: 123 (remaining gas: 1039918.744 units remaining) + - location: 123 (remaining gas: 1039902.267 units remaining) [ "3" (Some "three") { Elt "1" "one" } { Elt "2" "two" } ] - - location: 126 (remaining gas: 1039918.604 units remaining) + - location: 126 (remaining gas: 1039893.402 units remaining) [ { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" } ] - - location: -1 (remaining gas: 1039918.534 units remaining) + - location: -1 (remaining gas: 1039893.357 units remaining) [ { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" } ] - - location: 120 (remaining gas: 1039918.534 units remaining) + - location: 120 (remaining gas: 1039893.357 units remaining) [ { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" } ] - - location: 127 (remaining gas: 1039918.394 units remaining) + - location: 127 (remaining gas: 1039893.282 units remaining) [ (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" }) ] - - location: 128 (remaining gas: 1039918.254 units remaining) + - location: 128 (remaining gas: 1039893.207 units remaining) [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] - - location: -1 (remaining gas: 1039918.184 units remaining) + - location: -1 (remaining gas: 1039893.162 units remaining) [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] - - location: 107 (remaining gas: 1039918.114 units remaining) + - location: 107 (remaining gas: 1039893.117 units remaining) [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] - - location: 64 (remaining gas: 1039918.044 units remaining) + - location: 64 (remaining gas: 1039893.072 units remaining) [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] - - location: 59 (remaining gas: 1039917.974 units remaining) + - location: 59 (remaining gas: 1039893.027 units remaining) [ (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] - - location: 151 (remaining gas: 1039917.834 units remaining) + - location: 151 (remaining gas: 1039892.952 units remaining) [ {} (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" })) ] - - location: 153 (remaining gas: 1039917.694 units remaining) + - location: 153 (remaining gas: 1039892.877 units remaining) [ (Pair {} (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" }))) ] - - location: -1 (remaining gas: 1039917.624 units remaining) + - location: -1 (remaining gas: 1039892.832 units remaining) [ (Pair {} (Left (Pair { Elt "1" "one" ; Elt "3" "three" } { Elt "2" "two" }))) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" index 9538d38c832d..52e8833a6f41 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Left Unit)-(.1fc7748f5b.out" @@ -10,34 +10,34 @@ big_map diff New map(2) of type (big_map string string) Set map(2)["2"] to "two" trace - - location: 42 (remaining gas: 1039923.184 units remaining) + - location: 42 (remaining gas: 1039905.682 units remaining) [ (Pair (Left Unit) (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] - - location: 43 (remaining gas: 1039923.044 units remaining) + - location: 43 (remaining gas: 1039905.602 units remaining) [ (Left Unit) @parameter (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] - - location: 46 (remaining gas: 1039922.754 units remaining) + - location: 46 (remaining gas: 1039905.467 units remaining) [ (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] - - location: 49 (remaining gas: 1039922.474 units remaining) + - location: 49 (remaining gas: 1039905.332 units remaining) [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] - - location: 47 (remaining gas: 1039922.404 units remaining) + - location: 47 (remaining gas: 1039905.287 units remaining) [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] - - location: 54 (remaining gas: 1039922.264 units remaining) + - location: 54 (remaining gas: 1039905.207 units remaining) [ { Elt "1" "one" } { Elt "2" "two" } ] - - location: 55 (remaining gas: 1039922.134 units remaining) + - location: 55 (remaining gas: 1039905.137 units remaining) [ { Elt "2" "two" } { Elt "1" "one" } ] - - location: 56 (remaining gas: 1039921.994 units remaining) + - location: 56 (remaining gas: 1039905.062 units remaining) [ (Pair { Elt "2" "two" } { Elt "1" "one" }) ] - - location: 57 (remaining gas: 1039921.854 units remaining) + - location: 57 (remaining gas: 1039904.987 units remaining) [ (Left (Pair { Elt "2" "two" } { Elt "1" "one" })) ] - - location: -1 (remaining gas: 1039921.784 units remaining) + - location: -1 (remaining gas: 1039904.942 units remaining) [ (Left (Pair { Elt "2" "two" } { Elt "1" "one" })) ] - - location: 151 (remaining gas: 1039921.644 units remaining) + - location: 151 (remaining gas: 1039904.867 units remaining) [ {} (Left (Pair { Elt "2" "two" } { Elt "1" "one" })) ] - - location: 153 (remaining gas: 1039921.504 units remaining) + - location: 153 (remaining gas: 1039904.792 units remaining) [ (Pair {} (Left (Pair { Elt "2" "two" } { Elt "1" "one" }))) ] - - location: -1 (remaining gas: 1039921.434 units remaining) + - location: -1 (remaining gas: 1039904.747 units remaining) [ (Pair {} (Left (Pair { Elt "2" "two" } { Elt "1" "one" }))) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" index eedb7586ecd5..8f5f8ad4a9e2 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Left .45ba7bbe6e.out" @@ -10,26 +10,26 @@ big_map diff New map(2) of type (big_map string string) Set map(2)["3"] to "three" trace - - location: 42 (remaining gas: 1039919.438 units remaining) + - location: 42 (remaining gas: 1039884.434 units remaining) [ (Pair (Right (Left (Left (Pair { Elt "3" "three" } { Elt "4" "four" })))) (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] - - location: 43 (remaining gas: 1039919.298 units remaining) + - location: 43 (remaining gas: 1039884.354 units remaining) [ (Right (Left (Left (Pair { Elt "3" "three" } { Elt "4" "four" })))) @parameter (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] - - location: 62 (remaining gas: 1039918.868 units remaining) + - location: 62 (remaining gas: 1039884.164 units remaining) [ (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) @parameter.right.reset ] - - location: 63 (remaining gas: 1039918.728 units remaining) + - location: 63 (remaining gas: 1039884.089 units remaining) [ (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) @parameter.right.reset ] - - location: -1 (remaining gas: 1039918.658 units remaining) + - location: -1 (remaining gas: 1039884.044 units remaining) [ (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) @parameter.right.reset ] - - location: 59 (remaining gas: 1039918.588 units remaining) + - location: 59 (remaining gas: 1039883.999 units remaining) [ (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) ] - - location: 151 (remaining gas: 1039918.448 units remaining) + - location: 151 (remaining gas: 1039883.924 units remaining) [ {} (Left (Pair { Elt "3" "three" } { Elt "4" "four" })) ] - - location: 153 (remaining gas: 1039918.308 units remaining) + - location: 153 (remaining gas: 1039883.849 units remaining) [ (Pair {} (Left (Pair { Elt "3" "three" } { Elt "4" "four" }))) ] - - location: -1 (remaining gas: 1039918.238 units remaining) + - location: -1 (remaining gas: 1039883.804 units remaining) [ (Pair {} (Left (Pair { Elt "3" "three" } { Elt "4" "four" }))) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" index 1e8254ad6a0f..a9412d32a3d0 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Left (Pair { Elt \"1\" \"one\" } { Elt \"2\" \"two\" }))-(Right (Right.b11b9d15f4.out" @@ -10,65 +10,65 @@ big_map diff New map(2) of type (big_map string string) Unset map(2)["1"] trace - - location: 42 (remaining gas: 1039921.825 units remaining) + - location: 42 (remaining gas: 1039904.323 units remaining) [ (Pair (Right (Right (Right (Right { "1" })))) (Left (Pair { Elt "1" "one" } { Elt "2" "two" }))) ] - - location: 43 (remaining gas: 1039921.685 units remaining) + - location: 43 (remaining gas: 1039904.243 units remaining) [ (Right (Right (Right (Right { "1" })))) @parameter (Left (Pair { Elt "1" "one" } { Elt "2" "two" })) @storage ] - - location: 135 (remaining gas: 1039920.645 units remaining) + - location: 135 (remaining gas: 1039903.793 units remaining) [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] - - location: 133 (remaining gas: 1039920.575 units remaining) + - location: 133 (remaining gas: 1039903.748 units remaining) [ (Pair { Elt "1" "one" } { Elt "2" "two" }) @storage.left ] - - location: 140 (remaining gas: 1039920.435 units remaining) + - location: 140 (remaining gas: 1039903.668 units remaining) [ { Elt "1" "one" } { Elt "2" "two" } ] - - location: -1 (remaining gas: 1039920.365 units remaining) + - location: -1 (remaining gas: 1039903.623 units remaining) [ { Elt "1" "one" } { Elt "2" "two" } ] - - location: 131 (remaining gas: 1039920.365 units remaining) + - location: 131 (remaining gas: 1039903.623 units remaining) [ { "1" } @parameter.right.right.right.rem { Elt "1" "one" } { Elt "2" "two" } ] - - location: 145 (remaining gas: 1039919.498 units remaining) + - location: 145 (remaining gas: 1039902.936 units remaining) [ None { Elt "1" "one" } { Elt "2" "two" } ] - - location: 144 (remaining gas: 1039919.428 units remaining) + - location: 144 (remaining gas: 1039902.891 units remaining) [ None { Elt "1" "one" } { Elt "2" "two" } ] - - location: 143 (remaining gas: 1039919.428 units remaining) + - location: 143 (remaining gas: 1039902.891 units remaining) [ "1" @parameter.right.right.right.rem.elt None { Elt "1" "one" } { Elt "2" "two" } ] - - location: 147 (remaining gas: 1039919.288 units remaining) + - location: 147 (remaining gas: 1039894.026 units remaining) [ {} { Elt "2" "two" } ] - - location: -1 (remaining gas: 1039919.218 units remaining) + - location: -1 (remaining gas: 1039893.981 units remaining) [ {} { Elt "2" "two" } ] - - location: 141 (remaining gas: 1039919.218 units remaining) + - location: 141 (remaining gas: 1039893.981 units remaining) [ {} { Elt "2" "two" } ] - - location: 148 (remaining gas: 1039919.078 units remaining) + - location: 148 (remaining gas: 1039893.906 units remaining) [ (Pair {} { Elt "2" "two" }) ] - - location: 149 (remaining gas: 1039918.938 units remaining) + - location: 149 (remaining gas: 1039893.831 units remaining) [ (Left (Pair {} { Elt "2" "two" })) ] - - location: -1 (remaining gas: 1039918.868 units remaining) + - location: -1 (remaining gas: 1039893.786 units remaining) [ (Left (Pair {} { Elt "2" "two" })) ] - - location: 107 (remaining gas: 1039918.798 units remaining) + - location: 107 (remaining gas: 1039893.741 units remaining) [ (Left (Pair {} { Elt "2" "two" })) ] - - location: 64 (remaining gas: 1039918.728 units remaining) + - location: 64 (remaining gas: 1039893.696 units remaining) [ (Left (Pair {} { Elt "2" "two" })) ] - - location: 59 (remaining gas: 1039918.658 units remaining) + - location: 59 (remaining gas: 1039893.651 units remaining) [ (Left (Pair {} { Elt "2" "two" })) ] - - location: 151 (remaining gas: 1039918.518 units remaining) + - location: 151 (remaining gas: 1039893.576 units remaining) [ {} (Left (Pair {} { Elt "2" "two" })) ] - - location: 153 (remaining gas: 1039918.378 units remaining) + - location: 153 (remaining gas: 1039893.501 units remaining) [ (Pair {} (Left (Pair {} { Elt "2" "two" }))) ] - - location: -1 (remaining gas: 1039918.308 units remaining) + - location: -1 (remaining gas: 1039893.456 units remaining) [ (Pair {} (Left (Pair {} { Elt "2" "two" }))) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" index 367d8cf8d3d6..99bb61491df2 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_big_map_magic[(Right Unit)-(Right (Right (Left (Pair { Pair \"foo\" \"bar\" } { P.4cc6d15be9.out" @@ -12,117 +12,117 @@ big_map diff trace - location: 42 (remaining gas: 1039922.719 units remaining) [ (Pair (Right (Right (Left (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" })))) (Right Unit)) ] - - location: 43 (remaining gas: 1039922.579 units remaining) + - location: 43 (remaining gas: 1039922.639 units remaining) [ (Right (Right (Left (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" })))) @parameter (Right Unit) @storage ] - - location: 75 (remaining gas: 1039921.689 units remaining) + - location: 75 (remaining gas: 1039922.249 units remaining) [ Unit @storage.right ] - - location: 69 (remaining gas: 1039921.619 units remaining) + - location: 69 (remaining gas: 1039922.204 units remaining) [ Unit @storage.right ] - - location: 76 (remaining gas: 1039921.479 units remaining) + - location: 76 (remaining gas: 1039922.129 units remaining) [ ] - - location: -1 (remaining gas: 1039921.409 units remaining) + - location: -1 (remaining gas: 1039922.084 units remaining) [ ] - - location: 67 (remaining gas: 1039921.409 units remaining) + - location: 67 (remaining gas: 1039922.084 units remaining) [ (Pair { Pair "foo" "bar" } { Pair "gaz" "baz" }) @parameter.right.right.import ] - - location: 77 (remaining gas: 1039921.269 units remaining) + - location: 77 (remaining gas: 1039922.004 units remaining) [ { Pair "foo" "bar" } { Pair "gaz" "baz" } ] - - location: 80 (remaining gas: 1039920.809 units remaining) + - location: 80 (remaining gas: 1039921.699 units remaining) [ {} { Pair "gaz" "baz" } ] - - location: 79 (remaining gas: 1039920.739 units remaining) + - location: 79 (remaining gas: 1039921.654 units remaining) [ {} { Pair "gaz" "baz" } ] - - location: 78 (remaining gas: 1039920.739 units remaining) + - location: 78 (remaining gas: 1039921.654 units remaining) [ { Pair "foo" "bar" } {} { Pair "gaz" "baz" } ] - - location: 85 (remaining gas: 1039920.032 units remaining) + - location: 85 (remaining gas: 1039921.037 units remaining) [ "foo" "bar" {} { Pair "gaz" "baz" } ] - - location: 88 (remaining gas: 1039919.732 units remaining) + - location: 88 (remaining gas: 1039920.887 units remaining) [ (Some "bar") {} { Pair "gaz" "baz" } ] - - location: 87 (remaining gas: 1039919.662 units remaining) + - location: 87 (remaining gas: 1039920.842 units remaining) [ (Some "bar") {} { Pair "gaz" "baz" } ] - - location: 86 (remaining gas: 1039919.662 units remaining) + - location: 86 (remaining gas: 1039920.842 units remaining) [ "foo" (Some "bar") {} { Pair "gaz" "baz" } ] - - location: 89 (remaining gas: 1039919.522 units remaining) + - location: 89 (remaining gas: 1039909.978 units remaining) [ { Elt "foo" "bar" } { Pair "gaz" "baz" } ] - - location: -1 (remaining gas: 1039919.452 units remaining) + - location: -1 (remaining gas: 1039909.933 units remaining) [ { Elt "foo" "bar" } { Pair "gaz" "baz" } ] - - location: 83 (remaining gas: 1039919.452 units remaining) + - location: 83 (remaining gas: 1039909.933 units remaining) [ { Elt "foo" "bar" } { Pair "gaz" "baz" } ] - - location: 90 (remaining gas: 1039919.322 units remaining) + - location: 90 (remaining gas: 1039909.863 units remaining) [ { Pair "gaz" "baz" } { Elt "foo" "bar" } ] - - location: 93 (remaining gas: 1039918.862 units remaining) + - location: 93 (remaining gas: 1039909.558 units remaining) [ {} { Elt "foo" "bar" } ] - - location: 92 (remaining gas: 1039918.792 units remaining) + - location: 92 (remaining gas: 1039909.513 units remaining) [ {} { Elt "foo" "bar" } ] - - location: 91 (remaining gas: 1039918.792 units remaining) + - location: 91 (remaining gas: 1039909.513 units remaining) [ { Pair "gaz" "baz" } {} { Elt "foo" "bar" } ] - - location: 98 (remaining gas: 1039918.085 units remaining) + - location: 98 (remaining gas: 1039908.896 units remaining) [ "gaz" "baz" {} { Elt "foo" "bar" } ] - - location: 101 (remaining gas: 1039917.785 units remaining) + - location: 101 (remaining gas: 1039908.746 units remaining) [ (Some "baz") {} { Elt "foo" "bar" } ] - - location: 100 (remaining gas: 1039917.715 units remaining) + - location: 100 (remaining gas: 1039908.701 units remaining) [ (Some "baz") {} { Elt "foo" "bar" } ] - - location: 99 (remaining gas: 1039917.715 units remaining) + - location: 99 (remaining gas: 1039908.701 units remaining) [ "gaz" (Some "baz") {} { Elt "foo" "bar" } ] - - location: 102 (remaining gas: 1039917.575 units remaining) + - location: 102 (remaining gas: 1039897.837 units remaining) [ { Elt "gaz" "baz" } { Elt "foo" "bar" } ] - - location: -1 (remaining gas: 1039917.505 units remaining) + - location: -1 (remaining gas: 1039897.792 units remaining) [ { Elt "gaz" "baz" } { Elt "foo" "bar" } ] - - location: 96 (remaining gas: 1039917.505 units remaining) + - location: 96 (remaining gas: 1039897.792 units remaining) [ { Elt "gaz" "baz" } { Elt "foo" "bar" } ] - - location: 103 (remaining gas: 1039917.375 units remaining) + - location: 103 (remaining gas: 1039897.722 units remaining) [ { Elt "foo" "bar" } { Elt "gaz" "baz" } ] - - location: 104 (remaining gas: 1039917.235 units remaining) + - location: 104 (remaining gas: 1039897.647 units remaining) [ (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" }) ] - - location: 105 (remaining gas: 1039917.095 units remaining) + - location: 105 (remaining gas: 1039897.572 units remaining) [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] - - location: -1 (remaining gas: 1039917.025 units remaining) + - location: -1 (remaining gas: 1039897.527 units remaining) [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] - - location: 64 (remaining gas: 1039916.955 units remaining) + - location: 64 (remaining gas: 1039897.482 units remaining) [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] - - location: 59 (remaining gas: 1039916.885 units remaining) + - location: 59 (remaining gas: 1039897.437 units remaining) [ (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] - - location: 151 (remaining gas: 1039916.745 units remaining) + - location: 151 (remaining gas: 1039897.362 units remaining) [ {} (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" })) ] - - location: 153 (remaining gas: 1039916.605 units remaining) + - location: 153 (remaining gas: 1039897.287 units remaining) [ (Pair {} (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" }))) ] - - location: -1 (remaining gas: 1039916.535 units remaining) + - location: -1 (remaining gas: 1039897.242 units remaining) [ (Pair {} (Left (Pair { Elt "foo" "bar" } { Elt "gaz" "baz" }))) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out index d2d64637dc02..cfe1ba1c26a9 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.3a3a8a99c0.out @@ -8,39 +8,39 @@ big_map diff New map(2) of type (big_map nat nat) Set map(2)[0] to 1 trace - - location: 11 (remaining gas: 1039986.170 units remaining) + - location: 11 (remaining gas: 1039977.424 units remaining) [ (Pair 1 { Elt 0 1 } None) ] - - location: 12 (remaining gas: 1039986.030 units remaining) + - location: 12 (remaining gas: 1039977.344 units remaining) [ 1 @parameter (Pair { Elt 0 1 } None) @storage ] - - location: 15 (remaining gas: 1039985.730 units remaining) + - location: 15 (remaining gas: 1039977.189 units remaining) [ { Elt 0 1 } ] - - location: 16 (remaining gas: 1039985.590 units remaining) + - location: 16 (remaining gas: 1039977.109 units remaining) [ { Elt 0 1 } { Elt 0 1 } ] - - location: -1 (remaining gas: 1039985.520 units remaining) + - location: -1 (remaining gas: 1039977.064 units remaining) [ { Elt 0 1 } { Elt 0 1 } ] - - location: 13 (remaining gas: 1039985.520 units remaining) + - location: 13 (remaining gas: 1039977.064 units remaining) [ 1 @parameter { Elt 0 1 } { Elt 0 1 } ] - - location: 17 (remaining gas: 1039985.380 units remaining) + - location: 17 (remaining gas: 1039968.208 units remaining) [ False { Elt 0 1 } ] - - location: 18 (remaining gas: 1039985.240 units remaining) + - location: 18 (remaining gas: 1039968.133 units remaining) [ (Some False) { Elt 0 1 } ] - - location: 19 (remaining gas: 1039985.110 units remaining) + - location: 19 (remaining gas: 1039968.063 units remaining) [ { Elt 0 1 } (Some False) ] - - location: 20 (remaining gas: 1039984.970 units remaining) + - location: 20 (remaining gas: 1039967.988 units remaining) [ (Pair { Elt 0 1 } (Some False)) ] - - location: 21 (remaining gas: 1039984.830 units remaining) + - location: 21 (remaining gas: 1039967.913 units remaining) [ {} (Pair { Elt 0 1 } (Some False)) ] - - location: 23 (remaining gas: 1039984.690 units remaining) + - location: 23 (remaining gas: 1039967.838 units remaining) [ (Pair {} { Elt 0 1 } (Some False)) ] - - location: -1 (remaining gas: 1039984.620 units remaining) + - location: -1 (remaining gas: 1039967.793 units remaining) [ (Pair {} { Elt 0 1 } (Some False)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out index db1d692ded9e..4185b9399131 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 2 (S.7495f2e912.out @@ -8,39 +8,39 @@ big_map diff New map(2) of type (big_map nat nat) Set map(2)[0] to 1 trace - - location: 11 (remaining gas: 1039986.170 units remaining) + - location: 11 (remaining gas: 1039977.424 units remaining) [ (Pair 1 { Elt 0 1 } None) ] - - location: 12 (remaining gas: 1039986.030 units remaining) + - location: 12 (remaining gas: 1039977.344 units remaining) [ 1 @parameter (Pair { Elt 0 1 } None) @storage ] - - location: 15 (remaining gas: 1039985.730 units remaining) + - location: 15 (remaining gas: 1039977.189 units remaining) [ { Elt 0 1 } ] - - location: 16 (remaining gas: 1039985.590 units remaining) + - location: 16 (remaining gas: 1039977.109 units remaining) [ { Elt 0 1 } { Elt 0 1 } ] - - location: -1 (remaining gas: 1039985.520 units remaining) + - location: -1 (remaining gas: 1039977.064 units remaining) [ { Elt 0 1 } { Elt 0 1 } ] - - location: 13 (remaining gas: 1039985.520 units remaining) + - location: 13 (remaining gas: 1039977.064 units remaining) [ 1 @parameter { Elt 0 1 } { Elt 0 1 } ] - - location: 17 (remaining gas: 1039985.380 units remaining) + - location: 17 (remaining gas: 1039968.208 units remaining) [ False { Elt 0 1 } ] - - location: 18 (remaining gas: 1039985.240 units remaining) + - location: 18 (remaining gas: 1039968.133 units remaining) [ (Some False) { Elt 0 1 } ] - - location: 19 (remaining gas: 1039985.110 units remaining) + - location: 19 (remaining gas: 1039968.063 units remaining) [ { Elt 0 1 } (Some False) ] - - location: 20 (remaining gas: 1039984.970 units remaining) + - location: 20 (remaining gas: 1039967.988 units remaining) [ (Pair { Elt 0 1 } (Some False)) ] - - location: 21 (remaining gas: 1039984.830 units remaining) + - location: 21 (remaining gas: 1039967.913 units remaining) [ {} (Pair { Elt 0 1 } (Some False)) ] - - location: 23 (remaining gas: 1039984.690 units remaining) + - location: 23 (remaining gas: 1039967.838 units remaining) [ (Pair {} { Elt 0 1 } (Some False)) ] - - location: -1 (remaining gas: 1039984.620 units remaining) + - location: -1 (remaining gas: 1039967.793 units remaining) [ (Pair {} { Elt 0 1 } (Some False)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out index 417b6cfb9ddb..951bfd5c328f 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.5fbf509810.out @@ -8,39 +8,39 @@ big_map diff New map(2) of type (big_map nat nat) Set map(2)[1] to 0 trace - - location: 11 (remaining gas: 1039986.170 units remaining) + - location: 11 (remaining gas: 1039977.424 units remaining) [ (Pair 1 { Elt 1 0 } None) ] - - location: 12 (remaining gas: 1039986.030 units remaining) + - location: 12 (remaining gas: 1039977.344 units remaining) [ 1 @parameter (Pair { Elt 1 0 } None) @storage ] - - location: 15 (remaining gas: 1039985.730 units remaining) + - location: 15 (remaining gas: 1039977.189 units remaining) [ { Elt 1 0 } ] - - location: 16 (remaining gas: 1039985.590 units remaining) + - location: 16 (remaining gas: 1039977.109 units remaining) [ { Elt 1 0 } { Elt 1 0 } ] - - location: -1 (remaining gas: 1039985.520 units remaining) + - location: -1 (remaining gas: 1039977.064 units remaining) [ { Elt 1 0 } { Elt 1 0 } ] - - location: 13 (remaining gas: 1039985.520 units remaining) + - location: 13 (remaining gas: 1039977.064 units remaining) [ 1 @parameter { Elt 1 0 } { Elt 1 0 } ] - - location: 17 (remaining gas: 1039985.380 units remaining) + - location: 17 (remaining gas: 1039968.208 units remaining) [ True { Elt 1 0 } ] - - location: 18 (remaining gas: 1039985.240 units remaining) + - location: 18 (remaining gas: 1039968.133 units remaining) [ (Some True) { Elt 1 0 } ] - - location: 19 (remaining gas: 1039985.110 units remaining) + - location: 19 (remaining gas: 1039968.063 units remaining) [ { Elt 1 0 } (Some True) ] - - location: 20 (remaining gas: 1039984.970 units remaining) + - location: 20 (remaining gas: 1039967.988 units remaining) [ (Pair { Elt 1 0 } (Some True)) ] - - location: 21 (remaining gas: 1039984.830 units remaining) + - location: 21 (remaining gas: 1039967.913 units remaining) [ {} (Pair { Elt 1 0 } (Some True)) ] - - location: 23 (remaining gas: 1039984.690 units remaining) + - location: 23 (remaining gas: 1039967.838 units remaining) [ (Pair {} { Elt 1 0 } (Some True)) ] - - location: -1 (remaining gas: 1039984.620 units remaining) + - location: -1 (remaining gas: 1039967.793 units remaining) [ (Pair {} { Elt 1 0 } (Some True)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out index ec0b98789664..1d8b53d3c1eb 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 0 } None)-1-(Pair 2 (S.cc58463f52.out @@ -8,39 +8,39 @@ big_map diff New map(2) of type (big_map nat nat) Set map(2)[1] to 0 trace - - location: 11 (remaining gas: 1039986.170 units remaining) + - location: 11 (remaining gas: 1039977.424 units remaining) [ (Pair 1 { Elt 1 0 } None) ] - - location: 12 (remaining gas: 1039986.030 units remaining) + - location: 12 (remaining gas: 1039977.344 units remaining) [ 1 @parameter (Pair { Elt 1 0 } None) @storage ] - - location: 15 (remaining gas: 1039985.730 units remaining) + - location: 15 (remaining gas: 1039977.189 units remaining) [ { Elt 1 0 } ] - - location: 16 (remaining gas: 1039985.590 units remaining) + - location: 16 (remaining gas: 1039977.109 units remaining) [ { Elt 1 0 } { Elt 1 0 } ] - - location: -1 (remaining gas: 1039985.520 units remaining) + - location: -1 (remaining gas: 1039977.064 units remaining) [ { Elt 1 0 } { Elt 1 0 } ] - - location: 13 (remaining gas: 1039985.520 units remaining) + - location: 13 (remaining gas: 1039977.064 units remaining) [ 1 @parameter { Elt 1 0 } { Elt 1 0 } ] - - location: 17 (remaining gas: 1039985.380 units remaining) + - location: 17 (remaining gas: 1039968.208 units remaining) [ True { Elt 1 0 } ] - - location: 18 (remaining gas: 1039985.240 units remaining) + - location: 18 (remaining gas: 1039968.133 units remaining) [ (Some True) { Elt 1 0 } ] - - location: 19 (remaining gas: 1039985.110 units remaining) + - location: 19 (remaining gas: 1039968.063 units remaining) [ { Elt 1 0 } (Some True) ] - - location: 20 (remaining gas: 1039984.970 units remaining) + - location: 20 (remaining gas: 1039967.988 units remaining) [ (Pair { Elt 1 0 } (Some True)) ] - - location: 21 (remaining gas: 1039984.830 units remaining) + - location: 21 (remaining gas: 1039967.913 units remaining) [ {} (Pair { Elt 1 0 } (Some True)) ] - - location: 23 (remaining gas: 1039984.690 units remaining) + - location: 23 (remaining gas: 1039967.838 units remaining) [ (Pair {} { Elt 1 0 } (Some True)) ] - - location: -1 (remaining gas: 1039984.620 units remaining) + - location: -1 (remaining gas: 1039967.793 units remaining) [ (Pair {} { Elt 1 0 } (Some True)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out index f3076a12414f..40c1c359ea6d 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.3684da1d4a.out @@ -9,39 +9,39 @@ big_map diff Set map(2)[1] to 4 Set map(2)[2] to 11 trace - - location: 11 (remaining gas: 1039985.460 units remaining) + - location: 11 (remaining gas: 1039967.964 units remaining) [ (Pair 1 { Elt 1 4 ; Elt 2 11 } None) ] - - location: 12 (remaining gas: 1039985.320 units remaining) + - location: 12 (remaining gas: 1039967.884 units remaining) [ 1 @parameter (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] - - location: 15 (remaining gas: 1039985.020 units remaining) + - location: 15 (remaining gas: 1039967.729 units remaining) [ { Elt 1 4 ; Elt 2 11 } ] - - location: 16 (remaining gas: 1039984.880 units remaining) + - location: 16 (remaining gas: 1039967.649 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: -1 (remaining gas: 1039984.810 units remaining) + - location: -1 (remaining gas: 1039967.604 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 13 (remaining gas: 1039984.810 units remaining) + - location: 13 (remaining gas: 1039967.604 units remaining) [ 1 @parameter { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 17 (remaining gas: 1039984.670 units remaining) + - location: 17 (remaining gas: 1039958.747 units remaining) [ True { Elt 1 4 ; Elt 2 11 } ] - - location: 18 (remaining gas: 1039984.530 units remaining) + - location: 18 (remaining gas: 1039958.672 units remaining) [ (Some True) { Elt 1 4 ; Elt 2 11 } ] - - location: 19 (remaining gas: 1039984.400 units remaining) + - location: 19 (remaining gas: 1039958.602 units remaining) [ { Elt 1 4 ; Elt 2 11 } (Some True) ] - - location: 20 (remaining gas: 1039984.260 units remaining) + - location: 20 (remaining gas: 1039958.527 units remaining) [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 21 (remaining gas: 1039984.120 units remaining) + - location: 21 (remaining gas: 1039958.452 units remaining) [ {} (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 23 (remaining gas: 1039983.980 units remaining) + - location: 23 (remaining gas: 1039958.377 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: -1 (remaining gas: 1039983.910 units remaining) + - location: -1 (remaining gas: 1039958.332 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out index e7848d3aafbe..c855d2a9fdeb 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-1.596eedbdf9.out @@ -9,39 +9,39 @@ big_map diff Set map(2)[1] to 4 Set map(2)[2] to 11 trace - - location: 11 (remaining gas: 1039985.460 units remaining) + - location: 11 (remaining gas: 1039967.964 units remaining) [ (Pair 1 { Elt 1 4 ; Elt 2 11 } None) ] - - location: 12 (remaining gas: 1039985.320 units remaining) + - location: 12 (remaining gas: 1039967.884 units remaining) [ 1 @parameter (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] - - location: 15 (remaining gas: 1039985.020 units remaining) + - location: 15 (remaining gas: 1039967.729 units remaining) [ { Elt 1 4 ; Elt 2 11 } ] - - location: 16 (remaining gas: 1039984.880 units remaining) + - location: 16 (remaining gas: 1039967.649 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: -1 (remaining gas: 1039984.810 units remaining) + - location: -1 (remaining gas: 1039967.604 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 13 (remaining gas: 1039984.810 units remaining) + - location: 13 (remaining gas: 1039967.604 units remaining) [ 1 @parameter { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 17 (remaining gas: 1039984.670 units remaining) + - location: 17 (remaining gas: 1039958.747 units remaining) [ True { Elt 1 4 ; Elt 2 11 } ] - - location: 18 (remaining gas: 1039984.530 units remaining) + - location: 18 (remaining gas: 1039958.672 units remaining) [ (Some True) { Elt 1 4 ; Elt 2 11 } ] - - location: 19 (remaining gas: 1039984.400 units remaining) + - location: 19 (remaining gas: 1039958.602 units remaining) [ { Elt 1 4 ; Elt 2 11 } (Some True) ] - - location: 20 (remaining gas: 1039984.260 units remaining) + - location: 20 (remaining gas: 1039958.527 units remaining) [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 21 (remaining gas: 1039984.120 units remaining) + - location: 21 (remaining gas: 1039958.452 units remaining) [ {} (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 23 (remaining gas: 1039983.980 units remaining) + - location: 23 (remaining gas: 1039958.377 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: -1 (remaining gas: 1039983.910 units remaining) + - location: -1 (remaining gas: 1039958.332 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out index fdbe6c8df07b..b5e7b7d051b1 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.2dc784176c.out @@ -9,39 +9,39 @@ big_map diff Set map(2)[1] to 4 Set map(2)[2] to 11 trace - - location: 11 (remaining gas: 1039985.460 units remaining) + - location: 11 (remaining gas: 1039967.964 units remaining) [ (Pair 2 { Elt 1 4 ; Elt 2 11 } None) ] - - location: 12 (remaining gas: 1039985.320 units remaining) + - location: 12 (remaining gas: 1039967.884 units remaining) [ 2 @parameter (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] - - location: 15 (remaining gas: 1039985.020 units remaining) + - location: 15 (remaining gas: 1039967.729 units remaining) [ { Elt 1 4 ; Elt 2 11 } ] - - location: 16 (remaining gas: 1039984.880 units remaining) + - location: 16 (remaining gas: 1039967.649 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: -1 (remaining gas: 1039984.810 units remaining) + - location: -1 (remaining gas: 1039967.604 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 13 (remaining gas: 1039984.810 units remaining) + - location: 13 (remaining gas: 1039967.604 units remaining) [ 2 @parameter { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 17 (remaining gas: 1039984.670 units remaining) + - location: 17 (remaining gas: 1039958.747 units remaining) [ True { Elt 1 4 ; Elt 2 11 } ] - - location: 18 (remaining gas: 1039984.530 units remaining) + - location: 18 (remaining gas: 1039958.672 units remaining) [ (Some True) { Elt 1 4 ; Elt 2 11 } ] - - location: 19 (remaining gas: 1039984.400 units remaining) + - location: 19 (remaining gas: 1039958.602 units remaining) [ { Elt 1 4 ; Elt 2 11 } (Some True) ] - - location: 20 (remaining gas: 1039984.260 units remaining) + - location: 20 (remaining gas: 1039958.527 units remaining) [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 21 (remaining gas: 1039984.120 units remaining) + - location: 21 (remaining gas: 1039958.452 units remaining) [ {} (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 23 (remaining gas: 1039983.980 units remaining) + - location: 23 (remaining gas: 1039958.377 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: -1 (remaining gas: 1039983.910 units remaining) + - location: -1 (remaining gas: 1039958.332 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out index 30ce7828ebd8..77256b5bb364 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-2.ff2ac70f53.out @@ -9,39 +9,39 @@ big_map diff Set map(2)[1] to 4 Set map(2)[2] to 11 trace - - location: 11 (remaining gas: 1039985.460 units remaining) + - location: 11 (remaining gas: 1039967.964 units remaining) [ (Pair 2 { Elt 1 4 ; Elt 2 11 } None) ] - - location: 12 (remaining gas: 1039985.320 units remaining) + - location: 12 (remaining gas: 1039967.884 units remaining) [ 2 @parameter (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] - - location: 15 (remaining gas: 1039985.020 units remaining) + - location: 15 (remaining gas: 1039967.729 units remaining) [ { Elt 1 4 ; Elt 2 11 } ] - - location: 16 (remaining gas: 1039984.880 units remaining) + - location: 16 (remaining gas: 1039967.649 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: -1 (remaining gas: 1039984.810 units remaining) + - location: -1 (remaining gas: 1039967.604 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 13 (remaining gas: 1039984.810 units remaining) + - location: 13 (remaining gas: 1039967.604 units remaining) [ 2 @parameter { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 17 (remaining gas: 1039984.670 units remaining) + - location: 17 (remaining gas: 1039958.747 units remaining) [ True { Elt 1 4 ; Elt 2 11 } ] - - location: 18 (remaining gas: 1039984.530 units remaining) + - location: 18 (remaining gas: 1039958.672 units remaining) [ (Some True) { Elt 1 4 ; Elt 2 11 } ] - - location: 19 (remaining gas: 1039984.400 units remaining) + - location: 19 (remaining gas: 1039958.602 units remaining) [ { Elt 1 4 ; Elt 2 11 } (Some True) ] - - location: 20 (remaining gas: 1039984.260 units remaining) + - location: 20 (remaining gas: 1039958.527 units remaining) [ (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 21 (remaining gas: 1039984.120 units remaining) + - location: 21 (remaining gas: 1039958.452 units remaining) [ {} (Pair { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: 23 (remaining gas: 1039983.980 units remaining) + - location: 23 (remaining gas: 1039958.377 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] - - location: -1 (remaining gas: 1039983.910 units remaining) + - location: -1 (remaining gas: 1039958.332 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some True)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out index 02daf08e37de..133a9e531673 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.1b9e98462c.out @@ -9,39 +9,39 @@ big_map diff Set map(2)[1] to 4 Set map(2)[2] to 11 trace - - location: 11 (remaining gas: 1039985.460 units remaining) + - location: 11 (remaining gas: 1039967.964 units remaining) [ (Pair 3 { Elt 1 4 ; Elt 2 11 } None) ] - - location: 12 (remaining gas: 1039985.320 units remaining) + - location: 12 (remaining gas: 1039967.884 units remaining) [ 3 @parameter (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] - - location: 15 (remaining gas: 1039985.020 units remaining) + - location: 15 (remaining gas: 1039967.729 units remaining) [ { Elt 1 4 ; Elt 2 11 } ] - - location: 16 (remaining gas: 1039984.880 units remaining) + - location: 16 (remaining gas: 1039967.649 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: -1 (remaining gas: 1039984.810 units remaining) + - location: -1 (remaining gas: 1039967.604 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 13 (remaining gas: 1039984.810 units remaining) + - location: 13 (remaining gas: 1039967.604 units remaining) [ 3 @parameter { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 17 (remaining gas: 1039984.670 units remaining) + - location: 17 (remaining gas: 1039958.747 units remaining) [ False { Elt 1 4 ; Elt 2 11 } ] - - location: 18 (remaining gas: 1039984.530 units remaining) + - location: 18 (remaining gas: 1039958.672 units remaining) [ (Some False) { Elt 1 4 ; Elt 2 11 } ] - - location: 19 (remaining gas: 1039984.400 units remaining) + - location: 19 (remaining gas: 1039958.602 units remaining) [ { Elt 1 4 ; Elt 2 11 } (Some False) ] - - location: 20 (remaining gas: 1039984.260 units remaining) + - location: 20 (remaining gas: 1039958.527 units remaining) [ (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] - - location: 21 (remaining gas: 1039984.120 units remaining) + - location: 21 (remaining gas: 1039958.452 units remaining) [ {} (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] - - location: 23 (remaining gas: 1039983.980 units remaining) + - location: 23 (remaining gas: 1039958.377 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] - - location: -1 (remaining gas: 1039983.910 units remaining) + - location: -1 (remaining gas: 1039958.332 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out index 8981825b7569..bac2ad97b192 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 1 4 ; Elt 2 11 } None)-3.cf9af2765c.out @@ -9,39 +9,39 @@ big_map diff Set map(2)[1] to 4 Set map(2)[2] to 11 trace - - location: 11 (remaining gas: 1039985.460 units remaining) + - location: 11 (remaining gas: 1039967.964 units remaining) [ (Pair 3 { Elt 1 4 ; Elt 2 11 } None) ] - - location: 12 (remaining gas: 1039985.320 units remaining) + - location: 12 (remaining gas: 1039967.884 units remaining) [ 3 @parameter (Pair { Elt 1 4 ; Elt 2 11 } None) @storage ] - - location: 15 (remaining gas: 1039985.020 units remaining) + - location: 15 (remaining gas: 1039967.729 units remaining) [ { Elt 1 4 ; Elt 2 11 } ] - - location: 16 (remaining gas: 1039984.880 units remaining) + - location: 16 (remaining gas: 1039967.649 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: -1 (remaining gas: 1039984.810 units remaining) + - location: -1 (remaining gas: 1039967.604 units remaining) [ { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 13 (remaining gas: 1039984.810 units remaining) + - location: 13 (remaining gas: 1039967.604 units remaining) [ 3 @parameter { Elt 1 4 ; Elt 2 11 } { Elt 1 4 ; Elt 2 11 } ] - - location: 17 (remaining gas: 1039984.670 units remaining) + - location: 17 (remaining gas: 1039958.747 units remaining) [ False { Elt 1 4 ; Elt 2 11 } ] - - location: 18 (remaining gas: 1039984.530 units remaining) + - location: 18 (remaining gas: 1039958.672 units remaining) [ (Some False) { Elt 1 4 ; Elt 2 11 } ] - - location: 19 (remaining gas: 1039984.400 units remaining) + - location: 19 (remaining gas: 1039958.602 units remaining) [ { Elt 1 4 ; Elt 2 11 } (Some False) ] - - location: 20 (remaining gas: 1039984.260 units remaining) + - location: 20 (remaining gas: 1039958.527 units remaining) [ (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] - - location: 21 (remaining gas: 1039984.120 units remaining) + - location: 21 (remaining gas: 1039958.452 units remaining) [ {} (Pair { Elt 1 4 ; Elt 2 11 } (Some False)) ] - - location: 23 (remaining gas: 1039983.980 units remaining) + - location: 23 (remaining gas: 1039958.377 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] - - location: -1 (remaining gas: 1039983.910 units remaining) + - location: -1 (remaining gas: 1039958.332 units remaining) [ (Pair {} { Elt 1 4 ; Elt 2 11 } (Some False)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out index 833013aef0e6..65e8f6cad01f 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))0].out @@ -9,37 +9,37 @@ big_map diff trace - location: 11 (remaining gas: 1039986.730 units remaining) [ (Pair 1 {} None) ] - - location: 12 (remaining gas: 1039986.590 units remaining) + - location: 12 (remaining gas: 1039986.650 units remaining) [ 1 @parameter (Pair {} None) @storage ] - - location: 15 (remaining gas: 1039986.290 units remaining) + - location: 15 (remaining gas: 1039986.495 units remaining) [ {} ] - - location: 16 (remaining gas: 1039986.150 units remaining) + - location: 16 (remaining gas: 1039986.415 units remaining) [ {} {} ] - - location: -1 (remaining gas: 1039986.080 units remaining) + - location: -1 (remaining gas: 1039986.370 units remaining) [ {} {} ] - - location: 13 (remaining gas: 1039986.080 units remaining) + - location: 13 (remaining gas: 1039986.370 units remaining) [ 1 @parameter {} {} ] - - location: 17 (remaining gas: 1039985.940 units remaining) + - location: 17 (remaining gas: 1039977.516 units remaining) [ False {} ] - - location: 18 (remaining gas: 1039985.800 units remaining) + - location: 18 (remaining gas: 1039977.441 units remaining) [ (Some False) {} ] - - location: 19 (remaining gas: 1039985.670 units remaining) + - location: 19 (remaining gas: 1039977.371 units remaining) [ {} (Some False) ] - - location: 20 (remaining gas: 1039985.530 units remaining) + - location: 20 (remaining gas: 1039977.296 units remaining) [ (Pair {} (Some False)) ] - - location: 21 (remaining gas: 1039985.390 units remaining) + - location: 21 (remaining gas: 1039977.221 units remaining) [ {} (Pair {} (Some False)) ] - - location: 23 (remaining gas: 1039985.250 units remaining) + - location: 23 (remaining gas: 1039977.146 units remaining) [ (Pair {} {} (Some False)) ] - - location: -1 (remaining gas: 1039985.180 units remaining) + - location: -1 (remaining gas: 1039977.101 units remaining) [ (Pair {} {} (Some False)) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out index d67e6cca78d2..d35cf9dfc848 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair {} None)-1-(Pair 2 (Some False))1].out @@ -9,37 +9,37 @@ big_map diff trace - location: 11 (remaining gas: 1039986.730 units remaining) [ (Pair 1 {} None) ] - - location: 12 (remaining gas: 1039986.590 units remaining) + - location: 12 (remaining gas: 1039986.650 units remaining) [ 1 @parameter (Pair {} None) @storage ] - - location: 15 (remaining gas: 1039986.290 units remaining) + - location: 15 (remaining gas: 1039986.495 units remaining) [ {} ] - - location: 16 (remaining gas: 1039986.150 units remaining) + - location: 16 (remaining gas: 1039986.415 units remaining) [ {} {} ] - - location: -1 (remaining gas: 1039986.080 units remaining) + - location: -1 (remaining gas: 1039986.370 units remaining) [ {} {} ] - - location: 13 (remaining gas: 1039986.080 units remaining) + - location: 13 (remaining gas: 1039986.370 units remaining) [ 1 @parameter {} {} ] - - location: 17 (remaining gas: 1039985.940 units remaining) + - location: 17 (remaining gas: 1039977.516 units remaining) [ False {} ] - - location: 18 (remaining gas: 1039985.800 units remaining) + - location: 18 (remaining gas: 1039977.441 units remaining) [ (Some False) {} ] - - location: 19 (remaining gas: 1039985.670 units remaining) + - location: 19 (remaining gas: 1039977.371 units remaining) [ {} (Some False) ] - - location: 20 (remaining gas: 1039985.530 units remaining) + - location: 20 (remaining gas: 1039977.296 units remaining) [ (Pair {} (Some False)) ] - - location: 21 (remaining gas: 1039985.390 units remaining) + - location: 21 (remaining gas: 1039977.221 units remaining) [ {} (Pair {} (Some False)) ] - - location: 23 (remaining gas: 1039985.250 units remaining) + - location: 23 (remaining gas: 1039977.146 units remaining) [ (Pair {} {} (Some False)) ] - - location: -1 (remaining gas: 1039985.180 units remaining) + - location: -1 (remaining gas: 1039977.101 units remaining) [ (Pair {} {} (Some False)) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" index 2f4b4e3f7e39..a5541718ebbe 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.06d068bc9e.out" @@ -9,39 +9,39 @@ big_map diff Set map(2)["bar"] to 4 Set map(2)["foo"] to 11 trace - - location: 11 (remaining gas: 1039985.358 units remaining) + - location: 11 (remaining gas: 1039963.846 units remaining) [ (Pair "baz" { Elt "bar" 4 ; Elt "foo" 11 } None) ] - - location: 12 (remaining gas: 1039985.218 units remaining) + - location: 12 (remaining gas: 1039963.766 units remaining) [ "baz" @parameter (Pair { Elt "bar" 4 ; Elt "foo" 11 } None) @storage ] - - location: 15 (remaining gas: 1039984.918 units remaining) + - location: 15 (remaining gas: 1039963.611 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 16 (remaining gas: 1039984.778 units remaining) + - location: 16 (remaining gas: 1039963.531 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: -1 (remaining gas: 1039984.708 units remaining) + - location: -1 (remaining gas: 1039963.486 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 13 (remaining gas: 1039984.708 units remaining) + - location: 13 (remaining gas: 1039963.486 units remaining) [ "baz" @parameter { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 17 (remaining gas: 1039984.568 units remaining) + - location: 17 (remaining gas: 1039952.621 units remaining) [ False { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 18 (remaining gas: 1039984.428 units remaining) + - location: 18 (remaining gas: 1039952.546 units remaining) [ (Some False) { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 19 (remaining gas: 1039984.298 units remaining) + - location: 19 (remaining gas: 1039952.476 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } (Some False) ] - - location: 20 (remaining gas: 1039984.158 units remaining) + - location: 20 (remaining gas: 1039952.401 units remaining) [ (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] - - location: 21 (remaining gas: 1039984.018 units remaining) + - location: 21 (remaining gas: 1039952.326 units remaining) [ {} (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] - - location: 23 (remaining gas: 1039983.878 units remaining) + - location: 23 (remaining gas: 1039952.251 units remaining) [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] - - location: -1 (remaining gas: 1039983.808 units remaining) + - location: -1 (remaining gas: 1039952.206 units remaining) [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some False)) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" index f7775c8764a4..f66abce4939d 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.1ef1e816d2.out" @@ -9,39 +9,39 @@ big_map diff Set map(2)["bar"] to 4 Set map(2)["foo"] to 11 trace - - location: 11 (remaining gas: 1039985.358 units remaining) + - location: 11 (remaining gas: 1039963.846 units remaining) [ (Pair "bar" { Elt "bar" 4 ; Elt "foo" 11 } None) ] - - location: 12 (remaining gas: 1039985.218 units remaining) + - location: 12 (remaining gas: 1039963.766 units remaining) [ "bar" @parameter (Pair { Elt "bar" 4 ; Elt "foo" 11 } None) @storage ] - - location: 15 (remaining gas: 1039984.918 units remaining) + - location: 15 (remaining gas: 1039963.611 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 16 (remaining gas: 1039984.778 units remaining) + - location: 16 (remaining gas: 1039963.531 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: -1 (remaining gas: 1039984.708 units remaining) + - location: -1 (remaining gas: 1039963.486 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 13 (remaining gas: 1039984.708 units remaining) + - location: 13 (remaining gas: 1039963.486 units remaining) [ "bar" @parameter { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 17 (remaining gas: 1039984.568 units remaining) + - location: 17 (remaining gas: 1039952.621 units remaining) [ True { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 18 (remaining gas: 1039984.428 units remaining) + - location: 18 (remaining gas: 1039952.546 units remaining) [ (Some True) { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 19 (remaining gas: 1039984.298 units remaining) + - location: 19 (remaining gas: 1039952.476 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } (Some True) ] - - location: 20 (remaining gas: 1039984.158 units remaining) + - location: 20 (remaining gas: 1039952.401 units remaining) [ (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] - - location: 21 (remaining gas: 1039984.018 units remaining) + - location: 21 (remaining gas: 1039952.326 units remaining) [ {} (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] - - location: 23 (remaining gas: 1039983.878 units remaining) + - location: 23 (remaining gas: 1039952.251 units remaining) [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] - - location: -1 (remaining gas: 1039983.808 units remaining) + - location: -1 (remaining gas: 1039952.206 units remaining) [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" index f57effbfe4c3..38bfa54cdb62 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"bar\" 4 ; Elt \"foo\" 1.42f59ef508.out" @@ -9,39 +9,39 @@ big_map diff Set map(2)["bar"] to 4 Set map(2)["foo"] to 11 trace - - location: 11 (remaining gas: 1039985.358 units remaining) + - location: 11 (remaining gas: 1039963.846 units remaining) [ (Pair "foo" { Elt "bar" 4 ; Elt "foo" 11 } None) ] - - location: 12 (remaining gas: 1039985.218 units remaining) + - location: 12 (remaining gas: 1039963.766 units remaining) [ "foo" @parameter (Pair { Elt "bar" 4 ; Elt "foo" 11 } None) @storage ] - - location: 15 (remaining gas: 1039984.918 units remaining) + - location: 15 (remaining gas: 1039963.611 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 16 (remaining gas: 1039984.778 units remaining) + - location: 16 (remaining gas: 1039963.531 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: -1 (remaining gas: 1039984.708 units remaining) + - location: -1 (remaining gas: 1039963.486 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 13 (remaining gas: 1039984.708 units remaining) + - location: 13 (remaining gas: 1039963.486 units remaining) [ "foo" @parameter { Elt "bar" 4 ; Elt "foo" 11 } { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 17 (remaining gas: 1039984.568 units remaining) + - location: 17 (remaining gas: 1039952.621 units remaining) [ True { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 18 (remaining gas: 1039984.428 units remaining) + - location: 18 (remaining gas: 1039952.546 units remaining) [ (Some True) { Elt "bar" 4 ; Elt "foo" 11 } ] - - location: 19 (remaining gas: 1039984.298 units remaining) + - location: 19 (remaining gas: 1039952.476 units remaining) [ { Elt "bar" 4 ; Elt "foo" 11 } (Some True) ] - - location: 20 (remaining gas: 1039984.158 units remaining) + - location: 20 (remaining gas: 1039952.401 units remaining) [ (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] - - location: 21 (remaining gas: 1039984.018 units remaining) + - location: 21 (remaining gas: 1039952.326 units remaining) [ {} (Pair { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] - - location: 23 (remaining gas: 1039983.878 units remaining) + - location: 23 (remaining gas: 1039952.251 units remaining) [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] - - location: -1 (remaining gas: 1039983.808 units remaining) + - location: -1 (remaining gas: 1039952.206 units remaining) [ (Pair {} { Elt "bar" 4 ; Elt "foo" 11 } (Some True)) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" index 55180a94d561..33bc2ee80a1a 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 0 } None)-\"foo\".ef9b82f95d.out" @@ -8,39 +8,39 @@ big_map diff New map(2) of type (big_map string nat) Set map(2)["foo"] to 0 trace - - location: 11 (remaining gas: 1039986.082 units remaining) + - location: 11 (remaining gas: 1039975.328 units remaining) [ (Pair "foo" { Elt "foo" 0 } None) ] - - location: 12 (remaining gas: 1039985.942 units remaining) + - location: 12 (remaining gas: 1039975.248 units remaining) [ "foo" @parameter (Pair { Elt "foo" 0 } None) @storage ] - - location: 15 (remaining gas: 1039985.642 units remaining) + - location: 15 (remaining gas: 1039975.093 units remaining) [ { Elt "foo" 0 } ] - - location: 16 (remaining gas: 1039985.502 units remaining) + - location: 16 (remaining gas: 1039975.013 units remaining) [ { Elt "foo" 0 } { Elt "foo" 0 } ] - - location: -1 (remaining gas: 1039985.432 units remaining) + - location: -1 (remaining gas: 1039974.968 units remaining) [ { Elt "foo" 0 } { Elt "foo" 0 } ] - - location: 13 (remaining gas: 1039985.432 units remaining) + - location: 13 (remaining gas: 1039974.968 units remaining) [ "foo" @parameter { Elt "foo" 0 } { Elt "foo" 0 } ] - - location: 17 (remaining gas: 1039985.292 units remaining) + - location: 17 (remaining gas: 1039964.104 units remaining) [ True { Elt "foo" 0 } ] - - location: 18 (remaining gas: 1039985.152 units remaining) + - location: 18 (remaining gas: 1039964.029 units remaining) [ (Some True) { Elt "foo" 0 } ] - - location: 19 (remaining gas: 1039985.022 units remaining) + - location: 19 (remaining gas: 1039963.959 units remaining) [ { Elt "foo" 0 } (Some True) ] - - location: 20 (remaining gas: 1039984.882 units remaining) + - location: 20 (remaining gas: 1039963.884 units remaining) [ (Pair { Elt "foo" 0 } (Some True)) ] - - location: 21 (remaining gas: 1039984.742 units remaining) + - location: 21 (remaining gas: 1039963.809 units remaining) [ {} (Pair { Elt "foo" 0 } (Some True)) ] - - location: 23 (remaining gas: 1039984.602 units remaining) + - location: 23 (remaining gas: 1039963.734 units remaining) [ (Pair {} { Elt "foo" 0 } (Some True)) ] - - location: -1 (remaining gas: 1039984.532 units remaining) + - location: -1 (remaining gas: 1039963.689 units remaining) [ (Pair {} { Elt "foo" 0 } (Some True)) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" index 08985432813d..62e69da07e0d 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair { Elt \"foo\" 1 } None)-\"bar\".68bbace451.out" @@ -8,39 +8,39 @@ big_map diff New map(2) of type (big_map string nat) Set map(2)["foo"] to 1 trace - - location: 11 (remaining gas: 1039986.082 units remaining) + - location: 11 (remaining gas: 1039975.328 units remaining) [ (Pair "bar" { Elt "foo" 1 } None) ] - - location: 12 (remaining gas: 1039985.942 units remaining) + - location: 12 (remaining gas: 1039975.248 units remaining) [ "bar" @parameter (Pair { Elt "foo" 1 } None) @storage ] - - location: 15 (remaining gas: 1039985.642 units remaining) + - location: 15 (remaining gas: 1039975.093 units remaining) [ { Elt "foo" 1 } ] - - location: 16 (remaining gas: 1039985.502 units remaining) + - location: 16 (remaining gas: 1039975.013 units remaining) [ { Elt "foo" 1 } { Elt "foo" 1 } ] - - location: -1 (remaining gas: 1039985.432 units remaining) + - location: -1 (remaining gas: 1039974.968 units remaining) [ { Elt "foo" 1 } { Elt "foo" 1 } ] - - location: 13 (remaining gas: 1039985.432 units remaining) + - location: 13 (remaining gas: 1039974.968 units remaining) [ "bar" @parameter { Elt "foo" 1 } { Elt "foo" 1 } ] - - location: 17 (remaining gas: 1039985.292 units remaining) + - location: 17 (remaining gas: 1039964.104 units remaining) [ False { Elt "foo" 1 } ] - - location: 18 (remaining gas: 1039985.152 units remaining) + - location: 18 (remaining gas: 1039964.029 units remaining) [ (Some False) { Elt "foo" 1 } ] - - location: 19 (remaining gas: 1039985.022 units remaining) + - location: 19 (remaining gas: 1039963.959 units remaining) [ { Elt "foo" 1 } (Some False) ] - - location: 20 (remaining gas: 1039984.882 units remaining) + - location: 20 (remaining gas: 1039963.884 units remaining) [ (Pair { Elt "foo" 1 } (Some False)) ] - - location: 21 (remaining gas: 1039984.742 units remaining) + - location: 21 (remaining gas: 1039963.809 units remaining) [ {} (Pair { Elt "foo" 1 } (Some False)) ] - - location: 23 (remaining gas: 1039984.602 units remaining) + - location: 23 (remaining gas: 1039963.734 units remaining) [ (Pair {} { Elt "foo" 1 } (Some False)) ] - - location: -1 (remaining gas: 1039984.532 units remaining) + - location: -1 (remaining gas: 1039963.689 units remaining) [ (Pair {} { Elt "foo" 1 } (Some False)) ] diff --git "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" index ad1d5bbcf781..6beaee9a281c 100644 --- "a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" +++ "b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_string.tz-(Pair {} None)-\"bar\"-(Pair 2 (Some False))].out" @@ -9,37 +9,37 @@ big_map diff trace - location: 11 (remaining gas: 1039986.686 units remaining) [ (Pair "bar" {} None) ] - - location: 12 (remaining gas: 1039986.546 units remaining) + - location: 12 (remaining gas: 1039986.606 units remaining) [ "bar" @parameter (Pair {} None) @storage ] - - location: 15 (remaining gas: 1039986.246 units remaining) + - location: 15 (remaining gas: 1039986.451 units remaining) [ {} ] - - location: 16 (remaining gas: 1039986.106 units remaining) + - location: 16 (remaining gas: 1039986.371 units remaining) [ {} {} ] - - location: -1 (remaining gas: 1039986.036 units remaining) + - location: -1 (remaining gas: 1039986.326 units remaining) [ {} {} ] - - location: 13 (remaining gas: 1039986.036 units remaining) + - location: 13 (remaining gas: 1039986.326 units remaining) [ "bar" @parameter {} {} ] - - location: 17 (remaining gas: 1039985.896 units remaining) + - location: 17 (remaining gas: 1039975.464 units remaining) [ False {} ] - - location: 18 (remaining gas: 1039985.756 units remaining) + - location: 18 (remaining gas: 1039975.389 units remaining) [ (Some False) {} ] - - location: 19 (remaining gas: 1039985.626 units remaining) + - location: 19 (remaining gas: 1039975.319 units remaining) [ {} (Some False) ] - - location: 20 (remaining gas: 1039985.486 units remaining) + - location: 20 (remaining gas: 1039975.244 units remaining) [ (Pair {} (Some False)) ] - - location: 21 (remaining gas: 1039985.346 units remaining) + - location: 21 (remaining gas: 1039975.169 units remaining) [ {} (Pair {} (Some False)) ] - - location: 23 (remaining gas: 1039985.206 units remaining) + - location: 23 (remaining gas: 1039975.094 units remaining) [ (Pair {} {} (Some False)) ] - - location: -1 (remaining gas: 1039985.136 units remaining) + - location: -1 (remaining gas: 1039975.049 units remaining) [ (Pair {} {} (Some False)) ] diff --git a/tests_python/tests_alpha/protocol.py b/tests_python/tests_alpha/protocol.py index 6216b7f8960f..76fd0b9fb5a0 100644 --- a/tests_python/tests_alpha/protocol.py +++ b/tests_python/tests_alpha/protocol.py @@ -4,9 +4,9 @@ HASH = constants.ALPHA DAEMON = constants.ALPHA_DAEMON PARAMETERS = constants.ALPHA_PARAMETERS -PREV_HASH = constants.EDO -PREV_DAEMON = constants.EDO_DAEMON -PREV_PARAMETERS = constants.EDO_PARAMETERS +PREV_HASH = constants.FLORENCE +PREV_DAEMON = constants.FLORENCE_DAEMON +PREV_PARAMETERS = constants.FLORENCE_PARAMETERS def activate( diff --git a/tests_python/tests_alpha/test_contract_opcodes.py b/tests_python/tests_alpha/test_contract_opcodes.py index 218ac7d1af94..46cf3fb90e02 100644 --- a/tests_python/tests_alpha/test_contract_opcodes.py +++ b/tests_python/tests_alpha/test_contract_opcodes.py @@ -1511,8 +1511,8 @@ class TestContractOpcodes: '(Pair 2 (Some "one"))', [ ["New map(2) of type (big_map string string)"], - ['Set map(2)["1"] to "one"'], ['Set map(2)["2"] to "two"'], + ['Set map(2)["1"] to "one"'], ], ), # Test updating big maps @@ -1523,8 +1523,8 @@ class TestContractOpcodes: '(Pair 2 Unit)', [ ["New map(2) of type (big_map string string)"], - ['Set map(2)["1"] to "one"'], ['Set map(2)["2"] to "two"'], + ['Set map(2)["1"] to "one"'], ], ), ( @@ -1534,8 +1534,8 @@ class TestContractOpcodes: '(Pair 2 Unit)', [ ["New map(2) of type (big_map string string)"], - ['Set map(2)["1"] to "two"'], ['Set map(2)["2"] to "two"'], + ['Set map(2)["1"] to "two"'], ], ), ( @@ -1545,9 +1545,9 @@ class TestContractOpcodes: '(Pair 2 Unit)', [ ["New map(2) of type (big_map string string)"], - ['Set map(2)["1"] to "one"'], ['Set map(2)["2"] to "two"'], ['Set map(2)["3"] to "three"'], + ['Set map(2)["1"] to "one"'], ], ), ( @@ -1557,9 +1557,9 @@ class TestContractOpcodes: '(Pair 2 Unit)', [ ["New map(2) of type (big_map string string)"], - ['Set map(2)["1"] to "one"'], ['Set map(2)["2"] to "two"'], ['Unset map(2)["3"]'], + ['Set map(2)["1"] to "one"'], ], ), ( @@ -1569,8 +1569,8 @@ class TestContractOpcodes: '(Pair 2 Unit)', [ ["New map(2) of type (big_map string string)"], - ['Set map(2)["1"] to "one"'], ['Unset map(2)["2"]'], + ['Set map(2)["1"] to "one"'], ], ), ( @@ -1580,8 +1580,8 @@ class TestContractOpcodes: '(Pair 2 Unit)', [ ["New map(2) of type (big_map string string)"], - ['Set map(2)["1"] to "two"'], ['Set map(2)["2"] to "two"'], + ['Set map(2)["1"] to "two"'], ], ), # test the GET_AND_UPDATE instruction on big maps @@ -1645,8 +1645,8 @@ class TestContractOpcodes: '(Pair (Some 1) 2)', [ ["New map(2) of type (big_map string nat)"], - ['Unset map(2)["1"]'], ['Set map(2)["2"] to 2'], + ['Unset map(2)["1"]'], ], ), ( @@ -1657,8 +1657,8 @@ class TestContractOpcodes: '(Pair (Some 1) 2)', [ ["New map(2) of type (big_map string nat)"], - ['Unset map(2)["1"]'], ['Set map(2)["2"] to 2'], + ['Unset map(2)["1"]'], ], ), ], @@ -1736,8 +1736,8 @@ class TestContractOpcodes: ['New map(3) of type (big_map string string)'], ['Set map(3)["2"] to "two"'], ['New map(2) of type (big_map string string)'], - ['Set map(2)["1"] to "one"'], ['Set map(2)["3"] to "three"'], + ['Set map(2)["1"] to "one"'], ], ), # test remove from big_map diff --git a/tests_python/tests_alpha/test_migration.py b/tests_python/tests_alpha/test_migration.py index 44022dc77c76..8df8d26d256e 100644 --- a/tests_python/tests_alpha/test_migration.py +++ b/tests_python/tests_alpha/test_migration.py @@ -65,7 +65,7 @@ MIGRATION_RECEIPTS = [ # configure user-activate-upgrade at MIGRATION_LEVEL to test migration NODE_CONFIG = { - 'network': { + 'Network': { 'genesis': { 'timestamp': '2018-06-30T16:07:32Z', 'block': 'BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2', diff --git a/tests_python/tests_alpha/test_mockup.py b/tests_python/tests_alpha/test_mockup.py index 49c721001e70..e598f9840b1d 100644 --- a/tests_python/tests_alpha/test_mockup.py +++ b/tests_python/tests_alpha/test_mockup.py @@ -604,6 +604,14 @@ def _test_create_mockup_init_show_roundtrip( "blocks_per_commitment": 5, "blocks_per_cycle": 9, "preserved_cycles": 3, + # switch off black formatter to avoid bug with long strings + # fmt: off + "liquidity_baking_cpmm_address": + "KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG", + # fmt: on + "liquidity_baking_escape_ema_threshold": 500000, + "liquidity_baking_subsidy": "5000000", + "liquidity_baking_sunset_duration": 1024, } ), ], diff --git a/tests_python/tests_alpha/test_voting_full.py b/tests_python/tests_alpha/test_voting_full.py index 2b1e14903359..fff8707c4a5c 100644 --- a/tests_python/tests_alpha/test_voting_full.py +++ b/tests_python/tests_alpha/test_voting_full.py @@ -1,9 +1,3 @@ -""" -This tests the migration from PROTO_A to PROTO_B. -""" - -import json -import os import time import pytest @@ -85,23 +79,6 @@ class TestVotingFull: new dummy protocol """ - def test_add_tmp_bootstrap_node(self, sandbox: Sandbox): - """ launch tmp nodes just to bootstrap all other ones """ - sandbox.add_node(10, params=node_params(0)) - sandbox.add_node(11, params=node_params(0)) - - def test_activate_proto_a(self, sandbox: Sandbox): - sandbox.client(10).activate_protocol_json(PROTO_A, PARAMETERS) - - def test_add_tmp_bootstrap_baker(self, sandbox: Sandbox): - """Launch a temporary baker so that 10 and 11 keep broadcasting - heads to the future joining nodes and help them bootstrap""" - # note we use 'bootstrap1' for all baking, this avoids the issue - # of a delegate becoming inactive. For instance, if we want - # to bake with 'bootstrap2' later in the test, it may have became - # inactive - sandbox.add_baker(10, 'bootstrap1', proto=PROTO_A_DAEMON) - def test_add_initial_nodes(self, sandbox: Sandbox): for i in range(NUM_NODES): sandbox.add_node(i, params=constants.NODE_PARAMS) diff --git a/tezt/_regressions/rpc/alpha.client.others.out b/tezt/_regressions/rpc/alpha.client.others.out index 1f65a7683e54..2ca1dd23de4d 100644 --- a/tezt/_regressions/rpc/alpha.client.others.out +++ b/tezt/_regressions/rpc/alpha.client.others.out @@ -15,9 +15,13 @@ tezt/_regressions/rpc/alpha.client.others.out "endorsement_security_deposit": "64000000", "baking_reward_per_endorsement": [ "1250000", "187500" ], "endorsement_reward": [ "1250000", "833333" ], "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "test_chain_duration": "0", - "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, - "initial_endorsers": 1, "delay_per_missing_endorsement": "1" } + "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, + "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 1, + "delay_per_missing_endorsement": "1", + "liquidity_baking_cpmm_address": "[CONTRACT_HASH]", + "liquidity_baking_subsidy": "5000000", + "liquidity_baking_sunset_duration": 1024, + "liquidity_baking_escape_ema_threshold": 500000 } ./tezos-client rpc get /chains/main/blocks/head/helpers/baking_rights [ { "level": 2, "delegate": "[PUBLIC_KEY_HASH]", diff --git a/tezt/_regressions/rpc/alpha.proxy.contracts.out b/tezt/_regressions/rpc/alpha.proxy.contracts.out index 62e42ef98d27..d54d32f43701 100644 --- a/tezt/_regressions/rpc/alpha.proxy.contracts.out +++ b/tezt/_regressions/rpc/alpha.proxy.contracts.out @@ -3,6 +3,8 @@ tezt/_regressions/rpc/alpha.proxy.contracts.out ./tezos-client --mode proxy rpc get /chains/main/blocks/head/context/contracts protocol of proxy unspecified, using the node's protocol: ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im [ "[PUBLIC_KEY_HASH]", + "[CONTRACT_HASH]", + "[CONTRACT_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", @@ -342,7 +344,7 @@ protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaAL "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], "storage": - { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } } + { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } } ./tezos-client --mode proxy rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/balance' protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK @@ -556,11 +558,11 @@ protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaAL { "prim": "PAIR" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], - "storage": { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } + "storage": { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } ./tezos-client --mode proxy rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/storage' protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK -{ "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } +{ "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } ./tezos-client --mode proxy rpc post '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/big_map_get' with '{ "key": { diff --git a/tezt/_regressions/rpc/alpha.proxy.others.out b/tezt/_regressions/rpc/alpha.proxy.others.out index df1fcc9a9b07..bebc686f8c75 100644 --- a/tezt/_regressions/rpc/alpha.proxy.others.out +++ b/tezt/_regressions/rpc/alpha.proxy.others.out @@ -16,9 +16,13 @@ protocol of proxy unspecified, using the node's protocol: ProtoGenesisGenesisGen "endorsement_security_deposit": "64000000", "baking_reward_per_endorsement": [ "1250000", "187500" ], "endorsement_reward": [ "1250000", "833333" ], "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "test_chain_duration": "0", - "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, - "initial_endorsers": 1, "delay_per_missing_endorsement": "1" } + "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, + "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 1, + "delay_per_missing_endorsement": "1", + "liquidity_baking_cpmm_address": "[CONTRACT_HASH]", + "liquidity_baking_subsidy": "5000000", + "liquidity_baking_sunset_duration": 1024, + "liquidity_baking_escape_ema_threshold": 500000 } ./tezos-client --mode proxy rpc get /chains/main/blocks/head/helpers/baking_rights protocol of proxy unspecified, using the node's protocol: ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im diff --git a/tezt/_regressions/rpc/current.client.others.out b/tezt/_regressions/rpc/current.client.others.out index a0fc43637fd1..147327f758db 100644 --- a/tezt/_regressions/rpc/current.client.others.out +++ b/tezt/_regressions/rpc/current.client.others.out @@ -15,13 +15,10 @@ tezt/_regressions/rpc/current.client.others.out "endorsement_security_deposit": "64000000", "baking_reward_per_endorsement": [ "1250000", "187500" ], "endorsement_reward": [ "1250000", "833333" ], "cost_per_byte": "250", - "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, - "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 1, - "delay_per_missing_endorsement": "1", - "liquidity_baking_cpmm_address": "[CONTRACT_HASH]", - "liquidity_baking_subsidy": "5000000", - "liquidity_baking_sunset_duration": 1024, - "liquidity_baking_escape_ema_threshold": 500000 } + "hard_storage_limit_per_operation": "60000", + "test_chain_duration": "1228800", "quorum_min": 2000, "quorum_max": 7000, + "min_proposal_quorum": 500, "initial_endorsers": 1, + "delay_per_missing_endorsement": "1" } ./tezos-client rpc get /chains/main/blocks/head/helpers/baking_rights [ { "level": 2, "delegate": "[PUBLIC_KEY_HASH]", diff --git a/vendors/flextesa-lib/tezos_protocol.ml b/vendors/flextesa-lib/tezos_protocol.ml index 9760d28c42f5..113ab39ae1a6 100644 --- a/vendors/flextesa-lib/tezos_protocol.ml +++ b/vendors/flextesa-lib/tezos_protocol.ml @@ -166,7 +166,7 @@ let protocol_parameters_json t : Ezjsonm.t = match subkind with | `Babylon | `Carthage | `Delphi | `Edo -> [ ("test_chain_duration", string (Int.to_string 1_966_080)) ] - | `Alpha -> [] + | `Florence | `Alpha -> [] in let op_gas_limit, block_gas_limit = match subkind with -- GitLab From 95236a12852b535e1e5136d0f37d10dd1388d73f Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 19 Mar 2021 13:01:40 -0400 Subject: [PATCH 59/62] liquidity baking: use dexter2 and originate in stitching --- src/proto_alpha/lib_client/mockup.ml | 20 +- .../lib_parameters/default_parameters.ml | 84 - .../lib_parameters/default_parameters.mli | 2 - src/proto_alpha/lib_parameters/gen.ml | 10 +- src/proto_alpha/lib_protocol/TEZOS_PROTOCOL | 4 + src/proto_alpha/lib_protocol/alpha_context.ml | 2 + .../lib_protocol/alpha_context.mli | 7 +- .../lib_protocol/alpha_services.ml | 23 +- .../lib_protocol/alpha_services.mli | 7 + src/proto_alpha/lib_protocol/apply.ml | 5 +- .../lib_protocol/constants_repr.ml | 7 +- .../lib_protocol/constants_repr.mli | 1 - .../lib_protocol/constants_storage.ml | 4 - .../lib_protocol/constants_storage.mli | 2 - src/proto_alpha/lib_protocol/dune.inc | 20 + src/proto_alpha/lib_protocol/init_storage.ml | 20 +- .../liquidity_baking_cpmm.ml} | 17991 +++++++--------- .../lib_protocol/liquidity_baking_lqt.ml | 1582 ++ .../lib_protocol/liquidity_baking_storage.ml | 168 + .../lib_protocol/liquidity_baking_storage.mli | 28 + .../liquidity_baking_test_fa12.ml} | 1479 +- src/proto_alpha/lib_protocol/raw_context.ml | 5 - src/proto_alpha/lib_protocol/storage.ml | 7 + src/proto_alpha/lib_protocol/storage.mli | 8 +- .../lib_protocol/test/helpers/context.ml | 3 + .../lib_protocol/test/helpers/context.mli | 2 + .../test/test_liquidity_baking.ml | 68 +- ...tion::test_big_map_origination_literal.out | 4 +- ...lt 0 1 } None)-1-(Pair 0 (S.f91eafd1f7.out | 46 + .../tests_alpha/test_contract_opcodes.py | 208 +- tests_python/tests_alpha/test_mockup.py | 5 - tests_python/tests_alpha/test_voting_full.py | 6 +- .../rpc/alpha.client.contracts.out | 9 +- tezt/_regressions/rpc/alpha.client.others.out | 1 - .../rpc/alpha.proxy.contracts.out | 9 +- tezt/_regressions/rpc/alpha.proxy.others.out | 1 - vendors/flextesa-lib/tezos_protocol.ml | 4 +- 37 files changed, 10307 insertions(+), 11545 deletions(-) rename src/proto_alpha/{lib_parameters/test_cpmm.ml => lib_protocol/liquidity_baking_cpmm.ml} (71%) create mode 100644 src/proto_alpha/lib_protocol/liquidity_baking_lqt.ml create mode 100644 src/proto_alpha/lib_protocol/liquidity_baking_storage.ml create mode 100644 src/proto_alpha/lib_protocol/liquidity_baking_storage.mli rename src/proto_alpha/{lib_parameters/test_fa12.ml => lib_protocol/liquidity_baking_test_fa12.ml} (54%) create mode 100644 tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 0 (S.f91eafd1f7.out diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index 1468a48efa8a..323d7d7827f1 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -59,7 +59,6 @@ module Protocol_constants_overrides = struct min_proposal_quorum : int32 option; initial_endorsers : int option; delay_per_missing_endorsement : Period.t option; - liquidity_baking_cpmm_address : Contract.t option; liquidity_baking_subsidy : Tez.t option; liquidity_baking_sunset_duration : int32 option; liquidity_baking_escape_ema_threshold : int32 option; @@ -98,7 +97,6 @@ module Protocol_constants_overrides = struct c.min_proposal_quorum, c.initial_endorsers, c.delay_per_missing_endorsement, - c.liquidity_baking_cpmm_address, c.liquidity_baking_subsidy, c.liquidity_baking_sunset_duration, c.liquidity_baking_escape_ema_threshold ), @@ -128,7 +126,6 @@ module Protocol_constants_overrides = struct min_proposal_quorum, initial_endorsers, delay_per_missing_endorsement, - liquidity_baking_cpmm_address, liquidity_baking_subsidy, liquidity_baking_sunset_duration, liquidity_baking_escape_ema_threshold ), @@ -159,7 +156,6 @@ module Protocol_constants_overrides = struct min_proposal_quorum; initial_endorsers; delay_per_missing_endorsement; - liquidity_baking_cpmm_address; liquidity_baking_subsidy; liquidity_baking_sunset_duration; liquidity_baking_escape_ema_threshold; @@ -191,13 +187,12 @@ module Protocol_constants_overrides = struct (opt "cost_per_byte" Tez.encoding) (opt "hard_storage_limit_per_operation" z)) (merge_objs - (obj9 + (obj8 (opt "quorum_min" int32) (opt "quorum_max" int32) (opt "min_proposal_quorum" int32) (opt "initial_endorsers" uint16) (opt "delay_per_missing_endorsement" Period.encoding) - (opt "liquidity_baking_cpmm_address" Contract.encoding) (opt "liquidity_baking_subsidy" Tez.encoding) (opt "liquidity_baking_sunset_duration" int32) (opt "liquidity_baking_escape_ema_threshold" int32)) @@ -250,8 +245,6 @@ module Protocol_constants_overrides = struct initial_endorsers = Some parametric.initial_endorsers; delay_per_missing_endorsement = Some parametric.delay_per_missing_endorsement; - liquidity_baking_cpmm_address = - Some parametric.liquidity_baking_cpmm_address; liquidity_baking_subsidy = Some parametric.liquidity_baking_subsidy; liquidity_baking_sunset_duration = Some parametric.liquidity_baking_sunset_duration; @@ -289,7 +282,6 @@ module Protocol_constants_overrides = struct min_proposal_quorum = None; initial_endorsers = None; delay_per_missing_endorsement = None; - liquidity_baking_cpmm_address = None; liquidity_baking_subsidy = None; liquidity_baking_sunset_duration = None; liquidity_baking_escape_ema_threshold = None; @@ -469,12 +461,6 @@ module Protocol_constants_overrides = struct override_value = o.delay_per_missing_endorsement; pp = Period.pp; }; - O - { - name = "liquidity_baking_cpmm_address"; - override_value = o.liquidity_baking_cpmm_address; - pp = Contract.pp; - }; O { name = "liquidity_baking_subsidy"; @@ -588,10 +574,6 @@ module Protocol_constants_overrides = struct Option.value ~default:c.delay_per_missing_endorsement o.delay_per_missing_endorsement; - liquidity_baking_cpmm_address = - Option.value - ~default:c.liquidity_baking_cpmm_address - o.liquidity_baking_cpmm_address; liquidity_baking_subsidy = Option.value ~default:c.liquidity_baking_subsidy diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 2f0583e40b69..a7675877e608 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -24,7 +24,6 @@ (*****************************************************************************) open Protocol.Alpha_context -open Micheline let constants_mainnet = Constants. @@ -57,11 +56,6 @@ let constants_mainnet = min_proposal_quorum = 5_00l; initial_endorsers = 24; delay_per_missing_endorsement = Period.of_seconds_exn 8L; - liquidity_baking_cpmm_address = - (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) - Contract.implicit_contract - (Signature.Public_key_hash.of_b58check_exn - "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU"); (* liquidity_baking_subsidy is 1/16th of total rewards *) liquidity_baking_subsidy = Tez.of_mutez_exn 5_000_000L; (* level after protocol activation when liquidity baking shuts off *) @@ -84,12 +78,6 @@ let constants_sandbox = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baking_cpmm_address = - Contract.( - originated_contract - (initial_origination_nonce - (Operation_hash.hash_bytes - [Bytes.of_string "Un festival de GADT."]))); liquidity_baking_sunset_duration = 1024l; } @@ -105,12 +93,6 @@ let constants_test = proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; delay_per_missing_endorsement = Period.of_seconds_exn 1L; - liquidity_baking_cpmm_address = - Contract.( - originated_contract - (initial_origination_nonce - (Operation_hash.hash_bytes - [Bytes.of_string "Un festival de GADT."]))); liquidity_baking_sunset_duration = 2048l; } @@ -136,72 +118,6 @@ let bootstrap_accounts = }) bootstrap_accounts_strings -(* For testing liquidity baking. The first is a sample FA1.2 contract and the second the CPMM. The FA1.2 contract's address is included in the CPMM's initial storage. *) -let test_bootstrap_contracts = - [ Parameters. - { - delegate = None; - amount = Tez.of_mutez_exn 4_000_000_000_000L; - script = - Script. - { - code = - Script.lazy_expr (Micheline.strip_locations Test_cpmm.script); - storage = - Script.lazy_expr - (Micheline.strip_locations - (Prim - ( 0, - D_Pair, - [ Seq (1, []); - Prim - ( 2, - D_Pair, - [ Prim - ( 3, - D_Pair, - [ Prim (4, D_False, [], []); - Int (5, Z.of_int 4000000000000) ], - [] ); - Prim - ( 6, - D_Pair, - [ String - ( 7, - "KT1CSKPf2jeLpMmrgKquN2bCjBTkAcAdRVDy" - ); - Prim - ( 8, - D_Pair, - [ Int (9, Z.of_int 2000000000000); - Int (10, Z.of_int 2000000000000) - ], - [] ) ], - [] ) ], - [] ) ], - [] ))); - }; - }; - Parameters. - { - delegate = None; - amount = Tez.of_mutez_exn 2_000_000_000_000L; - script = - Script. - { - code = - Script.lazy_expr (Micheline.strip_locations Test_fa12.script); - storage = - Script.lazy_expr - (Micheline.strip_locations - (Prim - ( 0, - D_Pair, - [Seq (1, []); Int (2, Z.of_int 2000000000000)], - [] ))); - }; - } ] - (* TODO this could be generated from OCaml together with the faucet for now these are hardcoded values in the tests *) let commitments = diff --git a/src/proto_alpha/lib_parameters/default_parameters.mli b/src/proto_alpha/lib_parameters/default_parameters.mli index 3f59176d3409..0a99181fe345 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.mli +++ b/src/proto_alpha/lib_parameters/default_parameters.mli @@ -35,8 +35,6 @@ val make_bootstrap_account : Signature.public_key_hash * Signature.public_key * Tez.t -> Parameters.bootstrap_account -val test_bootstrap_contracts : Parameters.bootstrap_contract list - val parameters_of_constants : ?bootstrap_accounts:Parameters.bootstrap_account list -> ?bootstrap_contracts:Parameters.bootstrap_contract list -> diff --git a/src/proto_alpha/lib_parameters/gen.ml b/src/proto_alpha/lib_parameters/gen.ml index ea006d42f506..98178f61e3e0 100644 --- a/src/proto_alpha/lib_parameters/gen.ml +++ b/src/proto_alpha/lib_parameters/gen.ml @@ -45,18 +45,12 @@ let () = match Sys.argv.(1) with | "--sandbox" -> dump - Default_parameters.( - parameters_of_constants - constants_sandbox - ~bootstrap_contracts:test_bootstrap_contracts) + Default_parameters.(parameters_of_constants constants_sandbox) "sandbox-parameters.json" | "--test" -> dump Default_parameters.( - parameters_of_constants - ~with_commitments:true - constants_sandbox - ~bootstrap_contracts:test_bootstrap_contracts) + parameters_of_constants ~with_commitments:true constants_sandbox) "test-parameters.json" | "--mainnet" -> dump diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index ad1a3ca47fba..ac348df0c9ab 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -60,6 +60,10 @@ "Voting_period_storage", "Vote_storage", "Commitment_storage", + "Liquidity_baking_cpmm", + "Liquidity_baking_lqt", + "Liquidity_baking_test_fa12", + "Liquidity_baking_storage", "Init_storage", "Fees_storage", "Sapling_validator", diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index d9e15ea32a50..92528722cfd7 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -320,4 +320,6 @@ module Liquidity_baking = struct let get_sunset_level = Storage.Liquidity_baking.Sunset_level.get let set_sunset_level = Storage.Liquidity_baking.Sunset_level.update + + let get_cpmm_address = Storage.Liquidity_baking.Cpmm_address.get end diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 4bc85c70a960..e92040d9916f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -860,6 +860,8 @@ module Contract : sig val originated_contract : origination_nonce -> contract val pp : Format.formatter -> contract -> unit + + val encoding : contract Data_encoding.t end module Constants : sig @@ -913,7 +915,6 @@ module Constants : sig min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period.t; - liquidity_baking_cpmm_address : Contract.t; liquidity_baking_subsidy : Tez.t; liquidity_baking_sunset_duration : int32; liquidity_baking_escape_ema_threshold : int32; @@ -973,8 +974,6 @@ module Constants : sig val min_proposal_quorum : context -> int32 - val liquidity_baking_cpmm_address : context -> Contract.t - val liquidity_baking_subsidy : context -> Tez.t val liquidity_baking_sunset_duration : context -> int32 @@ -1669,4 +1668,6 @@ module Liquidity_baking : sig val get_sunset_level : context -> Int32.t tzresult Lwt.t val set_sunset_level : context -> Int32.t -> context tzresult Lwt.t + + val get_cpmm_address : context -> Contract.t tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/alpha_services.ml b/src/proto_alpha/lib_protocol/alpha_services.ml index c774f0c74215..9dc3cebfadbc 100644 --- a/src/proto_alpha/lib_protocol/alpha_services.ml +++ b/src/proto_alpha/lib_protocol/alpha_services.ml @@ -110,6 +110,26 @@ module Parse = Helpers_services.Parse module Voting = Voting_services module Sapling = Sapling_services +module Liquidity_baking = struct + module S = struct + let get_cpmm_address = + RPC_service.get_service + ~description:"Liquidity baking CPMM address" + ~query:RPC_query.empty + ~output:Alpha_context.Contract.encoding + RPC_path.( + custom_root / "context" / "liquidity_baking" / "cpmm_address") + end + + let register () = + let open Services_registration in + register0 S.get_cpmm_address (fun ctxt () () -> + Alpha_context.Liquidity_baking.get_cpmm_address ctxt) + + let get_cpmm_address ctxt block = + RPC_context.make_call0 S.get_cpmm_address ctxt block () () +end + let register () = Contract.register () ; Constants.register () ; @@ -117,4 +137,5 @@ let register () = Helpers.register () ; Nonce.register () ; Voting.register () ; - Sapling.register () + Sapling.register () ; + Liquidity_baking.register () diff --git a/src/proto_alpha/lib_protocol/alpha_services.mli b/src/proto_alpha/lib_protocol/alpha_services.mli index 7c59bf7f2a18..c234ddf33ab3 100644 --- a/src/proto_alpha/lib_protocol/alpha_services.mli +++ b/src/proto_alpha/lib_protocol/alpha_services.mli @@ -46,4 +46,11 @@ module Parse = Helpers_services.Parse module Voting = Voting_services module Sapling = Sapling_services +module Liquidity_baking : sig + val get_cpmm_address : + 'a #RPC_context.simple -> + 'a -> + Alpha_context.Contract.t shell_tzresult Lwt.t +end + val register : unit -> unit diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 74d9bd89381a..2b25844843d2 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1575,9 +1575,8 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = >= Constants.liquidity_baking_escape_ema_threshold ctxt) then return (ctxt, [], liquidity_baking_escape_ema) else - let liquidity_baking_cpmm_contract = - Constants.liquidity_baking_cpmm_address ctxt - in + Liquidity_baking.get_cpmm_address ctxt + >>=? fun liquidity_baking_cpmm_contract -> Contract.exists ctxt liquidity_baking_cpmm_contract >>=? function | false -> diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index b3bf2de24a7b..2596f5a4af49 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -115,7 +115,6 @@ type parametric = { min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; - liquidity_baking_cpmm_address : Contract_repr.t; liquidity_baking_subsidy : Tez_repr.t; liquidity_baking_sunset_duration : int32; liquidity_baking_escape_ema_threshold : int32; @@ -150,7 +149,6 @@ let parametric_encoding = c.min_proposal_quorum, c.initial_endorsers, c.delay_per_missing_endorsement, - c.liquidity_baking_cpmm_address, c.liquidity_baking_subsidy, c.liquidity_baking_sunset_duration, c.liquidity_baking_escape_ema_threshold ) ) )) @@ -179,7 +177,6 @@ let parametric_encoding = min_proposal_quorum, initial_endorsers, delay_per_missing_endorsement, - liquidity_baking_cpmm_address, liquidity_baking_subsidy, liquidity_baking_sunset_duration, liquidity_baking_escape_ema_threshold ) ) ) -> @@ -209,7 +206,6 @@ let parametric_encoding = min_proposal_quorum; initial_endorsers; delay_per_missing_endorsement; - liquidity_baking_cpmm_address; liquidity_baking_subsidy; liquidity_baking_sunset_duration; liquidity_baking_escape_ema_threshold; @@ -242,13 +238,12 @@ let parametric_encoding = (req "endorsement_reward" (list Tez_repr.encoding)) (req "cost_per_byte" Tez_repr.encoding) (req "hard_storage_limit_per_operation" z)) - (obj9 + (obj8 (req "quorum_min" int32) (req "quorum_max" int32) (req "min_proposal_quorum" int32) (req "initial_endorsers" uint16) (req "delay_per_missing_endorsement" Period_repr.encoding) - (req "liquidity_baking_cpmm_address" Contract_repr.encoding) (req "liquidity_baking_subsidy" Tez_repr.encoding) (req "liquidity_baking_sunset_duration" int32) (req "liquidity_baking_escape_ema_threshold" int32)))) diff --git a/src/proto_alpha/lib_protocol/constants_repr.mli b/src/proto_alpha/lib_protocol/constants_repr.mli index b4d0b9c8a12f..9ac4358282a1 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_repr.mli @@ -77,7 +77,6 @@ type parametric = { min_proposal_quorum : int32; initial_endorsers : int; delay_per_missing_endorsement : Period_repr.t; - liquidity_baking_cpmm_address : Contract_repr.t; liquidity_baking_subsidy : Tez_repr.t; liquidity_baking_sunset_duration : int32; liquidity_baking_escape_ema_threshold : int32; diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index 342b7700774c..c8ac586717f3 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -123,10 +123,6 @@ let min_proposal_quorum c = let constants = Raw_context.constants c in constants.min_proposal_quorum -let liquidity_baking_cpmm_address c = - let constants = Raw_context.constants c in - constants.liquidity_baking_cpmm_address - let liquidity_baking_subsidy c = let constants = Raw_context.constants c in constants.liquidity_baking_subsidy diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 228137515863..8d579bccb67c 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -75,8 +75,6 @@ val quorum_max : Raw_context.t -> int32 val min_proposal_quorum : Raw_context.t -> int32 -val liquidity_baking_cpmm_address : Raw_context.t -> Contract_repr.t - val liquidity_baking_subsidy : Raw_context.t -> Tez_repr.t val liquidity_baking_sunset_duration : Raw_context.t -> int32 diff --git a/src/proto_alpha/lib_protocol/dune.inc b/src/proto_alpha/lib_protocol/dune.inc index 1621c34e8075..50d455bcd047 100644 --- a/src/proto_alpha/lib_protocol/dune.inc +++ b/src/proto_alpha/lib_protocol/dune.inc @@ -74,6 +74,10 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end voting_period_storage.mli voting_period_storage.ml vote_storage.mli vote_storage.ml commitment_storage.mli commitment_storage.ml + liquidity_baking_cpmm.ml + liquidity_baking_lqt.ml + liquidity_baking_test_fa12.ml + liquidity_baking_storage.mli liquidity_baking_storage.ml init_storage.mli init_storage.ml fees_storage.mli fees_storage.ml sapling_validator.ml @@ -161,6 +165,10 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end voting_period_storage.mli voting_period_storage.ml vote_storage.mli vote_storage.ml commitment_storage.mli commitment_storage.ml + liquidity_baking_cpmm.ml + liquidity_baking_lqt.ml + liquidity_baking_test_fa12.ml + liquidity_baking_storage.mli liquidity_baking_storage.ml init_storage.mli init_storage.ml fees_storage.mli fees_storage.ml sapling_validator.ml @@ -248,6 +256,10 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end voting_period_storage.mli voting_period_storage.ml vote_storage.mli vote_storage.ml commitment_storage.mli commitment_storage.ml + liquidity_baking_cpmm.ml + liquidity_baking_lqt.ml + liquidity_baking_test_fa12.ml + liquidity_baking_storage.mli liquidity_baking_storage.ml init_storage.mli init_storage.ml fees_storage.mli fees_storage.ml sapling_validator.ml @@ -355,6 +367,10 @@ include Tezos_raw_protocol_alpha.Main Voting_period_storage Vote_storage Commitment_storage + Liquidity_baking_cpmm + Liquidity_baking_lqt + Liquidity_baking_test_fa12 + Liquidity_baking_storage Init_storage Fees_storage Sapling_validator @@ -478,6 +494,10 @@ include Tezos_raw_protocol_alpha.Main voting_period_storage.mli voting_period_storage.ml vote_storage.mli vote_storage.ml commitment_storage.mli commitment_storage.ml + liquidity_baking_cpmm.ml + liquidity_baking_lqt.ml + liquidity_baking_test_fa12.ml + liquidity_baking_storage.mli liquidity_baking_storage.ml init_storage.mli init_storage.ml fees_storage.mli fees_storage.ml sapling_validator.ml diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index 9c2199e45cde..bd364e157063 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -76,15 +76,7 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = Storage.Block_priority.init ctxt 0 >>=? fun ctxt -> Vote_storage.update_listings ctxt - >>=? fun ctxt -> - Storage.Liquidity_baking.Escape_ema.init ctxt 0l - >>=? fun ctxt -> - Storage.Liquidity_baking.Sunset_level.init - ctxt - Int32.( - add - (Raw_level_repr.to_int32 (Level_storage.current ctxt).level) - (Constants_storage.liquidity_baking_sunset_duration ctxt)) + >>=? fun ctxt -> Liquidity_baking_storage.init_test ctxt | Edo_008 -> (* Add balance updates receipts to be attached on the first block of this protocol - see [[prepare]] function below. Any balance updates attached @@ -96,15 +88,7 @@ let prepare_first_block ctxt ~typecheck ~level ~timestamp ~fitness = ~amount_mutez:100_000_000L >>= fun (ctxt, balance_updates) -> Storage.Pending_migration_balance_updates.init ctxt balance_updates - >>=? fun ctxt -> - Storage.Liquidity_baking.Escape_ema.init ctxt 0l - >>=? fun ctxt -> - Storage.Liquidity_baking.Sunset_level.init - ctxt - Int32.( - add - (Raw_level_repr.to_int32 (Level_storage.current ctxt).level) - (Constants_storage.liquidity_baking_sunset_duration ctxt)) + >>=? fun ctxt -> Liquidity_baking_storage.init ctxt let prepare ctxt ~level ~predecessor_timestamp ~timestamp ~fitness = Raw_context.prepare ~level ~predecessor_timestamp ~timestamp ~fitness ctxt diff --git a/src/proto_alpha/lib_parameters/test_cpmm.ml b/src/proto_alpha/lib_protocol/liquidity_baking_cpmm.ml similarity index 71% rename from src/proto_alpha/lib_parameters/test_cpmm.ml rename to src/proto_alpha/lib_protocol/liquidity_baking_cpmm.ml index 7c3398f84d1d..fb45fc8d5546 100644 --- a/src/proto_alpha/lib_parameters/test_cpmm.ml +++ b/src/proto_alpha/lib_protocol/liquidity_baking_cpmm.ml @@ -1,4 +1,4 @@ -open Protocol.Alpha_context.Script +open Michelson_v1_primitives open Micheline let script = @@ -19,549 +19,332 @@ let script = [ Prim ( 5, T_pair, - [ Prim (6, T_address, [], [":spender"]); + [ Prim (6, T_address, [], ["%owner"]); Prim ( 7, - T_pair, - [ Prim (8, T_nat, [], [":allowance"]); - Prim - ( 9, - T_nat, - [], - [":currentAllowance"] ) ], - [] ) ], - ["%approve"] ); - Prim - ( 10, - T_pair, - [ Prim - ( 11, - T_pair, - [ Prim (12, T_address, [], [":owner"]); - Prim - (13, T_nat, [], [":minLqtMinted"]) - ], - [] ); - Prim - ( 14, T_pair, [ Prim - ( 15, - T_nat, - [], - [":maxTokensDeposited"] ); + (8, T_nat, [], ["%minLqtMinted"]); Prim - ( 16, - T_timestamp, - [], - [":deadline"] ) ], + ( 9, + T_pair, + [ Prim + ( 10, + T_nat, + [], + ["%maxTokensDeposited"] + ); + Prim + ( 11, + T_timestamp, + [], + ["%deadline"] ) ], + [] ) ], [] ) ], - ["%addLiquidity"] ) ], + ["%addLiquidity"] ); + Prim (12, T_unit, [], ["%default"]) ], [] ); Prim - ( 17, + ( 13, T_or, [ Prim - ( 18, + ( 14, T_pair, - [ Prim - ( 19, - T_pair, - [ Prim (20, T_address, [], [":owner"]); - Prim - ( 21, - T_pair, - [ Prim - (22, T_address, [], [":to"]); - Prim - ( 23, - T_nat, - [], - [":lqtBurned"] ) ], - [] ) ], - [] ); + [ Prim (15, T_address, [], ["%to"]); Prim - ( 24, + ( 16, T_pair, - [ Prim - ( 25, - T_mutez, - [], - [":minXtzWithdrawn"] ); + [ Prim (17, T_nat, [], ["%lqtBurned"]); Prim - ( 26, + ( 18, T_pair, [ Prim - ( 27, - T_nat, + ( 19, + T_mutez, [], - [":minTokensWithdrawn"] - ); + ["%minXtzWithdrawn"] ); Prim - ( 28, - T_timestamp, - [], - [":deadline"] ) ], + ( 20, + T_pair, + [ Prim + ( 21, + T_nat, + [], + [ "%minTokensWithdrawn" + ] ); + Prim + ( 22, + T_timestamp, + [], + ["%deadline"] ) ], + [] ) ], [] ) ], [] ) ], ["%removeLiquidity"] ); Prim - ( 29, - T_pair, - [ Prim (30, T_address, [], [":to"]); - Prim - ( 31, - T_pair, - [ Prim - ( 32, - T_nat, - [], - [":minTokensBought"] ); - Prim - ( 33, - T_timestamp, - [], - [":deadline"] ) ], - [] ) ], - ["%xtzToToken"] ) ], - [] ) ], - [] ); - Prim - ( 34, - T_or, - [ Prim - ( 35, - T_or, - [ Prim - ( 36, + ( 23, T_pair, - [ Prim - ( 37, - T_pair, - [ Prim (38, T_address, [], [":owner"]); - Prim (39, T_address, [], [":to"]) - ], - [] ); + [ Prim (24, T_address, [], ["%to"]); Prim - ( 40, + ( 25, T_pair, [ Prim - (41, T_nat, [], [":tokensSold"]); + (26, T_nat, [], ["%tokensSold"]); Prim - ( 42, + ( 27, T_pair, [ Prim - ( 43, + ( 28, T_mutez, [], - [":minXtzBought"] ); + ["%minXtzBought"] ); Prim - ( 44, + ( 29, T_timestamp, [], - [":deadline"] ) ], + ["%deadline"] ) ], [] ) ], [] ) ], - ["%tokenToXtz"] ); - Prim (45, T_key_hash, [], ["%updateTokenPool"]) + ["%tokenToXtz"] ) ], + [] ) ], + [] ); + Prim + ( 30, + T_or, + [ Prim + ( 31, + T_or, + [ Prim (32, T_unit, [], ["%updateTokenPool"]); + Prim + (33, T_nat, [], ["%updateTokenPoolInternal"]) ], [] ); Prim - ( 46, - T_or, - [ Prim - (47, T_nat, [], ["%updateTokenPoolInternal"]); - Prim (48, T_unit, [], ["%default"]) ], - [] ) ], + ( 34, + T_pair, + [ Prim (35, T_address, [], ["%to"]); + Prim + ( 36, + T_pair, + [ Prim (37, T_nat, [], ["%minTokensBought"]); + Prim (38, T_timestamp, [], ["%deadline"]) + ], + [] ) ], + ["%xtzToToken"] ) ], [] ) ], [] ) ], [] ); Prim - ( 49, + ( 39, K_storage, [ Prim - ( 50, + ( 40, T_pair, - [ Prim - ( 51, - T_big_map, - [ Prim (52, T_address, [], [":owner"]); - Prim - ( 53, - T_pair, - [ Prim (54, T_nat, [], [":balance"]); - Prim - ( 55, - T_map, - [ Prim (56, T_address, [], [":spender"]); - Prim (57, T_nat, [], [":allowance"]) ], - [] ) ], - [] ) ], - ["%accounts"] ); + [ Prim (41, T_nat, [], ["%tokenPool"]); Prim - ( 58, + ( 42, T_pair, - [ Prim - ( 59, - T_pair, - [ Prim - (60, T_bool, [], [":selfIsUpdatingTokenPool"]); - Prim (61, T_nat, [], [":lqtTotal"]) ], - [] ); + [ Prim (43, T_mutez, [], ["%xtzPool"]); Prim - ( 62, + ( 44, T_pair, - [ Prim (63, T_address, [], [":tokenAddress"]); + [ Prim (45, T_nat, [], ["%lqtTotal"]); Prim - ( 64, + ( 46, T_pair, - [ Prim (65, T_nat, [], [":tokenPool"]); - Prim (66, T_mutez, [], [":xtzPool"]) ], + [ Prim + ( 47, + T_bool, + [], + ["%selfIsUpdatingTokenPool"] ); + Prim + ( 48, + T_pair, + [ Prim + ( 49, + T_address, + [], + ["%tokenAddress"] ); + Prim + ( 50, + T_address, + [], + ["%lqtAddress"] ) ], + [] ) ], [] ) ], [] ) ], [] ) ], [] ) ], [] ); Prim - ( 67, + ( 51, K_code, [ Seq - ( 68, - [ Prim - ( 69, - I_CAST, - [ Prim - ( 70, - T_pair, + ( 52, + [ Prim (53, I_DUP, [], []); + Prim (54, I_CDR, [], []); + Prim (55, I_SWAP, [], []); + Prim (56, I_CAR, [], []); + Prim + ( 57, + I_IF_LEFT, + [ Seq + ( 58, [ Prim - ( 71, - T_or, - [ Prim - ( 72, - T_or, + ( 59, + I_IF_LEFT, + [ Seq + ( 60, [ Prim - ( 73, - T_or, - [ Prim - ( 74, - T_pair, - [ Prim - ( 75, - T_address, - [], + ( 61, + I_IF_LEFT, + [ Seq + ( 62, + [ Prim (63, I_DUP, [], []); + Prim (64, I_CDR, [], []); + Prim + (65, I_SWAP, [], []); + Prim (66, I_CAR, [], []); + Prim + (67, I_SWAP, [], []); + Prim (68, I_DUP, [], []); + Prim (69, I_CDR, [], []); + Prim + (70, I_SWAP, [], []); + Prim (71, I_CAR, [], []); + Prim + (72, I_SWAP, [], []); + Prim (73, I_DUP, [], []); + Prim (74, I_CDR, [], []); + Prim + (75, I_SWAP, [], []); + Prim (76, I_CAR, [], []); + Prim + ( 77, + I_DIG, + [ Int + (78, Z.of_int 4) + ], [] ); + Prim (79, I_DUP, [], []); Prim - ( 76, - T_pair, - [ Prim - ( 77, - T_nat, - [], - [] ); - Prim - ( 78, - T_nat, - [], - [] ) ], - [] ) ], - [] ); - Prim - ( 79, - T_pair, - [ Prim ( 80, - T_pair, - [ Prim - ( 81, - T_address, - [], - [] ); - Prim - ( 82, - T_nat, - [], - [] ) ], + I_DUG, + [ Int + (81, Z.of_int 5) + ], [] ); + Prim (82, I_CDR, [], []); + Prim (83, I_CDR, [], []); + Prim (84, I_CDR, [], []); + Prim (85, I_CAR, [], []); Prim - ( 83, - T_pair, - [ Prim - ( 84, - T_nat, - [], - [] ); - Prim - ( 85, - T_timestamp, - [], - [] ) ], - [] ) ], - [] ) ], - [] ); - Prim - ( 86, - T_or, - [ Prim - ( 87, - T_pair, - [ Prim - ( 88, - T_pair, - [ Prim - ( 89, - T_address, - [], - [] ); - Prim - ( 90, - T_pair, + ( 86, + I_IF, + [ Seq + ( 87, [ Prim - ( 91, - T_address, - [], + ( 88, + I_DROP, + [ Int + ( 89, + Z + .of_int + 5 + ) + ], + [] ); + Prim + ( 90, + I_PUSH, + [ Prim + ( 91, + T_nat, + [], + [] + ); + Int + ( 92, + Z + .of_int + 2 + ) + ], [] ); Prim - ( 92, - T_nat, + ( 93, + I_FAILWITH, [], - [] ) ], - [] ) ], - [] ); - Prim - ( 93, - T_pair, - [ Prim + [] ) ] + ); + Seq ( 94, - T_mutez, - [], - [] ); - Prim - ( 95, - T_pair, [ Prim + ( 95, + I_SWAP, + [], + [] ); + Prim ( 96, - T_nat, + I_NOW, [], [] ); Prim ( 97, - T_timestamp, - [], - [] ) ], - [] ) ], - [] ) ], - [] ); - Prim - ( 98, - T_pair, - [ Prim - ( 99, - T_address, - [], - [] ); - Prim - ( 100, - T_pair, - [ Prim - ( 101, - T_nat, - [], - [] ); - Prim - ( 102, - T_timestamp, - [], - [] ) ], - [] ) ], - [] ) ], - [] ) ], - [] ); - Prim - ( 103, - T_or, - [ Prim - ( 104, - T_or, - [ Prim - ( 105, - T_pair, - [ Prim - ( 106, - T_pair, - [ Prim - ( 107, - T_address, - [], - [] ); - Prim - ( 108, - T_address, - [], - [] ) ], - [] ); - Prim - ( 109, - T_pair, - [ Prim - ( 110, - T_nat, - [], - [] ); - Prim - ( 111, - T_pair, - [ Prim - ( 112, - T_mutez, + I_COMPARE, [], [] ); Prim - ( 113, - T_timestamp, - [], - [] ) ], - [] ) ], - [] ) ], - [] ); - Prim (114, T_key_hash, [], []) - ], - [] ); - Prim - ( 115, - T_or, - [ Prim (116, T_nat, [], []); - Prim (117, T_unit, [], []) ], - [] ) ], - [] ) ], - [] ); - Prim - ( 118, - T_pair, - [ Prim - ( 119, - T_big_map, - [ Prim (120, T_address, [], []); - Prim - ( 121, - T_pair, - [ Prim (122, T_nat, [], []); - Prim - ( 123, - T_map, - [ Prim - ( 124, - T_address, - [], - [] ); - Prim - (125, T_nat, [], []) - ], - [] ) ], - [] ) ], - [] ); - Prim - ( 126, - T_pair, - [ Prim - ( 127, - T_pair, - [ Prim (128, T_bool, [], []); - Prim (129, T_nat, [], []) ], - [] ); - Prim - ( 130, - T_pair, - [ Prim (131, T_address, [], []); - Prim - ( 132, - T_pair, - [ Prim - (133, T_nat, [], []); - Prim - (134, T_mutez, [], []) - ], - [] ) ], - [] ) ], - [] ) ], - [] ) ], - [] ) ], - [] ); - Prim (135, I_DUP, [], []); - Prim (136, I_CAR, [], []); - Prim - (137, I_DIP, [Seq (138, [Prim (139, I_CDR, [], [])])], []); - Prim - ( 140, - I_IF_LEFT, - [ Seq - ( 141, - [ Prim - ( 142, - I_IF_LEFT, - [ Seq - ( 143, - [ Prim - ( 144, - I_IF_LEFT, - [ Seq - ( 145, - [ Prim - ( 146, - I_DIP, - [ Seq - ( 147, - [ Prim - ( 148, - I_DUP, - [], - [] ); - Prim - ( 149, - I_CDR, - [], - [] ); - Prim - ( 150, - I_CAR, - [], - [] ); - Prim - ( 151, - I_CAR, + ( 98, + I_GE, [], [] ); Prim - ( 152, + ( 99, I_IF, [ Seq - ( 153, + ( 100, [ Prim ( - 154, + 101, + I_DROP, + [ + Int + ( + 102, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 103, I_PUSH, [ Prim ( - 155, - T_string, + 104, + T_nat, [], [] ); - String + Int ( - 156, - "selfIsUpdatingToken \ - must \ - be \ - false." + 105, + Z + .of_int + 3 ) ], [] ); Prim ( - 157, + 106, I_FAILWITH, [], [] @@ -569,3716 +352,2049 @@ let script = ] ); Seq - ( 158, - [] - ) - ], - [] ) ] - ) ], - [] ); - Prim - ( 159, - I_PUSH, - [ Prim - ( 160, - T_mutez, - [], - [] ); - Int (161, Z.zero) - ], - [] ); - Prim - ( 162, - I_AMOUNT, - [], - [] ); - Prim - ( 163, - I_COMPARE, - [], - [] ); - Prim (164, I_EQ, [], []); - Prim - ( 165, - I_IF, - [ Seq (166, []); - Seq - ( 167, - [ Prim - ( 168, - I_PUSH, - [ Prim - ( 169, - T_string, - [], - [] - ); - String - ( 170, - "Amount \ - must \ - be \ - zero." - ) - ], - [] ); - Prim - ( 171, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 172, - I_DIP, - [ Seq - ( 173, - [ Prim - ( 174, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - (175, I_SWAP, [], []); - Prim - (176, I_CAR, [], []); - Prim - ( 177, - I_SENDER, - [], - [] ); - Prim - (178, I_GET, [], []); - Prim - ( 179, - I_IF_NONE, - [ Seq - ( 180, - [ Prim - ( 181, - I_EMPTY_MAP, - [ Prim - ( 182, - T_address, - [], - [] - ); - Prim - ( 183, - T_nat, - [], - [] - ) - ], - [] ); - Prim - ( 184, - I_PUSH, - [ Prim - ( 185, - T_nat, - [], - [] - ); - Int - ( 186, - Z - .zero - ) - ], - [] ); - Prim - ( 187, - I_PAIR, - [], - [] ) ] - ); - Seq (188, []) ], - [] ); - Prim - (189, I_DUP, [], []); - Prim - (190, I_CDR, [], []); - Prim - ( 191, - I_DIP, - [ Int - ( 192, - Z.of_int 2 ); - Seq - ( 193, - [ Prim - ( 194, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 195, - I_DIG, - [ Int - ( 196, - Z.of_int 2 ) - ], - [] ); - Prim - (197, I_CAR, [], []); - Prim - (198, I_GET, [], []); - Prim - ( 199, - I_IF_NONE, - [ Seq - ( 200, - [ Prim - ( 201, - I_PUSH, - [ Prim - ( 202, - T_nat, - [], - [] - ); - Int - ( 203, - Z - .zero - ) - ], - [] ) ] - ); - Seq (204, []) ], - [] ); - Prim - ( 205, - I_DIP, - [ Int - ( 206, - Z.of_int 2 ); - Seq - ( 207, - [ Prim - ( 208, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 209, - I_DIG, - [ Int - ( 210, - Z.of_int 2 ) - ], - [] ); - Prim - (211, I_CDR, [], []); - Prim - (212, I_CDR, [], []); - Prim - ( 213, - I_COMPARE, - [], - [] ); - Prim (214, I_EQ, [], []); - Prim - ( 215, - I_IF, - [ Seq (216, []); - Seq - ( 217, - [ Prim - ( 218, - I_PUSH, - [ Prim - ( 219, - T_string, - [], - [] - ); - String - ( 220, - "The \ - current \ - allowance \ - parameter \ - must \ - equal \ - the \ - sender's \ - current \ - allowance \ - for \ - the \ - owner." - ) - ], - [] ); - Prim - ( 221, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (222, I_DUP, [], []); - Prim - (223, I_CDR, [], []); - Prim - ( 224, - I_DIG, - [ Int - ( 225, - Z.of_int 2 ) - ], - [] ); - Prim - (226, I_DUP, [], []); - Prim - (227, I_CAR, [], []); - Prim - ( 228, - I_DIP, - [ Seq - ( 229, - [ Prim - ( 230, - I_CDR, - [], - [] ); - Prim - ( 231, - I_CAR, - [], - [] ); - Prim - ( 232, - I_SOME, - [], - [] ) ] - ) ], - [] ); - Prim - ( 233, - I_UPDATE, - [], - [] ); - Prim - ( 234, - I_DIP, - [ Seq - ( 235, - [ Prim - ( 236, - I_DUP, - [], - [] ); - Prim - ( 237, - I_DIP, - [ Seq - ( 238, + ( 107, [ Prim ( - 239, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 240, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (241, I_SWAP, [], []); - Prim - (242, I_DROP, [], []); - Prim - (243, I_SWAP, [], []); - Prim - (244, I_PAIR, [], []); - Prim - ( 245, - I_DIP, - [ Seq - ( 246, - [ Prim - ( 247, - I_DUP, - [], - [] ); - Prim - ( 248, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (249, I_SOME, [], []); - Prim - ( 250, - I_SENDER, - [], - [] ); - Prim - ( 251, - I_UPDATE, - [], - [] ); - Prim - ( 252, - I_DIP, - [ Seq - ( 253, - [ Prim - ( 254, - I_DUP, - [], - [] ); - Prim - ( 255, - I_DIP, - [ Seq - ( 256, - [ - Prim + 108, + I_PUSH, + [ + Prim ( - 257, + 109, + T_mutez, + [], + [] + ); + Int + ( + 110, + Z + .one + ) + ], + [] + ); + Prim + ( + 111, + I_DIG, + [ + Int + ( + 112, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 113, + I_DUP, + [], + [] + ); + Prim + ( + 114, + I_DUG, + [ + Int + ( + 115, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 116, I_CDR, [], [] + ); + Prim + ( + 117, + I_CAR, + [], + [] + ); + Prim + ( + 118, + I_EDIV, + [], + [] + ); + Prim + ( + 119, + I_IF_NONE, + [ + Seq + ( + 120, + [ + Prim + ( + 121, + I_PUSH, + [ + Prim + ( + 122, + T_string, + [], + [] + ); + String + ( + 123, + "DIV \ + by \ + 0" ) - ] - ) - ], - [] ); - Prim - ( 258, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (259, I_SWAP, [], []); - Prim - (260, I_DROP, [], []); - Prim - (261, I_PAIR, [], []); - Prim - ( 262, - I_NIL, - [ Prim - ( 263, - T_operation, - [], - [] ) ], - [] ); - Prim - (264, I_PAIR, [], []) - ] ); - Seq - ( 265, - [ Prim - ( 266, - I_DIP, - [ Seq - ( 267, - [ Prim - ( 268, - I_DUP, - [], - [] ); - Prim - ( 269, - I_CDR, - [], - [] ); - Prim - ( 270, - I_CAR, - [], - [] ); - Prim - ( 271, - I_CAR, - [], - [] ); - Prim - ( 272, - I_IF, - [ Seq - ( 273, - [ - Prim + ], + [] + ); + Prim ( - 274, + 124, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 125, + [] + ) + ], + [] + ); + Prim + ( + 126, + I_CAR, + [], + [] + ); + Prim + ( + 127, + I_AMOUNT, + [], + [] + ); + Prim + ( + 128, I_PUSH, [ Prim ( - 275, + 129, + T_mutez, + [], + [] + ); + Int + ( + 130, + Z + .one + ) + ], + [] + ); + Prim + ( + 131, + I_SWAP, + [], + [] + ); + Prim + ( + 132, + I_EDIV, + [], + [] + ); + Prim + ( + 133, + I_IF_NONE, + [ + Seq + ( + 134, + [ + Prim + ( + 135, + I_PUSH, + [ + Prim + ( + 136, T_string, [], [] ); String ( - 276, - "selfIsUpdatingToken \ - must \ - be \ - false." + 137, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 277, + 138, I_FAILWITH, [], [] ) - ] - ); - Seq - ( 278, - [] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (279, I_DUP, [], []); - Prim - (280, I_CDR, [], []); - Prim - (281, I_CDR, [], []); - Prim - (282, I_NOW, [], []); - Prim - ( 283, - I_COMPARE, - [], - [] ); - Prim (284, I_LT, [], []); - Prim - ( 285, - I_IF, - [ Seq (286, []); - Seq - ( 287, - [ Prim - ( 288, - I_PUSH, - [ Prim - ( 289, - T_string, - [], - [] - ); - String - ( 290, - "NOW \ - is \ - greater \ - than \ - deadline." - ) - ], - [] ); - Prim - ( 291, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (292, I_DUP, [], []); - Prim - (293, I_CDR, [], []); - Prim - (294, I_CAR, [], []); - Prim - ( 295, - I_PUSH, - [ Prim - ( 296, - T_nat, - [], - [] ); - Int (297, Z.zero) - ], - [] ); - Prim - ( 298, - I_COMPARE, - [], - [] ); - Prim (299, I_LT, [], []); - Prim - ( 300, - I_IF, - [ Seq (301, []); - Seq - ( 302, - [ Prim - ( 303, - I_PUSH, - [ Prim - ( 304, - T_string, - [], - [] - ); - String - ( 305, - "maxTokensDeposited \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 306, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (307, I_DUP, [], []); - Prim - (308, I_CAR, [], []); - Prim - (309, I_CDR, [], []); - Prim - ( 310, - I_PUSH, - [ Prim - ( 311, - T_nat, - [], - [] ); - Int (312, Z.zero) - ], - [] ); - Prim - ( 313, - I_COMPARE, - [], - [] ); - Prim (314, I_LT, [], []); - Prim - ( 315, - I_IF, - [ Seq (316, []); - Seq - ( 317, - [ Prim - ( 318, - I_PUSH, - [ Prim - ( 319, - T_string, - [], - [] - ); - String - ( 320, - "minLqtMinted \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 321, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 322, - I_PUSH, - [ Prim - ( 323, - T_mutez, - [], - [] ); - Int (324, Z.zero) - ], - [] ); - Prim - ( 325, - I_AMOUNT, - [], - [] ); - Prim - ( 326, - I_COMPARE, - [], - [] ); - Prim (327, I_GT, [], []); - Prim - ( 328, - I_IF, - [ Seq (329, []); - Seq - ( 330, - [ Prim - ( 331, - I_PUSH, - [ Prim - ( 332, - T_string, - [], - [] - ); - String - ( 333, - "Amount \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 334, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 335, - I_DIP, - [ Seq - ( 336, - [ Prim - ( 337, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - (338, I_SWAP, [], []); - Prim - (339, I_CDR, [], []); - Prim - (340, I_CAR, [], []); - Prim - (341, I_CDR, [], []); - Prim - (342, I_INT, [], []); - Prim (343, I_EQ, [], []); - Prim - ( 344, - I_IF, - [ Seq - ( 345, - [ Prim - ( 346, - I_AMOUNT, - [], - [] ); - Prim - ( 347, - I_PUSH, - [ Prim - ( 348, - T_mutez, - [], - [] - ); - Int - ( 349, - Z - .of_int - 1000000 - ) - ], - [] ); - Prim - ( 350, - I_COMPARE, - [], - [] ); - Prim - ( 351, - I_LE, - [], - [] ); - Prim - ( 352, - I_IF, - [ Seq - ( 353, - [] - ); - Seq - ( 354, - [ - Prim - ( - 355, - I_PUSH, - [ - Prim - ( - 356, - T_string, - [], - [] + ] ); - String + Seq ( - 357, - "The \ - initial \ - liquidity \ - amount \ - must \ - be \ - greater \ - than \ - or \ - equal \ - to \ - 1 \ - XTZ." + 139, + [] ) ], [] ); Prim ( - 358, - I_FAILWITH, + 140, + I_CAR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 359, - I_SWAP, - [], - [] ); - Prim - ( 360, - I_AMOUNT, - [], - [] ); - Prim - ( 361, - I_DIP, - [ Seq - ( 362, - [ - Prim + ); + Prim ( - 363, - I_PUSH, - [ + 141, + I_SWAP, + [], + [] + ); Prim ( - 364, - T_mutez, + 142, + I_DUP, [], [] ); + Prim + ( + 143, + I_DUG, + [ Int ( - 365, + 144, Z - .one + .of_int + 2 ) ], [] - ) - ] - ) - ], - [] ); - Prim - ( 366, - I_EDIV, - [], - [] ); - Prim - ( 367, - I_IF_NONE, - [ Seq - ( 368, - [ - Prim - ( - 369, - I_PUSH, - [ + ); Prim ( - 370, - T_string, - [], - [] - ); - String + 145, + I_DIG, + [ + Int ( - 371, - "" + 146, + Z + .of_int + 6 ) ], [] ); Prim ( - 372, - I_FAILWITH, + 147, + I_DUP, [], [] - ) - ] - ); - Seq - ( 373, - [ - Prim - ( - 374, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 375, - I_DUP, - [], - [] ); - Prim - ( 376, - I_DIP, - [ Seq - ( 377, - [ - Prim + ); + Prim ( - 378, - I_DIP, + 148, + I_DUG, [ - Seq + Int ( - 379, - [ + 149, + Z + .of_int + 7 + ) + ], + [] + ); Prim ( - 380, - I_DUP, + 150, + I_CDR, [], [] ); Prim ( - 381, + 151, I_CDR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 152, + I_CAR, + [], [] ); Prim ( - 382, - I_DIP, + 153, + I_DIG, [ - Seq + Int ( - 383, - [ + 154, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 384, + 155, I_DUP, [], [] ); Prim ( - 385, - I_DIP, - [ - Seq - ( - 386, + 156, + I_DUG, [ - Prim + Int ( - 387, - I_CDR, - [], - [] - ) - ] + 157, + Z + .of_int + 3 ) ], [] ); Prim ( - 388, - I_CAR, + 158, + I_MUL, [], [] - ) - ] - ) - ], - [] ); Prim ( - 389, - I_DIP, - [ - Seq - ( - 390, - [ - Prim - ( - 391, - I_DUP, + 159, + I_EDIV, [], [] ); Prim ( - 392, - I_DIP, + 160, + I_IF_NONE, [ Seq ( - 393, + 161, [ Prim ( - 394, - I_CAR, + 162, + I_PUSH, + [ + Prim + ( + 163, + T_string, [], [] - ) - ] + ); + String + ( + 164, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 395, - I_CDR, + 165, + I_FAILWITH, [], [] ) ] + ); + Seq + ( + 166, + [] ) ], [] ); Prim ( - 396, - I_SWAP, + 167, + I_CAR, [], [] ); Prim ( - 397, - I_DROP, - [], + 168, + I_DIG, + [ + Int + ( + 169, + Z + .of_int + 2 + ) + ], [] ); Prim ( - 398, - I_SWAP, - [], + 170, + I_DIG, + [ + Int + ( + 171, + Z + .of_int + 6 + ) + ], [] ); Prim ( - 399, - I_PAIR, + 172, + I_DUP, [], [] ); Prim ( - 400, - I_PAIR, + 173, + I_DUG, + [ + Int + ( + 174, + Z + .of_int + 7 + ) + ], + [] + ); + Prim + ( + 175, + I_CAR, [], [] ); Prim ( - 401, - I_DIP, + 176, + I_DIG, [ - Seq + Int ( - 402, - [ + 177, + Z + .of_int + 3 + ) + ], + [] + ); Prim ( - 403, - I_DUP, + 178, + I_MUL, [], [] ); Prim ( - 404, - I_DIP, + 179, + I_EDIV, + [], + [] + ); + Prim + ( + 180, + I_IF_NONE, [ Seq ( - 405, + 181, [ Prim ( - 406, - I_CAR, + 182, + I_PUSH, + [ + Prim + ( + 183, + T_string, [], [] - ) - ] + ); + String + ( + 184, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 407, - I_CDR, + 185, + I_FAILWITH, [], [] ) ] - ) - ], - [] ); + Seq + ( + 186, + [ Prim ( - 408, - I_SWAP, + 187, + I_DUP, [], [] ); Prim ( - 409, - I_DROP, + 188, + I_CDR, [], [] ); Prim ( - 410, + 189, I_SWAP, [], [] ); Prim ( - 411, - I_PAIR, + 190, + I_CAR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 412, - I_SWAP, - [], - [] ); - Prim - ( 413, - I_DIP, - [ Int - ( 414, - Z - .of_int - 2 - ); - Seq - ( 415, - [ - Prim + ); + Prim ( - 416, - I_DUP, + 191, + I_PUSH, + [ + Prim + ( + 192, + T_nat, [], [] + ); + Int + ( + 193, + Z + .zero ) - ] - ) - ], - [] ); - Prim - ( 417, - I_DIG, - [ Int - ( 418, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 419, - I_CAR, - [], - [] ); - Prim - ( 420, - I_CAR, - [], - [] ); - Prim - ( 421, - I_DIP, - [ Seq - ( 422, - [ - Prim - ( - 423, - I_DUP, - [], + ], [] ); Prim ( - 424, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 425, - I_GET, - [], - [] ); - Prim - ( 426, - I_IF_NONE, - [ Seq - ( 427, - [ - Prim - ( - 428, - I_EMPTY_MAP, + 194, + I_DIG, [ + Int + ( + 195, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 429, - T_address, + 196, + I_COMPARE, [], [] ); Prim ( - 430, - T_nat, + 197, + I_EQ, [], [] - ) - ], + ); + Prim + ( + 198, + I_IF, + [ + Seq + ( + 199, [] ); + Seq + ( + 200, + [ Prim ( - 431, + 201, I_PUSH, [ Prim ( - 432, + 202, T_nat, [], [] ); Int ( - 433, + 203, Z - .zero + .one ) ], [] ); Prim ( - 434, - I_PAIR, + 204, + I_ADD, [], [] ) - ] - ); - Seq - ( 435, - [] - ) - ], - [] ); - Prim - ( 436, - I_DIG, - [ Int - ( 437, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 438, - I_DIP, - [ Seq - ( 439, - [ - Prim - ( - 440, - I_DUP, - [], + ] + ) + ], + [] + ) + ] + ) + ], [] ); Prim ( - 441, - I_DIP, - [ - Seq - ( - 442, + 205, + I_DIG, [ - Prim + Int ( - 443, - I_CDR, - [], - [] - ) - ] + 206, + Z + .of_int + 2 ) ], [] ); Prim ( - 444, - I_CAR, + 207, + I_SWAP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 445, - I_SWAP, - [], - [] ); - Prim - ( 446, - I_DROP, - [], - [] ); - Prim - ( 447, - I_PAIR, - [], - [] ); - Prim - ( 448, - I_DIP, - [ Seq - ( 449, - [ - Prim + ); + Prim ( - 450, + 208, I_DUP, [], [] ); Prim ( - 451, - I_CAR, - [], - [] + 209, + I_DUG, + [ + Int + ( + 210, + Z + .of_int + 2 ) - ] - ) - ], - [] ); - Prim - ( 452, - I_SOME, - [], - [] ); - Prim - ( 453, - I_DIP, - [ Int - ( 454, - Z - .of_int - 3 - ); - Seq - ( 455, - [ - Prim + ], + [] + ); + Prim ( - 456, - I_DUP, + 211, + I_COMPARE, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 457, - I_DIG, - [ Int - ( 458, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 459, - I_CAR, - [], - [] ); - Prim - ( 460, - I_CAR, - [], - [] ); - Prim - ( 461, - I_UPDATE, - [], - [] ); - Prim - ( 462, - I_DIP, - [ Seq - ( 463, - [ - Prim + ); + Prim ( - 464, - I_DUP, + 212, + I_GT, [], [] ); Prim ( - 465, - I_DIP, + 213, + I_IF, [ Seq ( - 466, + 214, [ Prim ( - 467, - I_CDR, + 215, + I_DROP, + [ + Int + ( + 216, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 217, + I_PUSH, + [ + Prim + ( + 218, + T_nat, + [], + [] + ); + Int + ( + 219, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 220, + I_FAILWITH, [], [] ) ] + ); + Seq + ( + 221, + [ + Prim + ( + 222, + I_DUG, + [ + Int + ( + 223, + Z + .of_int + 2 ) ], [] ); Prim ( - 468, - I_CAR, + 224, + I_DUP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 469, - I_SWAP, - [], - [] ); - Prim - ( 470, - I_DROP, - [], - [] ); - Prim - ( 471, - I_PAIR, - [], - [] ); - Prim - ( 472, - I_DUP, - [], - [] ); - Prim - ( 473, - I_CDR, - [], - [] ); - Prim - ( 474, - I_CDR, - [], - [] ); - Prim - ( 475, - I_CDR, - [], - [] ); - Prim - ( 476, - I_CDR, - [], - [] ); - Prim - ( 477, - I_AMOUNT, - [], - [] ); - Prim - ( 478, - I_ADD, - [], - [] ); - Prim - ( 479, - I_DIP, - [ Seq - ( 480, - [ - Prim + ); + Prim ( - 481, - I_DUP, - [], + 225, + I_DUG, + [ + Int + ( + 226, + Z + .of_int + 3 + ) + ], [] ); Prim ( - 482, - I_CDR, + 227, + I_COMPARE, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 483, - I_DIP, - [ Seq - ( 484, - [ - Prim + ); + Prim ( - 485, - I_DUP, + 228, + I_LT, [], [] ); Prim ( - 486, - I_DIP, + 229, + I_IF, [ Seq ( - 487, + 230, [ Prim ( - 488, - I_CAR, - [], - [] - ) - ] + 231, + I_DROP, + [ + Int + ( + 232, + Z + .of_int + 4 ) ], [] ); Prim ( - 489, - I_CDR, + 233, + I_PUSH, + [ + Prim + ( + 234, + T_nat, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 490, - I_DIP, - [ Seq - ( 491, - [ - Prim + ); + Int ( - 492, - I_DUP, - [], + 235, + Z + .of_int + 5 + ) + ], [] ); Prim ( - 493, - I_DIP, - [ + 236, + I_FAILWITH, + [], + [] + ) + ] + ); Seq ( - 494, + 237, [ Prim ( - 495, - I_CAR, - [], - [] - ) - ] + 238, + I_DIG, + [ + Int + ( + 239, + Z + .of_int + 3 ) ], [] ); Prim ( - 496, - I_CDR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 497, - I_DIP, - [ Seq - ( 498, - [ - Prim - ( - 499, + 240, I_DUP, [], [] ); Prim ( - 500, - I_DIP, + 241, + I_DUG, [ - Seq + Int ( - 501, - [ + 242, + Z + .of_int + 4 + ) + ], + [] + ); Prim ( - 502, - I_CAR, + 243, + I_CDR, [], [] - ) - ] - ) - ], - [] ); Prim ( - 503, + 244, I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 504, - I_SWAP, - [], - [] ); - Prim - ( 505, - I_DROP, - [], - [] ); - Prim - ( 506, - I_SWAP, - [], - [] ); - Prim - ( 507, - I_PAIR, - [], - [] ); - Prim - ( 508, - I_SWAP, - [], - [] ); - Prim - ( 509, - I_PAIR, - [], - [] ); - Prim - ( 510, - I_SWAP, - [], - [] ); - Prim - ( 511, - I_PAIR, - [], - [] ); - Prim - ( 512, - I_DIP, - [ Seq - ( 513, - [ - Prim + ); + Prim ( - 514, - I_DUP, + 245, + I_CDR, [], [] ); Prim ( - 515, - I_DIP, + 246, + I_DIG, [ - Seq + Int ( - 516, - [ + 247, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 517, - I_CAR, + 248, + I_DUP, [], [] - ) - ] + ); + Prim + ( + 249, + I_DUG, + [ + Int + ( + 250, + Z + .of_int + 3 ) ], [] ); Prim ( - 518, - I_CDR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 519, - I_SWAP, - [], - [] ); - Prim - ( 520, - I_DROP, - [], - [] ); - Prim - ( 521, - I_SWAP, - [], - [] ); - Prim - ( 522, - I_PAIR, - [], - [] ); - Prim - ( 523, - I_DUP, - [], - [] ); - Prim - ( 524, - I_CDR, - [], - [] ); - Prim - ( 525, - I_CDR, - [], - [] ); - Prim - ( 526, - I_CDR, - [], - [] ); - Prim - ( 527, - I_CAR, - [], - [] ); - Prim - ( 528, - I_DIP, - [ Int - ( 529, - Z - .of_int - 2 - ); - Seq - ( 530, - [ - Prim + 251, + I_DIG, + [ + Int ( - 531, + 252, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 253, I_DUP, [], [] + ); + Prim + ( + 254, + I_DUG, + [ + Int + ( + 255, + Z + .of_int + 6 ) - ] - ) - ], - [] ); - Prim - ( 532, - I_DIG, - [ Int - ( 533, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 534, - I_CDR, - [], - [] ); - Prim - ( 535, - I_CAR, - [], - [] ); - Prim - ( 536, - I_ADD, - [], - [] ); - Prim - ( 537, - I_DIP, - [ Seq - ( 538, - [ - Prim + ], + [] + ); + Prim ( - 539, - I_DUP, + 256, + I_CDR, [], [] ); Prim ( - 540, + 257, I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 541, - I_DIP, - [ Seq - ( 542, - [ - Prim + ); + Prim ( - 543, - I_DUP, + 258, + I_CAR, [], [] ); Prim ( - 544, - I_DIP, - [ - Seq + 259, + I_ADD, + [], + [] + ); + Prim ( - 545, + 260, + I_PAIR, + [], + [] + ); + Prim + ( + 261, + I_DIG, [ + Int + ( + 262, + Z + .of_int + 4 + ) + ], + [] + ); Prim ( - 546, - I_CAR, + 263, + I_DUP, [], [] - ) - ] + ); + Prim + ( + 264, + I_DUG, + [ + Int + ( + 265, + Z + .of_int + 5 ) ], [] ); Prim ( - 547, + 266, I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 548, - I_DIP, - [ Seq - ( 549, - [ - Prim + ); + Prim ( - 550, - I_DUP, + 267, + I_CAR, [], [] ); Prim ( - 551, - I_DIP, - [ - Seq + 268, + I_PAIR, + [], + [] + ); + Prim ( - 552, + 269, + I_DIG, [ - Prim + Int ( - 553, - I_CAR, - [], - [] - ) - ] + 270, + Z + .of_int + 4 ) ], [] ); Prim ( - 554, - I_CDR, + 271, + I_DUP, [], [] + ); + Prim + ( + 272, + I_DUG, + [ + Int + ( + 273, + Z + .of_int + 5 ) - ] - ) - ], - [] ); - Prim - ( 555, - I_DIP, - [ Seq - ( 556, - [ - Prim + ], + [] + ); + Prim ( - 557, - I_DUP, + 274, + I_CAR, [], [] ); Prim ( - 558, - I_DIP, - [ - Seq - ( - 559, - [ + 275, + I_PAIR, + [], + [] + ); Prim ( - 560, + 276, I_CDR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 277, + I_SWAP, + [], [] ); Prim ( - 561, - I_CAR, + 278, + I_DUP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 562, - I_SWAP, - [], - [] ); - Prim - ( 563, - I_DROP, - [], - [] ); - Prim - ( 564, - I_PAIR, - [], - [] ); - Prim - ( 565, - I_SWAP, - [], - [] ); - Prim - ( 566, - I_PAIR, - [], - [] ); - Prim - ( 567, - I_SWAP, - [], - [] ); - Prim - ( 568, - I_PAIR, - [], - [] ); - Prim - ( 569, - I_DIP, - [ Seq - ( 570, - [ - Prim + ); + Prim ( - 571, + 279, + I_DUG, + [ + Int + ( + 280, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 281, + I_DIG, + [ + Int + ( + 282, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 283, I_DUP, [], [] ); Prim ( - 572, - I_DIP, + 284, + I_DUG, [ - Seq + Int ( - 573, - [ + 285, + Z + .of_int + 6 + ) + ], + [] + ); Prim ( - 574, + 286, I_CAR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 287, + I_ADD, + [], [] ); Prim ( - 575, - I_CDR, + 288, + I_PAIR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 576, - I_SWAP, - [], - [] ); - Prim - ( 577, - I_DROP, - [], - [] ); - Prim - ( 578, - I_SWAP, - [], - [] ); - Prim - ( 579, - I_PAIR, - [], - [] ); - Prim - ( 580, - I_DIP, - [ Seq - ( 581, - [ - Prim + ); + Prim ( - 582, + 289, I_DUP, [], [] ); Prim ( - 583, + 290, I_CDR, [], [] ); Prim ( - 584, - I_CAR, + 291, + I_CDR, [], [] ); Prim ( - 585, - I_DIP, - [ - Seq + 292, + I_AMOUNT, + [], + [] + ); + Prim ( - 586, + 293, + I_DIG, [ + Int + ( + 294, + Z + .of_int + 6 + ) + ], + [] + ); Prim ( - 587, - I_CAR, + 295, + I_CDR, [], [] ); Prim ( - 588, + 296, I_CAR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 297, + I_ADD, + [], [] - ) - ] - ) - ], - [] ); - Prim - ( 589, - I_DUP, - [], - [] ); - Prim - ( 590, - I_CDR, - [], - [] ); - Prim - ( 591, - I_CDR, - [], - [] ); - Prim - ( 592, - I_CAR, - [], - [] ); - Prim - ( 593, - I_CONTRACT, - [ Prim - ( 594, - T_pair, - [ - Prim + ); + Prim ( - 595, - T_address, + 298, + I_PAIR, [], [] ); Prim ( - 596, - T_pair, - [ + 299, + I_SWAP, + [], + [] + ); Prim ( - 597, - T_address, + 300, + I_CAR, [], [] ); Prim ( - 598, - T_nat, + 301, + I_PAIR, [], [] - ) - ], + ); + Prim + ( + 302, + I_SWAP, + [], [] - ) - ], - [] - ) - ], - [ "%transfer" - ] ); - Prim - ( 599, - I_IF_NONE, - [ Seq - ( 600, - [ - Prim + ); + Prim ( - 601, - I_PUSH, - [ + 303, + I_SELF, + [], + [] + ); Prim ( - 602, - T_string, + 304, + I_ADDRESS, [], [] ); - String + Prim ( - 603, - "bad \ - address \ - for \ - get_entrypoint" - ) - ], + 305, + I_PAIR, + [], [] ); Prim ( - 604, - I_FAILWITH, + 306, + I_SENDER, [], [] - ) - ] - ); - Seq - ( 605, - [] - ) - ], - [] ); - Prim - ( 606, - I_PUSH, - [ Prim - ( 607, - T_mutez, - [], - [] - ); - Int - ( 608, - Z - .zero - ) - ], - [] ); - Prim - ( 609, - I_DIG, - [ Int - ( 610, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 611, - I_SELF, - [], - [] ); - Prim - ( 612, - I_ADDRESS, - [], - [] ); - Prim - ( 613, - I_DIG, - [ Int - ( 614, - Z - .of_int - 5 - ) - ], - [] ); - Prim - ( 615, - I_DIP, - [ Seq - ( 616, - [ - Prim + ); + Prim ( - 617, + 307, I_PAIR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 618, - I_PAIR, - [], - [] ); - Prim - ( 619, - I_TRANSFER_TOKENS, - [], - [] ); - Prim - ( 620, - I_DIP, - [ Seq - ( 621, - [ - Prim + ); + Prim ( - 622, - I_NIL, - [ + 308, + I_SWAP, + [], + [] + ); Prim ( - 623, - T_operation, + 309, + I_DUP, [], [] + ); + Prim + ( + 310, + I_DUG, + [ + Int + ( + 311, + Z + .of_int + 2 ) ], [] - ) - ] - ) - ], - [] ); - Prim - ( 624, - I_CONS, - [], - [] ); - Prim - ( 625, - I_PAIR, - [], - [] ) ] - ); - Seq - ( 626, - [ Prim - ( 627, - I_DIP, - [ Seq - ( 628, - [ - Prim + ); + Prim ( - 629, - I_DUP, + 312, + I_SWAP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 630, - I_SWAP, - [], - [] ); - Prim - ( 631, - I_CDR, - [], - [] ); - Prim - ( 632, - I_CDR, - [], - [] ); - Prim - ( 633, - I_CDR, - [], - [] ); - Prim - ( 634, - I_CDR, - [], - [] ); - Prim - ( 635, - I_DIP, - [ Seq - ( 636, - [ - Prim - ( - 637, - I_PUSH, - [ + ); Prim ( - 638, - T_mutez, + 313, + I_DUP, [], [] ); - Int + Prim ( - 639, - Z - .one - ) - ], + 314, + I_CDR, + [], [] - ) - ] - ) - ], - [] ); - Prim - ( 640, - I_EDIV, - [], - [] ); - Prim - ( 641, - I_IF_NONE, - [ Seq - ( 642, - [ - Prim + ); + Prim ( - 643, - I_PUSH, - [ + 315, + I_SWAP, + [], + [] + ); Prim ( - 644, - T_string, + 316, + I_CAR, [], [] ); - String + Prim ( - 645, - "" - ) - ], + 317, + I_SWAP, + [], [] ); Prim ( - 646, - I_FAILWITH, + 318, + I_DUP, [], [] - ) - ] - ); - Seq - ( 647, - [ - Prim + ); + Prim ( - 648, - I_CAR, + 319, + I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 649, - I_AMOUNT, - [], - [] ); - Prim - ( 650, - I_DIP, - [ Seq - ( 651, - [ - Prim + ); + Prim ( - 652, - I_PUSH, - [ + 320, + I_SWAP, + [], + [] + ); Prim ( - 653, - T_mutez, + 321, + I_CAR, [], [] ); + Prim + ( + 322, + I_DIG, + [ Int ( - 654, + 323, Z - .one + .of_int + 3 ) ], [] - ) - ] - ) - ], - [] ); - Prim - ( 655, - I_EDIV, - [], - [] ); - Prim - ( 656, - I_IF_NONE, - [ Seq - ( 657, - [ - Prim - ( - 658, - I_PUSH, - [ + ); Prim ( - 659, - T_string, + 324, + I_CDR, [], [] ); - String + Prim ( - 660, - "" - ) - ], + 325, + I_CDR, + [], [] ); Prim ( - 661, - I_FAILWITH, + 326, + I_CDR, [], [] - ) - ] - ); - Seq - ( 662, - [ - Prim - ( - 663, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 664, - I_DUP, - [], - [] ); - Prim - ( 665, - I_DIP, - [ Int - ( 666, - Z - .of_int - 4 - ); - Seq - ( 667, - [ - Prim - ( - 668, - I_DUP, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 669, - I_DIG, - [ Int - ( 670, - Z - .of_int - 4 - ) - ], - [] ); - Prim - ( 671, - I_CDR, - [], - [] ); - Prim - ( 672, - I_CDR, - [], - [] ); - Prim - ( 673, - I_CDR, - [], - [] ); - Prim - ( 674, - I_CAR, - [], - [] ); - Prim - ( 675, - I_MUL, - [], - [] ); - Prim - ( 676, - I_DIP, - [ Int - ( 677, - Z - .of_int - 2 - ); - Seq - ( 678, - [ - Prim - ( - 679, - I_DUP, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 680, - I_DIG, - [ Int - ( 681, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 682, - I_SWAP, - [], - [] ); - Prim - ( 683, - I_EDIV, - [], - [] ); - Prim - ( 684, - I_IF_NONE, - [ Seq - ( 685, - [ - Prim - ( - 686, - I_PUSH, - [ - Prim - ( - 687, - T_string, - [], - [] - ); - String - ( - 688, - "divByZero." - ) - ], - [] ); Prim ( - 689, - I_FAILWITH, - [], - [] - ) - ] - ); - Seq - ( 690, - [ - Prim - ( - 691, - I_DUP, + 327, + I_CDR, [], [] ); Prim ( - 692, + 328, I_CAR, [], [] ); Prim ( - 693, - I_DIP, + 329, + I_CONTRACT, [ - Seq + Prim ( - 694, + 330, + T_pair, [ Prim ( - 695, - I_CDR, + 331, + T_address, [], [] - ) - ] - ) - ], - [] ); Prim ( - 696, - I_SWAP, - [], - [] - ); + 332, + T_pair, + [ Prim ( - 697, - I_INT, + 333, + T_address, [], [] ); Prim ( - 698, - I_EQ, + 334, + T_nat, [], [] + ) + ], + [] + ) + ], + [] + ) + ], + [ + "%transfer" + ] ); Prim ( - 699, - I_IF, + 335, + I_IF_NONE, [ Seq ( - 700, - [] - ); - Seq - ( - 701, + 336, [ Prim ( - 702, + 337, I_PUSH, [ Prim ( - 703, + 338, T_nat, [], [] ); Int ( - 704, + 339, Z - .one + .zero ) ], [] ); Prim ( - 705, - I_ADD, + 340, + I_FAILWITH, [], [] ) ] + ); + Seq + ( + 341, + [] ) ], [] - ) - ] - ) - ], - [] ); - Prim - ( 706, - I_DUP, - [], - [] ); - Prim - ( 707, - I_PUSH, - [ Prim - ( 708, - T_nat, - [], - [] - ); - Int - ( 709, - Z - .zero - ) - ], - [] ); - Prim - ( 710, - I_COMPARE, - [], - [] ); - Prim - ( 711, - I_LT, - [], - [] ); - Prim - ( 712, - I_IF, - [ Seq - ( 713, - [] - ); - Seq - ( 714, - [ - Prim + ); + Prim ( - 715, + 342, I_PUSH, [ Prim ( - 716, - T_string, + 343, + T_mutez, [], [] ); - String + Int ( - 717, - "tokensDeposited \ - is \ - zero." + 344, + Z + .zero ) ], [] ); Prim ( - 718, - I_FAILWITH, - [], - [] + 345, + I_DIG, + [ + Int + ( + 346, + Z + .of_int + 3 ) - ] - ) - ], - [] ); - Prim - ( 719, - I_SWAP, - [], - [] ); - Prim - ( 720, - I_DIP, - [ Int - ( 721, - Z - .of_int - 4 - ); - Seq - ( 722, - [ - Prim - ( - 723, - I_DUP, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 724, - I_DIG, - [ Int - ( 725, - Z - .of_int - 4 - ) - ], - [] ); - Prim - ( 726, - I_CDR, - [], - [] ); - Prim - ( 727, - I_CAR, - [], - [] ); - Prim - ( 728, - I_CDR, - [], - [] ); - Prim - ( 729, - I_MUL, - [], - [] ); - Prim - ( 730, - I_DIP, - [ Seq - ( 731, - [ - Prim - ( - 732, - I_SWAP, - [], + ], [] - ) - ] - ) - ], - [] ); - Prim - ( 733, - I_EDIV, - [], - [] ); - Prim - ( 734, - I_IF_NONE, - [ Seq - ( 735, - [ - Prim - ( - 736, - I_PUSH, - [ + ); Prim ( - 737, - T_string, - [], - [] - ); - String + 347, + I_DIG, + [ + Int ( - 738, - "bad \ - address \ - for \ - get_entrypoint" + 348, + Z + .of_int + 3 ) ], [] ); Prim ( - 739, - I_FAILWITH, + 349, + I_PAIR, [], [] - ) - ] - ); - Seq - ( 740, - [ - Prim + ); + Prim ( - 741, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 742, - I_DIP, - [ Int - ( 743, - Z - .of_int - 2 - ); - Seq - ( 744, - [ - Prim + 350, + I_DIG, + [ + Int ( - 745, - I_DUP, - [], - [] + 351, + Z + .of_int + 3 ) - ] - ) - ], - [] ); - Prim - ( 746, - I_DIG, - [ Int - ( 747, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 748, - I_CAR, - [], - [] ); - Prim - ( 749, - I_CDR, - [], - [] ); - Prim - ( 750, - I_DIP, - [ Seq - ( 751, - [ - Prim + ], + [] + ); + Prim ( - 752, - I_DUP, + 352, + I_PAIR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 753, - I_COMPARE, - [], - [] ); - Prim - ( 754, - I_LE, - [], - [] ); - Prim - ( 755, - I_IF, - [ Seq - ( 756, - [] - ); - Seq - ( 757, - [ - Prim - ( - 758, - I_PUSH, - [ + ); Prim ( - 759, - T_string, + 353, + I_TRANSFER_TOKENS, [], [] ); - String + Prim ( - 760, - "lqtMinted \ - must \ - be \ - greater \ - than \ - or \ - equal \ - to \ - minLqtMinted." + 354, + I_DIG, + [ + Int + ( + 355, + Z + .of_int + 2 ) ], [] ); Prim ( - 761, - I_FAILWITH, + 356, + I_INT, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 762, - I_DIP, - [ Seq - ( 763, - [ - Prim - ( - 764, - I_DIP, - [ - Seq + ); + Prim ( - 765, + 357, + I_DIG, [ - Prim + Int ( - 766, - I_DUP, - [], - [] - ) - ] + 358, + Z + .of_int + 3 ) ], [] ); Prim ( - 767, - I_SWAP, + 359, + I_PAIR, [], [] ); Prim ( - 768, - I_CDR, - [], + 360, + I_DIG, + [ + Int + ( + 361, + Z + .of_int + 2 + ) + ], [] ); Prim ( - 769, - I_CAR, + 362, + I_DUP, [], [] ); Prim ( - 770, - I_DIP, + 363, + I_DUG, [ - Seq - ( - 771, - [ - Prim + Int ( - 772, - I_DUP, - [], - [] - ) - ] + 364, + Z + .of_int + 3 ) ], [] ); Prim ( - 773, - I_COMPARE, + 365, + I_SWAP, [], [] ); Prim ( - 774, - I_GE, + 366, + I_DUP, [], [] ); Prim ( - 775, - I_IF, - [ - Seq - ( - 776, + 367, + I_CDR, + [], [] ); - Seq - ( - 777, - [ Prim ( - 778, - I_PUSH, - [ + 368, + I_SWAP, + [], + [] + ); Prim ( - 779, - T_string, + 369, + I_CAR, [], [] ); - String + Prim ( - 780, - "tokensDeposited \ - is \ - greater \ - than \ - maxTokensDeposited." + 370, + I_DIG, + [ + Int + ( + 371, + Z + .of_int + 2 ) ], [] ); Prim ( - 781, - I_FAILWITH, + 372, + I_CDR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 373, + I_CDR, + [], [] - ) - ] - ) - ], - [] ); - Prim - ( 782, - I_DIP, - [ Int - ( 783, - Z - .of_int - 3 - ); - Seq - ( 784, - [ - Prim + ); + Prim ( - 785, - I_DUP, + 374, + I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 786, - I_DIG, - [ Int - ( 787, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 788, - I_DIP, - [ Int - ( 789, - Z - .of_int - 3 - ); - Seq - ( 790, - [ - Prim + ); + Prim ( - 791, - I_DUP, + 375, + I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 792, - I_DIG, - [ Int - ( 793, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 794, - I_CAR, - [], - [] ); - Prim - ( 795, - I_CAR, - [], - [] ); - Prim - ( 796, - I_DIP, - [ Seq - ( 797, - [ - Prim + ); + Prim ( - 798, - I_CAR, + 376, + I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 799, - I_GET, - [], - [] ); - Prim - ( 800, - I_IF_NONE, - [ Seq - ( 801, - [ - Prim + ); + Prim ( - 802, - I_EMPTY_MAP, + 377, + I_CONTRACT, [ Prim ( - 803, - T_address, + 378, + T_pair, + [ + Prim + ( + 379, + T_int, [], - [] + [ + "%quantity" + ] ); Prim ( - 804, - T_nat, + 380, + T_address, [], - [] + [ + "%target" + ] ) ], [] + ) + ], + [ + "%mintOrBurn" + ] ); Prim ( - 805, + 381, + I_IF_NONE, + [ + Seq + ( + 382, + [ + Prim + ( + 383, I_PUSH, [ Prim ( - 806, + 384, T_nat, [], [] ); Int ( - 807, + 385, Z - .zero + .of_int + 12 ) ], [] ); Prim ( - 808, - I_PAIR, + 386, + I_FAILWITH, [], [] ) - ] - ); - Seq - ( 809, - [] - ) - ], - [] ); - Prim - ( 810, - I_DUP, - [], - [] ); - Prim - ( 811, - I_CAR, - [], - [] ); - Prim - ( 812, - I_DIP, - [ Int - ( 813, - Z - .of_int - 2 - ); - Seq - ( 814, - [ - Prim + ] + ); + Seq ( - 815, - I_DUP, - [], + 387, [] ) - ] - ) - ], - [] ); - Prim - ( 816, - I_DIG, - [ Int - ( 817, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 818, - I_ADD, - [], - [] ); - Prim - ( 819, - I_DIP, - [ Seq - ( 820, - [ - Prim - ( - 821, - I_DUP, - [], + ], [] ); Prim ( - 822, - I_DIP, - [ - Seq - ( - 823, + 388, + I_PUSH, [ Prim ( - 824, - I_CDR, + 389, + T_mutez, [], [] - ) - ] + ); + Int + ( + 390, + Z + .zero ) ], [] ); Prim ( - 825, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 826, - I_SWAP, - [], - [] ); - Prim - ( 827, - I_DROP, - [], - [] ); - Prim - ( 828, - I_PAIR, - [], - [] ); - Prim - ( 829, - I_SOME, - [], - [] ); - Prim - ( 830, - I_DIP, - [ Int - ( 831, - Z - .of_int - 3 - ); - Seq - ( 832, - [ - Prim - ( - 833, - I_DUP, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 834, - I_DIG, - [ Int - ( 835, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 836, - I_CAR, - [], - [] ); - Prim - ( 837, - I_CAR, - [], - [] ); - Prim - ( 838, - I_DIP, - [ Seq - ( 839, - [ - Prim - ( - 840, - I_DIP, + 391, + I_DIG, [ - Seq + Int ( - 841, - [ + 392, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 842, + 393, I_DIG, [ Int ( - 843, + 394, Z .of_int 3 @@ -4288,117 +2404,189 @@ let script = ); Prim ( - 844, - I_DUP, + 395, + I_PAIR, [], [] ); Prim ( - 845, - I_CAR, + 396, + I_TRANSFER_TOKENS, [], [] - ) - ] + ); + Prim + ( + 397, + I_DIG, + [ + Int + ( + 398, + Z + .of_int + 2 ) ], [] - ) - ] - ) - ], - [] ); - Prim - ( 846, - I_UPDATE, - [], - [] ); - Prim - ( 847, - I_DIP, - [ Seq - ( 848, - [ - Prim + ); + Prim ( - 849, - I_DUP, + 399, + I_NIL, + [ + Prim + ( + 400, + T_operation, [], [] + ) + ], + [] ); Prim ( - 850, - I_DIP, + 401, + I_DIG, [ - Seq + Int ( - 851, - [ + 402, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 852, - I_CDR, + 403, + I_CONS, [], [] - ) - ] + ); + Prim + ( + 404, + I_DIG, + [ + Int + ( + 405, + Z + .of_int + 2 ) ], [] ); Prim ( - 853, - I_CAR, + 406, + I_CONS, [], [] + ); + Prim + ( + 407, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] ) ] ) ], - [] ); - Prim - ( 854, - I_SWAP, - [], - [] ); - Prim - ( 855, + [] ) ] + ) ], + [] ) ] ); + Seq + ( 408, + [ Prim + (409, I_DROP, [], []); + Prim + (410, I_DUP, [], []); + Prim + (411, I_CDR, [], []); + Prim + (412, I_CDR, [], []); + Prim + (413, I_CDR, [], []); + Prim + (414, I_CAR, [], []); + Prim + ( 415, + I_IF, + [ Seq + ( 416, + [ Prim + ( 417, I_DROP, [], [] ); Prim - ( 856, - I_PAIR, - [], + ( 418, + I_PUSH, + [ Prim + ( 419, + T_nat, + [], + [] + ); + Int + ( 420, + Z + .of_int + 2 + ) + ], [] ); Prim - ( 857, + ( 421, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( 422, + [ Prim + ( 423, I_DUP, [], [] ); Prim - ( 858, + ( 424, I_CDR, [], [] ); Prim - ( 859, - I_CAR, + ( 425, + I_CDR, [], [] ); Prim - ( 860, - I_CDR, + ( 426, + I_AMOUNT, [], [] ); Prim - ( 861, + ( 427, I_DIG, [ Int - ( 862, + ( 428, Z .of_int 2 @@ -4406,7317 +2594,6943 @@ let script = ], [] ); Prim - ( 863, - I_ADD, + ( 429, + I_DUP, [], [] ); Prim - ( 864, - I_DIP, - [ Seq - ( 865, - [ - Prim - ( - 866, - I_DUP, - [], - [] - ); - Prim - ( - 867, - I_CDR, - [], - [] - ) - ] + ( 430, + I_DUG, + [ Int + ( 431, + Z + .of_int + 3 ) ], [] ); Prim - ( 868, - I_DIP, - [ Seq - ( 869, - [ - Prim - ( - 870, - I_DUP, - [], - [] - ); - Prim - ( - 871, - I_DIP, - [ - Seq - ( - 872, - [ - Prim - ( - 873, - I_CDR, - [], - [] - ) - ] - ) - ], - [] - ); - Prim - ( - 874, - I_CAR, - [], - [] - ) - ] - ) - ], + ( 432, + I_CDR, + [], [] ); Prim - ( 875, - I_DIP, - [ Seq - ( 876, - [ - Prim - ( - 877, - I_DUP, - [], - [] - ); - Prim - ( - 878, - I_DIP, - [ - Seq - ( - 879, - [ - Prim - ( - 880, - I_CAR, - [], - [] - ) - ] - ) - ], - [] - ); - Prim - ( - 881, - I_CDR, - [], - [] - ) - ] - ) - ], + ( 433, + I_CAR, + [], [] ); Prim - ( 882, - I_SWAP, + ( 434, + I_ADD, [], [] ); Prim - ( 883, - I_DROP, + ( 435, + I_PAIR, [], [] ); Prim - ( 884, + ( 436, I_SWAP, [], [] ); Prim - ( 885, - I_PAIR, + ( 437, + I_CAR, [], [] ); Prim - ( 886, + ( 438, I_PAIR, [], [] ); Prim - ( 887, - I_DIP, - [ Seq - ( 888, - [ - Prim - ( - 889, - I_DUP, - [], - [] - ); - Prim - ( - 890, - I_DIP, - [ - Seq - ( - 891, - [ - Prim - ( - 892, - I_CAR, - [], - [] - ) - ] - ) - ], - [] - ); - Prim - ( - 893, - I_CDR, - [], - [] - ) - ] + ( 439, + I_NIL, + [ Prim + ( 440, + T_operation, + [], + [] ) ], [] ); Prim - ( 894, - I_SWAP, - [], - [] ); - Prim - ( 895, - I_DROP, - [], - [] ); - Prim - ( 896, - I_SWAP, - [], - [] ); - Prim - ( 897, + ( 441, I_PAIR, [], + [] ) ] + ) ], + [] ) ] ) ], + [] ) ] ); + Seq + ( 442, + [ Prim + ( 443, + I_IF_LEFT, + [ Seq + ( 444, + [ Prim + (445, I_DUP, [], []); + Prim + (446, I_CDR, [], []); + Prim + (447, I_SWAP, [], []); + Prim + (448, I_CAR, [], []); + Prim + (449, I_SWAP, [], []); + Prim + (450, I_DUP, [], []); + Prim + (451, I_CDR, [], []); + Prim + (452, I_SWAP, [], []); + Prim + (453, I_CAR, [], []); + Prim + (454, I_SWAP, [], []); + Prim + (455, I_DUP, [], []); + Prim + (456, I_CDR, [], []); + Prim + (457, I_SWAP, [], []); + Prim + (458, I_CAR, [], []); + Prim + (459, I_SWAP, [], []); + Prim + (460, I_DUP, [], []); + Prim + (461, I_CDR, [], []); + Prim + (462, I_SWAP, [], []); + Prim + (463, I_CAR, [], []); + Prim + ( 464, + I_DIG, + [ Int + ( 465, + Z.of_int 5 ) + ], + [] ); + Prim + (466, I_DUP, [], []); + Prim + ( 467, + I_DUG, + [ Int + ( 468, + Z.of_int 6 ) + ], + [] ); + Prim + (469, I_CDR, [], []); + Prim + (470, I_CDR, [], []); + Prim + (471, I_CDR, [], []); + Prim + (472, I_CAR, [], []); + Prim + ( 473, + I_IF, + [ Seq + ( 474, + [ Prim + ( 475, + I_DROP, + [ Int + ( 476, + Z + .of_int + 6 + ) + ], [] ); Prim - ( 898, - I_DUP, - [], - [] ); - Prim - ( 899, - I_CDR, - [], + ( 477, + I_PUSH, + [ Prim + ( 478, + T_nat, + [], + [] + ); + Int + ( 479, + Z + .of_int + 2 + ) + ], [] ); Prim - ( 900, - I_CDR, + ( 480, + I_FAILWITH, [], - [] ); - Prim - ( 901, - I_CDR, + [] ) ] + ); + Seq + ( 481, + [ Prim + ( 482, + I_SWAP, [], [] ); Prim - ( 902, - I_CDR, + ( 483, + I_NOW, [], [] ); Prim - ( 903, - I_AMOUNT, + ( 484, + I_COMPARE, [], [] ); Prim - ( 904, - I_ADD, + ( 485, + I_GE, [], [] ); Prim - ( 905, - I_DIP, + ( 486, + I_IF, [ Seq - ( 906, + ( 487, [ Prim ( - 907, - I_DUP, - [], + 488, + I_DROP, + [ + Int + ( + 489, + Z + .of_int + 5 + ) + ], [] ); Prim ( - 908, - I_CDR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 909, - I_DIP, - [ Seq - ( 910, - [ - Prim + 490, + I_PUSH, + [ + Prim ( - 911, - I_DUP, + 491, + T_nat, [], [] ); + Int + ( + 492, + Z + .of_int + 3 + ) + ], + [] + ); Prim ( - 912, - I_DIP, - [ - Seq + 493, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 494, + [ + Prim ( - 913, + 495, + I_PUSH, [ Prim ( - 914, - I_CAR, + 496, + T_mutez, [], [] - ) - ] + ); + Int + ( + 497, + Z + .zero ) ], [] ); Prim ( - 915, - I_CDR, + 498, + I_AMOUNT, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 916, - I_DIP, - [ Seq - ( 917, - [ - Prim + ); + Prim ( - 918, - I_DUP, + 499, + I_COMPARE, [], [] ); Prim ( - 919, - I_DIP, + 500, + I_GT, + [], + [] + ); + Prim + ( + 501, + I_IF, [ Seq ( - 920, + 502, [ Prim ( - 921, - I_CAR, - [], - [] - ) - ] + 503, + I_DROP, + [ + Int + ( + 504, + Z + .of_int + 5 ) ], [] ); Prim ( - 922, - I_CDR, + 505, + I_PUSH, + [ + Prim + ( + 506, + T_nat, [], [] + ); + Int + ( + 507, + Z + .of_int + 10 ) - ] - ) - ], - [] ); - Prim - ( 923, - I_DIP, - [ Seq - ( 924, - [ - Prim + ], + [] + ); + Prim ( - 925, - I_DUP, + 508, + I_FAILWITH, [], [] + ) + ] ); - Prim + Seq ( - 926, - I_DIP, + 509, [ - Seq + Prim ( - 927, + 510, + I_DIG, [ + Int + ( + 511, + Z + .of_int + 4 + ) + ], + [] + ); Prim ( - 928, - I_CAR, + 512, + I_DUP, [], [] - ) - ] + ); + Prim + ( + 513, + I_DUG, + [ + Int + ( + 514, + Z + .of_int + 5 ) ], [] ); Prim ( - 929, + 515, I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 930, - I_SWAP, - [], - [] ); - Prim - ( 931, - I_DROP, - [], - [] ); - Prim - ( 932, - I_SWAP, - [], - [] ); - Prim - ( 933, - I_PAIR, - [], - [] ); - Prim - ( 934, - I_SWAP, - [], - [] ); - Prim - ( 935, - I_PAIR, - [], - [] ); - Prim - ( 936, - I_SWAP, - [], - [] ); - Prim - ( 937, - I_PAIR, - [], - [] ); - Prim - ( 938, - I_DIP, - [ Seq - ( 939, - [ - Prim + ); + Prim ( - 940, - I_DUP, + 516, + I_CDR, [], [] ); Prim ( - 941, - I_DIP, - [ - Seq + 517, + I_CAR, + [], + [] + ); + Prim ( - 942, + 518, + I_PUSH, [ Prim ( - 943, - I_CAR, + 519, + T_mutez, [], [] + ); + Int + ( + 520, + Z + .one ) - ] + ], + [] + ); + Prim + ( + 521, + I_DIG, + [ + Int + ( + 522, + Z + .of_int + 6 ) ], [] ); Prim ( - 944, - I_CDR, + 523, + I_DUP, [], [] + ); + Prim + ( + 524, + I_DUG, + [ + Int + ( + 525, + Z + .of_int + 7 ) - ] - ) - ], - [] ); - Prim - ( 945, - I_SWAP, - [], - [] ); - Prim - ( 946, - I_DROP, - [], - [] ); - Prim - ( 947, - I_SWAP, - [], - [] ); - Prim - ( 948, - I_PAIR, - [], - [] ); - Prim - ( 949, - I_DUP, - [], - [] ); - Prim - ( 950, - I_CDR, - [], - [] ); - Prim - ( 951, - I_CDR, - [], - [] ); - Prim - ( 952, - I_CDR, - [], - [] ); - Prim - ( 953, - I_CAR, - [], - [] ); - Prim - ( 954, - I_DIP, - [ Int - ( 955, - Z - .of_int - 2 - ); - Seq - ( 956, - [ - Prim - ( - 957, - I_DUP, - [], + ], [] - ) - ] - ) - ], - [] ); - Prim - ( 958, - I_DIG, - [ Int - ( 959, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 960, - I_ADD, - [], - [] ); - Prim - ( 961, - I_DIP, - [ Seq - ( 962, - [ - Prim + ); + Prim ( - 963, - I_DUP, + 526, + I_CDR, [], [] ); Prim ( - 964, - I_CDR, + 527, + I_CAR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 965, - I_DIP, - [ Seq - ( 966, - [ - Prim + ); + Prim ( - 967, - I_DUP, + 528, + I_EDIV, [], [] ); Prim ( - 968, - I_DIP, + 529, + I_IF_NONE, [ Seq ( - 969, + 530, [ Prim ( - 970, - I_CAR, + 531, + I_PUSH, + [ + Prim + ( + 532, + T_string, [], [] - ) - ] + ); + String + ( + 533, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 971, - I_CDR, + 534, + I_FAILWITH, [], [] ) - ] - ) - ], - [] ); - Prim - ( 972, - I_DIP, - [ Seq - ( 973, - [ - Prim + ] + ); + Seq ( - 974, - I_DUP, + 535, + [] + ) + ], + [] + ); + Prim + ( + 536, + I_CAR, [], [] ); Prim ( - 975, - I_DIP, + 537, + I_DIG, [ - Seq + Int ( - 976, - [ + 538, + Z + .of_int + 4 + ) + ], + [] + ); Prim ( - 977, - I_CAR, + 539, + I_DUP, [], [] - ) - ] + ); + Prim + ( + 540, + I_DUG, + [ + Int + ( + 541, + Z + .of_int + 5 ) ], [] ); Prim ( - 978, - I_CDR, + 542, + I_MUL, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 979, - I_DIP, - [ Seq - ( 980, - [ - Prim + ); + Prim ( - 981, - I_DUP, + 543, + I_EDIV, [], [] ); Prim ( - 982, - I_DIP, + 544, + I_IF_NONE, [ Seq ( - 983, + 545, [ Prim ( - 984, - I_CDR, + 546, + I_PUSH, + [ + Prim + ( + 547, + T_string, [], [] - ) - ] + ); + String + ( + 548, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 985, - I_CAR, + 549, + I_FAILWITH, [], [] ) - ] - ) - ], - [] ); - Prim - ( 986, - I_SWAP, - [], - [] ); - Prim - ( 987, - I_DROP, - [], - [] ); - Prim - ( 988, - I_PAIR, - [], - [] ); - Prim - ( 989, - I_SWAP, - [], - [] ); - Prim - ( 990, - I_PAIR, - [], - [] ); - Prim - ( 991, - I_SWAP, - [], - [] ); - Prim - ( 992, - I_PAIR, - [], - [] ); - Prim - ( 993, - I_DIP, - [ Seq - ( 994, - [ - Prim - ( - 995, - I_DUP, - [], - [] + ] ); - Prim - ( - 996, - I_DIP, - [ Seq ( - 997, - [ - Prim - ( - 998, - I_CAR, - [], + 550, [] ) - ] - ) ], [] ); Prim ( - 999, - I_CDR, + 551, + I_CAR, [], [] + ); + Prim + ( + 552, + I_PUSH, + [ + Prim + ( + 553, + T_mutez, + [], + [] + ); + Int + ( + 554, + Z + .one ) - ] - ) - ], - [] ); - Prim - ( 1000, - I_SWAP, - [], - [] ); - Prim - ( 1001, - I_DROP, - [], - [] ); - Prim - ( 1002, - I_SWAP, - [], - [] ); - Prim - ( 1003, - I_PAIR, - [], - [] ); - Prim - ( 1004, - I_DIP, - [ Seq - ( 1005, - [ - Prim + ], + [] + ); + Prim ( - 1006, - I_DIP, + 555, + I_SWAP, + [], + [] + ); + Prim + ( + 556, + I_MUL, + [], + [] + ); + Prim + ( + 557, + I_DIG, [ - Seq + Int ( - 1007, + 558, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 559, + I_DUP, + [], + [] + ); + Prim + ( + 560, + I_DUG, [ + Int + ( + 561, + Z + .of_int + 6 + ) + ], + [] + ); Prim ( - 1008, - I_CAR, + 562, + I_CDR, [], [] ); Prim ( - 1009, + 563, + I_CDR, + [], + [] + ); + Prim + ( + 564, I_CAR, [], [] - ) - ] + ); + Prim + ( + 565, + I_DIG, + [ + Int + ( + 566, + Z + .of_int + 6 ) ], [] - ) - ] - ) - ], - [] ); - Prim - ( 1010, - I_DUP, - [], - [] ); - Prim - ( 1011, - I_CDR, - [], - [] ); - Prim - ( 1012, - I_CDR, - [], - [] ); - Prim - ( 1013, - I_CAR, - [], - [] ); - Prim - ( 1014, - I_CONTRACT, - [ Prim - ( 1015, - T_pair, - [ - Prim + ); + Prim ( - 1016, - T_address, + 567, + I_DUP, [], [] ); Prim ( - 1017, - T_pair, + 568, + I_DUG, [ + Int + ( + 569, + Z + .of_int + 7 + ) + ], + [] + ); Prim ( - 1018, - T_address, + 570, + I_CAR, [], [] ); Prim ( - 1019, - T_nat, + 571, + I_DIG, + [ + Int + ( + 572, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 573, + I_DUP, [], [] + ); + Prim + ( + 574, + I_DUG, + [ + Int + ( + 575, + Z + .of_int + 6 ) ], [] - ) - ], - [] - ) - ], - [ "%transfer" - ] ); - Prim - ( 1020, - I_IF_NONE, - [ Seq - ( 1021, - [ - Prim + ); + Prim ( - 1022, + 576, + I_MUL, + [], + [] + ); + Prim + ( + 577, + I_EDIV, + [], + [] + ); + Prim + ( + 578, + I_IF_NONE, + [ + Seq + ( + 579, + [ + Prim + ( + 580, I_PUSH, [ Prim ( - 1023, + 581, T_string, [], [] ); String ( - 1024, - "bad \ - address \ - for \ - get_entrypoint" + 582, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 1025, + 583, I_FAILWITH, [], [] ) - ] - ); - Seq - ( 1026, - [] - ) - ], - [] ); - Prim - ( 1027, - I_PUSH, - [ Prim - ( 1028, - T_mutez, - [], - [] - ); - Int - ( 1029, - Z - .zero - ) - ], - [] ); - Prim - ( 1030, - I_DIG, - [ Int - ( 1031, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 1032, - I_SELF, - [], - [] ); - Prim - ( 1033, - I_ADDRESS, - [], - [] ); - Prim - ( 1034, - I_DIG, - [ Int - ( 1035, - Z - .of_int - 5 - ) - ], - [] ); - Prim - ( 1036, - I_DIP, - [ Seq - ( 1037, - [ - Prim + ] + ); + Seq ( - 1038, - I_PAIR, + 584, + [] + ) + ], + [] + ); + Prim + ( + 585, + I_CAR, [], [] + ); + Prim + ( + 586, + I_DIG, + [ + Int + ( + 587, + Z + .of_int + 3 ) - ] - ) - ], - [] ); - Prim - ( 1039, - I_PAIR, - [], - [] ); - Prim - ( 1040, - I_TRANSFER_TOKENS, - [], - [] ); - Prim - ( 1041, - I_DIP, - [ Seq - ( 1042, - [ - Prim + ], + [] + ); + Prim ( - 1043, - I_NIL, + 588, + I_DIG, [ + Int + ( + 589, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 1044, - T_operation, + 590, + I_DUP, [], [] + ); + Prim + ( + 591, + I_DUG, + [ + Int + ( + 592, + Z + .of_int + 3 ) ], [] + ); + Prim + ( + 593, + I_COMPARE, + [], + [] + ); + Prim + ( + 594, + I_LT, + [], + [] + ); + Prim + ( + 595, + I_IF, + [ + Seq + ( + 596, + [ + Prim + ( + 597, + I_DROP, + [ + Int + ( + 598, + Z + .of_int + 6 ) - ] - ) - ], - [] ); - Prim - ( 1045, - I_CONS, - [], - [] ); - Prim - ( 1046, - I_PAIR, - [], - [] ) ] - ) ], - [] ) ] ) ], - [] ) ] ); - Seq - ( 1047, - [ Prim - ( 1048, - I_IF_LEFT, - [ Seq - ( 1049, - [ Prim - ( 1050, - I_DIP, - [ Seq - ( 1051, - [ Prim - ( 1052, - I_DUP, - [], - [] ); - Prim - ( 1053, - I_CDR, - [], - [] ); - Prim - ( 1054, - I_CAR, - [], - [] ); - Prim - ( 1055, - I_CAR, - [], - [] ); - Prim - ( 1056, - I_IF, - [ Seq - ( 1057, - [ - Prim + ], + [] + ); + Prim ( - 1058, + 599, I_PUSH, [ Prim ( - 1059, - T_string, + 600, + T_nat, [], [] ); - String + Int ( - 1060, - "selfIsUpdatingToken \ - must \ - be \ - false." + 601, + Z + .of_int + 11 ) ], [] ); Prim ( - 1061, + 602, I_FAILWITH, [], [] ) - ] - ); - Seq - ( 1062, - [] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (1063, I_DUP, [], []); - Prim - (1064, I_CDR, [], []); - Prim - (1065, I_CDR, [], []); - Prim - (1066, I_CDR, [], []); - Prim - (1067, I_NOW, [], []); - Prim - ( 1068, - I_COMPARE, - [], - [] ); - Prim - (1069, I_LT, [], []); - Prim - ( 1070, - I_IF, - [ Seq (1071, []); - Seq - ( 1072, - [ Prim - ( 1073, - I_PUSH, - [ Prim - ( 1074, - T_string, - [], - [] - ); - String - ( 1075, - "NOW \ - is \ - greater \ - than \ - deadline." - ) - ], - [] ); - Prim - ( 1076, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1077, - I_PUSH, - [ Prim - ( 1078, - T_mutez, - [], - [] ); - Int (1079, Z.zero) - ], - [] ); - Prim - ( 1080, - I_AMOUNT, - [], - [] ); - Prim - ( 1081, - I_COMPARE, - [], - [] ); - Prim - (1082, I_EQ, [], []); - Prim - ( 1083, - I_IF, - [ Seq (1084, []); - Seq - ( 1085, - [ Prim - ( 1086, - I_PUSH, - [ Prim - ( 1087, - T_string, - [], - [] - ); - String - ( 1088, - "Amount \ - must \ - be \ - zero." - ) - ], - [] ); - Prim - ( 1089, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (1090, I_DUP, [], []); - Prim - (1091, I_CDR, [], []); - Prim - (1092, I_CAR, [], []); - Prim - ( 1093, - I_PUSH, - [ Prim - ( 1094, - T_mutez, - [], - [] ); - Int (1095, Z.zero) - ], - [] ); - Prim - ( 1096, - I_COMPARE, - [], - [] ); - Prim - (1097, I_LT, [], []); - Prim - ( 1098, - I_IF, - [ Seq (1099, []); - Seq - ( 1100, - [ Prim - ( 1101, - I_PUSH, - [ Prim - ( 1102, - T_string, - [], - [] - ); - String - ( 1103, - "minXtzWithdrawn \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 1104, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (1105, I_DUP, [], []); - Prim - (1106, I_CDR, [], []); - Prim - (1107, I_CDR, [], []); - Prim - (1108, I_CAR, [], []); - Prim - ( 1109, - I_PUSH, - [ Prim - ( 1110, - T_nat, - [], - [] ); - Int (1111, Z.zero) - ], - [] ); - Prim - ( 1112, - I_COMPARE, - [], - [] ); - Prim - (1113, I_LT, [], []); - Prim - ( 1114, - I_IF, - [ Seq (1115, []); - Seq - ( 1116, - [ Prim - ( 1117, - I_PUSH, - [ Prim - ( 1118, - T_string, - [], - [] - ); - String - ( 1119, - "minTokensWithdrawn \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 1120, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (1121, I_DUP, [], []); - Prim - (1122, I_CAR, [], []); - Prim - (1123, I_CDR, [], []); - Prim - (1124, I_CDR, [], []); - Prim - ( 1125, - I_PUSH, - [ Prim - ( 1126, - T_nat, - [], - [] ); - Int (1127, Z.zero) - ], - [] ); - Prim - ( 1128, - I_COMPARE, - [], - [] ); - Prim - (1129, I_LT, [], []); - Prim - ( 1130, - I_IF, - [ Seq (1131, []); - Seq - ( 1132, - [ Prim - ( 1133, - I_PUSH, - [ Prim - ( 1134, - T_string, - [], - [] - ); - String - ( 1135, - "lqtBurned \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 1136, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (1137, I_DUP, [], []); - Prim - (1138, I_CAR, [], []); - Prim - (1139, I_CAR, [], []); - Prim - ( 1140, - I_DIP, - [ Seq - ( 1141, - [ Prim - ( 1142, - I_DIP, - [ Seq - ( 1143, - [ - Prim + ] + ); + Seq ( - 1144, + 603, + [ + Prim + ( + 604, + I_DIG, + [ + Int + ( + 605, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 606, + I_SWAP, + [], + [] + ); + Prim + ( + 607, I_DUP, [], [] + ); + Prim + ( + 608, + I_DUG, + [ + Int + ( + 609, + Z + .of_int + 2 ) - ] - ) - ], - [] ); - Prim - ( 1145, - I_SWAP, - [], - [] ); - Prim - ( 1146, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1147, I_GET, [], []); - Prim - ( 1148, - I_IF_NONE, - [ Seq - ( 1149, - [ Prim - ( 1150, - I_PUSH, - [ Prim - ( 1151, - T_string, - [], - [] - ); - String - ( 1152, - "owner \ - has \ - no \ - liquidity." - ) - ], - [] ); - Prim - ( 1153, - I_FAILWITH, - [], - [] ) ] - ); - Seq (1154, []) ], - [] ); - Prim - (1155, I_SWAP, [], []); - Prim - (1156, I_DUP, [], []); - Prim - (1157, I_CAR, [], []); - Prim - (1158, I_CDR, [], []); - Prim - (1159, I_CDR, [], []); - Prim - ( 1160, - I_DIP, - [ Int - ( 1161, - Z.of_int 2 ); - Seq - ( 1162, - [ Prim - ( 1163, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1164, - I_DIG, - [ Int - ( 1165, - Z.of_int 2 ) - ], - [] ); - Prim - (1166, I_CAR, [], []); - Prim - ( 1167, - I_COMPARE, - [], - [] ); - Prim - (1168, I_GE, [], []); - Prim - ( 1169, - I_IF, - [ Seq (1170, []); - Seq - ( 1171, - [ Prim - ( 1172, - I_PUSH, - [ Prim - ( 1173, - T_string, - [], - [] - ); - String - ( 1174, - "lqtBurned \ - is \ - greater \ - than \ - owner's \ - balance." - ) - ], - [] ); - Prim - ( 1175, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (1176, I_DUP, [], []); - Prim - (1177, I_CAR, [], []); - Prim - (1178, I_CAR, [], []); - Prim - ( 1179, - I_SENDER, - [], - [] ); - Prim - ( 1180, - I_COMPARE, - [], - [] ); - Prim - (1181, I_EQ, [], []); - Prim - ( 1182, - I_IF, - [ Seq - ( 1183, - [ Prim - ( 1184, - I_SWAP, - [], - [] ); - Prim - ( 1185, - I_CAR, - [], - [] ) ] - ); - Seq - ( 1186, - [ Prim - ( 1187, - I_SWAP, - [], - [] ); - Prim - ( 1188, - I_DUP, - [], - [] ); - Prim - ( 1189, - I_CDR, - [], - [] ); - Prim - ( 1190, - I_SENDER, - [], - [] ); - Prim - ( 1191, - I_GET, - [], - [] ); - Prim - ( 1192, - I_IF_NONE, - [ Seq - ( 1193, - [ - Prim + ], + [] + ); + Prim + ( + 610, + I_COMPARE, + [], + [] + ); + Prim + ( + 611, + I_LT, + [], + [] + ); + Prim + ( + 612, + I_IF, + [ + Seq + ( + 613, + [ + Prim + ( + 614, + I_DROP, + [ + Int + ( + 615, + Z + .of_int + 5 + ) + ], + [] + ); + Prim ( - 1194, + 616, I_PUSH, [ Prim ( - 1195, - T_string, + 617, + T_nat, [], [] ); - String + Int ( - 1196, - "sender \ - has \ - no \ - approval \ - balance." + 618, + Z + .of_int + 13 ) ], [] ); Prim ( - 1197, + 619, I_FAILWITH, [], [] ) - ] - ); - Seq - ( 1198, - [] - ) - ], - [] ); - Prim - ( 1199, - I_DIP, - [ Seq - ( 1200, - [ - Prim + ] + ); + Seq ( - 1201, - I_SWAP, - [], + 620, + [ + Prim + ( + 621, + I_DIG, + [ + Int + ( + 622, + Z + .of_int + 2 + ) + ], [] ); Prim ( - 1202, + 623, I_DUP, [], [] ); Prim ( - 1203, - I_CAR, + 624, + I_DUG, + [ + Int + ( + 625, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 626, + I_DIG, + [ + Int + ( + 627, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 628, + I_DUP, [], [] ); Prim ( - 1204, + 629, + I_DUG, + [ + Int + ( + 630, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 631, I_CDR, [], [] ); Prim ( - 1205, + 632, I_CDR, [], [] ); Prim ( - 1206, - I_DIP, + 633, + I_CAR, + [], + [] + ); + Prim + ( + 634, + I_SUB, + [], + [] + ); + Prim + ( + 635, + I_ISNAT, + [], + [] + ); + Prim + ( + 636, + I_IF_NONE, [ Seq ( - 1207, + 637, [ Prim ( - 1208, + 638, I_PUSH, [ Prim ( - 1209, - T_int, + 639, + T_nat, [], [] ); Int ( - 1210, + 640, Z - .zero + .of_int + 14 ) ], [] + ); + Prim + ( + 641, + I_FAILWITH, + [], + [] ) ] + ); + Seq + ( + 642, + [] ) ], [] - ) - ] - ) - ], - [] ); - Prim - ( 1211, - I_SUB, - [], - [] ); - Prim - ( 1212, - I_DUP, - [], - [] ); - Prim - ( 1213, - I_DIP, - [ Seq - ( 1214, - [ - Prim + ); + Prim ( - 1215, - I_COMPARE, + 643, + I_SWAP, [], [] ); Prim ( - 1216, - I_GE, + 644, + I_DUP, [], [] ); Prim ( - 1217, - I_IF, + 645, + I_DUG, [ - Seq + Int ( - 1218, + 646, + Z + .of_int + 2 + ) + ], [] ); - Seq - ( - 1219, - [ Prim ( - 1220, - I_PUSH, + 647, + I_DIG, [ + Int + ( + 648, + Z + .of_int + 6 + ) + ], + [] + ); Prim ( - 1221, - T_string, + 649, + I_DUP, [], [] ); - String + Prim ( - 1222, - "sender \ - approval \ - balance \ - is \ - less \ - than \ - LQT \ - burned." + 650, + I_DUG, + [ + Int + ( + 651, + Z + .of_int + 7 ) ], [] ); Prim ( - 1223, - I_FAILWITH, + 652, + I_CAR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 653, + I_SUB, + [], [] - ) - ] - ) - ], - [] ); - Prim - ( 1224, - I_ABS, - [], - [] ); - Prim - ( 1225, - I_SOME, - [], - [] ); - Prim - ( 1226, - I_DIG, - [ Int - ( 1227, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 1228, - I_DUP, - [], - [] ); - Prim - ( 1229, - I_CDR, - [], - [] ); - Prim - ( 1230, - I_DIG, - [ Int - ( 1231, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 1232, - I_SENDER, - [], - [] ); - Prim - ( 1233, - I_UPDATE, - [], - [] ); - Prim - ( 1234, - I_DIP, - [ Seq - ( 1235, - [ - Prim + ); + Prim ( - 1236, - I_DUP, + 654, + I_ISNAT, [], [] ); Prim ( - 1237, - I_DIP, + 655, + I_IF_NONE, [ Seq ( - 1238, + 656, [ Prim ( - 1239, - I_CAR, + 657, + I_PUSH, + [ + Prim + ( + 658, + T_nat, [], [] - ) - ] + ); + Int + ( + 659, + Z + .of_int + 15 ) ], [] ); Prim ( - 1240, - I_CDR, + 660, + I_FAILWITH, [], [] ) - ] - ) - ], - [] ); - Prim - ( 1241, - I_SWAP, - [], - [] ); - Prim - ( 1242, - I_DROP, - [], - [] ); - Prim - ( 1243, - I_SWAP, - [], - [] ); - Prim - ( 1244, - I_PAIR, - [], - [] ); - Prim - ( 1245, - I_DUP, - [], - [] ); - Prim - ( 1246, - I_CAR, - [], - [] ); - Prim - ( 1247, - I_DIP, - [ Seq - ( 1248, - [ - Prim + ] + ); + Seq ( - 1249, - I_SOME, - [], + 661, + [] + ) + ], [] ); Prim ( - 1250, - I_DUG, + 662, + I_DIG, [ Int ( - 1251, + 663, Z - .one + .of_int + 4 ) ], [] ); Prim ( - 1252, - I_DUP, + 664, + I_PUSH, + [ + Prim + ( + 665, + T_int, [], [] ); + Int + ( + 666, + Z + .zero + ) + ], + [] + ); Prim ( - 1253, - I_CAR, + 667, + I_SUB, [], [] ); Prim ( - 1254, - I_CAR, + 668, + I_SENDER, [], [] ); Prim ( - 1255, - I_SWAP, + 669, + I_PAIR, [], [] ); Prim ( - 1256, - I_DIP, + 670, + I_DIG, [ - Seq + Int ( - 1257, - [ + 671, + Z + .of_int + 6 + ) + ], + [] + ); Prim ( - 1258, - I_DIP, - [ - Seq - ( - 1259, - [ + 672, + I_DUP, + [], + [] + ); Prim ( - 1260, - I_DIP, + 673, + I_DUG, [ - Seq + Int ( - 1261, - [ + 674, + Z + .of_int + 7 + ) + ], + [] + ); Prim ( - 1262, - I_DUP, + 675, + I_SWAP, [], [] ); Prim ( - 1263, - I_CAR, + 676, + I_DUP, [], [] - ) - ] - ) - ], - [] - ) - ] - ) - ], - [] ); Prim ( - 1264, - I_UPDATE, + 677, + I_CDR, [], [] ); Prim ( - 1265, - I_DIP, - [ - Seq - ( - 1266, - [ + 678, + I_SWAP, + [], + [] + ); Prim ( - 1267, - I_DUP, + 679, + I_CAR, [], [] ); Prim ( - 1268, - I_DIP, + 680, + I_DIG, [ - Seq + Int ( - 1269, - [ + 681, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 1270, + 682, I_CDR, [], [] - ) - ] - ) - ], - [] ); Prim ( - 1271, - I_CAR, + 683, + I_CDR, [], [] - ) - ] - ) - ], - [] ); Prim ( - 1272, - I_SWAP, + 684, + I_CDR, [], [] ); Prim ( - 1273, - I_DROP, + 685, + I_CDR, [], [] ); Prim ( - 1274, - I_PAIR, + 686, + I_CDR, [], [] + ); + Prim + ( + 687, + I_CONTRACT, + [ + Prim + ( + 688, + T_pair, + [ + Prim + ( + 689, + T_int, + [], + [ + "%quantity" + ] + ); + Prim + ( + 690, + T_address, + [], + [ + "%target" + ] ) + ], + [] + ) + ], + [ + "%mintOrBurn" ] + ); + Prim + ( + 691, + I_IF_NONE, + [ + Seq + ( + 692, + [ + Prim + ( + 693, + I_PUSH, + [ + Prim + ( + 694, + T_nat, + [], + [] + ); + Int + ( + 695, + Z + .of_int + 12 ) ], [] + ); + Prim + ( + 696, + I_FAILWITH, + [], + [] ) - ] - ) - ], - [] ) ] - ) ], - [] ); - Prim - ( 1275, - I_DIP, - [ Seq - ( 1276, - [ Prim - ( 1277, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - (1278, I_SWAP, [], []); - Prim - (1279, I_CAR, [], []); - Prim - (1280, I_CDR, [], []); - Prim - (1281, I_CDR, [], []); - Prim - ( 1282, - I_DIP, - [ Int - ( 1283, - Z.of_int 3 ); - Seq - ( 1284, - [ Prim - ( 1285, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1286, - I_DIG, - [ Int - ( 1287, - Z.of_int 3 ) - ], - [] ); - Prim - (1288, I_CDR, [], []); - Prim - (1289, I_CDR, [], []); - Prim - (1290, I_CDR, [], []); - Prim - (1291, I_CDR, [], []); - Prim - ( 1292, - I_DIP, - [ Seq - ( 1293, - [ Prim - ( 1294, - I_PUSH, - [ Prim - ( 1295, - T_mutez, - [], - [] - ); - Int - ( 1296, - Z - .one - ) - ], - [] ) ] - ) ], - [] ); - Prim - (1297, I_EDIV, [], []); - Prim - ( 1298, - I_IF_NONE, - [ Seq - ( 1299, - [ Prim - ( 1300, - I_PUSH, - [ Prim - ( 1301, - T_string, - [], - [] - ); - String - ( 1302, - "" - ) - ], - [] ); - Prim - ( 1303, - I_FAILWITH, - [], - [] ) ] - ); - Seq - ( 1304, - [ Prim - ( 1305, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1306, I_MUL, [], []); - Prim - ( 1307, - I_DIP, - [ Seq - ( 1308, - [ Prim - ( 1309, - I_DIP, - [ Int - ( 1310, - Z - .of_int - 2 - ); - Seq - ( 1311, - [ - Prim + ] + ); + Seq ( - 1312, - I_DUP, + 697, + [] + ) + ], + [] + ); + Prim + ( + 698, + I_PUSH, + [ + Prim + ( + 699, + T_mutez, [], [] + ); + Int + ( + 700, + Z + .zero ) - ] - ) - ], - [] ); - Prim - ( 1313, - I_DIG, - [ Int - ( 1314, - Z - .of_int + ], + [] + ); + Prim + ( + 701, + I_DIG, + [ + Int + ( + 702, + Z + .of_int 2 - ) - ], - [] ); - Prim - ( 1315, - I_CDR, - [], - [] ); - Prim - ( 1316, - I_CAR, - [], - [] ); - Prim - ( 1317, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (1318, I_EDIV, [], []); - Prim - ( 1319, - I_IF_NONE, - [ Seq - ( 1320, - [ Prim - ( 1321, - I_PUSH, - [ Prim - ( 1322, - T_string, - [], - [] - ); - String - ( 1323, - "divByZero." - ) - ], - [] ); - Prim - ( 1324, - I_FAILWITH, - [], - [] ) ] - ); - Seq - ( 1325, - [ Prim - ( 1326, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1327, - I_PUSH, - [ Prim - ( 1328, - T_mutez, - [], - [] ); - Int (1329, Z.one) - ], - [] ); - Prim - (1330, I_MUL, [], []); - Prim - (1331, I_DUP, [], []); - Prim - ( 1332, - I_DIP, - [ Int - ( 1333, - Z.of_int 3 ); - Seq - ( 1334, - [ Prim - ( 1335, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1336, - I_DIG, - [ Int - ( 1337, - Z.of_int 3 ) - ], - [] ); - Prim - (1338, I_CDR, [], []); - Prim - (1339, I_CAR, [], []); - Prim - ( 1340, - I_COMPARE, - [], - [] ); - Prim - (1341, I_LE, [], []); - Prim - ( 1342, - I_IF, - [ Seq (1343, []); - Seq - ( 1344, - [ Prim - ( 1345, - I_PUSH, - [ Prim - ( 1346, - T_string, - [], - [] - ); - String - ( 1347, - "xtzWithdrawn \ - is \ - less \ - than \ - minXtzWithdrawn." - ) - ], - [] ); - Prim - ( 1348, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1349, - I_DIP, - [ Int - ( 1350, - Z.of_int 2 ); - Seq - ( 1351, - [ Prim - ( 1352, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1353, - I_DIG, - [ Int - ( 1354, - Z.of_int 2 ) - ], - [] ); - Prim - (1355, I_CAR, [], []); - Prim - (1356, I_CDR, [], []); - Prim - (1357, I_CDR, [], []); - Prim - ( 1358, - I_DIP, - [ Seq - ( 1359, - [ Prim - ( 1360, - I_DIP, - [ Int - ( 1361, - Z - .of_int + ) + ], + [] + ); + Prim + ( + 703, + I_DIG, + [ + Int + ( + 704, + Z + .of_int 3 - ); - Seq - ( 1362, - [ - Prim + ) + ], + [] + ); + Prim ( - 1363, + 705, + I_PAIR, + [], + [] + ); + Prim + ( + 706, + I_TRANSFER_TOKENS, + [], + [] + ); + Prim + ( + 707, + I_DIG, + [ + Int + ( + 708, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 709, + I_DIG, + [ + Int + ( + 710, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 711, I_DUP, [], [] + ); + Prim + ( + 712, + I_DUG, + [ + Int + ( + 713, + Z + .of_int + 6 ) - ] - ) - ], - [] ); - Prim - ( 1364, - I_DIG, - [ Int - ( 1365, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 1366, - I_DUP, - [], - [] ); - Prim - ( 1367, - I_CDR, - [], - [] ); - Prim - ( 1368, - I_CAR, - [], - [] ); - Prim - ( 1369, - I_CDR, - [], - [] ); - Prim - ( 1370, - I_SWAP, - [], - [] ); - Prim - ( 1371, - I_CDR, - [], - [] ); - Prim - ( 1372, - I_CDR, - [], - [] ); - Prim - ( 1373, - I_CDR, - [], - [] ); - Prim - ( 1374, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1375, I_MUL, [], []); - Prim - (1376, I_EDIV, [], []); - Prim - ( 1377, - I_IF_NONE, - [ Seq - ( 1378, - [ Prim - ( 1379, - I_PUSH, - [ Prim - ( 1380, - T_string, - [], - [] - ); - String - ( 1381, - "divByZero." - ) - ], - [] ); - Prim - ( 1382, - I_FAILWITH, - [], - [] ) ] - ); - Seq - ( 1383, - [ Prim - ( 1384, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1385, I_DUP, [], []); - Prim - ( 1386, - I_DIP, - [ Int - ( 1387, - Z.of_int 4 ); - Seq - ( 1388, - [ Prim - ( 1389, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1390, - I_DIG, - [ Int - ( 1391, - Z.of_int 4 ) - ], - [] ); - Prim - (1392, I_CDR, [], []); - Prim - (1393, I_CDR, [], []); - Prim - (1394, I_CAR, [], []); - Prim - ( 1395, - I_COMPARE, - [], - [] ); - Prim - (1396, I_LE, [], []); - Prim - ( 1397, - I_IF, - [ Seq (1398, []); - Seq - ( 1399, - [ Prim - ( 1400, - I_PUSH, - [ Prim - ( 1401, - T_string, - [], - [] - ); - String - ( 1402, - "tokensWithdrawn \ - is \ - less \ - than \ - minTokensWithdrawn." - ) - ], - [] ); - Prim - ( 1403, - I_FAILWITH, - [], + ], + [] + ); + Prim + ( + 714, + I_PAIR, + [], + [] + ); + Prim + ( + 715, + I_SELF, + [], + [] + ); + Prim + ( + 716, + I_ADDRESS, + [], + [] + ); + Prim + ( + 717, + I_PAIR, + [], + [] + ); + Prim + ( + 718, + I_DIG, + [ + Int + ( + 719, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 720, + I_DUP, + [], + [] + ); + Prim + ( + 721, + I_DUG, + [ + Int + ( + 722, + Z + .of_int + 7 + ) + ], + [] + ); + Prim + ( + 723, + I_SWAP, + [], + [] + ); + Prim + ( + 724, + I_DUP, + [], + [] + ); + Prim + ( + 725, + I_CDR, + [], + [] + ); + Prim + ( + 726, + I_SWAP, + [], + [] + ); + Prim + ( + 727, + I_CAR, + [], + [] + ); + Prim + ( + 728, + I_SWAP, + [], + [] + ); + Prim + ( + 729, + I_DUP, + [], + [] + ); + Prim + ( + 730, + I_CDR, + [], + [] + ); + Prim + ( + 731, + I_SWAP, + [], + [] + ); + Prim + ( + 732, + I_CAR, + [], + [] + ); + Prim + ( + 733, + I_DIG, + [ + Int + ( + 734, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 735, + I_CDR, + [], + [] + ); + Prim + ( + 736, + I_CDR, + [], + [] + ); + Prim + ( + 737, + I_CDR, + [], + [] + ); + Prim + ( + 738, + I_CDR, + [], + [] + ); + Prim + ( + 739, + I_CAR, + [], + [] + ); + Prim + ( + 740, + I_CONTRACT, + [ + Prim + ( + 741, + T_pair, + [ + Prim + ( + 742, + T_address, + [], + [] + ); + Prim + ( + 743, + T_pair, + [ + Prim + ( + 744, + T_address, + [], + [] + ); + Prim + ( + 745, + T_nat, + [], + [] + ) + ], + [] + ) + ], + [] + ) + ], + [ + "%transfer" + ] + ); + Prim + ( + 746, + I_IF_NONE, + [ + Seq + ( + 747, + [ + Prim + ( + 748, + I_PUSH, + [ + Prim + ( + 749, + T_nat, + [], + [] + ); + Int + ( + 750, + Z + .zero + ) + ], + [] + ); + Prim + ( + 751, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 752, + [] + ) + ], + [] + ); + Prim + ( + 753, + I_PUSH, + [ + Prim + ( + 754, + T_mutez, + [], + [] + ); + Int + ( + 755, + Z + .zero + ) + ], + [] + ); + Prim + ( + 756, + I_DIG, + [ + Int + ( + 757, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 758, + I_DIG, + [ + Int + ( + 759, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 760, + I_PAIR, + [], + [] + ); + Prim + ( + 761, + I_DIG, + [ + Int + ( + 762, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 763, + I_PAIR, + [], + [] + ); + Prim + ( + 764, + I_TRANSFER_TOKENS, + [], + [] + ); + Prim + ( + 765, + I_DIG, + [ + Int + ( + 766, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 767, + I_DUP, + [], + [] + ); + Prim + ( + 768, + I_DUG, + [ + Int + ( + 769, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 770, + I_DIG, + [ + Int + ( + 771, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 772, + I_CONTRACT, + [ + Prim + ( + 773, + T_unit, + [], + [] + ) + ], + [] + ); + Prim + ( + 774, + I_IF_NONE, + [ + Seq + ( + 775, + [ + Prim + ( + 776, + I_PUSH, + [ + Prim + ( + 777, + T_nat, + [], + [] + ); + Int + ( + 778, + Z + .of_int + 9 + ) + ], + [] + ); + Prim + ( + 779, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 780, + [] + ) + ], + [] + ); + Prim + ( + 781, + I_SWAP, + [], + [] + ); + Prim + ( + 782, + I_PUSH, + [ + Prim + ( + 783, + T_unit, + [], + [] + ); + Prim + ( + 784, + D_Unit, + [], + [] + ) + ], + [] + ); + Prim + ( + 785, + I_TRANSFER_TOKENS, + [], + [] + ); + Prim + ( + 786, + I_DIG, + [ + Int + ( + 787, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 788, + I_DUP, + [], + [] + ); + Prim + ( + 789, + I_DUG, + [ + Int + ( + 790, + Z + .of_int + 7 + ) + ], + [] + ); + Prim + ( + 791, + I_CDR, + [], + [] + ); + Prim + ( + 792, + I_CDR, + [], + [] + ); + Prim + ( + 793, + I_DIG, + [ + Int + ( + 794, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 795, + I_DIG, + [ + Int + ( + 796, + Z + .of_int + 7 + ) + ], + [] + ); + Prim + ( + 797, + I_DUP, + [], + [] + ); + Prim + ( + 798, + I_DUG, + [ + Int + ( + 799, + Z + .of_int + 8 + ) + ], + [] + ); + Prim + ( + 800, + I_CDR, + [], + [] + ); + Prim + ( + 801, + I_CAR, + [], + [] + ); + Prim + ( + 802, + I_SUB, + [], + [] + ); + Prim + ( + 803, + I_PAIR, + [], + [] + ); + Prim + ( + 804, + I_DIG, + [ + Int + ( + 805, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 806, + I_CAR, + [], + [] + ); + Prim + ( + 807, + I_PAIR, + [], + [] + ); + Prim + ( + 808, + I_DUP, + [], + [] + ); + Prim + ( + 809, + I_CDR, + [], + [] + ); + Prim + ( + 810, + I_CDR, + [], + [] + ); + Prim + ( + 811, + I_CDR, + [], + [] + ); + Prim + ( + 812, + I_DIG, + [ + Int + ( + 813, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 814, + I_PAIR, + [], + [] + ); + Prim + ( + 815, + I_SWAP, + [], + [] + ); + Prim + ( + 816, + I_DUP, + [], + [] + ); + Prim + ( + 817, + I_DUG, + [ + Int + ( + 818, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 819, + I_CDR, + [], + [] + ); + Prim + ( + 820, + I_CAR, + [], + [] + ); + Prim + ( + 821, + I_PAIR, + [], + [] + ); + Prim + ( + 822, + I_SWAP, + [], + [] + ); + Prim + ( + 823, + I_CAR, + [], + [] + ); + Prim + ( + 824, + I_PAIR, + [], + [] + ); + Prim + ( + 825, + I_CDR, + [], + [] + ); + Prim + ( + 826, + I_DIG, + [ + Int + ( + 827, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 828, + I_PAIR, + [], + [] + ); + Prim + ( + 829, + I_NIL, + [ + Prim + ( + 830, + T_operation, + [], + [] + ) + ], + [] + ); + Prim + ( + 831, + I_DIG, + [ + Int + ( + 832, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 833, + I_CONS, + [], + [] + ); + Prim + ( + 834, + I_DIG, + [ + Int + ( + 835, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 836, + I_CONS, + [], + [] + ); + Prim + ( + 837, + I_DIG, + [ + Int + ( + 838, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 839, + I_CONS, + [], + [] + ); + Prim + ( + 840, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], + [] + ) + ] + ) + ], [] ) ] ) ], - [] ); + [] ) ] ); + Seq + ( 841, + [ Prim + (842, I_DUP, [], []); Prim - ( 1404, - I_DIP, - [ Int - ( 1405, - Z.of_int 3 ); - Seq - ( 1406, - [ Prim - ( 1407, - I_DUP, - [], - [] ) ] - ) ], - [] ); + (843, I_CDR, [], []); Prim - ( 1408, - I_DIG, - [ Int - ( 1409, - Z.of_int 3 ) - ], - [] ); + (844, I_SWAP, [], []); Prim - (1410, I_CAR, [], []); + (845, I_CAR, [], []); Prim - (1411, I_CDR, [], []); + (846, I_SWAP, [], []); Prim - (1412, I_CDR, [], []); + (847, I_DUP, [], []); Prim - ( 1413, - I_DIG, - [ Int - ( 1414, - Z.of_int 3 ) - ], - [] ); + (848, I_CDR, [], []); Prim - (1415, I_SUB, [], []); + (849, I_SWAP, [], []); Prim - (1416, I_DUP, [], []); + (850, I_CAR, [], []); Prim - ( 1417, - I_PUSH, - [ Prim - ( 1418, - T_int, - [], - [] ); - Int (1419, Z.zero) - ], - [] ); + (851, I_SWAP, [], []); Prim - ( 1420, - I_COMPARE, - [], - [] ); + (852, I_DUP, [], []); Prim - (1421, I_LE, [], []); + (853, I_CDR, [], []); Prim - ( 1422, - I_IF, - [ Seq - ( 1423, - [ Prim - ( 1424, - I_ABS, - [], - [] ) ] - ); - Seq - ( 1425, - [ Prim - ( 1426, - I_PUSH, - [ Prim - ( 1427, - T_string, - [], - [] - ); - String - ( 1428, - "" - ) - ], - [] ); - Prim - ( 1429, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); + (854, I_SWAP, [], []); + Prim + (855, I_CAR, [], []); Prim - ( 1430, + ( 856, I_DIG, [ Int - ( 1431, + ( 857, Z.of_int 4 ) ], [] ); Prim - (1432, I_DUP, [], []); - Prim - ( 1433, - I_DIP, - [ Int - ( 1434, - Z.of_int 5 ); - Seq - ( 1435, - [ Prim - ( 1436, - I_DUP, - [], - [] ) ] - ) ], - [] ); + (858, I_DUP, [], []); Prim - ( 1437, - I_DIG, + ( 859, + I_DUG, [ Int - ( 1438, + ( 860, Z.of_int 5 ) - ], - [] ); - Prim - (1439, I_CAR, [], []); - Prim - (1440, I_CAR, [], []); - Prim - ( 1441, - I_DIP, - [ Seq - ( 1442, - [ Prim - ( 1443, - I_CAR, - [], - [] ) ] - ) ], + ], [] ); Prim - (1444, I_GET, [], []); + (861, I_CDR, [], []); + Prim + (862, I_CDR, [], []); + Prim + (863, I_CDR, [], []); + Prim + (864, I_CAR, [], []); Prim - ( 1445, - I_IF_NONE, + ( 865, + I_IF, [ Seq - ( 1446, + ( 866, [ Prim - ( 1447, - I_EMPTY_MAP, - [ Prim - ( 1448, - T_address, - [], - [] - ); - Prim - ( 1449, - T_nat, - [], - [] + ( 867, + I_DROP, + [ Int + ( 868, + Z + .of_int + 5 ) ], [] ); Prim - ( 1450, + ( 869, I_PUSH, [ Prim - ( 1451, + ( 870, T_nat, [], [] ); Int - ( 1452, + ( 871, Z - .zero + .of_int + 2 ) ], [] ); Prim - ( 1453, - I_PAIR, + ( 872, + I_FAILWITH, [], [] ) ] ); - Seq (1454, []) ], - [] ); - Prim - ( 1455, - I_DIG, - [ Int - ( 1456, - Z.of_int 2 ) - ], - [] ); - Prim - ( 1457, - I_DIP, - [ Seq - ( 1458, + Seq + ( 873, [ Prim - ( 1459, - I_DUP, + ( 874, + I_SWAP, [], [] ); Prim - ( 1460, - I_DIP, + ( 875, + I_NOW, + [], + [] ); + Prim + ( 876, + I_COMPARE, + [], + [] ); + Prim + ( 877, + I_GE, + [], + [] ); + Prim + ( 878, + I_IF, [ Seq - ( 1461, + ( 879, + [ + Prim + ( + 880, + I_DROP, + [ + Int + ( + 881, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 882, + I_PUSH, + [ + Prim + ( + 883, + T_nat, + [], + [] + ); + Int + ( + 884, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 885, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( 886, [ Prim ( - 1462, - I_CDR, - [], + 887, + I_PUSH, + [ + Prim + ( + 888, + T_mutez, + [], + [] + ); + Int + ( + 889, + Z + .zero + ) + ], + [] + ); + Prim + ( + 890, + I_AMOUNT, + [], + [] + ); + Prim + ( + 891, + I_COMPARE, + [], + [] + ); + Prim + ( + 892, + I_GT, + [], + [] + ); + Prim + ( + 893, + I_IF, + [ + Seq + ( + 894, + [ + Prim + ( + 895, + I_DROP, + [ + Int + ( + 896, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 897, + I_PUSH, + [ + Prim + ( + 898, + T_nat, + [], + [] + ); + Int + ( + 899, + Z + .of_int + 10 + ) + ], + [] + ); + Prim + ( + 900, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 901, + [ + Prim + ( + 902, + I_PUSH, + [ + Prim + ( + 903, + T_nat, + [], + [] + ); + Int + ( + 904, + Z + .of_int + 999 + ) + ], + [] + ); + Prim + ( + 905, + I_DIG, + [ + Int + ( + 906, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 907, + I_DUP, + [], + [] + ); + Prim + ( + 908, + I_DUG, + [ + Int + ( + 909, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 910, + I_MUL, + [], + [] + ); + Prim + ( + 911, + I_PUSH, + [ + Prim + ( + 912, + T_nat, + [], + [] + ); + Int + ( + 913, + Z + .of_int + 1000 + ) + ], + [] + ); + Prim + ( + 914, + I_DIG, + [ + Int + ( + 915, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 916, + I_DUP, + [], + [] + ); + Prim + ( + 917, + I_DUG, + [ + Int + ( + 918, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 919, + I_CAR, + [], + [] + ); + Prim + ( + 920, + I_MUL, + [], + [] + ); + Prim + ( + 921, + I_ADD, + [], + [] + ); + Prim + ( + 922, + I_PUSH, + [ + Prim + ( + 923, + T_mutez, + [], + [] + ); + Int + ( + 924, + Z + .one + ) + ], + [] + ); + Prim + ( + 925, + I_DIG, + [ + Int + ( + 926, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 927, + I_DUP, + [], + [] + ); + Prim + ( + 928, + I_DUG, + [ + Int + ( + 929, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 930, + I_CDR, + [], + [] + ); + Prim + ( + 931, + I_CAR, + [], + [] + ); + Prim + ( + 932, + I_EDIV, + [], + [] + ); + Prim + ( + 933, + I_IF_NONE, + [ + Seq + ( + 934, + [ + Prim + ( + 935, + I_PUSH, + [ + Prim + ( + 936, + T_string, + [], + [] + ); + String + ( + 937, + "DIV \ + by \ + 0" + ) + ], + [] + ); + Prim + ( + 938, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 939, + [] + ) + ], + [] + ); + Prim + ( + 940, + I_CAR, + [], + [] + ); + Prim + ( + 941, + I_PUSH, + [ + Prim + ( + 942, + T_nat, + [], + [] + ); + Int + ( + 943, + Z + .of_int + 999 + ) + ], + [] + ); + Prim + ( + 944, + I_DIG, + [ + Int + ( + 945, + Z + .of_int + 4 + ) + ], + [] + ); + Prim + ( + 946, + I_DUP, + [], + [] + ); + Prim + ( + 947, + I_DUG, + [ + Int + ( + 948, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 949, + I_MUL, + [], + [] + ); + Prim + ( + 950, + I_MUL, + [], + [] + ); + Prim + ( + 951, + I_EDIV, + [], + [] + ); + Prim + ( + 952, + I_IF_NONE, + [ + Seq + ( + 953, + [ + Prim + ( + 954, + I_PUSH, + [ + Prim + ( + 955, + T_string, + [], + [] + ); + String + ( + 956, + "DIV \ + by \ + 0" + ) + ], + [] + ); + Prim + ( + 957, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 958, + [] + ) + ], + [] + ); + Prim + ( + 959, + I_CAR, + [], + [] + ); + Prim + ( + 960, + I_PUSH, + [ + Prim + ( + 961, + T_mutez, + [], + [] + ); + Int + ( + 962, + Z + .one + ) + ], + [] + ); + Prim + ( + 963, + I_SWAP, + [], + [] + ); + Prim + ( + 964, + I_MUL, + [], + [] + ); + Prim + ( + 965, + I_DUP, + [], + [] + ); + Prim + ( + 966, + I_DUG, + [ + Int + ( + 967, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 968, + I_COMPARE, + [], + [] + ); + Prim + ( + 969, + I_LT, + [], + [] + ); + Prim + ( + 970, + I_IF, + [ + Seq + ( + 971, + [ + Prim + ( + 972, + I_DROP, + [], + [] + ); + Prim + ( + 973, + I_PUSH, + [ + Prim + ( + 974, + T_nat, + [], + [] + ); + Int + ( + 975, + Z + .of_int + 8 + ) + ], + [] + ); + Prim + ( + 976, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 977, + [] + ) + ], + [] + ); + Prim + ( + 978, + I_PUSH, + [ + Prim + ( + 979, + T_nat, + [], + [] + ); + Int + ( + 980, + Z + .of_int + 1000 + ) + ], + [] + ); + Prim + ( + 981, + I_PUSH, + [ + Prim + ( + 982, + T_mutez, + [], + [] + ); + Int + ( + 983, + Z + .one + ) + ], + [] + ); + Prim + ( + 984, + I_DIG, + [ + Int + ( + 985, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 986, + I_DUP, + [], + [] + ); + Prim + ( + 987, + I_DUG, + [ + Int + ( + 988, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 989, + I_EDIV, + [], + [] + ); + Prim + ( + 990, + I_IF_NONE, + [ + Seq + ( + 991, + [ + Prim + ( + 992, + I_PUSH, + [ + Prim + ( + 993, + T_string, + [], + [] + ); + String + ( + 994, + "DIV \ + by \ + 0" + ) + ], + [] + ); + Prim + ( + 995, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 996, + [] + ) + ], + [] + ); + Prim + ( + 997, + I_CAR, + [], + [] + ); + Prim + ( + 998, + I_EDIV, + [], + [] + ); + Prim + ( + 999, + I_IF_NONE, + [ + Seq + ( + 1000, + [ + Prim + ( + 1001, + I_PUSH, + [ + Prim + ( + 1002, + T_string, + [], + [] + ); + String + ( + 1003, + "DIV \ + by \ + 0" + ) + ], + [] + ); + Prim + ( + 1004, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 1005, + [] + ) + ], + [] + ); + Prim + ( + 1006, + I_CAR, + [], + [] + ); + Prim + ( + 1007, + I_DUP, + [], + [] + ); + Prim + ( + 1008, + I_PUSH, + [ + Prim + ( + 1009, + T_mutez, + [], + [] + ); + Int + ( + 1010, + Z + .one + ) + ], + [] + ); + Prim + ( + 1011, + I_DIG, + [ + Int + ( + 1012, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 1013, + I_EDIV, + [], + [] + ); + Prim + ( + 1014, + I_IF_NONE, + [ + Seq + ( + 1015, + [ + Prim + ( + 1016, + I_PUSH, + [ + Prim + ( + 1017, + T_string, + [], + [] + ); + String + ( + 1018, + "DIV \ + by \ + 0" + ) + ], + [] + ); + Prim + ( + 1019, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 1020, + [] + ) + ], + [] + ); + Prim + ( + 1021, + I_CAR, + [], + [] + ); + Prim + ( + 1022, + I_SUB, + [], + [] + ); + Prim + ( + 1023, + I_ABS, + [], + [] + ); + Prim + ( + 1024, + I_PUSH, + [ + Prim + ( + 1025, + T_mutez, + [], + [] + ); + Int + ( + 1026, + Z + .one + ) + ], + [] + ); + Prim + ( + 1027, + I_SWAP, + [], + [] + ); + Prim + ( + 1028, + I_MUL, + [], + [] + ); + Prim + ( + 1029, + I_DIG, + [ + Int + ( + 1030, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 1031, + I_DUP, + [], + [] + ); + Prim + ( + 1032, + I_DUG, + [ + Int + ( + 1033, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 1034, + I_SELF, + [], + [] + ); + Prim + ( + 1035, + I_ADDRESS, + [], + [] + ); + Prim + ( + 1036, + I_PAIR, + [], + [] + ); + Prim + ( + 1037, + I_SENDER, + [], + [] + ); + Prim + ( + 1038, + I_PAIR, + [], + [] + ); + Prim + ( + 1039, + I_DIG, + [ + Int + ( + 1040, + Z + .of_int + 5 + ) + ], + [] + ); + Prim + ( + 1041, + I_DUP, + [], + [] + ); + Prim + ( + 1042, + I_DUG, + [ + Int + ( + 1043, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 1044, + I_SWAP, + [], + [] + ); + Prim + ( + 1045, + I_DUP, + [], + [] + ); + Prim + ( + 1046, + I_CDR, + [], + [] + ); + Prim + ( + 1047, + I_SWAP, + [], + [] + ); + Prim + ( + 1048, + I_CAR, + [], + [] + ); + Prim + ( + 1049, + I_SWAP, + [], + [] + ); + Prim + ( + 1050, + I_DUP, + [], + [] + ); + Prim + ( + 1051, + I_CDR, + [], + [] + ); + Prim + ( + 1052, + I_SWAP, + [], + [] + ); + Prim + ( + 1053, + I_CAR, + [], + [] + ); + Prim + ( + 1054, + I_DIG, + [ + Int + ( + 1055, + Z + .of_int + 3 + ) + ], + [] + ); + Prim + ( + 1056, + I_CDR, + [], + [] + ); + Prim + ( + 1057, + I_CDR, + [], + [] + ); + Prim + ( + 1058, + I_CDR, + [], + [] + ); + Prim + ( + 1059, + I_CDR, + [], + [] + ); + Prim + ( + 1060, + I_CAR, + [], + [] + ); + Prim + ( + 1061, + I_CONTRACT, + [ + Prim + ( + 1062, + T_pair, + [ + Prim + ( + 1063, + T_address, + [], + [] + ); + Prim + ( + 1064, + T_pair, + [ + Prim + ( + 1065, + T_address, + [], + [] + ); + Prim + ( + 1066, + T_nat, + [], + [] + ) + ], + [] + ) + ], + [] + ) + ], + [ + "%transfer" + ] + ); + Prim + ( + 1067, + I_IF_NONE, + [ + Seq + ( + 1068, + [ + Prim + ( + 1069, + I_PUSH, + [ + Prim + ( + 1070, + T_nat, + [], + [] + ); + Int + ( + 1071, + Z + .zero + ) + ], + [] + ); + Prim + ( + 1072, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 1073, + [] + ) + ], + [] + ); + Prim + ( + 1074, + I_PUSH, + [ + Prim + ( + 1075, + T_mutez, + [], + [] + ); + Int + ( + 1076, + Z + .zero + ) + ], + [] + ); + Prim + ( + 1077, + I_DIG, + [ + Int + ( + 1078, + Z + .of_int + 3 + ) + ], [] + ); + Prim + ( + 1079, + I_DIG, + [ + Int + ( + 1080, + Z + .of_int + 3 ) - ] - ) - ], - [] ); - Prim - ( 1463, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1464, I_SWAP, [], []); - Prim - (1465, I_DROP, [], []); - Prim - (1466, I_PAIR, [], []); - Prim - ( 1467, - I_DIP, - [ Seq - ( 1468, - [ Prim - ( 1469, - I_DUP, - [], - [] ); - Prim - ( 1470, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1471, I_SOME, [], []); - Prim - ( 1472, - I_DIP, - [ Int - ( 1473, - Z.of_int 5 ); - Seq - ( 1474, - [ Prim - ( 1475, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1476, - I_DIG, - [ Int - ( 1477, - Z.of_int 5 ) - ], - [] ); - Prim - (1478, I_CAR, [], []); - Prim - (1479, I_CAR, [], []); - Prim - ( 1480, - I_UPDATE, - [], - [] ); - Prim - ( 1481, - I_DIP, - [ Seq - ( 1482, - [ Prim - ( 1483, - I_DUP, - [], - [] ); - Prim - ( 1484, - I_DIP, - [ Seq - ( 1485, - [ - Prim + ], + [] + ); + Prim ( - 1486, - I_CDR, + 1081, + I_PAIR, [], [] + ); + Prim + ( + 1082, + I_DIG, + [ + Int + ( + 1083, + Z + .of_int + 3 ) - ] - ) - ], - [] ); - Prim - ( 1487, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1488, I_SWAP, [], []); - Prim - (1489, I_DROP, [], []); - Prim - (1490, I_PAIR, [], []); - Prim - (1491, I_DUP, [], []); - Prim - (1492, I_CDR, [], []); - Prim - (1493, I_CAR, [], []); - Prim - (1494, I_CDR, [], []); - Prim - ( 1495, - I_DIP, - [ Int - ( 1496, - Z.of_int 4 ); - Seq - ( 1497, - [ Prim - ( 1498, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1499, - I_DIG, - [ Int - ( 1500, - Z.of_int 4 ) - ], - [] ); - Prim - (1501, I_CAR, [], []); - Prim - (1502, I_CDR, [], []); - Prim - (1503, I_CDR, [], []); - Prim - (1504, I_SWAP, [], []); - Prim - (1505, I_SUB, [], []); - Prim - (1506, I_DUP, [], []); - Prim - ( 1507, - I_PUSH, - [ Prim - ( 1508, - T_int, - [], - [] ); - Int (1509, Z.zero) - ], - [] ); - Prim - ( 1510, - I_COMPARE, - [], - [] ); - Prim - (1511, I_LE, [], []); - Prim - ( 1512, - I_IF, - [ Seq - ( 1513, - [ Prim - ( 1514, - I_ABS, - [], - [] ) ] - ); - Seq - ( 1515, - [ Prim - ( 1516, - I_PUSH, - [ Prim - ( 1517, - T_string, - [], - [] - ); - String - ( 1518, - "" - ) - ], - [] ); - Prim - ( 1519, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1520, - I_DIP, - [ Seq - ( 1521, - [ Prim - ( 1522, - I_DUP, - [], - [] ); - Prim - ( 1523, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1524, - I_DIP, - [ Seq - ( 1525, - [ Prim - ( 1526, - I_DUP, - [], - [] ); - Prim - ( 1527, - I_DIP, - [ Seq - ( 1528, - [ - Prim + ], + [] + ); + Prim ( - 1529, - I_CDR, + 1084, + I_PAIR, + [], + [] + ); + Prim + ( + 1085, + I_TRANSFER_TOKENS, + [], + [] + ); + Prim + ( + 1086, + I_SWAP, + [], + [] + ); + Prim + ( + 1087, + I_DUP, [], [] + ); + Prim + ( + 1088, + I_DUG, + [ + Int + ( + 1089, + Z + .of_int + 2 ) - ] - ) - ], - [] ); - Prim - ( 1530, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1531, - I_DIP, - [ Seq - ( 1532, - [ Prim - ( 1533, - I_DUP, - [], - [] ); - Prim - ( 1534, - I_DIP, - [ Seq - ( 1535, - [ - Prim + ], + [] + ); + Prim + ( + 1090, + I_DIG, + [ + Int + ( + 1091, + Z + .of_int + 5 + ) + ], + [] + ); + Prim ( - 1536, - I_CAR, + 1092, + I_CONTRACT, + [ + Prim + ( + 1093, + T_unit, [], [] ) - ] - ) - ], - [] ); - Prim - ( 1537, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (1538, I_SWAP, [], []); - Prim - (1539, I_DROP, [], []); - Prim - (1540, I_SWAP, [], []); - Prim - (1541, I_PAIR, [], []); - Prim - (1542, I_PAIR, [], []); - Prim - ( 1543, - I_DIP, - [ Seq - ( 1544, - [ Prim - ( 1545, - I_DUP, - [], - [] ); - Prim - ( 1546, - I_DIP, - [ Seq - ( 1547, - [ - Prim + ], + [] + ); + Prim ( - 1548, - I_CAR, + 1094, + I_IF_NONE, + [ + Seq + ( + 1095, + [ + Prim + ( + 1096, + I_PUSH, + [ + Prim + ( + 1097, + T_nat, [], [] + ); + Int + ( + 1098, + Z + .of_int + 9 ) - ] - ) - ], - [] ); - Prim - ( 1549, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (1550, I_SWAP, [], []); - Prim - (1551, I_DROP, [], []); - Prim - (1552, I_SWAP, [], []); - Prim - (1553, I_PAIR, [], []); - Prim - (1554, I_DUP, [], []); - Prim - (1555, I_CDR, [], []); - Prim - (1556, I_CDR, [], []); - Prim - (1557, I_CDR, [], []); - Prim - (1558, I_CAR, [], []); - Prim - ( 1559, - I_DIP, - [ Int - ( 1560, - Z.of_int 2 ); - Seq - ( 1561, - [ Prim - ( 1562, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1563, - I_DIG, - [ Int - ( 1564, - Z.of_int 2 ) - ], - [] ); - Prim - (1565, I_SWAP, [], []); - Prim - (1566, I_SUB, [], []); - Prim - (1567, I_DUP, [], []); - Prim - ( 1568, - I_PUSH, - [ Prim - ( 1569, - T_int, - [], - [] ); - Int (1570, Z.zero) - ], - [] ); - Prim - ( 1571, - I_COMPARE, - [], - [] ); - Prim - (1572, I_LE, [], []); - Prim - ( 1573, - I_IF, - [ Seq - ( 1574, - [ Prim - ( 1575, - I_ABS, - [], - [] ) ] - ); - Seq - ( 1576, - [ Prim - ( 1577, - I_PUSH, - [ Prim - ( 1578, - T_string, - [], - [] - ); - String - ( 1579, - "" - ) - ], - [] ); - Prim - ( 1580, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1581, - I_DIP, - [ Seq - ( 1582, - [ Prim - ( 1583, - I_DUP, - [], - [] ); - Prim - ( 1584, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1585, - I_DIP, - [ Seq - ( 1586, - [ Prim - ( 1587, - I_DUP, - [], - [] ); - Prim - ( 1588, - I_DIP, - [ Seq - ( 1589, - [ - Prim + ], + [] + ); + Prim ( - 1590, - I_CAR, + 1099, + I_FAILWITH, [], [] ) - ] - ) - ], - [] ); - Prim - ( 1591, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1592, - I_DIP, - [ Seq - ( 1593, - [ Prim - ( 1594, - I_DUP, - [], - [] ); - Prim - ( 1595, - I_DIP, - [ Seq - ( 1596, - [ - Prim + ] + ); + Seq ( - 1597, - I_CAR, - [], + 1100, [] ) - ] - ) - ], - [] ); - Prim - ( 1598, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1599, - I_DIP, - [ Seq - ( 1600, - [ Prim - ( 1601, - I_DUP, - [], - [] ); - Prim - ( 1602, - I_DIP, - [ Seq - ( 1603, - [ - Prim + ], + [] + ); + Prim ( - 1604, - I_CDR, + 1101, + I_SWAP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 1605, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1606, I_SWAP, [], []); - Prim - (1607, I_DROP, [], []); - Prim - (1608, I_PAIR, [], []); - Prim - (1609, I_SWAP, [], []); - Prim - (1610, I_PAIR, [], []); - Prim - (1611, I_SWAP, [], []); - Prim - (1612, I_PAIR, [], []); - Prim - ( 1613, - I_DIP, - [ Seq - ( 1614, - [ Prim - ( 1615, - I_DUP, - [], - [] ); - Prim - ( 1616, - I_DIP, - [ Seq - ( 1617, - [ - Prim + ); + Prim ( - 1618, - I_CAR, + 1102, + I_PUSH, + [ + Prim + ( + 1103, + T_unit, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 1619, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (1620, I_SWAP, [], []); - Prim - (1621, I_DROP, [], []); - Prim - (1622, I_SWAP, [], []); - Prim - (1623, I_PAIR, [], []); - Prim - (1624, I_DUP, [], []); - Prim - (1625, I_CDR, [], []); - Prim - (1626, I_CDR, [], []); - Prim - (1627, I_CDR, [], []); - Prim - (1628, I_CDR, [], []); - Prim - ( 1629, - I_DIP, - [ Int - ( 1630, - Z.of_int 3 ); - Seq - ( 1631, - [ Prim - ( 1632, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1633, - I_DIG, - [ Int - ( 1634, - Z.of_int 3 ) - ], - [] ); - Prim - (1635, I_SWAP, [], []); - Prim - (1636, I_SUB, [], []); - Prim - ( 1637, - I_DIP, - [ Seq - ( 1638, - [ Prim - ( 1639, - I_DUP, - [], - [] ); - Prim - ( 1640, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1641, - I_DIP, - [ Seq - ( 1642, - [ Prim - ( 1643, - I_DUP, - [], - [] ); - Prim - ( 1644, - I_DIP, - [ Seq - ( 1645, - [ - Prim + ); + Prim ( - 1646, - I_CAR, + 1104, + D_Unit, [], [] ) - ] - ) - ], - [] ); - Prim - ( 1647, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1648, - I_DIP, - [ Seq - ( 1649, - [ Prim - ( 1650, - I_DUP, - [], - [] ); - Prim - ( 1651, - I_DIP, - [ Seq - ( 1652, - [ - Prim + ], + [] + ); + Prim ( - 1653, - I_CAR, + 1105, + I_TRANSFER_TOKENS, [], [] + ); + Prim + ( + 1106, + I_DIG, + [ + Int + ( + 1107, + Z + .of_int + 5 ) - ] - ) - ], - [] ); - Prim - ( 1654, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1655, - I_DIP, - [ Seq - ( 1656, - [ Prim - ( 1657, - I_DUP, - [], - [] ); - Prim - ( 1658, - I_DIP, - [ Seq - ( 1659, - [ - Prim + ], + [] + ); + Prim ( - 1660, - I_CAR, + 1108, + I_DUP, [], [] + ); + Prim + ( + 1109, + I_DUG, + [ + Int + ( + 1110, + Z + .of_int + 6 ) - ] - ) - ], - [] ); - Prim - ( 1661, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (1662, I_SWAP, [], []); - Prim - (1663, I_DROP, [], []); - Prim - (1664, I_SWAP, [], []); - Prim - (1665, I_PAIR, [], []); - Prim - (1666, I_SWAP, [], []); - Prim - (1667, I_PAIR, [], []); - Prim - (1668, I_SWAP, [], []); - Prim - (1669, I_PAIR, [], []); - Prim - ( 1670, - I_DIP, - [ Seq - ( 1671, - [ Prim - ( 1672, - I_DUP, - [], - [] ); - Prim - ( 1673, - I_DIP, - [ Seq - ( 1674, - [ - Prim + ], + [] + ); + Prim ( - 1675, - I_CAR, + 1111, + I_CDR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 1676, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (1677, I_SWAP, [], []); - Prim - (1678, I_DROP, [], []); - Prim - (1679, I_SWAP, [], []); - Prim - (1680, I_PAIR, [], []); - Prim - ( 1681, - I_DIP, - [ Int - ( 1682, - Z.of_int 3 ); - Seq - ( 1683, - [ Prim - ( 1684, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1685, - I_DIG, - [ Int - ( 1686, - Z.of_int 3 ) - ], - [] ); - Prim - (1687, I_CAR, [], []); - Prim - (1688, I_CDR, [], []); - Prim - (1689, I_CAR, [], []); - Prim - ( 1690, - I_CONTRACT, - [ Prim - ( 1691, - T_unit, - [], - [] ) ], - [] ); - Prim - ( 1692, - I_IF_NONE, - [ Seq - ( 1693, - [ Prim - ( 1694, - I_PUSH, - [ Prim - ( 1695, - T_string, - [], - [] - ); - String - ( 1696, - "bad \ - address \ - for \ - get_entrypoint" - ) - ], - [] ); - Prim - ( 1697, - I_FAILWITH, - [], - [] ) ] - ); - Seq (1698, []) ], - [] ); - Prim - ( 1699, - I_DIG, - [ Int - ( 1700, - Z.of_int 3 ) - ], - [] ); - Prim - (1701, I_UNIT, [], []); - Prim - ( 1702, - I_TRANSFER_TOKENS, - [], - [] ); - Prim - ( 1703, - I_DIP, - [ Seq - ( 1704, - [ Prim - ( 1705, - I_DIP, - [ Seq - ( 1706, - [ - Prim + ); + Prim + ( + 1112, + I_DIG, + [ + Int + ( + 1113, + Z + .of_int + 5 + ) + ], + [] + ); + Prim ( - 1707, - I_DIP, + 1114, + I_DIG, [ - Seq + Int + ( + 1115, + Z + .of_int + 6 + ) + ], + [] + ); + Prim + ( + 1116, + I_DUP, + [], + [] + ); + Prim ( - 1708, + 1117, + I_DUG, [ + Int + ( + 1118, + Z + .of_int + 7 + ) + ], + [] + ); Prim ( - 1709, + 1119, I_CAR, [], [] ); Prim ( - 1710, + 1120, + I_ADD, + [], + [] + ); + Prim + ( + 1121, + I_PAIR, + [], + [] + ); + Prim + ( + 1122, + I_DUP, + [], + [] + ); + Prim + ( + 1123, I_CDR, [], [] ); Prim ( - 1711, - I_CAR, + 1124, + I_CDR, [], [] - ) - ] + ); + Prim + ( + 1125, + I_DIG, + [ + Int + ( + 1126, + Z + .of_int + 4 ) ], [] + ); + Prim + ( + 1127, + I_DIG, + [ + Int + ( + 1128, + Z + .of_int + 6 ) - ] - ) - ], - [] ); - Prim - ( 1712, - I_DUP, - [], - [] ); - Prim - ( 1713, - I_CDR, - [], - [] ); - Prim - ( 1714, - I_CDR, - [], - [] ); - Prim - ( 1715, - I_CAR, - [], - [] ); - Prim - ( 1716, - I_CONTRACT, - [ Prim - ( 1717, - T_pair, - [ - Prim + ], + [] + ); + Prim ( - 1718, - T_address, + 1129, + I_CDR, [], [] ); Prim ( - 1719, - T_pair, - [ + 1130, + I_CAR, + [], + [] + ); Prim ( - 1720, - T_address, + 1131, + I_SUB, [], [] ); Prim ( - 1721, - T_nat, + 1132, + I_PAIR, [], [] - ) - ], + ); + Prim + ( + 1133, + I_SWAP, + [], [] - ) - ], - [] - ) - ], - [ "%transfer" - ] ); - Prim - ( 1722, - I_IF_NONE, - [ Seq - ( 1723, - [ - Prim + ); + Prim + ( + 1134, + I_CAR, + [], + [] + ); + Prim + ( + 1135, + I_PAIR, + [], + [] + ); + Prim ( - 1724, + 1136, I_PUSH, [ Prim ( - 1725, - T_string, + 1137, + T_mutez, [], [] ); - String + Int ( - 1726, - "bad \ - address \ - for \ - get_entrypoint" + 1138, + Z + .one ) ], [] ); Prim ( - 1727, - I_FAILWITH, - [], - [] - ) - ] - ); - Seq - ( 1728, - [] - ) - ], - [] ); - Prim - ( 1729, - I_PUSH, - [ Prim - ( 1730, - T_mutez, - [], - [] - ); - Int - ( 1731, - Z - .zero - ) - ], - [] ); - Prim - ( 1732, - I_DIG, - [ Int - ( 1733, - Z - .of_int - 3 - ) - ], - [] ); - Prim - ( 1734, - I_DIG, - [ Int - ( 1735, - Z - .of_int - 4 - ) - ], - [] ); - Prim - ( 1736, - I_PAIR, - [], - [] ); - Prim - ( 1737, - I_SELF, - [], - [] ); - Prim - ( 1738, - I_ADDRESS, - [], - [] ); - Prim - ( 1739, - I_PAIR, - [], - [] ); - Prim - ( 1740, - I_TRANSFER_TOKENS, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1741, - I_NIL, - [ Prim - ( 1742, - T_operation, - [], - [] ) ], - [] ); - Prim - (1743, I_SWAP, [], []); - Prim - (1744, I_CONS, [], []); - Prim - (1745, I_SWAP, [], []); - Prim - (1746, I_CONS, [], []); - Prim - (1747, I_PAIR, [], []) - ] ); - Seq - ( 1748, - [ Prim - ( 1749, - I_DIP, - [ Seq - ( 1750, - [ Prim - ( 1751, - I_DUP, - [], - [] ); - Prim - ( 1752, - I_CDR, - [], - [] ); - Prim - ( 1753, - I_CAR, - [], - [] ); - Prim - ( 1754, - I_CAR, - [], - [] ); - Prim - ( 1755, - I_IF, - [ Seq - ( 1756, - [ - Prim + 1139, + I_DIG, + [ + Int + ( + 1140, + Z + .of_int + 4 + ) + ], + [] + ); + Prim ( - 1757, + 1141, + I_MUL, + [], + [] + ); + Prim + ( + 1142, I_PUSH, [ Prim ( - 1758, - T_string, + 1143, + T_address, [], [] ); String ( - 1759, - "selfIsUpdatingToken \ - must \ - be \ - false." + 1144, + "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" ) ], [] ); Prim ( - 1760, - I_FAILWITH, + 1145, + I_CONTRACT, + [ + Prim + ( + 1146, + T_unit, [], [] ) - ] - ); - Seq - ( 1761, - [] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (1762, I_DUP, [], []); - Prim - (1763, I_CDR, [], []); - Prim - (1764, I_CDR, [], []); - Prim - (1765, I_NOW, [], []); - Prim - ( 1766, - I_COMPARE, - [], - [] ); - Prim - (1767, I_LT, [], []); - Prim - ( 1768, - I_IF, - [ Seq (1769, []); - Seq - ( 1770, - [ Prim - ( 1771, - I_PUSH, - [ Prim - ( 1772, - T_string, - [], - [] - ); - String - ( 1773, - "NOW \ - is \ - greater \ - than \ - deadline." - ) - ], - [] ); - Prim - ( 1774, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1775, - I_PUSH, - [ Prim - ( 1776, - T_mutez, - [], - [] ); - Int (1777, Z.zero) - ], - [] ); - Prim - ( 1778, - I_AMOUNT, - [], - [] ); - Prim - ( 1779, - I_COMPARE, - [], - [] ); - Prim - (1780, I_GT, [], []); - Prim - ( 1781, - I_IF, - [ Seq (1782, []); - Seq - ( 1783, - [ Prim - ( 1784, - I_PUSH, - [ Prim - ( 1785, - T_string, - [], - [] - ); - String - ( 1786, - "Amount \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 1787, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (1788, I_DUP, [], []); - Prim - (1789, I_CDR, [], []); - Prim - (1790, I_CAR, [], []); - Prim - ( 1791, - I_PUSH, - [ Prim - ( 1792, - T_nat, - [], - [] ); - Int (1793, Z.zero) - ], - [] ); - Prim - ( 1794, - I_COMPARE, - [], - [] ); - Prim - (1795, I_LT, [], []); - Prim - ( 1796, - I_IF, - [ Seq (1797, []); - Seq - ( 1798, - [ Prim - ( 1799, - I_PUSH, - [ Prim - ( 1800, - T_string, - [], - [] - ); - String - ( 1801, - "minTokensBought \ - must \ - be \ - greater \ - than \ - zero." - ) - ], - [] ); - Prim - ( 1802, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1803, - I_DIP, - [ Seq - ( 1804, - [ Prim - ( 1805, - I_DUP, - [], - [] ); - Prim - ( 1806, - I_CDR, - [], - [] ); - Prim - ( 1807, - I_CDR, - [], - [] ); - Prim - ( 1808, - I_CDR, - [], - [] ); - Prim - ( 1809, - I_CDR, - [], - [] ); - Prim - ( 1810, - I_PUSH, - [ Prim - ( 1811, - T_mutez, - [], - [] - ); - Int - ( 1812, - Z - .zero - ) - ], - [] ); - Prim - ( 1813, - I_COMPARE, - [], - [] ); - Prim - ( 1814, - I_LT, - [], - [] ); - Prim - ( 1815, - I_IF, - [ Seq - ( 1816, - [] - ); - Seq - ( 1817, - [ - Prim + ], + [] + ); + Prim + ( + 1147, + I_IF_NONE, + [ + Seq ( - 1818, + 1148, + [ + Prim + ( + 1149, I_PUSH, [ Prim ( - 1819, - T_string, + 1150, + T_nat, [], [] ); - String + Int ( - 1820, - "xtzPool \ - must \ - be \ - greater \ - than \ - zero." + 1151, + Z + .of_int + 9 ) ], [] ); - Prim - ( - 1821, - I_FAILWITH, - [], - [] - ) - ] - ) - ], - [] ) ] - ) ], - [] ); - Prim - ( 1822, - I_DIP, - [ Seq - ( 1823, - [ Prim - ( 1824, - I_DUP, - [], - [] ); - Prim - ( 1825, - I_CDR, - [], - [] ); - Prim - ( 1826, - I_CDR, - [], - [] ); - Prim - ( 1827, - I_CDR, - [], - [] ); - Prim - ( 1828, - I_CAR, - [], - [] ); - Prim - ( 1829, - I_PUSH, - [ Prim - ( 1830, - T_nat, - [], - [] - ); - Int - ( 1831, - Z - .zero - ) - ], - [] ); - Prim - ( 1832, - I_COMPARE, - [], - [] ); - Prim - ( 1833, - I_LT, - [], - [] ); - Prim - ( 1834, - I_IF, - [ Seq - ( 1835, - [] - ); - Seq - ( 1836, - [ - Prim + Prim + ( + 1152, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 1153, + [] + ) + ], + [] + ); + Prim ( - 1837, + 1154, + I_SWAP, + [], + [] + ); + Prim + ( + 1155, I_PUSH, [ Prim ( - 1838, - T_string, + 1156, + T_unit, [], [] ); - String + Prim ( - 1839, - "tokenPool \ - must \ - be \ - greater \ - than \ - zero" + 1157, + D_Unit, + [], + [] ) ], [] ); Prim ( - 1840, - I_FAILWITH, + 1158, + I_TRANSFER_TOKENS, + [], + [] + ); + Prim + ( + 1159, + I_SWAP, + [], + [] + ); + Prim + ( + 1160, + I_NIL, + [ + Prim + ( + 1161, + T_operation, [], [] ) - ] - ) - ], - [] ) ] - ) ], - [] ); - Prim - ( 1841, - I_DIP, - [ Seq - ( 1842, - [ Prim - ( 1843, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - (1844, I_SWAP, [], []); - Prim - (1845, I_CDR, [], []); - Prim - (1846, I_CDR, [], []); - Prim - (1847, I_CDR, [], []); - Prim - (1848, I_CDR, [], []); - Prim - ( 1849, - I_DIP, - [ Seq - ( 1850, - [ Prim - ( 1851, - I_PUSH, - [ Prim - ( 1852, - T_mutez, - [], - [] - ); - Int - ( 1853, - Z - .one - ) - ], - [] ) ] - ) ], - [] ); - Prim - (1854, I_EDIV, [], []); - Prim - ( 1855, - I_IF_NONE, - [ Seq - ( 1856, - [ Prim - ( 1857, - I_PUSH, - [ Prim - ( 1858, - T_string, - [], - [] - ); - String - ( 1859, - "" - ) - ], - [] ); - Prim - ( 1860, - I_FAILWITH, - [], - [] ) ] - ); - Seq - ( 1861, - [ Prim - ( 1862, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1863, - I_PUSH, - [ Prim - ( 1864, - T_nat, - [], - [] ); - Int - ( 1865, - Z.of_int 1000 - ) ], - [] ); - Prim - (1866, I_MUL, [], []); - Prim - ( 1867, - I_AMOUNT, - [], - [] ); - Prim - ( 1868, - I_DIP, - [ Seq - ( 1869, - [ Prim - ( 1870, - I_PUSH, - [ Prim - ( 1871, - T_mutez, - [], - [] - ); - Int - ( 1872, - Z - .one - ) - ], - [] ) ] - ) ], - [] ); - Prim - (1873, I_EDIV, [], []); - Prim - ( 1874, - I_IF_NONE, - [ Seq - ( 1875, - [ Prim - ( 1876, - I_PUSH, - [ Prim - ( 1877, - T_string, - [], - [] - ); - String - ( 1878, - "" - ) - ], - [] ); - Prim - ( 1879, - I_FAILWITH, - [], - [] ) ] - ); - Seq - ( 1880, - [ Prim - ( 1881, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1882, I_DUP, [], []); - Prim - ( 1883, - I_DIP, - [ Seq - ( 1884, - [ Prim - ( 1885, - I_PUSH, - [ Prim - ( 1886, - T_nat, - [], - [] - ); - Int - ( 1887, - Z - .of_int - 999 - ) - ], - [] ); - Prim - ( 1888, - I_MUL, - [], - [] ); - Prim - ( 1889, - I_ADD, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1890, - I_PUSH, - [ Prim - ( 1891, - T_nat, - [], - [] ); - Int - ( 1892, - Z.of_int 999 - ) ], - [] ); - Prim - (1893, I_MUL, [], []); - Prim - ( 1894, - I_DIP, - [ Int - ( 1895, - Z.of_int 3 ); - Seq - ( 1896, - [ Prim - ( 1897, - I_DUP, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1898, - I_DIG, - [ Int - ( 1899, - Z.of_int 3 ) - ], - [] ); - Prim - (1900, I_CDR, [], []); - Prim - (1901, I_CDR, [], []); - Prim - (1902, I_CDR, [], []); - Prim - (1903, I_CAR, [], []); - Prim - (1904, I_MUL, [], []); - Prim - (1905, I_EDIV, [], []); - Prim - ( 1906, - I_IF_NONE, - [ Seq - ( 1907, - [ Prim - ( 1908, - I_PUSH, - [ Prim - ( 1909, - T_string, - [], - [] - ); - String - ( 1910, - "divByZero." - ) - ], - [] ); - Prim - ( 1911, - I_FAILWITH, - [], - [] ) ] - ); - Seq - ( 1912, - [ Prim - ( 1913, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1914, I_DUP, [], []); - Prim - ( 1915, - I_DIP, - [ Seq - ( 1916, - [ Prim - ( 1917, - I_DIP, - [ Seq - ( 1918, - [ - Prim + ], + [] + ); + Prim + ( + 1162, + I_DIG, + [ + Int ( - 1919, - I_DUP, - [], + 1163, + Z + .of_int + 2 + ) + ], [] ); Prim ( - 1920, - I_CDR, + 1164, + I_CONS, [], [] ); Prim ( - 1921, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 1922, - I_COMPARE, - [], - [] ); - Prim - ( 1923, - I_GE, - [], - [] ); - Prim - ( 1924, - I_IF, - [ Seq - ( 1925, - [] - ); - Seq - ( 1926, - [ - Prim - ( - 1927, - I_PUSH, + 1165, + I_DIG, [ + Int + ( + 1166, + Z + .of_int + 2 + ) + ], + [] + ); Prim ( - 1928, - T_string, + 1167, + I_CONS, [], [] ); - String + Prim ( - 1929, - "tokensBought \ - is \ - less \ - than \ - minTokensBought." + 1168, + I_DIG, + [ + Int + ( + 1169, + Z + .of_int + 2 ) ], [] ); Prim ( - 1930, - I_FAILWITH, + 1170, + I_CONS, [], [] + ); + Prim + ( + 1171, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] ) ] ) ], [] ) ] ) ], - [] ); - Prim - (1931, I_DUP, [], []); - Prim - ( 1932, - I_DIP, - [ Int - ( 1933, - Z.of_int 3 ); - Seq - ( 1934, - [ Prim - ( 1935, - I_DUP, - [], - [] ) ] - ) ], - [] ); + [] ) ] ) ], + [] ) ] ) ], + [] ) ] ); + Seq + ( 1172, + [ Prim + ( 1173, + I_IF_LEFT, + [ Seq + ( 1174, + [ Prim + ( 1175, + I_IF_LEFT, + [ Seq + ( 1176, + [ Prim + (1177, I_DROP, [], []); Prim - ( 1936, - I_DIG, - [ Int - ( 1937, - Z.of_int 3 ) - ], + ( 1178, + I_SOURCE, + [], [] ); Prim - (1938, I_CDR, [], []); - Prim - (1939, I_CDR, [], []); - Prim - (1940, I_CDR, [], []); - Prim - (1941, I_CAR, [], []); - Prim - (1942, I_SUB, [], []); - Prim - (1943, I_DUP, [], []); - Prim - ( 1944, - I_PUSH, - [ Prim - ( 1945, - T_int, - [], - [] ); - Int (1946, Z.zero) - ], + ( 1179, + I_SENDER, + [], [] ); Prim - ( 1947, + ( 1180, I_COMPARE, [], [] ); Prim - (1948, I_LE, [], []); + (1181, I_NEQ, [], []); Prim - ( 1949, + ( 1182, I_IF, [ Seq - ( 1950, + ( 1183, [ Prim - ( 1951, - I_ABS, + ( 1184, + I_DROP, [], - [] ) ] - ); - Seq - ( 1952, - [ Prim - ( 1953, + [] ); + Prim + ( 1185, I_PUSH, [ Prim - ( 1954, - T_string, + ( 1186, + T_nat, [], [] ); - String - ( 1955, - "" - ) - ], - [] ); - Prim - ( 1956, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1957, - I_DIP, - [ Seq - ( 1958, - [ Prim - ( 1959, - I_DIG, - [ Int - ( 1960, - Z - .of_int - 2 - ) - ], - [] ) ] - ) ], - [] ); - Prim - ( 1961, - I_DIP, - [ Seq - ( 1962, - [ Prim - ( 1963, - I_DUP, - [], - [] ); - Prim - ( 1964, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1965, - I_DIP, - [ Seq - ( 1966, - [ Prim - ( 1967, - I_DUP, - [], - [] ); - Prim - ( 1968, - I_DIP, - [ Seq - ( 1969, - [ - Prim - ( - 1970, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 1971, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1972, - I_DIP, - [ Seq - ( 1973, - [ Prim - ( 1974, - I_DUP, - [], - [] ); - Prim - ( 1975, - I_DIP, - [ Seq - ( 1976, - [ - Prim - ( - 1977, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 1978, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 1979, - I_DIP, - [ Seq - ( 1980, - [ Prim - ( 1981, - I_DUP, - [], - [] ); - Prim - ( 1982, - I_DIP, - [ Seq - ( 1983, - [ - Prim - ( - 1984, - I_CDR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 1985, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (1986, I_SWAP, [], []); - Prim - (1987, I_DROP, [], []); - Prim - (1988, I_PAIR, [], []); - Prim - (1989, I_SWAP, [], []); - Prim - (1990, I_PAIR, [], []); - Prim - (1991, I_SWAP, [], []); - Prim - (1992, I_PAIR, [], []); - Prim - ( 1993, - I_DIP, - [ Seq - ( 1994, - [ Prim - ( 1995, - I_DUP, - [], - [] ); - Prim - ( 1996, - I_DIP, - [ Seq - ( 1997, - [ - Prim - ( - 1998, - I_CAR, - [], - [] - ) - ] + Int + ( 1187, + Z + .of_int + 25 ) ], [] ); Prim - ( 1999, - I_CDR, + ( 1188, + I_FAILWITH, [], [] ) ] - ) ], - [] ); - Prim - (2000, I_SWAP, [], []); - Prim - (2001, I_DROP, [], []); - Prim - (2002, I_SWAP, [], []); - Prim - (2003, I_PAIR, [], []); - Prim - (2004, I_DUP, [], []); - Prim - (2005, I_CDR, [], []); - Prim - (2006, I_CDR, [], []); - Prim - (2007, I_CDR, [], []); - Prim - (2008, I_CDR, [], []); - Prim - ( 2009, - I_AMOUNT, - [], - [] ); - Prim - (2010, I_ADD, [], []); - Prim - ( 2011, - I_DIP, - [ Seq - ( 2012, + ); + Seq + ( 1189, [ Prim - ( 2013, - I_DUP, + ( 1190, + I_PUSH, + [ Prim + ( 1191, + T_mutez, + [], + [] + ); + Int + ( 1192, + Z + .zero + ) + ], + [] ); + Prim + ( 1193, + I_AMOUNT, [], [] ); Prim - ( 2014, - I_CDR, + ( 1194, + I_COMPARE, [], - [] ) ] - ) ], - [] ); - Prim - ( 2015, - I_DIP, - [ Seq - ( 2016, - [ Prim - ( 2017, - I_DUP, + [] ); + Prim + ( 1195, + I_GT, [], [] ); Prim - ( 2018, - I_DIP, + ( 1196, + I_IF, [ Seq - ( 2019, + ( 1197, [ Prim ( - 2020, - I_CAR, + 1198, + I_DROP, + [], + [] + ); + Prim + ( + 1199, + I_PUSH, + [ + Prim + ( + 1200, + T_nat, + [], + [] + ); + Int + ( + 1201, + Z + .of_int + 10 + ) + ], + [] + ); + Prim + ( + 1202, + I_FAILWITH, [], [] ) ] - ) - ], - [] ); - Prim - ( 2021, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2022, - I_DIP, - [ Seq - ( 2023, - [ Prim - ( 2024, - I_DUP, - [], - [] ); - Prim - ( 2025, - I_DIP, - [ Seq - ( 2026, + ); + Seq + ( 1203, [ Prim ( - 2027, + 1204, + I_DUP, + [], + [] + ); + Prim + ( + 1205, + I_CDR, + [], + [] + ); + Prim + ( + 1206, + I_CDR, + [], + [] + ); + Prim + ( + 1207, + I_CDR, + [], + [] + ); + Prim + ( + 1208, I_CAR, [], [] + ); + Prim + ( + 1209, + I_IF, + [ + Seq + ( + 1210, + [ + Prim + ( + 1211, + I_DROP, + [], + [] + ); + Prim + ( + 1212, + I_PUSH, + [ + Prim + ( + 1213, + T_nat, + [], + [] + ); + Int + ( + 1214, + Z + .of_int + 33 ) - ] - ) - ], - [] ); - Prim - ( 2028, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2029, - I_DIP, - [ Seq - ( 2030, - [ Prim - ( 2031, - I_DUP, - [], - [] ); - Prim - ( 2032, - I_DIP, - [ Seq - ( 2033, - [ - Prim + ], + [] + ); + Prim + ( + 1215, + I_FAILWITH, + [], + [] + ) + ] + ); + Seq + ( + 1216, + [ + Prim + ( + 1217, + I_SELF, + [], + [ + "%updateTokenPoolInternal" + ] + ); + Prim + ( + 1218, + I_SWAP, + [], + [] + ); + Prim + ( + 1219, + I_DUP, + [], + [] + ); + Prim + ( + 1220, + I_DUG, + [ + Int + ( + 1221, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 1222, + I_CDR, + [], + [] + ); + Prim + ( + 1223, + I_CDR, + [], + [] + ); + Prim + ( + 1224, + I_CDR, + [], + [] + ); + Prim + ( + 1225, + I_CDR, + [], + [] + ); + Prim ( - 2034, + 1226, I_CAR, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 2035, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (2036, I_SWAP, [], []); - Prim - (2037, I_DROP, [], []); - Prim - (2038, I_SWAP, [], []); - Prim - (2039, I_PAIR, [], []); - Prim - (2040, I_SWAP, [], []); - Prim - (2041, I_PAIR, [], []); - Prim - (2042, I_SWAP, [], []); - Prim - (2043, I_PAIR, [], []); - Prim - ( 2044, - I_DIP, - [ Seq - ( 2045, - [ Prim - ( 2046, - I_DUP, - [], - [] ); - Prim - ( 2047, - I_DIP, - [ Seq - ( 2048, - [ - Prim + ); + Prim ( - 2049, - I_CAR, + 1227, + I_CONTRACT, + [ + Prim + ( + 1228, + T_pair, + [ + Prim + ( + 1229, + T_address, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 2050, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (2051, I_SWAP, [], []); - Prim - (2052, I_DROP, [], []); - Prim - (2053, I_SWAP, [], []); - Prim - (2054, I_PAIR, [], []); - Prim - ( 2055, - I_DIP, - [ Seq - ( 2056, - [ Prim - ( 2057, - I_DIP, - [ Seq - ( 2058, - [ - Prim + ); + Prim ( - 2059, - I_CAR, + 1230, + T_contract, + [ + Prim + ( + 1231, + T_nat, [], [] + ) + ], + [] + ) + ], + [] + ) + ], + [ + "%getBalance" + ] ); Prim ( - 2060, - I_SELF, + 1232, + I_IF_NONE, + [ + Seq + ( + 1233, + [ + Prim + ( + 1234, + I_PUSH, + [ + Prim + ( + 1235, + T_nat, [], [] ); + Int + ( + 1236, + Z + .of_int + 28 + ) + ], + [] + ); Prim ( - 2061, - I_ADDRESS, + 1237, + I_FAILWITH, [], [] ) - ] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (2062, I_DUP, [], []); - Prim - (2063, I_CDR, [], []); - Prim - (2064, I_CDR, [], []); - Prim - (2065, I_CAR, [], []); - Prim - ( 2066, - I_CONTRACT, - [ Prim - ( 2067, - T_pair, - [ Prim - ( 2068, - T_address, - [], - [] ); - Prim - ( 2069, - T_pair, - [ Prim - ( 2070, - T_address, - [], - [] - ); - Prim - ( 2071, - T_nat, - [], - [] - ) - ], - [] ) ], - [] ) ], - ["%transfer"] ); - Prim - ( 2072, - I_IF_NONE, - [ Seq - ( 2073, - [ Prim - ( 2074, - I_PUSH, - [ Prim - ( 2075, - T_string, - [], - [] - ); - String - ( 2076, - "bad \ - address \ - for \ - get_entrypoint" - ) - ], - [] ); - Prim - ( 2077, - I_FAILWITH, - [], - [] ) ] - ); - Seq (2078, []) ], - [] ); - Prim - ( 2079, - I_PUSH, - [ Prim - ( 2080, - T_mutez, - [], - [] ); - Int (2081, Z.zero) - ], - [] ); - Prim - ( 2082, - I_DIG, - [ Int - ( 2083, - Z.of_int 3 ) - ], - [] ); - Prim - ( 2084, - I_DIG, - [ Int - ( 2085, - Z.of_int 5 ) - ], - [] ); - Prim - ( 2086, - I_DIG, - [ Int - ( 2087, - Z.of_int 5 ) - ], - [] ); - Prim - ( 2088, - I_DIP, - [ Seq - ( 2089, - [ Prim - ( 2090, - I_PAIR, - [], - [] ) ] - ) ], - [] ); - Prim - (2091, I_PAIR, [], []); - Prim - ( 2092, - I_TRANSFER_TOKENS, - [], - [] ); - Prim - ( 2093, - I_DIP, - [ Seq - ( 2094, - [ Prim - ( 2095, - I_NIL, - [ Prim - ( 2096, - T_operation, - [], - [] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (2097, I_CONS, [], []); - Prim - (2098, I_PAIR, [], []) - ] ) ], - [] ) ] ) ], - [] ) ] ); - Seq - ( 2099, - [ Prim - ( 2100, - I_IF_LEFT, - [ Seq - ( 2101, - [ Prim - ( 2102, - I_IF_LEFT, - [ Seq - ( 2103, - [ Prim - ( 2104, - I_DIP, - [ Seq - ( 2105, - [ Prim - ( 2106, - I_DUP, - [], - [] ); - Prim - ( 2107, - I_CDR, - [], - [] ); - Prim - ( 2108, - I_CAR, - [], - [] ); - Prim - ( 2109, - I_CAR, - [], - [] ); - Prim - ( 2110, - I_IF, - [ Seq - ( 2111, - [ - Prim + ] + ); + Seq + ( + 1238, + [] + ) + ], + [] + ); + Prim + ( + 1239, + I_PUSH, + [ + Prim + ( + 1240, + T_mutez, + [], + [] + ); + Int ( - 2112, + 1241, + Z + .zero + ) + ], + [] + ); + Prim + ( + 1242, + I_DIG, + [ + Int + ( + 1243, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 1244, + I_SELF, + [], + [] + ); + Prim + ( + 1245, + I_ADDRESS, + [], + [] + ); + Prim + ( + 1246, + I_PAIR, + [], + [] + ); + Prim + ( + 1247, + I_TRANSFER_TOKENS, + [], + [] + ); + Prim + ( + 1248, + I_SWAP, + [], + [] + ); + Prim + ( + 1249, + I_DUP, + [], + [] + ); + Prim + ( + 1250, + I_DUG, + [ + Int + ( + 1251, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 1252, + I_CDR, + [], + [] + ); + Prim + ( + 1253, + I_CDR, + [], + [] + ); + Prim + ( + 1254, + I_CDR, + [], + [] + ); + Prim + ( + 1255, + I_CDR, + [], + [] + ); + Prim + ( + 1256, I_PUSH, [ Prim ( - 2113, - T_string, + 1257, + T_bool, [], [] ); - String + Prim ( - 2114, - "selfIsUpdatingToken \ - must \ - be \ - false." + 1258, + D_True, + [], + [] ) ], [] ); Prim ( - 2115, - I_FAILWITH, + 1259, + I_PAIR, [], [] + ); + Prim + ( + 1260, + I_DIG, + [ + Int + ( + 1261, + Z + .of_int + 2 ) - ] - ); - Seq - ( 2116, - [] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (2117, I_DUP, [], []); - Prim - (2118, I_CDR, [], []); - Prim - (2119, I_CDR, [], []); - Prim - (2120, I_CDR, [], []); - Prim - (2121, I_NOW, [], []); - Prim - ( 2122, - I_COMPARE, - [], - [] ); - Prim - (2123, I_LT, [], []); - Prim - ( 2124, - I_IF, - [ Seq (2125, []); - Seq - ( 2126, - [ Prim - ( 2127, - I_PUSH, - [ Prim - ( 2128, - T_string, - [], - [] - ); - String - ( 2129, - "NOW \ - is \ - greater \ - than \ - deadline." - ) - ], - [] ); - Prim - ( 2130, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2131, - I_PUSH, - [ Prim - ( 2132, - T_mutez, - [], - [] ); - Int (2133, Z.zero) - ], - [] ); - Prim - ( 2134, - I_AMOUNT, - [], - [] ); - Prim - ( 2135, - I_COMPARE, - [], - [] ); - Prim - (2136, I_EQ, [], []); - Prim - ( 2137, - I_IF, - [ Seq (2138, []); - Seq - ( 2139, - [ Prim - ( 2140, - I_PUSH, - [ Prim - ( 2141, - T_string, - [], - [] - ); - String - ( 2142, - "Amount \ - must \ - be \ - zero." - ) - ], - [] ); - Prim - ( 2143, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2144, - I_DIP, - [ Seq - ( 2145, - [ Prim - ( 2146, - I_DUP, - [], - [] ); - Prim - ( 2147, - I_CDR, - [], - [] ); - Prim - ( 2148, - I_CDR, - [], - [] ); - Prim - ( 2149, - I_CDR, - [], - [] ); - Prim - ( 2150, - I_CDR, - [], - [] ); - Prim - ( 2151, - I_PUSH, - [ Prim - ( 2152, - T_mutez, - [], - [] - ); - Int - ( 2153, - Z - .zero - ) - ], - [] ); - Prim - ( 2154, - I_COMPARE, - [], - [] ); - Prim - ( 2155, - I_LT, - [], - [] ); - Prim - ( 2156, - I_IF, - [ Seq - ( 2157, - [] - ); - Seq - ( 2158, - [ - Prim + ], + [] + ); + Prim + ( + 1262, + I_DUP, + [], + [] + ); + Prim ( - 2159, - I_PUSH, + 1263, + I_DUG, [ + Int + ( + 1264, + Z + .of_int + 3 + ) + ], + [] + ); Prim ( - 2160, - T_string, + 1265, + I_CDR, [], [] ); - String + Prim + ( + 1266, + I_CDR, + [], + [] + ); + Prim + ( + 1267, + I_CAR, + [], + [] + ); + Prim + ( + 1268, + I_PAIR, + [], + [] + ); + Prim ( - 2161, - "xtzPool \ - must \ - be \ - greater \ - than \ - zero." + 1269, + I_DIG, + [ + Int + ( + 1270, + Z + .of_int + 2 ) ], [] ); Prim ( - 2162, - I_FAILWITH, + 1271, + I_DUP, [], [] - ) - ] - ) - ], - [] ) ] - ) ], - [] ); - Prim - ( 2163, - I_DIP, - [ Seq - ( 2164, - [ Prim - ( 2165, - I_DUP, - [], - [] ); - Prim - ( 2166, - I_CDR, - [], - [] ); - Prim - ( 2167, - I_CDR, - [], - [] ); - Prim - ( 2168, - I_CDR, - [], - [] ); - Prim - ( 2169, - I_CAR, - [], - [] ); - Prim - ( 2170, - I_PUSH, - [ Prim - ( 2171, - T_nat, - [], - [] - ); - Int - ( 2172, - Z - .zero - ) - ], - [] ); - Prim - ( 2173, - I_COMPARE, - [], - [] ); - Prim - ( 2174, - I_LT, - [], - [] ); - Prim - ( 2175, - I_IF, - [ Seq - ( 2176, - [] - ); - Seq - ( 2177, - [ - Prim + ); + Prim ( - 2178, - I_PUSH, + 1272, + I_DUG, [ + Int + ( + 1273, + Z + .of_int + 3 + ) + ], + [] + ); Prim ( - 2179, - T_string, + 1274, + I_CDR, [], [] ); - String + Prim + ( + 1275, + I_CAR, + [], + [] + ); + Prim + ( + 1276, + I_PAIR, + [], + [] + ); + Prim + ( + 1277, + I_DIG, + [ + Int ( - 2180, - "tokenPool \ - must \ - be \ - greater \ - than \ - zero" + 1278, + Z + .of_int + 2 ) ], [] ); Prim ( - 2181, - I_FAILWITH, + 1279, + I_CAR, + [], + [] + ); + Prim + ( + 1280, + I_PAIR, + [], + [] + ); + Prim + ( + 1281, + I_NIL, + [ + Prim + ( + 1282, + T_operation, [], [] ) - ] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (2182, I_DUP, [], []); - Prim - (2183, I_CDR, [], []); - Prim - (2184, I_CAR, [], []); - Prim - ( 2185, - I_PUSH, - [ Prim - ( 2186, - T_nat, - [], - [] ); - Int (2187, Z.zero) - ], - [] ); - Prim - ( 2188, - I_COMPARE, - [], - [] ); - Prim - (2189, I_LT, [], []); - Prim - ( 2190, - I_IF, - [ Seq (2191, []); - Seq - ( 2192, - [ Prim - ( 2193, - I_PUSH, - [ Prim - ( 2194, - T_string, - [], - [] - ); - String - ( 2195, - "tokensSold \ - is \ - zero" - ) - ], - [] ); - Prim - ( 2196, - I_FAILWITH, - [], - [] ) ] - ) ], - [] ); - Prim - (2197, I_DUP, [], []); - Prim - (2198, I_CDR, [], []); - Prim - (2199, I_CDR, [], []); - Prim - (2200, I_CAR, [], []); - Prim - ( 2201, - I_PUSH, - [ Prim - ( 2202, - T_mutez, - [], - [] ); - Int (2203, Z.zero) - ], - [] ); - Prim - ( 2204, - I_COMPARE, - [], - [] ); - Prim - (2205, I_LT, [], []); - Prim - ( 2206, - I_IF, - [ Seq (2207, []); - Seq - ( 2208, - [ Prim - ( 2209, - I_PUSH, - [ Prim - ( 2210, - T_string, - [], - [] - ); - String - ( 2211, - "minXtzBought \ - must \ - be \ - greater \ - than \ - zero." + ], + [] + ); + Prim + ( + 1283, + I_DIG, + [ + Int + ( + 1284, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 1285, + I_CONS, + [], + [] + ); + Prim + ( + 1286, + I_PAIR, + [], + [] + ) + ] + ) + ], + [] + ) + ] ) ], - [] ); - Prim - ( 2212, - I_FAILWITH, - [], [] ) ] ) ], - [] ); - Prim - (2213, I_DUP, [], []); - Prim - (2214, I_CDR, [], []); - Prim - (2215, I_CAR, [], []); - Prim - ( 2216, - I_PUSH, - [ Prim - ( 2217, - T_nat, - [], - [] ); - Int - ( 2218, - Z.of_int 999 - ) ], - [] ); - Prim - (2219, I_MUL, [], []); + [] ) ] ); + Seq + ( 1287, + [ Prim + (1288, I_SWAP, [], []); Prim - ( 2220, - I_DIP, - [ Int - ( 2221, - Z.of_int 2 ); - Seq - ( 2222, - [ Prim - ( 2223, - I_DUP, - [], - [] ) ] - ) ], - [] ); + (1289, I_DUP, [], []); Prim - ( 2224, - I_DIG, + ( 1290, + I_DUG, [ Int - ( 2225, + ( 1291, Z.of_int 2 ) ], [] ); Prim - (2226, I_CDR, [], []); + (1292, I_CDR, [], []); Prim - (2227, I_CDR, [], []); + (1293, I_CDR, [], []); Prim - (2228, I_CDR, [], []); - Prim - (2229, I_CAR, [], []); - Prim - ( 2230, - I_PUSH, - [ Prim - ( 2231, - T_nat, - [], - [] ); - Int - ( 2232, - Z.of_int 1000 - ) ], - [] ); + (1294, I_CDR, [], []); Prim - (2233, I_MUL, [], []); + (1295, I_CDR, [], []); Prim - (2234, I_ADD, [], []); + (1296, I_CAR, [], []); Prim - ( 2235, - I_DIP, - [ Seq - ( 2236, - [ Prim - ( 2237, - I_DUP, - [], - [] ) ] - ) ], + ( 1297, + I_SENDER, + [], [] ); Prim - (2238, I_SWAP, [], []); - Prim - (2239, I_CDR, [], []); - Prim - (2240, I_CAR, [], []); - Prim - ( 2241, - I_PUSH, - [ Prim - ( 2242, - T_nat, - [], - [] ); - Int - ( 2243, - Z.of_int 999 - ) ], + ( 1298, + I_COMPARE, + [], [] ); Prim - (2244, I_MUL, [], []); + (1299, I_NEQ, [], []); Prim - ( 2245, - I_DIP, + ( 1300, + I_DIG, [ Int - ( 2246, - Z.of_int 3 ); - Seq - ( 2247, - [ Prim - ( 2248, - I_DUP, - [], - [] ) ] - ) ], + ( 1301, + Z.of_int 2 ) + ], [] ); Prim - ( 2249, - I_DIG, + (1302, I_DUP, [], []); + Prim + ( 1303, + I_DUG, [ Int - ( 2250, + ( 1304, Z.of_int 3 ) ], [] ); Prim - (2251, I_CDR, [], []); + (1305, I_CDR, [], []); + Prim + (1306, I_CDR, [], []); Prim - (2252, I_CDR, [], []); + (1307, I_CDR, [], []); Prim - (2253, I_CDR, [], []); + (1308, I_CAR, [], []); Prim - (2254, I_CDR, [], []); + (1309, I_NOT, [], []); Prim - ( 2255, - I_DIP, + (1310, I_OR, [], []); + Prim + ( 1311, + I_IF, [ Seq - ( 2256, + ( 1312, [ Prim - ( 2257, - I_PUSH, - [ Prim - ( 2258, - T_mutez, - [], - [] - ); - Int - ( 2259, + ( 1313, + I_DROP, + [ Int + ( 1314, Z - .one + .of_int + 2 ) ], - [] ) ] - ) ], - [] ); - Prim - (2260, I_EDIV, [], []); - Prim - ( 2261, - I_IF_NONE, - [ Seq - ( 2262, - [ Prim - ( 2263, + [] ); + Prim + ( 1315, I_PUSH, [ Prim - ( 2264, - T_string, + ( 1316, + T_nat, [], [] ); - String - ( 2265, - "" + Int + ( 1317, + Z + .of_int + 29 ) ], [] ); Prim - ( 2266, + ( 1318, I_FAILWITH, [], [] ) ] ); Seq - ( 2267, - [ Prim - ( 2268, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (2269, I_MUL, [], []); - Prim - (2270, I_EDIV, [], []); - Prim - ( 2271, - I_IF_NONE, - [ Seq - ( 2272, + ( 1319, [ Prim - ( 2273, + ( 1320, I_PUSH, [ Prim - ( 2274, - T_string, + ( 1321, + T_mutez, [], [] ); - String - ( 2275, - "divByZero." + Int + ( 1322, + Z + .zero ) ], [] ); Prim - ( 2276, - I_FAILWITH, + ( 1323, + I_AMOUNT, [], - [] ) ] - ); - Seq - ( 2277, - [ Prim - ( 2278, - I_CAR, + [] ); + Prim + ( 1324, + I_COMPARE, [], - [] ) ] - ) ], - [] ); - Prim - ( 2279, - I_PUSH, - [ Prim - ( 2280, - T_mutez, - [], - [] ); - Int (2281, Z.one) - ], - [] ); - Prim - (2282, I_MUL, [], []); - Prim - (2283, I_DUP, [], []); - Prim - ( 2284, - I_DIP, - [ Seq - ( 2285, - [ Prim - ( 2286, - I_DIP, + [] ); + Prim + ( 1325, + I_GT, + [], + [] ); + Prim + ( 1326, + I_IF, [ Seq - ( 2287, + ( 1327, [ Prim ( - 2288, - I_DUP, - [], + 1328, + I_DROP, + [ + Int + ( + 1329, + Z + .of_int + 2 + ) + ], [] ); Prim ( - 2289, - I_CDR, + 1330, + I_PUSH, + [ + Prim + ( + 1331, + T_nat, [], [] ); - Prim + Int ( - 2290, - I_CDR, - [], + 1332, + Z + .of_int + 10 + ) + ], [] ); Prim ( - 2291, - I_CAR, + 1333, + I_FAILWITH, [], [] ) ] - ) - ], - [] ); - Prim - ( 2292, - I_COMPARE, - [], - [] ); - Prim - ( 2293, - I_GE, - [], - [] ); - Prim - ( 2294, - I_IF, - [ Seq - ( 2295, - [] ); Seq - ( 2296, + ( 1334, [ Prim ( - 2297, + 1335, + I_SWAP, + [], + [] + ); + Prim + ( + 1336, + I_CDR, + [], + [] + ); + Prim + ( + 1337, + I_SWAP, + [], + [] + ); + Prim + ( + 1338, + I_PAIR, + [], + [] + ); + Prim + ( + 1339, + I_DUP, + [], + [] + ); + Prim + ( + 1340, + I_CDR, + [], + [] + ); + Prim + ( + 1341, + I_CDR, + [], + [] + ); + Prim + ( + 1342, + I_CDR, + [], + [] + ); + Prim + ( + 1343, + I_CDR, + [], + [] + ); + Prim + ( + 1344, I_PUSH, [ Prim ( - 2298, - T_string, + 1345, + T_bool, [], [] ); - String + Prim ( - 2299, - "xtzBought \ - is \ - less \ - than \ - minXtzBought." + 1346, + D_False, + [], + [] ) ], [] ); Prim ( - 2300, - I_FAILWITH, + 1347, + I_PAIR, [], [] - ) - ] - ) - ], - [] ) ] - ) ], - [] ); - Prim - ( 2301, - I_DIP, - [ Seq - ( 2302, - [ Prim - ( 2303, - I_SWAP, - [], - [] ); - Prim - ( 2304, - I_DUP, - [], - [] ); - Prim - ( 2305, - I_CDR, - [], - [] ); - Prim - ( 2306, - I_CDR, - [], - [] ); - Prim - ( 2307, - I_CDR, - [], - [] ); - Prim - ( 2308, - I_CAR, - [], - [] ); - Prim - ( 2309, - I_DIP, - [ Int - ( 2310, - Z - .of_int - 2 - ); - Seq - ( 2311, - [ - Prim + ); + Prim ( - 2312, - I_DUP, + 1348, + I_SWAP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 2313, - I_DIG, - [ Int - ( 2314, - Z - .of_int - 2 - ) - ], - [] ); - Prim - ( 2315, - I_CDR, - [], - [] ); - Prim - ( 2316, - I_CAR, - [], - [] ); - Prim - ( 2317, - I_ADD, - [], - [] ); - Prim - ( 2318, - I_DIP, - [ Seq - ( 2319, - [ - Prim + ); + Prim ( - 2320, + 1349, I_DUP, [], [] ); Prim ( - 2321, - I_CDR, - [], - [] + 1350, + I_DUG, + [ + Int + ( + 1351, + Z + .of_int + 2 ) - ] - ) - ], - [] ); - Prim - ( 2322, - I_DIP, - [ Seq - ( 2323, - [ - Prim + ], + [] + ); + Prim ( - 2324, - I_DUP, + 1352, + I_CDR, [], [] ); Prim ( - 2325, - I_DIP, - [ - Seq - ( - 2326, - [ + 1353, + I_CDR, + [], + [] + ); Prim ( - 2327, + 1354, I_CAR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 1355, + I_PAIR, + [], [] ); Prim ( - 2328, - I_CDR, + 1356, + I_SWAP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 2329, - I_DIP, - [ Seq - ( 2330, - [ - Prim + ); + Prim ( - 2331, + 1357, I_DUP, [], [] ); Prim ( - 2332, - I_DIP, + 1358, + I_DUG, [ - Seq + Int ( - 2333, - [ + 1359, + Z + .of_int + 2 + ) + ], + [] + ); + Prim + ( + 1360, + I_CDR, + [], + [] + ); Prim ( - 2334, + 1361, I_CAR, [], [] - ) - ] - ) - ], + ); + Prim + ( + 1362, + I_PAIR, + [], [] ); Prim ( - 2335, - I_CDR, + 1363, + I_SWAP, [], [] - ) - ] - ) - ], - [] ); - Prim - ( 2336, - I_DIP, - [ Seq - ( 2337, - [ - Prim + ); + Prim ( - 2338, - I_DUP, + 1364, + I_CAR, [], [] ); Prim ( - 2339, - I_DIP, - [ - Seq + 1365, + I_PAIR, + [], + [] + ); + Prim ( - 2340, + 1366, + I_NIL, [ Prim ( - 2341, - I_CDR, + 1367, + T_operation, [], [] ) - ] - ) ], [] ); Prim ( - 2342, - I_CAR, + 1368, + I_PAIR, [], [] ) ] ) ], + [] ) ] + ) ], + [] ) ] ) ], + [] ) ] ); + Seq + ( 1369, + [ Prim (1370, I_DUP, [], []); + Prim (1371, I_CDR, [], []); + Prim (1372, I_SWAP, [], []); + Prim (1373, I_CAR, [], []); + Prim (1374, I_SWAP, [], []); + Prim (1375, I_DUP, [], []); + Prim (1376, I_CDR, [], []); + Prim (1377, I_SWAP, [], []); + Prim (1378, I_CAR, [], []); + Prim + ( 1379, + I_DIG, + [Int (1380, Z.of_int 3)], + [] ); + Prim (1381, I_DUP, [], []); + Prim + ( 1382, + I_DUG, + [Int (1383, Z.of_int 4)], + [] ); + Prim (1384, I_CDR, [], []); + Prim (1385, I_CDR, [], []); + Prim (1386, I_CDR, [], []); + Prim (1387, I_CAR, [], []); + Prim + ( 1388, + I_IF, + [ Seq + ( 1389, + [ Prim + ( 1390, + I_DROP, + [ Int + ( 1391, + Z.of_int 4 ) + ], + [] ); + Prim + ( 1392, + I_PUSH, + [ Prim + ( 1393, + T_nat, + [], + [] ); + Int + ( 1394, + Z.of_int 2 ) + ], + [] ); + Prim + ( 1395, + I_FAILWITH, + [], + [] ) ] ); + Seq + ( 1396, + [ Prim + (1397, I_SWAP, [], []); + Prim + (1398, I_NOW, [], []); + Prim + ( 1399, + I_COMPARE, + [], + [] ); + Prim + (1400, I_GE, [], []); + Prim + ( 1401, + I_IF, + [ Seq + ( 1402, + [ Prim + ( 1403, + I_DROP, + [ Int + ( 1404, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1405, + I_PUSH, + [ Prim + ( 1406, + T_nat, + [], + [] + ); + Int + ( 1407, + Z + .of_int + 3 + ) + ], [] ); Prim - ( 2343, - I_SWAP, + ( 1408, + I_FAILWITH, [], + [] ) ] + ); + Seq + ( 1409, + [ Prim + ( 1410, + I_PUSH, + [ Prim + ( 1411, + T_mutez, + [], + [] + ); + Int + ( 1412, + Z + .one + ) + ], [] ); Prim - ( 2344, - I_DROP, - [], + ( 1413, + I_DIG, + [ Int + ( 1414, + Z + .of_int + 3 + ) + ], [] ); Prim - ( 2345, - I_PAIR, + ( 1415, + I_DUP, [], [] ); Prim - ( 2346, - I_SWAP, - [], + ( 1416, + I_DUG, + [ Int + ( 1417, + Z + .of_int + 4 + ) + ], [] ); Prim - ( 2347, - I_PAIR, + ( 1418, + I_CDR, [], [] ); Prim - ( 2348, - I_SWAP, + ( 1419, + I_CAR, [], [] ); Prim - ( 2349, - I_PAIR, + ( 1420, + I_EDIV, [], [] ); Prim - ( 2350, - I_DIP, + ( 1421, + I_IF_NONE, [ Seq - ( 2351, + ( 1422, [ Prim ( - 2352, - I_DUP, - [], - [] - ); - Prim - ( - 2353, - I_DIP, - [ - Seq - ( - 2354, + 1423, + I_PUSH, [ Prim ( - 2355, - I_CAR, + 1424, + T_string, [], [] - ) - ] + ); + String + ( + 1425, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 2356, - I_CDR, + 1426, + I_FAILWITH, [], [] ) ] + ); + Seq + ( 1427, + [] ) ], [] ); Prim - ( 2357, - I_SWAP, + ( 1428, + I_CAR, [], [] ); Prim - ( 2358, - I_DROP, + ( 1429, + I_AMOUNT, [], [] ); Prim - ( 2359, + ( 1430, + I_PUSH, + [ Prim + ( 1431, + T_mutez, + [], + [] + ); + Int + ( 1432, + Z + .one + ) + ], + [] ); + Prim + ( 1433, I_SWAP, [], [] ); Prim - ( 2360, - I_PAIR, + ( 1434, + I_EDIV, [], - [] ) ] - ) ], - [] ); - Prim - (2361, I_DUP, [], []); - Prim - ( 2362, - I_DIP, - [ Seq - ( 2363, - [ Prim - ( 2364, - I_DIP, + [] ); + Prim + ( 1435, + I_IF_NONE, [ Seq - ( 2365, + ( 1436, [ Prim ( - 2366, - I_DUP, - [], - [] - ); - Prim - ( - 2367, - I_CDR, - [], - [] - ); + 1437, + I_PUSH, + [ Prim ( - 2368, - I_CDR, + 1438, + T_string, [], [] ); - Prim + String ( - 2369, - I_CDR, - [], + 1439, + "DIV \ + by \ + 0" + ) + ], [] ); Prim ( - 2370, - I_CDR, + 1440, + I_FAILWITH, [], [] ) ] + ); + Seq + ( 1441, + [] ) ], [] ); Prim - ( 2371, - I_SWAP, + ( 1442, + I_CAR, [], [] ); Prim - ( 2372, - I_SUB, + ( 1443, + I_PUSH, + [ Prim + ( 1444, + T_nat, + [], + [] + ); + Int + ( 1445, + Z + .of_int + 1000 + ) + ], + [] ); + Prim + ( 1446, + I_SWAP, [], [] ); Prim - ( 2373, - I_DIP, - [ Seq - ( 2374, - [ - Prim - ( - 2375, - I_DUP, - [], - [] - ); - Prim - ( - 2376, - I_CDR, - [], - [] - ) - ] - ) - ], + ( 1447, + I_DUP, + [], [] ); Prim - ( 2377, - I_DIP, - [ Seq - ( 2378, - [ - Prim - ( - 2379, - I_DUP, - [], - [] - ); - Prim - ( - 2380, - I_DIP, - [ - Seq - ( - 2381, - [ - Prim - ( - 2382, - I_CAR, - [], - [] - ) - ] - ) - ], - [] - ); - Prim - ( - 2383, - I_CDR, - [], - [] - ) - ] + ( 1448, + I_DUG, + [ Int + ( 1449, + Z + .of_int + 2 ) ], [] ); Prim - ( 2384, - I_DIP, - [ Seq - ( 2385, - [ - Prim - ( - 2386, - I_DUP, - [], - [] - ); - Prim - ( - 2387, - I_DIP, - [ - Seq - ( - 2388, - [ - Prim - ( - 2389, - I_CAR, - [], - [] - ) - ] - ) - ], - [] - ); - Prim - ( - 2390, - I_CDR, - [], - [] - ) - ] - ) - ], + ( 1450, + I_EDIV, + [], [] ); Prim - ( 2391, - I_DIP, + ( 1451, + I_IF_NONE, [ Seq - ( 2392, + ( 1452, [ Prim ( - 2393, - I_DUP, - [], - [] - ); - Prim - ( - 2394, - I_DIP, - [ - Seq - ( - 2395, + 1453, + I_PUSH, [ Prim ( - 2396, - I_CAR, + 1454, + T_string, [], [] - ) - ] + ); + String + ( + 1455, + "DIV \ + by \ + 0" ) ], [] ); Prim ( - 2397, - I_CDR, + 1456, + I_FAILWITH, [], [] ) ] + ); + Seq + ( 1457, + [] ) ], [] ); Prim - ( 2398, - I_SWAP, + ( 1458, + I_CAR, [], [] ); Prim - ( 2399, - I_DROP, + ( 1459, + I_DUP, [], [] ); Prim - ( 2400, - I_SWAP, - [], + ( 1460, + I_DIG, + [ Int + ( 1461, + Z + .of_int + 2 + ) + ], [] ); Prim - ( 2401, - I_PAIR, + ( 1462, + I_SUB, [], [] ); Prim - ( 2402, - I_SWAP, + ( 1463, + I_ABS, [], [] ); Prim - ( 2403, - I_PAIR, - [], + ( 1464, + I_PUSH, + [ Prim + ( 1465, + T_nat, + [], + [] + ); + Int + ( 1466, + Z + .of_int + 999 + ) + ], [] ); Prim - ( 2404, + ( 1467, I_SWAP, [], [] ); Prim - ( 2405, - I_PAIR, + ( 1468, + I_DUP, [], [] ); Prim - ( 2406, - I_DIP, - [ Seq - ( 2407, - [ - Prim - ( - 2408, - I_DUP, - [], - [] - ); - Prim - ( - 2409, - I_DIP, - [ - Seq - ( - 2410, - [ - Prim - ( - 2411, - I_CAR, - [], - [] - ) - ] - ) - ], - [] - ); - Prim - ( - 2412, - I_CDR, - [], - [] - ) - ] + ( 1469, + I_DUG, + [ Int + ( 1470, + Z + .of_int + 2 ) ], [] ); Prim - ( 2413, - I_SWAP, + ( 1471, + I_MUL, [], [] ); Prim - ( 2414, - I_DROP, - [], + ( 1472, + I_PUSH, + [ Prim + ( 1473, + T_nat, + [], + [] + ); + Int + ( 1474, + Z + .of_int + 1000 + ) + ], [] ); Prim - ( 2415, - I_SWAP, + ( 1475, + I_DIG, + [ Int + ( 1476, + Z + .of_int + 4 + ) + ], + [] ); + Prim + ( 1477, + I_MUL, [], [] ); Prim - ( 2416, - I_PAIR, + ( 1478, + I_ADD, [], - [] ) ] - ) ], - [] ); - Prim - ( 2417, - I_DIP, - [ Int - ( 2418, - Z.of_int 2 ); - Seq - ( 2419, - [ Prim - ( 2420, + [] ); + Prim + ( 1479, + I_DIG, + [ Int + ( 1480, + Z + .of_int + 5 + ) + ], + [] ); + Prim + ( 1481, I_DUP, [], - [] ) ] - ) ], - [] ); - Prim - ( 2421, - I_DIG, - [ Int - ( 2422, - Z.of_int 2 ) - ], - [] ); - Prim - (2423, I_CAR, [], []); - Prim - (2424, I_CDR, [], []); - Prim - ( 2425, - I_CONTRACT, - [ Prim - ( 2426, - T_unit, - [], - [] ) ], - [] ); - Prim - ( 2427, - I_IF_NONE, - [ Seq - ( 2428, - [ Prim - ( 2429, + [] ); + Prim + ( 1482, + I_DUG, + [ Int + ( 1483, + Z + .of_int + 6 + ) + ], + [] ); + Prim + ( 1484, + I_CAR, + [], + [] ); + Prim + ( 1485, I_PUSH, [ Prim - ( 2430, - T_string, + ( 1486, + T_nat, [], [] ); - String - ( 2431, - "bad \ - address \ - for \ - get_entrypoint" + Int + ( 1487, + Z + .of_int + 999 ) ], [] ); Prim - ( 2432, - I_FAILWITH, + ( 1488, + I_DIG, + [ Int + ( 1489, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1490, + I_MUL, [], - [] ) ] - ); - Seq (2433, []) ], - [] ); - Prim - ( 2434, - I_DIG, - [Int (2435, Z.one)], - [] ); - Prim - (2436, I_UNIT, [], []); - Prim - ( 2437, - I_TRANSFER_TOKENS, - [], - [] ); - Prim - ( 2438, - I_DIP, - [ Seq - ( 2439, - [ Prim - ( 2440, - I_DIP, + [] ); + Prim + ( 1491, + I_MUL, + [], + [] ); + Prim + ( 1492, + I_EDIV, + [], + [] ); + Prim + ( 1493, + I_IF_NONE, [ Seq - ( 2441, + ( 1494, [ Prim ( - 2442, - I_DUP, - [], - [] - ); - Prim - ( - 2443, - I_CDR, - [], - [] - ); + 1495, + I_PUSH, + [ Prim ( - 2444, - I_CAR, + 1496, + T_string, [], [] ); - Prim - ( - 2445, - I_DIP, - [ - Seq - ( - 2446, - [ - Prim + String ( - 2447, - I_CAR, - [], + 1497, + "DIV \ + by \ + 0" + ) + ], [] ); Prim ( - 2448, - I_CAR, + 1498, + I_FAILWITH, [], [] ) - ] - ) - ], - [] - ) ] + ); + Seq + ( 1499, + [] ) ], [] ); Prim - ( 2449, + ( 1500, + I_CAR, + [], + [] ); + Prim + ( 1501, + I_DIG, + [ Int + ( 1502, + Z + .of_int + 2 + ) + ], + [] ); + Prim + ( 1503, + I_SWAP, + [], + [] ); + Prim + ( 1504, I_DUP, [], [] ); Prim - ( 2450, - I_CDR, - [], + ( 1505, + I_DUG, + [ Int + ( 1506, + Z + .of_int + 2 + ) + ], [] ); Prim - ( 2451, - I_CDR, + ( 1507, + I_COMPARE, [], [] ); Prim - ( 2452, - I_CAR, + ( 1508, + I_LT, [], [] ); Prim - ( 2453, - I_CONTRACT, - [ Prim - ( 2454, - T_pair, + ( 1509, + I_IF, + [ Seq + ( 1510, [ Prim ( - 2455, - T_address, + 1511, + I_DROP, [], [] ); Prim ( - 2456, - T_pair, + 1512, + I_PUSH, [ Prim ( - 2457, - T_address, + 1513, + T_nat, [], [] ); - Prim + Int ( - 2458, - T_nat, - [], - [] + 1514, + Z + .of_int + 18 ) ], [] + ); + Prim + ( + 1515, + I_FAILWITH, + [], + [] ) - ], + ] + ); + Seq + ( 1516, [] ) ], - [ "%transfer" - ] ); + [] ); + Prim + ( 1517, + I_DUP, + [], + [] ); + Prim + ( 1518, + I_DIG, + [ Int + ( 1519, + Z + .of_int + 4 + ) + ], + [] ); + Prim + ( 1520, + I_DUP, + [], + [] ); + Prim + ( 1521, + I_DUG, + [ Int + ( 1522, + Z + .of_int + 5 + ) + ], + [] ); + Prim + ( 1523, + I_CAR, + [], + [] ); + Prim + ( 1524, + I_SUB, + [], + [] ); + Prim + ( 1525, + I_ISNAT, + [], + [] ); Prim - ( 2459, + ( 1526, I_IF_NONE, [ Seq - ( 2460, + ( 1527, [ Prim ( - 2461, + 1528, I_PUSH, [ Prim ( - 2462, - T_string, + 1529, + T_nat, [], [] ); - String + Int ( - 2463, - "bad \ - address \ - for \ - get_entrypoint" + 1530, + Z + .of_int + 19 ) ], [] ); Prim ( - 2464, + 1531, I_FAILWITH, [], [] @@ -11724,1269 +9538,616 @@ let script = ] ); Seq - ( 2465, + ( 1532, [] ) ], [] ); Prim - ( 2466, - I_PUSH, - [ Prim - ( 2467, - T_mutez, - [], - [] - ); - Int - ( 2468, + ( 1533, + I_DIG, + [ Int + ( 1534, Z - .zero + .of_int + 4 ) ], [] ); Prim - ( 2469, - I_DIG, + ( 1535, + I_DUP, + [], + [] ); + Prim + ( 1536, + I_DUG, [ Int - ( 2470, + ( 1537, Z .of_int - 3 + 5 ) ], [] ); Prim - ( 2471, - I_SELF, + ( 1538, + I_CDR, [], [] ); Prim - ( 2472, - I_ADDRESS, + ( 1539, + I_CDR, + [], + [] ); + Prim + ( 1540, + I_AMOUNT, [], [] ); Prim - ( 2473, + ( 1541, I_DIG, [ Int - ( 2474, + ( 1542, Z .of_int - 5 - ) - ], - [] ); - Prim - ( 2475, - I_DIP, - [ Seq - ( 2476, - [ - Prim - ( - 2477, - I_PAIR, - [], - [] - ) - ] + 6 ) ], [] ); Prim - ( 2478, - I_PAIR, + ( 1543, + I_DUP, [], [] ); Prim - ( 2479, - I_TRANSFER_TOKENS, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2480, - I_NIL, - [ Prim - ( 2481, - T_operation, - [], - [] ) ], - [] ); - Prim - ( 2482, - I_DIG, - [ Int - ( 2483, - Z.of_int 2 ) - ], - [] ); - Prim - (2484, I_CONS, [], []); - Prim - (2485, I_SWAP, [], []); - Prim - (2486, I_CONS, [], []); - Prim - (2487, I_PAIR, [], []) - ] ); - Seq - ( 2488, - [ Prim - ( 2489, - I_PUSH, - [ Prim - ( 2490, - T_mutez, - [], - [] ); - Int (2491, Z.zero) - ], - [] ); - Prim - ( 2492, - I_AMOUNT, - [], - [] ); - Prim - ( 2493, - I_COMPARE, - [], - [] ); - Prim - (2494, I_EQ, [], []); - Prim - ( 2495, - I_IF, - [ Seq (2496, []); - Seq - ( 2497, - [ Prim - ( 2498, - I_PUSH, - [ Prim - ( 2499, - T_string, - [], - [] - ); - String - ( 2500, - "Amount \ - must \ - be \ - zero." + ( 1544, + I_DUG, + [ Int + ( 1545, + Z + .of_int + 7 ) ], [] ); Prim - ( 2501, - I_FAILWITH, + ( 1546, + I_CDR, [], - [] ) ] - ) ], - [] ); - Prim - ( 2502, - I_IMPLICIT_ACCOUNT, - [], - [] ); - Prim - ( 2503, - I_ADDRESS, - [], - [] ); - Prim - ( 2504, - I_SENDER, - [], - [] ); - Prim - ( 2505, - I_COMPARE, - [], - [] ); - Prim - (2506, I_EQ, [], []); - Prim - ( 2507, - I_IF, - [ Seq (2508, []); - Seq - ( 2509, - [ Prim - ( 2510, - I_PUSH, - [ Prim - ( 2511, - T_string, - [], - [] - ); - String - ( 2512, - "unsafeUpdateTokenPool" - ) - ], [] ); Prim - ( 2513, - I_FAILWITH, + ( 1547, + I_CAR, [], - [] ) ] - ) ], - [] ); - Prim - (2514, I_DUP, [], []); - Prim - (2515, I_CDR, [], []); - Prim - (2516, I_CAR, [], []); - Prim - (2517, I_CAR, [], []); - Prim - ( 2518, - I_IF, - [ Seq - ( 2519, - [ Prim - ( 2520, - I_PUSH, - [ Prim - ( 2521, - T_string, - [], - [] - ); - String - ( 2522, - "selfIsUpdatingToken \ - must \ - be \ - false." - ) - ], [] ); Prim - ( 2523, - I_FAILWITH, + ( 1548, + I_ADD, [], - [] ) ] - ); - Seq (2524, []) ], - [] ); - Prim - (2525, I_DUP, [], []); - Prim - (2526, I_CDR, [], []); - Prim - ( 2527, - I_PUSH, - [ Prim - ( 2528, - T_bool, - [], - [] ); - Prim - ( 2529, - D_True, - [], - [] ) ], - [] ); - Prim - ( 2530, - I_DIP, - [ Seq - ( 2531, - [ Prim - ( 2532, - I_DUP, + [] ); + Prim + ( 1549, + I_PAIR, [], [] ); Prim - ( 2533, - I_DIP, - [ Seq - ( 2534, - [ - Prim - ( - 2535, - I_CDR, - [], - [] - ) - ] + ( 1550, + I_DIG, + [ Int + ( 1551, + Z + .of_int + 5 ) ], [] ); Prim - ( 2536, + ( 1552, I_CAR, [], - [] ) ] - ) ], - [] ); - Prim - ( 2537, - I_DIP, - [ Seq - ( 2538, - [ Prim - ( 2539, - I_DUP, + [] ); + Prim + ( 1553, + I_PAIR, [], [] ); Prim - ( 2540, - I_DIP, - [ Seq - ( 2541, - [ - Prim - ( - 2542, - I_CDR, - [], - [] - ) - ] - ) - ], + ( 1554, + I_CDR, + [], [] ); Prim - ( 2543, - I_CAR, + ( 1555, + I_SWAP, [], - [] ) ] - ) ], - [] ); - Prim - (2544, I_SWAP, [], []); - Prim - (2545, I_DROP, [], []); - Prim - (2546, I_PAIR, [], []); - Prim - (2547, I_PAIR, [], []); - Prim - ( 2548, - I_DIP, - [ Seq - ( 2549, - [ Prim - ( 2550, - I_DUP, + [] ); + Prim + ( 1556, + I_PAIR, [], [] ); Prim - ( 2551, - I_DIP, - [ Seq - ( 2552, - [ - Prim - ( - 2553, - I_CAR, - [], - [] - ) - ] + ( 1557, + I_SWAP, + [], + [] ); + Prim + ( 1558, + I_DIG, + [ Int + ( 1559, + Z + .of_int + 3 ) ], [] ); Prim - ( 2554, - I_CDR, + ( 1560, + I_PAIR, [], - [] ) ] - ) ], - [] ); - Prim - (2555, I_SWAP, [], []); - Prim - (2556, I_DROP, [], []); - Prim - (2557, I_SWAP, [], []); - Prim - (2558, I_PAIR, [], []); - Prim - (2559, I_DUP, [], []); - Prim - (2560, I_CDR, [], []); - Prim - (2561, I_CDR, [], []); - Prim - (2562, I_CAR, [], []); - Prim - ( 2563, - I_CONTRACT, - [ Prim - ( 2564, - T_pair, - [ Prim - ( 2565, - T_address, + [] ); + Prim + ( 1561, + I_SELF, [], [] ); Prim - ( 2566, - T_contract, - [ Prim - ( 2567, - T_nat, - [], - [] - ) - ], - [] ) ], - [] ) ], - ["%getBalance"] ); - Prim - ( 2568, - I_IF_NONE, - [ Seq - ( 2569, - [ Prim - ( 2570, - I_PUSH, - [ Prim - ( 2571, - T_string, - [], - [] - ); - String - ( 2572, - "bad \ - address \ - for \ - get_entrypoint" - ) - ], + ( 1562, + I_ADDRESS, + [], [] ); Prim - ( 2573, - I_FAILWITH, + ( 1563, + I_PAIR, [], - [] ) ] - ); - Seq (2574, []) ], - [] ); - Prim - ( 2575, - I_PUSH, - [ Prim - ( 2576, - T_mutez, - [], - [] ); - Int (2577, Z.zero) - ], - [] ); - Prim - ( 2578, - I_SELF, - [], - [ "%updateTokenPoolInternal" - ] ); - Prim - (2579, I_SELF, [], []); - Prim - ( 2580, - I_ADDRESS, - [], - [] ); - Prim - (2581, I_PAIR, [], []); - Prim - ( 2582, - I_TRANSFER_TOKENS, - [], - [] ); - Prim - ( 2583, - I_DIP, - [ Seq - ( 2584, - [ Prim - ( 2585, - I_NIL, - [ Prim - ( 2586, - T_operation, - [], - [] - ) - ], - [] ) ] - ) ], - [] ); - Prim - (2587, I_CONS, [], []); - Prim - (2588, I_PAIR, [], []) - ] ) ], - [] ) ] ); - Seq - ( 2589, - [ Prim - ( 2590, - I_IF_LEFT, - [ Seq - ( 2591, - [ Prim - ( 2592, - I_PUSH, - [ Prim - ( 2593, - T_mutez, - [], - [] ); - Int (2594, Z.zero) - ], - [] ); - Prim - ( 2595, - I_AMOUNT, - [], - [] ); - Prim - ( 2596, - I_COMPARE, - [], - [] ); - Prim - (2597, I_EQ, [], []); - Prim - ( 2598, - I_IF, - [ Seq (2599, []); - Seq - ( 2600, - [ Prim - ( 2601, - I_PUSH, - [ Prim - ( 2602, - T_string, - [], - [] - ); - String - ( 2603, - "Amount \ - must \ - be \ - zero." - ) - ], [] ); Prim - ( 2604, - I_FAILWITH, + ( 1564, + I_SWAP, [], - [] ) ] - ) ], - [] ); - Prim - ( 2605, - I_DIP, - [ Seq - ( 2606, - [ Prim - ( 2607, + [] ); + Prim + ( 1565, I_DUP, [], - [] ) ] - ) ], - [] ); - Prim - (2608, I_SWAP, [], []); - Prim - (2609, I_CDR, [], []); - Prim - (2610, I_CAR, [], []); - Prim - (2611, I_CAR, [], []); - Prim - ( 2612, - I_IF, - [ Seq (2613, []); - Seq - ( 2614, - [ Prim - ( 2615, - I_PUSH, - [ Prim - ( 2616, - T_string, - [], - [] - ); - String - ( 2617, - "Dexter \ - did \ - not \ - initiate \ - this \ - operation." + [] ); + Prim + ( 1566, + I_DUG, + [ Int + ( 1567, + Z + .of_int + 2 ) ], [] ); Prim - ( 2618, - I_FAILWITH, + ( 1568, + I_SWAP, [], - [] ) ] - ) ], - [] ); - Prim - ( 2619, - I_DIP, - [ Seq - ( 2620, - [ Prim - ( 2621, + [] ); + Prim + ( 1569, I_DUP, [], - [] ) ] - ) ], - [] ); - Prim - (2622, I_SWAP, [], []); - Prim - (2623, I_CDR, [], []); - Prim - (2624, I_CDR, [], []); - Prim - (2625, I_CAR, [], []); - Prim - ( 2626, - I_SENDER, - [], - [] ); - Prim - ( 2627, - I_COMPARE, - [], - [] ); - Prim - (2628, I_EQ, [], []); - Prim - ( 2629, - I_IF, - [ Seq (2630, []); - Seq - ( 2631, - [ Prim - ( 2632, - I_PUSH, - [ Prim - ( 2633, - T_string, - [], - [] - ); - String - ( 2634, - "The \ - sender \ - is \ - not \ - the \ - token \ - contract \ - associated \ - with \ - this \ - contract." - ) - ], [] ); Prim - ( 2635, - I_FAILWITH, + ( 1570, + I_CDR, + [], + [] ); + Prim + ( 1571, + I_SWAP, [], - [] ) ] - ) ], - [] ); - Prim - ( 2636, - I_DIP, - [ Seq - ( 2637, - [ Prim - ( 2638, + [] ); + Prim + ( 1572, + I_CAR, + [], + [] ); + Prim + ( 1573, + I_SWAP, + [], + [] ); + Prim + ( 1574, I_DUP, [], [] ); Prim - ( 2639, + ( 1575, I_CDR, [], - [] ) ] - ) ], - [] ); - Prim - ( 2640, - I_DIP, - [ Seq - ( 2641, - [ Prim - ( 2642, - I_DUP, + [] ); + Prim + ( 1576, + I_SWAP, [], [] ); Prim - ( 2643, - I_DIP, - [ Seq - ( 2644, - [ - Prim - ( - 2645, - I_CAR, - [], - [] - ) - ] + ( 1577, + I_CAR, + [], + [] ); + Prim + ( 1578, + I_DIG, + [ Int + ( 1579, + Z + .of_int + 3 ) ], [] ); Prim - ( 2646, + ( 1580, I_CDR, [], - [] ) ] - ) ], - [] ); - Prim - ( 2647, - I_DIP, - [ Seq - ( 2648, - [ Prim - ( 2649, - I_DUP, + [] ); + Prim + ( 1581, + I_CDR, [], [] ); Prim - ( 2650, - I_DIP, - [ Seq - ( 2651, - [ - Prim - ( - 2652, - I_CAR, - [], - [] - ) - ] - ) - ], + ( 1582, + I_CDR, + [], [] ); Prim - ( 2653, + ( 1583, I_CDR, [], - [] ) ] - ) ], - [] ); - Prim - ( 2654, - I_DIP, - [ Seq - ( 2655, - [ Prim - ( 2656, - I_DUP, + [] ); + Prim + ( 1584, + I_CAR, [], [] ); Prim - ( 2657, - I_DIP, - [ Seq - ( 2658, + ( 1585, + I_CONTRACT, + [ Prim + ( 1586, + T_pair, [ Prim ( - 2659, - I_CDR, + 1587, + T_address, + [], + [] + ); + Prim + ( + 1588, + T_pair, + [ + Prim + ( + 1589, + T_address, + [], + [] + ); + Prim + ( + 1590, + T_nat, [], [] ) - ] + ], + [] + ) + ], + [] ) ], - [] ); - Prim - ( 2660, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (2661, I_SWAP, [], []); - Prim - (2662, I_DROP, [], []); - Prim - (2663, I_PAIR, [], []); - Prim - (2664, I_SWAP, [], []); - Prim - (2665, I_PAIR, [], []); - Prim - (2666, I_SWAP, [], []); - Prim - (2667, I_PAIR, [], []); - Prim - ( 2668, - I_DIP, - [ Seq - ( 2669, - [ Prim - ( 2670, - I_DUP, - [], - [] ); + [ "%transfer" + ] ); Prim - ( 2671, - I_DIP, + ( 1591, + I_IF_NONE, [ Seq - ( 2672, + ( 1592, [ Prim ( - 2673, - I_CAR, + 1593, + I_PUSH, + [ + Prim + ( + 1594, + T_nat, + [], + [] + ); + Int + ( + 1595, + Z + .zero + ) + ], + [] + ); + Prim + ( + 1596, + I_FAILWITH, [], [] ) ] + ); + Seq + ( 1597, + [] ) ], [] ); Prim - ( 2674, - I_CDR, + ( 1598, + I_PUSH, + [ Prim + ( 1599, + T_mutez, + [], + [] + ); + Int + ( 1600, + Z + .zero + ) + ], + [] ); + Prim + ( 1601, + I_DIG, + [ Int + ( 1602, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1603, + I_DIG, + [ Int + ( 1604, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1605, + I_PAIR, [], - [] ) ] - ) ], - [] ); - Prim - (2675, I_SWAP, [], []); - Prim - (2676, I_DROP, [], []); - Prim - (2677, I_SWAP, [], []); - Prim - (2678, I_PAIR, [], []); - Prim - (2679, I_DUP, [], []); - Prim - (2680, I_CDR, [], []); - Prim - ( 2681, - I_PUSH, - [ Prim - ( 2682, - T_bool, - [], - [] ); - Prim - ( 2683, - D_False, - [], - [] ) ], - [] ); - Prim - ( 2684, - I_DIP, - [ Seq - ( 2685, - [ Prim - ( 2686, - I_DUP, + [] ); + Prim + ( 1606, + I_DIG, + [ Int + ( 1607, + Z + .of_int + 3 + ) + ], + [] ); + Prim + ( 1608, + I_PAIR, [], [] ); Prim - ( 2687, - I_DIP, - [ Seq - ( 2688, - [ - Prim - ( - 2689, - I_CDR, - [], - [] - ) - ] + ( 1609, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + ( 1610, + I_PUSH, + [ Prim + ( 1611, + T_mutez, + [], + [] + ); + Int + ( 1612, + Z + .one + ) + ], + [] ); + Prim + ( 1613, + I_DIG, + [ Int + ( 1614, + Z + .of_int + 3 ) ], [] ); Prim - ( 2690, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2691, - I_DIP, - [ Seq - ( 2692, - [ Prim - ( 2693, - I_DUP, + ( 1615, + I_MUL, [], [] ); Prim - ( 2694, - I_DIP, - [ Seq - ( 2695, - [ - Prim - ( - 2696, - I_CDR, - [], - [] - ) - ] + ( 1616, + I_PUSH, + [ Prim + ( 1617, + T_address, + [], + [] + ); + String + ( 1618, + "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" ) ], [] ); Prim - ( 2697, - I_CAR, - [], - [] ) ] - ) ], - [] ); - Prim - (2698, I_SWAP, [], []); - Prim - (2699, I_DROP, [], []); - Prim - (2700, I_PAIR, [], []); - Prim - (2701, I_PAIR, [], []); - Prim - ( 2702, - I_DIP, - [ Seq - ( 2703, - [ Prim - ( 2704, - I_DUP, - [], + ( 1619, + I_CONTRACT, + [ Prim + ( 1620, + T_unit, + [], + [] + ) + ], [] ); Prim - ( 2705, - I_DIP, + ( 1621, + I_IF_NONE, [ Seq - ( 2706, + ( 1622, [ Prim ( - 2707, - I_CAR, + 1623, + I_PUSH, + [ + Prim + ( + 1624, + T_nat, + [], + [] + ); + Int + ( + 1625, + Z + .of_int + 9 + ) + ], + [] + ); + Prim + ( + 1626, + I_FAILWITH, [], [] ) ] + ); + Seq + ( 1627, + [] ) ], [] ); Prim - ( 2708, - I_CDR, + ( 1628, + I_SWAP, [], - [] ) ] - ) ], - [] ); - Prim - (2709, I_SWAP, [], []); - Prim - (2710, I_DROP, [], []); - Prim - (2711, I_SWAP, [], []); - Prim - (2712, I_PAIR, [], []); - Prim - ( 2713, - I_NIL, - [ Prim - ( 2714, - T_operation, - [], - [] ) ], - [] ); - Prim - (2715, I_PAIR, [], []) - ] ); - Seq - ( 2716, - [ Prim - (2717, I_DROP, [], []); - Prim - (2718, I_DUP, [], []); - Prim - (2719, I_CDR, [], []); - Prim - (2720, I_CAR, [], []); - Prim - (2721, I_CAR, [], []); - Prim - ( 2722, - I_IF, - [ Seq - ( 2723, - [ Prim - ( 2724, + [] ); + Prim + ( 1629, I_PUSH, [ Prim - ( 2725, - T_string, + ( 1630, + T_unit, [], [] ); - String - ( 2726, - "selfIsUpdatingToken \ - must \ - be \ - false." + Prim + ( 1631, + D_Unit, + [], + [] ) ], [] ); Prim - ( 2727, - I_FAILWITH, - [], - [] ) ] - ); - Seq (2728, []) ], - [] ); - Prim - (2729, I_DUP, [], []); - Prim - (2730, I_CDR, [], []); - Prim - (2731, I_CDR, [], []); - Prim - (2732, I_CDR, [], []); - Prim - (2733, I_CDR, [], []); - Prim - ( 2734, - I_AMOUNT, - [], - [] ); - Prim - (2735, I_ADD, [], []); - Prim - ( 2736, - I_DIP, - [ Seq - ( 2737, - [ Prim - ( 2738, - I_DUP, - [], - [] ); - Prim - ( 2739, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2740, - I_DIP, - [ Seq - ( 2741, - [ Prim - ( 2742, - I_DUP, + ( 1632, + I_TRANSFER_TOKENS, [], [] ); Prim - ( 2743, - I_DIP, - [ Seq - ( 2744, - [ - Prim - ( - 2745, - I_CAR, - [], - [] - ) - ] + ( 1633, + I_DIG, + [ Int + ( 1634, + Z + .of_int + 2 ) ], [] ); Prim - ( 2746, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2747, - I_DIP, - [ Seq - ( 2748, - [ Prim - ( 2749, - I_DUP, - [], + ( 1635, + I_NIL, + [ Prim + ( 1636, + T_operation, + [], + [] + ) + ], [] ); Prim - ( 2750, - I_DIP, - [ Seq - ( 2751, - [ - Prim - ( - 2752, - I_CAR, - [], - [] - ) - ] + ( 1637, + I_DIG, + [ Int + ( 1638, + Z + .of_int + 2 ) ], [] ); Prim - ( 2753, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - ( 2754, - I_DIP, - [ Seq - ( 2755, - [ Prim - ( 2756, - I_DUP, + ( 1639, + I_CONS, [], [] ); Prim - ( 2757, - I_DIP, - [ Seq - ( 2758, - [ - Prim - ( - 2759, - I_CAR, - [], - [] - ) - ] + ( 1640, + I_DIG, + [ Int + ( 1641, + Z + .of_int + 2 ) ], [] ); Prim - ( 2760, - I_CDR, - [], - [] ) ] - ) ], - [] ); - Prim - (2761, I_SWAP, [], []); - Prim - (2762, I_DROP, [], []); - Prim - (2763, I_SWAP, [], []); - Prim - (2764, I_PAIR, [], []); - Prim - (2765, I_SWAP, [], []); - Prim - (2766, I_PAIR, [], []); - Prim - (2767, I_SWAP, [], []); - Prim - (2768, I_PAIR, [], []); - Prim - ( 2769, - I_DIP, - [ Seq - ( 2770, - [ Prim - ( 2771, - I_DUP, + ( 1642, + I_CONS, [], [] ); Prim - ( 2772, - I_DIP, - [ Seq - ( 2773, - [ - Prim - ( - 2774, - I_CAR, - [], - [] - ) - ] - ) - ], - [] ); - Prim - ( 2775, - I_CDR, + ( 1643, + I_PAIR, [], [] ) ] ) ], - [] ); - Prim - (2776, I_SWAP, [], []); - Prim - (2777, I_DROP, [], []); - Prim - (2778, I_SWAP, [], []); - Prim - (2779, I_PAIR, [], []); - Prim - ( 2780, - I_NIL, - [ Prim - ( 2781, - T_operation, - [], - [] ) ], - [] ); - Prim - (2782, I_PAIR, [], []) - ] ) ], + [] ) ] ) ], [] ) ] ) ], [] ) ] ) ], [] ) ] ) ], diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_lqt.ml b/src/proto_alpha/lib_protocol/liquidity_baking_lqt.ml new file mode 100644 index 000000000000..a335efa6fe32 --- /dev/null +++ b/src/proto_alpha/lib_protocol/liquidity_baking_lqt.ml @@ -0,0 +1,1582 @@ +open Michelson_v1_primitives +open Micheline + +let script = + Seq + ( 0, + [ Prim + ( 1, + K_parameter, + [ Prim + ( 2, + T_or, + [ Prim + ( 3, + T_or, + [ Prim + ( 4, + T_or, + [ Prim + ( 5, + T_pair, + [ Prim (6, T_address, [], ["%spender"]); + Prim (7, T_nat, [], ["%value"]) ], + ["%approve"] ); + Prim + ( 8, + T_pair, + [ Prim + ( 9, + T_pair, + [ Prim (10, T_address, [], ["%owner"]); + Prim + (11, T_address, [], ["%spender"]) + ], + ["%request"] ); + Prim + ( 12, + T_contract, + [Prim (13, T_nat, [], [])], + ["%callback"] ) ], + ["%getAllowance"] ) ], + [] ); + Prim + ( 14, + T_or, + [ Prim + ( 15, + T_pair, + [ Prim (16, T_address, [], ["%owner"]); + Prim + ( 17, + T_contract, + [Prim (18, T_nat, [], [])], + ["%callback"] ) ], + ["%getBalance"] ); + Prim + ( 19, + T_pair, + [ Prim (20, T_unit, [], ["%request"]); + Prim + ( 21, + T_contract, + [Prim (22, T_nat, [], [])], + ["%callback"] ) ], + ["%getTotalSupply"] ) ], + [] ) ], + [] ); + Prim + ( 23, + T_or, + [ Prim + ( 24, + T_pair, + [ Prim (25, T_int, [], ["%quantity"]); + Prim (26, T_address, [], ["%target"]) ], + ["%mintOrBurn"] ); + Prim + ( 27, + T_pair, + [ Prim (28, T_address, [], ["%from"]); + Prim + ( 29, + T_pair, + [ Prim (30, T_address, [], ["%to"]); + Prim (31, T_nat, [], ["%value"]) ], + [] ) ], + ["%transfer"] ) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 32, + K_storage, + [ Prim + ( 33, + T_pair, + [ Prim + ( 34, + T_big_map, + [Prim (35, T_address, [], []); Prim (36, T_nat, [], [])], + ["%tokens"] ); + Prim + ( 37, + T_pair, + [ Prim + ( 38, + T_big_map, + [ Prim + ( 39, + T_pair, + [ Prim (40, T_address, [], ["%owner"]); + Prim (41, T_address, [], ["%spender"]) ], + [] ); + Prim (42, T_nat, [], []) ], + ["%allowances"] ); + Prim + ( 43, + T_pair, + [ Prim (44, T_address, [], ["%admin"]); + Prim (45, T_nat, [], ["%total_supply"]) ], + [] ) ], + [] ) ], + [] ) ], + [] ); + Prim + ( 46, + K_code, + [ Seq + ( 47, + [ Prim (48, I_DUP, [], []); + Prim (49, I_CDR, [], []); + Prim + ( 50, + I_PUSH, + [Prim (51, T_mutez, [], []); Int (52, Z.zero)], + [] ); + Prim (53, I_AMOUNT, [], []); + Prim (54, I_COMPARE, [], []); + Prim (55, I_NEQ, [], []); + Prim + ( 56, + I_IF, + [ Seq + ( 57, + [ Prim + ( 58, + I_PUSH, + [ Prim (59, T_string, [], []); + String (60, "DontSendTez") ], + [] ); + Prim (61, I_FAILWITH, [], []) ] ); + Seq (62, []) ], + [] ); + Prim (63, I_SWAP, [], []); + Prim (64, I_CAR, [], []); + Prim + ( 65, + I_IF_LEFT, + [ Seq + ( 66, + [ Prim + ( 67, + I_IF_LEFT, + [ Seq + ( 68, + [ Prim + ( 69, + I_IF_LEFT, + [ Seq + ( 70, + [ Prim + (71, I_SWAP, [], []); + Prim (72, I_DUP, [], []); + Prim + ( 73, + I_DUG, + [ Int + (74, Z.of_int 2) + ], + [] ); + Prim (75, I_CDR, [], []); + Prim (76, I_CAR, [], []); + Prim + (77, I_SWAP, [], []); + Prim (78, I_DUP, [], []); + Prim + ( 79, + I_DUG, + [ Int + (80, Z.of_int 2) + ], + [] ); + Prim (81, I_CAR, [], []); + Prim + (82, I_SENDER, [], []); + Prim + (83, I_PAIR, [], []); + Prim + ( 84, + I_PUSH, + [ Prim + ( 85, + T_nat, + [], + [] ); + Int (86, Z.zero) + ], + [] ); + Prim + ( 87, + I_DIG, + [ Int + (88, Z.of_int 3) + ], + [] ); + Prim (89, I_DUP, [], []); + Prim + ( 90, + I_DUG, + [ Int + (91, Z.of_int 4) + ], + [] ); + Prim (92, I_CDR, [], []); + Prim + ( 93, + I_COMPARE, + [], + [] ); + Prim (94, I_GT, [], []); + Prim + ( 95, + I_PUSH, + [ Prim + ( 96, + T_nat, + [], + [] ); + Int (97, Z.zero) + ], + [] ); + Prim + ( 98, + I_DIG, + [ Int + (99, Z.of_int 3) + ], + [] ); + Prim + (100, I_DUP, [], []); + Prim + ( 101, + I_DUG, + [ Int + ( 102, + Z.of_int 4 ) + ], + [] ); + Prim + ( 103, + I_DIG, + [ Int + ( 104, + Z.of_int 3 ) + ], + [] ); + Prim + (105, I_DUP, [], []); + Prim + ( 106, + I_DUG, + [ Int + ( 107, + Z.of_int 4 ) + ], + [] ); + Prim + (108, I_GET, [], []); + Prim + ( 109, + I_IF_NONE, + [ Seq + ( 110, + [ Prim + ( 111, + I_PUSH, + [ Prim + ( 112, + T_nat, + [], + [] + ); + Int + ( 113, + Z + .zero + ) + ], + [] ) ] + ); + Seq (114, []) ], + [] ); + Prim + ( 115, + I_COMPARE, + [], + [] ); + Prim (116, I_GT, [], []); + Prim + (117, I_AND, [], []); + Prim + ( 118, + I_IF, + [ Seq + ( 119, + [ Prim + ( 120, + I_PUSH, + [ Prim + ( 121, + T_string, + [], + [] + ); + String + ( 122, + "UnsafeAllowanceChange" + ) + ], + [] ); + Prim + ( 123, + I_FAILWITH, + [], + [] ) ] + ); + Seq (124, []) ], + [] ); + Prim + ( 125, + I_DIG, + [ Int + ( 126, + Z.of_int 3 ) + ], + [] ); + Prim + (127, I_DUP, [], []); + Prim + ( 128, + I_DUG, + [ Int + ( 129, + Z.of_int 4 ) + ], + [] ); + Prim + (130, I_CDR, [], []); + Prim + (131, I_CDR, [], []); + Prim + ( 132, + I_DIG, + [ Int + ( 133, + Z.of_int 2 ) + ], + [] ); + Prim + ( 134, + I_DIG, + [ Int + ( 135, + Z.of_int 3 ) + ], + [] ); + Prim + (136, I_CDR, [], []); + Prim + ( 137, + I_PUSH, + [ Prim + ( 138, + T_nat, + [], + [] ); + Int (139, Z.zero) + ], + [] ); + Prim + (140, I_SWAP, [], []); + Prim + (141, I_DUP, [], []); + Prim + ( 142, + I_DUG, + [ Int + ( 143, + Z.of_int 2 ) + ], + [] ); + Prim + ( 144, + I_COMPARE, + [], + [] ); + Prim (145, I_EQ, [], []); + Prim + ( 146, + I_IF, + [ Seq + ( 147, + [ Prim + ( 148, + I_DROP, + [], + [] ); + Prim + ( 149, + I_NONE, + [ Prim + ( 150, + T_nat, + [], + [] + ) + ], + [] ) ] + ); + Seq + ( 151, + [ Prim + ( 152, + I_SOME, + [], + [] ) ] + ) ], + [] ); + Prim + ( 153, + I_DIG, + [ Int + ( 154, + Z.of_int 3 ) + ], + [] ); + Prim + ( 155, + I_UPDATE, + [], + [] ); + Prim + (156, I_PAIR, [], []); + Prim + (157, I_SWAP, [], []); + Prim + (158, I_CAR, [], []); + Prim + (159, I_PAIR, [], []); + Prim + ( 160, + I_NIL, + [ Prim + ( 161, + T_operation, + [], + [] ) ], + [] ); + Prim + (162, I_PAIR, [], []) + ] ); + Seq + ( 163, + [ Prim + (164, I_SWAP, [], []); + Prim + (165, I_DUP, [], []); + Prim + ( 166, + I_DIG, + [ Int + ( 167, + Z.of_int 2 ) + ], + [] ); + Prim + ( 168, + I_NIL, + [ Prim + ( 169, + T_operation, + [], + [] ) ], + [] ); + Prim + (170, I_SWAP, [], []); + Prim + (171, I_DUP, [], []); + Prim + ( 172, + I_DUG, + [ Int + ( 173, + Z.of_int 2 ) + ], + [] ); + Prim + (174, I_CDR, [], []); + Prim + ( 175, + I_PUSH, + [ Prim + ( 176, + T_mutez, + [], + [] ); + Int (177, Z.zero) + ], + [] ); + Prim + ( 178, + I_DIG, + [ Int + ( 179, + Z.of_int 4 ) + ], + [] ); + Prim + (180, I_CDR, [], []); + Prim + (181, I_CAR, [], []); + Prim + ( 182, + I_DIG, + [ Int + ( 183, + Z.of_int 4 ) + ], + [] ); + Prim + (184, I_CAR, [], []); + Prim + (185, I_GET, [], []); + Prim + ( 186, + I_IF_NONE, + [ Seq + ( 187, + [ Prim + ( 188, + I_PUSH, + [ Prim + ( 189, + T_nat, + [], + [] + ); + Int + ( 190, + Z + .zero + ) + ], + [] ) ] + ); + Seq (191, []) ], + [] ); + Prim + ( 192, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + (193, I_CONS, [], []); + Prim + (194, I_PAIR, [], []) + ] ) ], + [] ) ] ); + Seq + ( 195, + [ Prim + ( 196, + I_IF_LEFT, + [ Seq + ( 197, + [ Prim + (198, I_SWAP, [], []); + Prim + (199, I_DUP, [], []); + Prim + ( 200, + I_DIG, + [ Int + ( 201, + Z.of_int 2 ) + ], + [] ); + Prim + ( 202, + I_NIL, + [ Prim + ( 203, + T_operation, + [], + [] ) ], + [] ); + Prim + (204, I_SWAP, [], []); + Prim + (205, I_DUP, [], []); + Prim + ( 206, + I_DUG, + [ Int + ( 207, + Z.of_int 2 ) + ], + [] ); + Prim + (208, I_CDR, [], []); + Prim + ( 209, + I_PUSH, + [ Prim + ( 210, + T_mutez, + [], + [] ); + Int (211, Z.zero) + ], + [] ); + Prim + ( 212, + I_DIG, + [ Int + ( 213, + Z.of_int 4 ) + ], + [] ); + Prim + (214, I_CAR, [], []); + Prim + ( 215, + I_DIG, + [ Int + ( 216, + Z.of_int 4 ) + ], + [] ); + Prim + (217, I_CAR, [], []); + Prim + (218, I_GET, [], []); + Prim + ( 219, + I_IF_NONE, + [ Seq + ( 220, + [ Prim + ( 221, + I_PUSH, + [ Prim + ( 222, + T_nat, + [], + [] + ); + Int + ( 223, + Z + .zero + ) + ], + [] ) ] + ); + Seq (224, []) ], + [] ); + Prim + ( 225, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + (226, I_CONS, [], []); + Prim + (227, I_PAIR, [], []) + ] ); + Seq + ( 228, + [ Prim + (229, I_SWAP, [], []); + Prim + (230, I_DUP, [], []); + Prim + ( 231, + I_DIG, + [ Int + ( 232, + Z.of_int 2 ) + ], + [] ); + Prim + ( 233, + I_NIL, + [ Prim + ( 234, + T_operation, + [], + [] ) ], + [] ); + Prim + (235, I_SWAP, [], []); + Prim + (236, I_CDR, [], []); + Prim + ( 237, + I_PUSH, + [ Prim + ( 238, + T_mutez, + [], + [] ); + Int (239, Z.zero) + ], + [] ); + Prim + ( 240, + I_DIG, + [ Int + ( 241, + Z.of_int 3 ) + ], + [] ); + Prim + (242, I_CDR, [], []); + Prim + (243, I_CDR, [], []); + Prim + (244, I_CDR, [], []); + Prim + ( 245, + I_TRANSFER_TOKENS, + [], + [] ); + Prim + (246, I_CONS, [], []); + Prim + (247, I_PAIR, [], []) + ] ) ], + [] ) ] ) ], + [] ) ] ); + Seq + ( 248, + [ Prim + ( 249, + I_IF_LEFT, + [ Seq + ( 250, + [ Prim (251, I_SWAP, [], []); + Prim (252, I_DUP, [], []); + Prim + ( 253, + I_DUG, + [Int (254, Z.of_int 2)], + [] ); + Prim (255, I_CDR, [], []); + Prim (256, I_CDR, [], []); + Prim (257, I_CAR, [], []); + Prim (258, I_SENDER, [], []); + Prim (259, I_COMPARE, [], []); + Prim (260, I_NEQ, [], []); + Prim + ( 261, + I_IF, + [ Seq + ( 262, + [ Prim + ( 263, + I_PUSH, + [ Prim + ( 264, + T_string, + [], + [] ); + String + ( 265, + "OnlyAdmin" + ) ], + [] ); + Prim + ( 266, + I_FAILWITH, + [], + [] ) ] ); + Seq (267, []) ], + [] ); + Prim (268, I_DUP, [], []); + Prim (269, I_CAR, [], []); + Prim + ( 270, + I_DIG, + [Int (271, Z.of_int 2)], + [] ); + Prim (272, I_DUP, [], []); + Prim + ( 273, + I_DUG, + [Int (274, Z.of_int 3)], + [] ); + Prim (275, I_CAR, [], []); + Prim + ( 276, + I_DIG, + [Int (277, Z.of_int 2)], + [] ); + Prim (278, I_DUP, [], []); + Prim + ( 279, + I_DUG, + [Int (280, Z.of_int 3)], + [] ); + Prim (281, I_CDR, [], []); + Prim (282, I_GET, [], []); + Prim + ( 283, + I_IF_NONE, + [ Seq + ( 284, + [ Prim + ( 285, + I_PUSH, + [ Prim + ( 286, + T_nat, + [], + [] ); + Int (287, Z.zero) + ], + [] ) ] ); + Seq (288, []) ], + [] ); + Prim (289, I_ADD, [], []); + Prim (290, I_ISNAT, [], []); + Prim + ( 291, + I_IF_NONE, + [ Seq + ( 292, + [ Prim + ( 293, + I_PUSH, + [ Prim + ( 294, + T_string, + [], + [] ); + String + ( 295, + "Cannot \ + burn more \ + than the \ + target's \ + balance." ) + ], + [] ); + Prim + ( 296, + I_FAILWITH, + [], + [] ) ] ); + Seq (297, []) ], + [] ); + Prim (298, I_SWAP, [], []); + Prim (299, I_DUP, [], []); + Prim + ( 300, + I_DUG, + [Int (301, Z.of_int 2)], + [] ); + Prim (302, I_CAR, [], []); + Prim + ( 303, + I_DIG, + [Int (304, Z.of_int 3)], + [] ); + Prim (305, I_DUP, [], []); + Prim + ( 306, + I_DUG, + [Int (307, Z.of_int 4)], + [] ); + Prim (308, I_CDR, [], []); + Prim (309, I_CDR, [], []); + Prim (310, I_CDR, [], []); + Prim (311, I_ADD, [], []); + Prim (312, I_ABS, [], []); + Prim + ( 313, + I_DIG, + [Int (314, Z.of_int 3)], + [] ); + Prim (315, I_DUP, [], []); + Prim + ( 316, + I_DUG, + [Int (317, Z.of_int 4)], + [] ); + Prim (318, I_CDR, [], []); + Prim + ( 319, + I_DIG, + [Int (320, Z.of_int 4)], + [] ); + Prim (321, I_CAR, [], []); + Prim + ( 322, + I_PUSH, + [ Prim (323, T_nat, [], []); + Int (324, Z.zero) ], + [] ); + Prim + ( 325, + I_DIG, + [Int (326, Z.of_int 4)], + [] ); + Prim (327, I_DUP, [], []); + Prim + ( 328, + I_DUG, + [Int (329, Z.of_int 5)], + [] ); + Prim (330, I_COMPARE, [], []); + Prim (331, I_EQ, [], []); + Prim + ( 332, + I_IF, + [ Seq + ( 333, + [ Prim + ( 334, + I_DIG, + [ Int + ( 335, + Z.of_int 3 ) + ], + [] ); + Prim + (336, I_DROP, [], []); + Prim + ( 337, + I_NONE, + [ Prim + ( 338, + T_nat, + [], + [] ) ], + [] ) ] ); + Seq + ( 339, + [ Prim + ( 340, + I_DIG, + [ Int + ( 341, + Z.of_int 3 ) + ], + [] ); + Prim + (342, I_SOME, [], []) + ] ) ], + [] ); + Prim + ( 343, + I_DIG, + [Int (344, Z.of_int 4)], + [] ); + Prim (345, I_CDR, [], []); + Prim (346, I_UPDATE, [], []); + Prim (347, I_PAIR, [], []); + Prim (348, I_DUP, [], []); + Prim + ( 349, + I_DUG, + [Int (350, Z.of_int 2)], + [] ); + Prim (351, I_CDR, [], []); + Prim (352, I_CDR, [], []); + Prim (353, I_CAR, [], []); + Prim (354, I_PAIR, [], []); + Prim (355, I_SWAP, [], []); + Prim (356, I_DUP, [], []); + Prim + ( 357, + I_DUG, + [Int (358, Z.of_int 2)], + [] ); + Prim (359, I_CDR, [], []); + Prim (360, I_CAR, [], []); + Prim (361, I_PAIR, [], []); + Prim (362, I_SWAP, [], []); + Prim (363, I_CAR, [], []); + Prim (364, I_PAIR, [], []); + Prim + ( 365, + I_NIL, + [ Prim + (366, T_operation, [], []) + ], + [] ); + Prim (367, I_PAIR, [], []) ] ); + Seq + ( 368, + [ Prim (369, I_SWAP, [], []); + Prim (370, I_DUP, [], []); + Prim + ( 371, + I_DUG, + [Int (372, Z.of_int 2)], + [] ); + Prim (373, I_CDR, [], []); + Prim (374, I_CAR, [], []); + Prim + ( 375, + I_DIG, + [Int (376, Z.of_int 2)], + [] ); + Prim (377, I_DUP, [], []); + Prim + ( 378, + I_DUG, + [Int (379, Z.of_int 3)], + [] ); + Prim (380, I_CAR, [], []); + Prim + ( 381, + I_DIG, + [Int (382, Z.of_int 2)], + [] ); + Prim (383, I_DUP, [], []); + Prim + ( 384, + I_DUG, + [Int (385, Z.of_int 3)], + [] ); + Prim (386, I_CAR, [], []); + Prim (387, I_SENDER, [], []); + Prim (388, I_COMPARE, [], []); + Prim (389, I_EQ, [], []); + Prim + ( 390, + I_IF, + [ Seq + ( 391, + [ Prim + (392, I_SWAP, [], []) + ] ); + Seq + ( 393, + [ Prim + ( 394, + I_SENDER, + [], + [] ); + Prim + ( 395, + I_DIG, + [ Int + ( 396, + Z.of_int 3 ) + ], + [] ); + Prim + (397, I_DUP, [], []); + Prim + ( 398, + I_DUG, + [ Int + ( 399, + Z.of_int 4 ) + ], + [] ); + Prim + (400, I_CAR, [], []); + Prim + (401, I_PAIR, [], []); + Prim + ( 402, + I_DIG, + [ Int + ( 403, + Z.of_int 3 ) + ], + [] ); + Prim + (404, I_DUP, [], []); + Prim + ( 405, + I_DUG, + [ Int + ( 406, + Z.of_int 4 ) + ], + [] ); + Prim + (407, I_CDR, [], []); + Prim + (408, I_CDR, [], []); + Prim + ( 409, + I_DIG, + [ Int + ( 410, + Z.of_int 3 ) + ], + [] ); + Prim + (411, I_DUP, [], []); + Prim + ( 412, + I_DUG, + [ Int + ( 413, + Z.of_int 4 ) + ], + [] ); + Prim + ( 414, + I_DIG, + [ Int + ( 415, + Z.of_int 2 ) + ], + [] ); + Prim + (416, I_DUP, [], []); + Prim + ( 417, + I_DUG, + [ Int + ( 418, + Z.of_int 3 ) + ], + [] ); + Prim + (419, I_GET, [], []); + Prim + ( 420, + I_IF_NONE, + [ Seq + ( 421, + [ Prim + ( 422, + I_PUSH, + [ Prim + ( 423, + T_nat, + [], + [] + ); + Int + ( 424, + Z + .zero + ) + ], + [] ) ] + ); + Seq (425, []) ], + [] ); + Prim + (426, I_SUB, [], []); + Prim + (427, I_ISNAT, [], []); + Prim + ( 428, + I_IF_NONE, + [ Seq + ( 429, + [ Prim + ( 430, + I_PUSH, + [ Prim + ( 431, + T_string, + [], + [] + ); + String + ( 432, + "NotEnoughAllowance" + ) + ], + [] ); + Prim + ( 433, + I_FAILWITH, + [], + [] ) ] + ); + Seq (434, []) ], + [] ); + Prim + ( 435, + I_DIG, + [ Int + ( 436, + Z.of_int 3 ) + ], + [] ); + Prim + ( 437, + I_PUSH, + [ Prim + ( 438, + T_nat, + [], + [] ); + Int (439, Z.zero) + ], + [] ); + Prim + ( 440, + I_DIG, + [ Int + ( 441, + Z.of_int 2 ) + ], + [] ); + Prim + (442, I_DUP, [], []); + Prim + ( 443, + I_DUG, + [ Int + ( 444, + Z.of_int 3 ) + ], + [] ); + Prim + ( 445, + I_COMPARE, + [], + [] ); + Prim (446, I_EQ, [], []); + Prim + ( 447, + I_IF, + [ Seq + ( 448, + [ Prim + ( 449, + I_SWAP, + [], + [] ); + Prim + ( 450, + I_DROP, + [], + [] ); + Prim + ( 451, + I_NONE, + [ Prim + ( 452, + T_nat, + [], + [] + ) + ], + [] ) ] + ); + Seq + ( 453, + [ Prim + ( 454, + I_SWAP, + [], + [] ); + Prim + ( 455, + I_SOME, + [], + [] ) ] + ) ], + [] ); + Prim + ( 456, + I_DIG, + [ Int + ( 457, + Z.of_int 2 ) + ], + [] ); + Prim + ( 458, + I_UPDATE, + [], + [] ) ] ) ], + [] ); + Prim + ( 459, + I_DIG, + [Int (460, Z.of_int 2)], + [] ); + Prim (461, I_DUP, [], []); + Prim + ( 462, + I_DUG, + [Int (463, Z.of_int 3)], + [] ); + Prim (464, I_CDR, [], []); + Prim (465, I_CDR, [], []); + Prim + ( 466, + I_DIG, + [Int (467, Z.of_int 2)], + [] ); + Prim (468, I_DUP, [], []); + Prim + ( 469, + I_DUG, + [Int (470, Z.of_int 3)], + [] ); + Prim + ( 471, + I_DIG, + [Int (472, Z.of_int 4)], + [] ); + Prim (473, I_DUP, [], []); + Prim + ( 474, + I_DUG, + [Int (475, Z.of_int 5)], + [] ); + Prim (476, I_CAR, [], []); + Prim (477, I_GET, [], []); + Prim + ( 478, + I_IF_NONE, + [ Seq + ( 479, + [ Prim + ( 480, + I_PUSH, + [ Prim + ( 481, + T_nat, + [], + [] ); + Int (482, Z.zero) + ], + [] ) ] ); + Seq (483, []) ], + [] ); + Prim (484, I_SUB, [], []); + Prim (485, I_ISNAT, [], []); + Prim + ( 486, + I_IF_NONE, + [ Seq + ( 487, + [ Prim + ( 488, + I_PUSH, + [ Prim + ( 489, + T_string, + [], + [] ); + String + ( 490, + "NotEnoughBalance" + ) ], + [] ); + Prim + ( 491, + I_FAILWITH, + [], + [] ) ] ); + Seq (492, []) ], + [] ); + Prim + ( 493, + I_DIG, + [Int (494, Z.of_int 2)], + [] ); + Prim + ( 495, + I_PUSH, + [ Prim (496, T_nat, [], []); + Int (497, Z.zero) ], + [] ); + Prim + ( 498, + I_DIG, + [Int (499, Z.of_int 2)], + [] ); + Prim (500, I_DUP, [], []); + Prim + ( 501, + I_DUG, + [Int (502, Z.of_int 3)], + [] ); + Prim (503, I_COMPARE, [], []); + Prim (504, I_EQ, [], []); + Prim + ( 505, + I_IF, + [ Seq + ( 506, + [ Prim + (507, I_SWAP, [], []); + Prim + (508, I_DROP, [], []); + Prim + ( 509, + I_NONE, + [ Prim + ( 510, + T_nat, + [], + [] ) ], + [] ) ] ); + Seq + ( 511, + [ Prim + (512, I_SWAP, [], []); + Prim + (513, I_SOME, [], []) + ] ) ], + [] ); + Prim + ( 514, + I_DIG, + [Int (515, Z.of_int 3)], + [] ); + Prim (516, I_DUP, [], []); + Prim + ( 517, + I_DUG, + [Int (518, Z.of_int 4)], + [] ); + Prim (519, I_CAR, [], []); + Prim (520, I_UPDATE, [], []); + Prim + ( 521, + I_DIG, + [Int (522, Z.of_int 2)], + [] ); + Prim (523, I_DUP, [], []); + Prim + ( 524, + I_DUG, + [Int (525, Z.of_int 3)], + [] ); + Prim (526, I_CDR, [], []); + Prim (527, I_CDR, [], []); + Prim (528, I_SWAP, [], []); + Prim (529, I_DUP, [], []); + Prim + ( 530, + I_DUG, + [Int (531, Z.of_int 2)], + [] ); + Prim + ( 532, + I_DIG, + [Int (533, Z.of_int 4)], + [] ); + Prim (534, I_DUP, [], []); + Prim + ( 535, + I_DUG, + [Int (536, Z.of_int 5)], + [] ); + Prim (537, I_CDR, [], []); + Prim (538, I_CAR, [], []); + Prim (539, I_GET, [], []); + Prim + ( 540, + I_IF_NONE, + [ Seq + ( 541, + [ Prim + ( 542, + I_PUSH, + [ Prim + ( 543, + T_nat, + [], + [] ); + Int (544, Z.zero) + ], + [] ) ] ); + Seq (545, []) ], + [] ); + Prim (546, I_ADD, [], []); + Prim (547, I_SWAP, [], []); + Prim + ( 548, + I_PUSH, + [ Prim (549, T_nat, [], []); + Int (550, Z.zero) ], + [] ); + Prim + ( 551, + I_DIG, + [Int (552, Z.of_int 2)], + [] ); + Prim (553, I_DUP, [], []); + Prim + ( 554, + I_DUG, + [Int (555, Z.of_int 3)], + [] ); + Prim (556, I_COMPARE, [], []); + Prim (557, I_EQ, [], []); + Prim + ( 558, + I_IF, + [ Seq + ( 559, + [ Prim + (560, I_SWAP, [], []); + Prim + (561, I_DROP, [], []); + Prim + ( 562, + I_NONE, + [ Prim + ( 563, + T_nat, + [], + [] ) ], + [] ) ] ); + Seq + ( 564, + [ Prim + (565, I_SWAP, [], []); + Prim + (566, I_SOME, [], []) + ] ) ], + [] ); + Prim + ( 567, + I_DIG, + [Int (568, Z.of_int 3)], + [] ); + Prim (569, I_CDR, [], []); + Prim (570, I_CAR, [], []); + Prim (571, I_UPDATE, [], []); + Prim + ( 572, + I_DIG, + [Int (573, Z.of_int 2)], + [] ); + Prim (574, I_CDR, [], []); + Prim (575, I_SWAP, [], []); + Prim (576, I_PAIR, [], []); + Prim (577, I_DUP, [], []); + Prim (578, I_CDR, [], []); + Prim (579, I_CDR, [], []); + Prim + ( 580, + I_DIG, + [Int (581, Z.of_int 2)], + [] ); + Prim (582, I_PAIR, [], []); + Prim (583, I_SWAP, [], []); + Prim (584, I_CAR, [], []); + Prim (585, I_PAIR, [], []); + Prim + ( 586, + I_NIL, + [ Prim + (587, T_operation, [], []) + ], + [] ); + Prim (588, I_PAIR, [], []) ] ) ], + [] ) ] ) ], + [] ) ] ) ], + [] ) ] ) diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml b/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml new file mode 100644 index 000000000000..e67c75564688 --- /dev/null +++ b/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml @@ -0,0 +1,168 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2021 Tocqueville Group, Inc. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** This module is used to originate contracts for liquidity baking during + protocol stitching. Two functions are exposed: one for stitching from 009 + to 010 on mainnet and one for stitching from Genesis to Alpha for testing. + + Both originate a CPMM (constant product market making) contract and a + liquidity token FA1.2 contract, with the storage of each containing the + other's address. The CPMM's storage contains a token address, which + corresponds to tzBTC in the mainnet version and a reference FA1.2 contract + in the test version. + + The liquidity baking contracts are originated with a contrived origination + nonce similar to origination of bootstrap contracts, but with a different + nonce. + + The Michelson and Ligo code, as well as Coq proofs, for the CPMM and + liquidity token contracts are available here: + https://gitlab.com/dexter2tz/dexter2tz/-/tree/liquidity_baking + + The test FA1.2 contract is generated from: + https://gitlab.com/ligolang/ligo/-/blob/dev/src/test/contracts/FA1.2.mligo + + All contracts were generated from Ligo at revision + 4d10d07ca05abe0f8a5fb97d15267bf5d339d9f4 and converted to OCaml using + `tezos-client convert`. +*) + +open Michelson_v1_primitives +open Micheline + +let cpmm_init_storage token_address lqt_address = + Script_repr.lazy_expr + (Micheline.strip_locations + (Prim + ( 0, + D_Pair, + [ Int (1, Z.zero); + Int (2, Z.zero); + Int (3, Z.zero); + Prim (4, D_False, [], []); + String (5, token_address); + String (6, lqt_address) ], + [] ))) + +let lqt_init_storage cpmm_address = + Script_repr.lazy_expr + (Micheline.strip_locations + (Prim + ( 0, + D_Pair, + [ Seq (1, []); + Seq (2, []); + String (3, cpmm_address); + Int (4, Z.zero) ], + [] ))) + +let test_fa12_init_storage = + Script_repr.lazy_expr + (Micheline.strip_locations + (Prim (0, D_Pair, [Seq (1, []); Int (2, Z.of_int 2000000000000)], []))) + +let tzBTC_address = "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" + +let init_common ctxt token_address = + Storage.Liquidity_baking.Escape_ema.init ctxt 0l + >>=? fun ctxt -> + Storage.Liquidity_baking.Sunset_level.init + ctxt + Int32.( + add + (Raw_level_repr.to_int32 (Level_storage.current ctxt).level) + (Constants_storage.liquidity_baking_sunset_duration ctxt)) + >>=? fun ctxt -> + Contract_storage.fresh_contract_from_current_nonce ctxt + >>?= fun (ctxt, cpmm_address) -> + Contract_storage.fresh_contract_from_current_nonce ctxt + >>?= fun (ctxt, lqt_address) -> + Storage.Liquidity_baking.Cpmm_address.init ctxt cpmm_address + >>=? fun ctxt -> + Contract_storage.raw_originate + ctxt + cpmm_address + ~balance:Tez_repr.zero + ~script: + ( Script_repr. + { + code = + Script_repr.lazy_expr + (Micheline.strip_locations Liquidity_baking_cpmm.script); + storage = + cpmm_init_storage + token_address + (Contract_repr.to_b58check lqt_address); + }, + None ) + ~delegate:None + >>=? fun ctxt -> + Contract_storage.raw_originate + ctxt + lqt_address + ~balance:Tez_repr.zero + ~script: + ( Script_repr. + { + code = + Script_repr.lazy_expr + (Micheline.strip_locations Liquidity_baking_lqt.script); + storage = lqt_init_storage (Contract_repr.to_b58check cpmm_address); + }, + None ) + ~delegate:None + +let ctxt_with_origination_nonce ctxt = + let nonce = + Operation_hash.hash_bytes [Bytes.of_string "Drip, drip, drip."] + in + Raw_context.init_origination_nonce ctxt nonce + +let init ctxt = + let ctxt = ctxt_with_origination_nonce ctxt in + init_common ctxt tzBTC_address + >>=? fun ctxt -> return (Raw_context.unset_origination_nonce ctxt) + +let init_test ctxt = + let ctxt = ctxt_with_origination_nonce ctxt in + Contract_storage.fresh_contract_from_current_nonce ctxt + >>?= fun (ctxt, fa12_address) -> + Contract_storage.raw_originate + ctxt + fa12_address + ~balance:(Tez_repr.of_mutez_exn 2_000_000_000_000L) + ~script: + ( Script_repr. + { + code = + Script_repr.lazy_expr + (Micheline.strip_locations Liquidity_baking_test_fa12.script); + storage = test_fa12_init_storage; + }, + None ) + ~delegate:None + >>=? fun ctxt -> + init_common ctxt (Contract_repr.to_b58check fa12_address) + >>=? fun ctxt -> return (Raw_context.unset_origination_nonce ctxt) diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_storage.mli b/src/proto_alpha/lib_protocol/liquidity_baking_storage.mli new file mode 100644 index 000000000000..e90bd35eb832 --- /dev/null +++ b/src/proto_alpha/lib_protocol/liquidity_baking_storage.mli @@ -0,0 +1,28 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2021 Tocqueville Group, Inc. *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +val init : Raw_context.t -> Raw_context.t tzresult Lwt.t + +val init_test : Raw_context.t -> Raw_context.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_parameters/test_fa12.ml b/src/proto_alpha/lib_protocol/liquidity_baking_test_fa12.ml similarity index 54% rename from src/proto_alpha/lib_parameters/test_fa12.ml rename to src/proto_alpha/lib_protocol/liquidity_baking_test_fa12.ml index 40ee39d8cac7..0bd18e02eee9 100644 --- a/src/proto_alpha/lib_parameters/test_fa12.ml +++ b/src/proto_alpha/lib_protocol/liquidity_baking_test_fa12.ml @@ -1,4 +1,4 @@ -open Protocol.Alpha_context.Script +open Michelson_v1_primitives open Micheline let script = @@ -32,12 +32,12 @@ let script = Prim (11, T_address, [], ["%spender"]) ], - [] ); + ["%request"] ); Prim ( 12, T_contract, [Prim (13, T_nat, [], [])], - [] ) ], + ["%callback"] ) ], ["%getAllowance"] ) ], [] ); Prim @@ -51,17 +51,17 @@ let script = ( 17, T_contract, [Prim (18, T_nat, [], [])], - [] ) ], + ["%callback"] ) ], ["%getBalance"] ); Prim ( 19, T_pair, - [ Prim (20, T_unit, [], []); + [ Prim (20, T_unit, [], ["%request"]); Prim ( 21, T_contract, [Prim (22, T_nat, [], [])], - [] ) ], + ["%callback"] ) ], ["%getTotalSupply"] ) ], [] ) ], [] ); @@ -86,1164 +86,1021 @@ let script = T_pair, [ Prim ( 30, - T_big_map, - [ Prim (31, T_address, [], []); - Prim - ( 32, - T_pair, + T_pair, + [ Prim + ( 31, + T_big_map, [ Prim - ( 33, - T_map, - [ Prim (34, T_address, [], []); - Prim (35, T_nat, [], []) ], - ["%allowances"] ); - Prim (36, T_nat, [], ["%balance"]) ], - [] ) ], - ["%ledger"] ); - Prim (37, T_nat, [], ["%totalSupply"]) ], + ( 32, + T_pair, + [ Prim (33, T_address, [], ["%owner"]); + Prim (34, T_address, [], ["%spender"]) ], + [] ); + Prim (35, T_nat, [], []) ], + ["%allowances"] ); + Prim + ( 36, + T_big_map, + [ Prim (37, T_address, [], []); + Prim (38, T_nat, [], []) ], + ["%tokens"] ) ], + [] ); + Prim (39, T_nat, [], ["%total_supply"]) ], [] ) ], [] ); Prim - ( 38, + ( 40, K_code, [ Seq - ( 39, - [ Prim (40, I_NIL, [Prim (41, T_operation, [], [])], []); + ( 41, + [ Prim (42, I_DUP, [], []); + Prim (43, I_CDR, [], []); Prim - ( 42, - I_LAMBDA, - [ Prim - ( 43, - T_pair, - [ Prim (44, T_address, [], []); - Prim - ( 45, - T_pair, - [ Prim - ( 46, - T_big_map, - [ Prim (47, T_address, [], []); - Prim - ( 48, - T_pair, - [ Prim - ( 49, - T_map, - [ Prim - ( 50, - T_address, - [], - [] ); - Prim (51, T_nat, [], []) - ], - [] ); - Prim (52, T_nat, [], []) ], - [] ) ], - [] ); - Prim (53, T_nat, [], []) ], - [] ) ], - [] ); - Prim - ( 54, - T_pair, - [ Prim - ( 55, - T_map, - [ Prim (56, T_address, [], []); - Prim (57, T_nat, [], []) ], - [] ); - Prim (58, T_nat, [], []) ], - [] ); - Seq - ( 59, - [ Prim (60, I_DUP, [], []); - Prim (61, I_CDR, [], []); - Prim (62, I_SWAP, [], []); - Prim (63, I_CAR, [], []); - Prim (64, I_SWAP, [], []); - Prim (65, I_CAR, [], []); - Prim (66, I_SWAP, [], []); - Prim (67, I_GET, [], []); - Prim - ( 68, - I_IF_NONE, - [ Seq - ( 69, - [ Prim - ( 70, - I_PUSH, - [ Prim (71, T_nat, [], []); - Int (72, Z.zero) ], - [] ); - Prim - ( 73, - I_EMPTY_MAP, - [ Prim (74, T_address, [], []); - Prim (75, T_nat, [], []) ], - [] ); - Prim (76, I_PAIR, [], []) ] ); - Seq (77, []) ], - [] ) ] ) ], + ( 44, + I_PUSH, + [Prim (45, T_mutez, [], []); Int (46, Z.zero)], [] ); + Prim (47, I_AMOUNT, [], []); + Prim (48, I_COMPARE, [], []); + Prim (49, I_NEQ, [], []); Prim - ( 78, - I_LAMBDA, - [ Prim - ( 79, - T_pair, + ( 50, + I_IF, + [ Seq + ( 51, [ Prim - ( 80, - T_pair, - [ Prim - ( 81, - T_pair, - [ Prim - ( 82, - T_map, - [ Prim (83, T_address, [], []); - Prim (84, T_nat, [], []) ], - [] ); - Prim (85, T_nat, [], []) ], - [] ); - Prim (86, T_address, [], []) ], + ( 52, + I_PUSH, + [ Prim (53, T_string, [], []); + String (54, "DontSendTez") ], [] ); - Prim - ( 87, - T_pair, - [ Prim - ( 88, - T_big_map, - [ Prim (89, T_address, [], []); - Prim - ( 90, - T_pair, - [ Prim - ( 91, - T_map, - [ Prim - ( 92, - T_address, - [], - [] ); - Prim (93, T_nat, [], []) - ], - [] ); - Prim (94, T_nat, [], []) ], - [] ) ], - [] ); - Prim (95, T_nat, [], []) ], - [] ) ], - [] ); - Prim (96, T_nat, [], []); - Seq - ( 97, - [ Prim (98, I_DUP, [], []); - Prim (99, I_CDR, [], []); - Prim (100, I_SWAP, [], []); - Prim (101, I_CAR, [], []); - Prim (102, I_SWAP, [], []); - Prim (103, I_DROP, [], []); - Prim (104, I_DUP, [], []); - Prim (105, I_CDR, [], []); - Prim (106, I_SWAP, [], []); - Prim (107, I_CAR, [], []); - Prim (108, I_CAR, [], []); - Prim (109, I_SWAP, [], []); - Prim (110, I_GET, [], []); - Prim - ( 111, - I_IF_NONE, - [ Seq - ( 112, - [ Prim - ( 113, - I_PUSH, - [ Prim (114, T_nat, [], []); - Int (115, Z.zero) ], - [] ) ] ); - Seq (116, []) ], - [] ) ] ) ], + Prim (55, I_FAILWITH, [], []) ] ); + Seq (56, []) ], [] ); - Prim (117, I_DIG, [Int (118, Z.of_int 3)], []); - Prim (119, I_DUP, [], []); - Prim (120, I_CDR, [], []); - Prim (121, I_SWAP, [], []); - Prim (122, I_CAR, [], []); + Prim (57, I_SWAP, [], []); + Prim (58, I_CAR, [], []); Prim - ( 123, + ( 59, I_IF_LEFT, [ Seq - ( 124, + ( 60, [ Prim - ( 125, + ( 61, I_IF_LEFT, [ Seq - ( 126, + ( 62, [ Prim - ( 127, + ( 63, I_IF_LEFT, [ Seq - ( 128, + ( 64, [ Prim - (129, I_DUP, [], []); + (65, I_SWAP, [], []); + Prim (66, I_DUP, [], []); Prim - (130, I_CDR, [], []); - Prim - (131, I_SWAP, [], []); - Prim - (132, I_CAR, [], []); - Prim - ( 133, - I_DIG, - [ Int - ( 134, - Z.of_int 2 ) - ], - [] ); - Prim - (135, I_DUP, [], []); - Prim - ( 136, + ( 67, I_DUG, [ Int - ( 137, - Z.of_int 3 ) - ], - [] ); - Prim - ( 138, - I_SENDER, - [], - [] ); - Prim - (139, I_PAIR, [], []); - Prim - ( 140, - I_DIG, - [ Int - ( 141, - Z.of_int 5 ) - ], - [] ); - Prim - (142, I_SWAP, [], []); - Prim - (143, I_EXEC, [], []); - Prim - ( 144, - I_DIG, - [ Int - ( 145, - Z.of_int 3 ) + (68, Z.of_int 2) ], [] ); + Prim (69, I_CAR, [], []); + Prim (70, I_CAR, [], []); Prim - (146, I_DUP, [], []); + (71, I_SWAP, [], []); + Prim (72, I_DUP, [], []); Prim - ( 147, + ( 73, I_DUG, [ Int - ( 148, - Z.of_int 4 ) + (74, Z.of_int 2) ], [] ); + Prim (75, I_CAR, [], []); Prim - ( 149, - I_DIG, - [ Int - ( 150, - Z.of_int 2 ) - ], - [] ); + (76, I_SENDER, [], []); Prim - (151, I_DUP, [], []); + (77, I_PAIR, [], []); Prim - ( 152, - I_DUG, - [ Int - ( 153, - Z.of_int 3 ) + ( 78, + I_PUSH, + [ Prim + ( 79, + T_nat, + [], + [] ); + Int (80, Z.zero) ], [] ); Prim - ( 154, + ( 81, I_DIG, [ Int - ( 155, - Z.of_int 2 ) + (82, Z.of_int 3) ], [] ); + Prim (83, I_DUP, [], []); Prim - (156, I_DUP, [], []); - Prim - ( 157, + ( 84, I_DUG, [ Int - ( 158, - Z.of_int 3 ) + (85, Z.of_int 4) ], [] ); + Prim (86, I_CDR, [], []); Prim - (159, I_PAIR, [], []); - Prim - (160, I_PAIR, [], []); - Prim - ( 161, - I_DIG, - [ Int - ( 162, - Z.of_int 5 ) - ], + ( 87, + I_COMPARE, + [], [] ); + Prim (88, I_GT, [], []); Prim - (163, I_SWAP, [], []); - Prim - (164, I_EXEC, [], []); - Prim - ( 165, + ( 89, I_PUSH, [ Prim - ( 166, + ( 90, T_nat, [], [] ); - Int (167, Z.zero) + Int (91, Z.zero) ], [] ); Prim - ( 168, + ( 92, I_DIG, [ Int - ( 169, - Z.of_int 4 ) + (93, Z.of_int 3) ], [] ); + Prim (94, I_DUP, [], []); Prim - (170, I_DUP, [], []); - Prim - ( 171, + ( 95, I_DUG, [ Int - ( 172, - Z.of_int 5 ) + (96, Z.of_int 4) ], [] ); Prim - ( 173, - I_COMPARE, - [], - [] ); - Prim (174, I_GT, [], []); - Prim - ( 175, - I_PUSH, - [ Prim - ( 176, - T_nat, - [], - [] ); - Int (177, Z.zero) + ( 97, + I_DIG, + [ Int + (98, Z.of_int 3) ], [] ); + Prim (99, I_DUP, [], []); Prim - ( 178, - I_DIG, + ( 100, + I_DUG, [ Int - ( 179, - Z.of_int 2 ) + ( 101, + Z.of_int 4 ) ], [] ); Prim - ( 180, + (102, I_GET, [], []); + Prim + ( 103, + I_IF_NONE, + [ Seq + ( 104, + [ Prim + ( 105, + I_PUSH, + [ Prim + ( 106, + T_nat, + [], + [] + ); + Int + ( 107, + Z + .zero + ) + ], + [] ) ] + ); + Seq (108, []) ], + [] ); + Prim + ( 109, I_COMPARE, [], [] ); - Prim (181, I_GT, [], []); + Prim (110, I_GT, [], []); Prim - (182, I_AND, [], []); + (111, I_AND, [], []); Prim - ( 183, + ( 112, I_IF, [ Seq - ( 184, + ( 113, [ Prim - ( 185, + ( 114, I_PUSH, [ Prim - ( 186, + ( 115, T_string, [], [] ); String - ( 187, + ( 116, "UnsafeAllowanceChange" ) ], [] ); Prim - ( 188, + ( 117, I_FAILWITH, [], [] ) ] ); - Seq (189, []) ], + Seq (118, []) ], [] ); Prim - ( 190, + ( 119, I_DIG, [ Int - ( 191, + ( 120, Z.of_int 3 ) ], [] ); Prim - (192, I_DUP, [], []); + (121, I_DUP, [], []); Prim - ( 193, + ( 122, I_DUG, [ Int - ( 194, + ( 123, Z.of_int 4 ) ], [] ); Prim - (195, I_CDR, [], []); + (124, I_CDR, [], []); Prim - ( 196, + ( 125, I_DIG, [ Int - ( 197, + ( 126, Z.of_int 4 ) ], [] ); Prim - (198, I_CAR, [], []); - Prim - ( 199, - I_DIG, - [ Int - ( 200, - Z.of_int 2 ) - ], - [] ); + (127, I_CAR, [], []); Prim - (201, I_DUP, [], []); + (128, I_CDR, [], []); Prim - ( 202, - I_DUG, - [ Int - ( 203, - Z.of_int 3 ) - ], - [] ); - Prim - (204, I_CDR, [], []); - Prim - ( 205, + ( 129, I_DIG, [ Int - ( 206, + ( 130, Z.of_int 3 ) ], [] ); Prim - (207, I_CAR, [], []); - Prim - ( 208, + ( 131, I_DIG, [ Int - ( 209, - Z.of_int 5 ) - ], - [] ); - Prim - ( 210, - I_DIG, - [ Int - ( 211, - Z.of_int 5 ) - ], - [] ); - Prim - (212, I_SWAP, [], []); - Prim - (213, I_SOME, [], []); - Prim - (214, I_SWAP, [], []); - Prim - ( 215, - I_UPDATE, - [], - [] ); - Prim - (216, I_PAIR, [], []); - Prim - (217, I_SOME, [], []); - Prim - ( 218, - I_SENDER, - [], - [] ); - Prim - ( 219, - I_UPDATE, - [], - [] ); - Prim - (220, I_PAIR, [], []); - Prim - (221, I_SWAP, [], []); - Prim - (222, I_PAIR, [], []) - ] ); - Seq - ( 223, - [ Prim - ( 224, - I_DIG, - [ Int - ( 225, + ( 132, Z.of_int 4 ) ], [] ); Prim - (226, I_DROP, [], []); - Prim - (227, I_DUP, [], []); - Prim - ( 228, - I_DUG, - [ Int - ( 229, - Z.of_int 2 ) - ], - [] ); - Prim - (230, I_CDR, [], []); - Prim - (231, I_PAIR, [], []); + (133, I_CDR, [], []); Prim - (232, I_SWAP, [], []); - Prim - (233, I_DUP, [], []); - Prim - ( 234, - I_DUG, - [ Int - ( 235, - Z.of_int 2 ) - ], - [] ); - Prim - (236, I_CAR, [], []); - Prim - (237, I_CDR, [], []); - Prim - ( 238, - I_DIG, - [ Int - ( 239, - Z.of_int 2 ) - ], - [] ); - Prim - (240, I_CAR, [], []); - Prim - (241, I_CAR, [], []); - Prim - ( 242, - I_DIG, - [ Int - ( 243, - Z.of_int 2 ) + ( 134, + I_PUSH, + [ Prim + ( 135, + T_nat, + [], + [] ); + Int (136, Z.zero) ], [] ); Prim - (244, I_DUP, [], []); - Prim - (245, I_CDR, [], []); - Prim - (246, I_SWAP, [], []); - Prim - (247, I_CAR, [], []); + (137, I_SWAP, [], []); Prim - (248, I_SWAP, [], []); + (138, I_DUP, [], []); Prim - (249, I_DUP, [], []); - Prim - ( 250, + ( 139, I_DUG, [ Int - ( 251, + ( 140, Z.of_int 2 ) ], [] ); Prim - ( 252, - I_DIG, - [ Int - ( 253, - Z.of_int 3 ) - ], - [] ); - Prim - (254, I_PAIR, [], []); - Prim - ( 255, - I_DIG, - [ Int - ( 256, - Z.of_int 5 ) - ], - [] ); - Prim - (257, I_SWAP, [], []); - Prim - (258, I_EXEC, [], []); - Prim - ( 259, - I_DIG, - [ Int - ( 260, - Z.of_int 2 ) - ], + ( 141, + I_COMPARE, + [], [] ); + Prim (142, I_EQ, [], []); Prim - (261, I_DUP, [], []); - Prim - ( 262, - I_DUG, - [ Int - ( 263, - Z.of_int 3 ) - ], + ( 143, + I_IF, + [ Seq + ( 144, + [ Prim + ( 145, + I_DROP, + [], + [] ); + Prim + ( 146, + I_NONE, + [ Prim + ( 147, + T_nat, + [], + [] + ) + ], + [] ) ] + ); + Seq + ( 148, + [ Prim + ( 149, + I_SOME, + [], + [] ) ] + ) ], [] ); Prim - ( 264, + ( 150, I_DIG, [ Int - ( 265, + ( 151, Z.of_int 4 ) ], [] ); Prim - ( 266, - I_DIG, - [ Int - ( 267, - Z.of_int 2 ) - ], + ( 152, + I_UPDATE, + [], [] ); Prim - (268, I_PAIR, [], []); + (153, I_PAIR, [], []); Prim - (269, I_PAIR, [], []); + (154, I_PAIR, [], []); Prim - ( 270, - I_DIG, - [ Int - ( 271, - Z.of_int 3 ) - ], + ( 155, + I_NIL, + [ Prim + ( 156, + T_operation, + [], + [] ) ], [] ); Prim - (272, I_SWAP, [], []); + (157, I_PAIR, [], []) + ] ); + Seq + ( 158, + [ Prim + (159, I_SWAP, [], []); Prim - (273, I_EXEC, [], []); + (160, I_DUP, [], []); Prim - ( 274, + ( 161, I_DIG, [ Int - ( 275, + ( 162, Z.of_int 2 ) ], [] ); Prim - ( 276, + (163, I_PAIR, [], []); + Prim + (164, I_DUP, [], []); + Prim + (165, I_CAR, [], []); + Prim + ( 166, I_NIL, [ Prim - ( 277, + ( 167, T_operation, [], [] ) ], [] ); Prim - ( 278, - I_DIG, + (168, I_SWAP, [], []); + Prim + (169, I_DUP, [], []); + Prim + ( 170, + I_DUG, [ Int - ( 279, - Z.of_int 3 ) + ( 171, + Z.of_int 2 ) ], [] ); Prim - ( 280, + (172, I_CDR, [], []); + Prim + ( 173, I_PUSH, [ Prim - ( 281, + ( 174, T_mutez, [], [] ); - Int (282, Z.zero) + Int (175, Z.zero) + ], + [] ); + Prim + ( 176, + I_DIG, + [ Int + ( 177, + Z.of_int 4 ) ], [] ); Prim - ( 283, + (178, I_CDR, [], []); + Prim + (179, I_CAR, [], []); + Prim + (180, I_CAR, [], []); + Prim + ( 181, I_DIG, [ Int - ( 284, + ( 182, Z.of_int 4 ) ], [] ); Prim - ( 285, + (183, I_CAR, [], []); + Prim + (184, I_GET, [], []); + Prim + ( 185, + I_IF_NONE, + [ Seq + ( 186, + [ Prim + ( 187, + I_PUSH, + [ Prim + ( 188, + T_nat, + [], + [] + ); + Int + ( 189, + Z + .zero + ) + ], + [] ) ] + ); + Seq (190, []) ], + [] ); + Prim + ( 191, I_TRANSFER_TOKENS, [], [] ); Prim - (286, I_CONS, [], []); + (192, I_CONS, [], []); Prim - (287, I_PAIR, [], []) + (193, I_PAIR, [], []) ] ) ], [] ) ] ); Seq - ( 288, + ( 194, [ Prim - ( 289, - I_DIG, - [Int (290, Z.of_int 2)], - [] ); - Prim (291, I_DROP, [], []); - Prim - ( 292, - I_DIG, - [Int (293, Z.of_int 3)], - [] ); - Prim (294, I_DROP, [], []); - Prim - ( 295, + ( 195, I_IF_LEFT, [ Seq - ( 296, + ( 196, [ Prim - (297, I_DUP, [], []); + (197, I_SWAP, [], []); Prim - (298, I_CDR, [], []); + (198, I_DUP, [], []); Prim - (299, I_SWAP, [], []); - Prim - (300, I_CAR, [], []); - Prim - ( 301, + ( 199, I_DIG, [ Int - ( 302, + ( 200, Z.of_int 2 ) ], [] ); Prim - (303, I_DUP, [], []); - Prim - ( 304, - I_DUG, - [ Int - ( 305, - Z.of_int 3 ) - ], - [] ); - Prim - (306, I_SWAP, [], []); - Prim - (307, I_PAIR, [], []); - Prim - ( 308, - I_DIG, - [ Int - ( 309, - Z.of_int 3 ) - ], - [] ); - Prim - (310, I_SWAP, [], []); + (201, I_PAIR, [], []); Prim - (311, I_EXEC, [], []); + (202, I_DUP, [], []); Prim - ( 312, - I_DIG, - [ Int - ( 313, - Z.of_int 2 ) - ], - [] ); + (203, I_CAR, [], []); Prim - ( 314, + ( 204, I_NIL, [ Prim - ( 315, + ( 205, T_operation, [], [] ) ], [] ); Prim - ( 316, - I_DIG, + (206, I_SWAP, [], []); + Prim + (207, I_DUP, [], []); + Prim + ( 208, + I_DUG, [ Int - ( 317, - Z.of_int 3 ) + ( 209, + Z.of_int 2 ) ], [] ); Prim - ( 318, + (210, I_CDR, [], []); + Prim + ( 211, I_PUSH, [ Prim - ( 319, + ( 212, T_mutez, [], [] ); - Int (320, Z.zero) + Int (213, Z.zero) ], [] ); Prim - ( 321, + ( 214, I_DIG, [ Int - ( 322, + ( 215, Z.of_int 4 ) ], [] ); Prim - (323, I_CDR, [], []); + (216, I_CDR, [], []); Prim - ( 324, - I_TRANSFER_TOKENS, - [], - [] ); + (217, I_CAR, [], []); Prim - (325, I_CONS, [], []); + (218, I_CDR, [], []); Prim - (326, I_PAIR, [], []) - ] ); - Seq - ( 327, - [ Prim - ( 328, + ( 219, I_DIG, [ Int - ( 329, - Z.of_int 2 ) + ( 220, + Z.of_int 4 ) ], [] ); Prim - (330, I_DROP, [], []); + (221, I_CAR, [], []); + Prim + (222, I_GET, [], []); + Prim + ( 223, + I_IF_NONE, + [ Seq + ( 224, + [ Prim + ( 225, + I_PUSH, + [ Prim + ( 226, + T_nat, + [], + [] + ); + Int + ( 227, + Z + .zero + ) + ], + [] ) ] + ); + Seq (228, []) ], + [] ); + Prim + ( 229, + I_TRANSFER_TOKENS, + [], + [] ); Prim - (331, I_CDR, [], []); + (230, I_CONS, [], []); Prim - (332, I_SWAP, [], []); + (231, I_PAIR, [], []) + ] ); + Seq + ( 232, + [ Prim + (233, I_SWAP, [], []); Prim - (333, I_DUP, [], []); + (234, I_DUP, [], []); Prim - ( 334, - I_DUG, + ( 235, + I_DIG, [ Int - ( 335, + ( 236, Z.of_int 2 ) ], [] ); Prim - ( 336, + (237, I_PAIR, [], []); + Prim + ( 238, I_NIL, [ Prim - ( 337, + ( 239, T_operation, [], [] ) ], [] ); Prim - ( 338, - I_DIG, + (240, I_SWAP, [], []); + Prim + (241, I_DUP, [], []); + Prim + ( 242, + I_DUG, [ Int - ( 339, + ( 243, Z.of_int 2 ) ], [] ); Prim - ( 340, + (244, I_CAR, [], []); + Prim + (245, I_CDR, [], []); + Prim + ( 246, I_PUSH, [ Prim - ( 341, + ( 247, T_mutez, [], [] ); - Int (342, Z.zero) + Int (248, Z.zero) ], [] ); Prim - ( 343, + ( 249, I_DIG, [ Int - ( 344, - Z.of_int 4 ) + ( 250, + Z.of_int 3 ) ], [] ); Prim - (345, I_CDR, [], []); + (251, I_CDR, [], []); + Prim + (252, I_CDR, [], []); Prim - ( 346, + ( 253, I_TRANSFER_TOKENS, [], [] ); Prim - (347, I_CONS, [], []); + (254, I_CONS, [], []); Prim - (348, I_PAIR, [], []) + (255, I_PAIR, [], []) ] ) ], [] ) ] ) ], [] ) ] ); Seq - ( 349, - [ Prim (350, I_DUP, [], []); - Prim (351, I_DUG, [Int (352, Z.of_int 2)], []); - Prim (353, I_CDR, [], []); - Prim (354, I_CDR, [], []); - Prim (355, I_PAIR, [], []); - Prim (356, I_SWAP, [], []); - Prim (357, I_DUP, [], []); - Prim (358, I_DUG, [Int (359, Z.of_int 2)], []); - Prim (360, I_CDR, [], []); - Prim (361, I_CAR, [], []); - Prim (362, I_DIG, [Int (363, Z.of_int 2)], []); - Prim (364, I_CAR, [], []); - Prim (365, I_DIG, [Int (366, Z.of_int 2)], []); - Prim (367, I_DUP, [], []); - Prim (368, I_CDR, [], []); - Prim (369, I_SWAP, [], []); - Prim (370, I_CAR, [], []); - Prim (371, I_SWAP, [], []); - Prim (372, I_DUP, [], []); - Prim (373, I_DUG, [Int (374, Z.of_int 2)], []); - Prim (375, I_DIG, [Int (376, Z.of_int 3)], []); - Prim (377, I_DUP, [], []); - Prim (378, I_DUG, [Int (379, Z.of_int 4)], []); - Prim (380, I_PAIR, [], []); - Prim (381, I_DIG, [Int (382, Z.of_int 6)], []); - Prim (383, I_DUP, [], []); - Prim (384, I_DUG, [Int (385, Z.of_int 7)], []); - Prim (386, I_SWAP, [], []); - Prim (387, I_EXEC, [], []); - Prim (388, I_SWAP, [], []); - Prim (389, I_DUP, [], []); - Prim (390, I_DUG, [Int (391, Z.of_int 2)], []); - Prim (392, I_SWAP, [], []); - Prim (393, I_DUP, [], []); - Prim (394, I_DUG, [Int (395, Z.of_int 2)], []); - Prim (396, I_CDR, [], []); - Prim (397, I_COMPARE, [], []); - Prim (398, I_LT, [], []); - Prim - ( 399, - I_IF, - [ Seq - ( 400, - [ Prim - ( 401, - I_PUSH, - [ Prim (402, T_string, [], []); - String - (403, "NotEnoughBalance") - ], - [] ); - Prim (404, I_FAILWITH, [], []) ] ); - Seq (405, []) ], - [] ); - Prim (406, I_SENDER, [], []); - Prim (407, I_DIG, [Int (408, Z.of_int 4)], []); - Prim (409, I_DUP, [], []); - Prim (410, I_DUG, [Int (411, Z.of_int 5)], []); - Prim (412, I_COMPARE, [], []); - Prim (413, I_NEQ, [], []); + ( 256, + [ Prim (257, I_SWAP, [], []); + Prim (258, I_DUP, [], []); + Prim (259, I_DUG, [Int (260, Z.of_int 2)], []); + Prim (261, I_CAR, [], []); + Prim (262, I_CAR, [], []); + Prim (263, I_DIG, [Int (264, Z.of_int 2)], []); + Prim (265, I_DUP, [], []); + Prim (266, I_DUG, [Int (267, Z.of_int 3)], []); + Prim (268, I_CAR, [], []); + Prim (269, I_CDR, [], []); + Prim (270, I_DIG, [Int (271, Z.of_int 2)], []); + Prim (272, I_DUP, [], []); + Prim (273, I_DUG, [Int (274, Z.of_int 3)], []); + Prim (275, I_CAR, [], []); + Prim (276, I_SENDER, [], []); + Prim (277, I_COMPARE, [], []); + Prim (278, I_EQ, [], []); Prim - ( 414, + ( 279, I_IF, - [ Seq - ( 415, - [ Prim - ( 416, + [ Seq (280, [Prim (281, I_SWAP, [], [])]); + Seq + ( 282, + [ Prim (283, I_SENDER, [], []); + Prim + ( 284, I_DIG, - [Int (417, Z.of_int 2)], + [Int (285, Z.of_int 3)], [] ); - Prim (418, I_DUP, [], []); + Prim (286, I_DUP, [], []); Prim - ( 419, + ( 287, I_DUG, - [Int (420, Z.of_int 3)], + [Int (288, Z.of_int 4)], [] ); - Prim (421, I_SENDER, [], []); + Prim (289, I_CAR, [], []); + Prim (290, I_PAIR, [], []); Prim - ( 422, + ( 291, I_DIG, - [Int (423, Z.of_int 2)], + [Int (292, Z.of_int 3)], [] ); - Prim (424, I_DUP, [], []); + Prim (293, I_DUP, [], []); Prim - ( 425, + ( 294, I_DUG, - [Int (426, Z.of_int 3)], + [Int (295, Z.of_int 4)], [] ); - Prim (427, I_PAIR, [], []); - Prim (428, I_PAIR, [], []); + Prim (296, I_CDR, [], []); + Prim (297, I_CDR, [], []); Prim - ( 429, + ( 298, I_DIG, - [Int (430, Z.of_int 6)], + [Int (299, Z.of_int 3)], [] ); - Prim (431, I_SWAP, [], []); - Prim (432, I_EXEC, [], []); + Prim (300, I_DUP, [], []); Prim - ( 433, + ( 301, + I_DUG, + [Int (302, Z.of_int 4)], + [] ); + Prim + ( 303, I_DIG, - [Int (434, Z.of_int 2)], + [Int (304, Z.of_int 2)], [] ); - Prim (435, I_DUP, [], []); + Prim (305, I_DUP, [], []); Prim - ( 436, + ( 306, I_DUG, - [Int (437, Z.of_int 3)], + [Int (307, Z.of_int 3)], [] ); - Prim (438, I_SWAP, [], []); - Prim (439, I_DUP, [], []); + Prim (308, I_GET, [], []); Prim - ( 440, - I_DUG, - [Int (441, Z.of_int 2)], + ( 309, + I_IF_NONE, + [ Seq + ( 310, + [ Prim + ( 311, + I_PUSH, + [ Prim + ( 312, + T_nat, + [], + [] ); + Int (313, Z.zero) + ], + [] ) ] ); + Seq (314, []) ], [] ); - Prim (442, I_COMPARE, [], []); - Prim (443, I_LT, [], []); + Prim (315, I_SUB, [], []); + Prim (316, I_ISNAT, [], []); Prim - ( 444, - I_IF, + ( 317, + I_IF_NONE, [ Seq - ( 445, + ( 318, [ Prim - ( 446, + ( 319, I_PUSH, [ Prim - ( 447, + ( 320, T_string, [], [] ); String - ( 448, + ( 321, "NotEnoughAllowance" ) ], [] ); Prim - ( 449, + ( 322, I_FAILWITH, [], [] ) ] ); - Seq (450, []) ], + Seq (323, []) ], [] ); - Prim (451, I_SWAP, [], []); - Prim (452, I_DUP, [], []); Prim - ( 453, - I_DUG, - [Int (454, Z.of_int 2)], + ( 324, + I_DIG, + [Int (325, Z.of_int 3)], [] ); - Prim (455, I_CDR, [], []); Prim - ( 456, - I_DIG, - [Int (457, Z.of_int 2)], + ( 326, + I_PUSH, + [ Prim (327, T_nat, [], []); + Int (328, Z.zero) ], [] ); - Prim (458, I_CAR, [], []); Prim - ( 459, + ( 329, I_DIG, - [Int (460, Z.of_int 3)], + [Int (330, Z.of_int 2)], [] ); - Prim (461, I_DUP, [], []); + Prim (331, I_DUP, [], []); Prim - ( 462, + ( 332, I_DUG, - [Int (463, Z.of_int 4)], + [Int (333, Z.of_int 3)], + [] ); + Prim (334, I_COMPARE, [], []); + Prim (335, I_EQ, [], []); + Prim + ( 336, + I_IF, + [ Seq + ( 337, + [ Prim + (338, I_SWAP, [], []); + Prim + (339, I_DROP, [], []); + Prim + ( 340, + I_NONE, + [ Prim + ( 341, + T_nat, + [], + [] ) ], + [] ) ] ); + Seq + ( 342, + [ Prim + (343, I_SWAP, [], []); + Prim + (344, I_SOME, [], []) + ] ) ], [] ); Prim - ( 464, + ( 345, I_DIG, - [Int (465, Z.of_int 3)], + [Int (346, Z.of_int 2)], [] ); - Prim (466, I_SUB, [], []); - Prim (467, I_ABS, [], []); - Prim (468, I_SOME, [], []); - Prim (469, I_SENDER, [], []); - Prim (470, I_UPDATE, [], []); - Prim (471, I_PAIR, [], []) ] ); - Seq - ( 472, + Prim (347, I_UPDATE, [], []) ] ) ], + [] ); + Prim (348, I_DIG, [Int (349, Z.of_int 2)], []); + Prim (350, I_DUP, [], []); + Prim (351, I_DUG, [Int (352, Z.of_int 3)], []); + Prim (353, I_CDR, [], []); + Prim (354, I_CDR, [], []); + Prim (355, I_DIG, [Int (356, Z.of_int 2)], []); + Prim (357, I_DUP, [], []); + Prim (358, I_DUG, [Int (359, Z.of_int 3)], []); + Prim (360, I_DIG, [Int (361, Z.of_int 4)], []); + Prim (362, I_DUP, [], []); + Prim (363, I_DUG, [Int (364, Z.of_int 5)], []); + Prim (365, I_CAR, [], []); + Prim (366, I_GET, [], []); + Prim + ( 367, + I_IF_NONE, + [ Seq + ( 368, [ Prim - ( 473, - I_DIG, - [Int (474, Z.of_int 5)], + ( 369, + I_PUSH, + [ Prim (370, T_nat, [], []); + Int (371, Z.zero) ], + [] ) ] ); + Seq (372, []) ], + [] ); + Prim (373, I_SUB, [], []); + Prim (374, I_ISNAT, [], []); + Prim + ( 375, + I_IF_NONE, + [ Seq + ( 376, + [ Prim + ( 377, + I_PUSH, + [ Prim (378, T_string, [], []); + String + (379, "NotEnoughBalance") + ], [] ); - Prim (475, I_DROP, [], []) ] ) ], + Prim (380, I_FAILWITH, [], []) ] ); + Seq (381, []) ], + [] ); + Prim (382, I_DIG, [Int (383, Z.of_int 2)], []); + Prim + ( 384, + I_PUSH, + [ Prim (385, T_nat, [], []); + Int (386, Z.zero) ], + [] ); + Prim (387, I_DIG, [Int (388, Z.of_int 2)], []); + Prim (389, I_DUP, [], []); + Prim (390, I_DUG, [Int (391, Z.of_int 3)], []); + Prim (392, I_COMPARE, [], []); + Prim (393, I_EQ, [], []); + Prim + ( 394, + I_IF, + [ Seq + ( 395, + [ Prim (396, I_SWAP, [], []); + Prim (397, I_DROP, [], []); + Prim + ( 398, + I_NONE, + [Prim (399, T_nat, [], [])], + [] ) ] ); + Seq + ( 400, + [ Prim (401, I_SWAP, [], []); + Prim (402, I_SOME, [], []) ] ) ], + [] ); + Prim (403, I_DIG, [Int (404, Z.of_int 3)], []); + Prim (405, I_DUP, [], []); + Prim (406, I_DUG, [Int (407, Z.of_int 4)], []); + Prim (408, I_CAR, [], []); + Prim (409, I_UPDATE, [], []); + Prim (410, I_DIG, [Int (411, Z.of_int 2)], []); + Prim (412, I_DUP, [], []); + Prim (413, I_DUG, [Int (414, Z.of_int 3)], []); + Prim (415, I_CDR, [], []); + Prim (416, I_CDR, [], []); + Prim (417, I_SWAP, [], []); + Prim (418, I_DUP, [], []); + Prim (419, I_DUG, [Int (420, Z.of_int 2)], []); + Prim (421, I_DIG, [Int (422, Z.of_int 4)], []); + Prim (423, I_DUP, [], []); + Prim (424, I_DUG, [Int (425, Z.of_int 5)], []); + Prim (426, I_CDR, [], []); + Prim (427, I_CAR, [], []); + Prim (428, I_GET, [], []); + Prim + ( 429, + I_IF_NONE, + [ Seq + ( 430, + [ Prim + ( 431, + I_PUSH, + [ Prim (432, T_nat, [], []); + Int (433, Z.zero) ], + [] ) ] ); + Seq (434, []) ], + [] ); + Prim (435, I_ADD, [], []); + Prim (436, I_SWAP, [], []); + Prim + ( 437, + I_PUSH, + [ Prim (438, T_nat, [], []); + Int (439, Z.zero) ], + [] ); + Prim (440, I_DIG, [Int (441, Z.of_int 2)], []); + Prim (442, I_DUP, [], []); + Prim (443, I_DUG, [Int (444, Z.of_int 3)], []); + Prim (445, I_COMPARE, [], []); + Prim (446, I_EQ, [], []); + Prim + ( 447, + I_IF, + [ Seq + ( 448, + [ Prim (449, I_SWAP, [], []); + Prim (450, I_DROP, [], []); + Prim + ( 451, + I_NONE, + [Prim (452, T_nat, [], [])], + [] ) ] ); + Seq + ( 453, + [ Prim (454, I_SWAP, [], []); + Prim (455, I_SOME, [], []) ] ) ], + [] ); + Prim (456, I_DIG, [Int (457, Z.of_int 3)], []); + Prim (458, I_CDR, [], []); + Prim (459, I_CAR, [], []); + Prim (460, I_UPDATE, [], []); + Prim (461, I_DIG, [Int (462, Z.of_int 2)], []); + Prim (463, I_DUP, [], []); + Prim (464, I_DUG, [Int (465, Z.of_int 3)], []); + Prim (466, I_CDR, [], []); + Prim (467, I_SWAP, [], []); + Prim (468, I_DIG, [Int (469, Z.of_int 3)], []); + Prim (470, I_CAR, [], []); + Prim (471, I_CAR, [], []); + Prim (472, I_PAIR, [], []); + Prim (473, I_CDR, [], []); + Prim (474, I_DIG, [Int (475, Z.of_int 2)], []); + Prim (476, I_PAIR, [], []); + Prim (477, I_PAIR, [], []); + Prim + ( 478, + I_NIL, + [Prim (479, T_operation, [], [])], [] ); - Prim (476, I_SWAP, [], []); - Prim (477, I_DUP, [], []); - Prim (478, I_DUG, [Int (479, Z.of_int 2)], []); - Prim (480, I_SWAP, [], []); - Prim (481, I_DUP, [], []); - Prim (482, I_DUG, [Int (483, Z.of_int 2)], []); - Prim (484, I_CDR, [], []); - Prim (485, I_SUB, [], []); - Prim (486, I_ABS, [], []); - Prim (487, I_SWAP, [], []); - Prim (488, I_CAR, [], []); - Prim (489, I_PAIR, [], []); - Prim (490, I_DIG, [Int (491, Z.of_int 2)], []); - Prim (492, I_DUP, [], []); - Prim (493, I_DUG, [Int (494, Z.of_int 3)], []); - Prim (495, I_CDR, [], []); - Prim (496, I_DIG, [Int (497, Z.of_int 3)], []); - Prim (498, I_CAR, [], []); - Prim (499, I_DIG, [Int (500, Z.of_int 2)], []); - Prim (501, I_DIG, [Int (502, Z.of_int 4)], []); - Prim (503, I_SWAP, [], []); - Prim (504, I_SOME, [], []); - Prim (505, I_SWAP, [], []); - Prim (506, I_UPDATE, [], []); - Prim (507, I_PAIR, [], []); - Prim (508, I_DUP, [], []); - Prim (509, I_DIG, [Int (510, Z.of_int 3)], []); - Prim (511, I_DUP, [], []); - Prim (512, I_DUG, [Int (513, Z.of_int 4)], []); - Prim (514, I_PAIR, [], []); - Prim (515, I_DIG, [Int (516, Z.of_int 4)], []); - Prim (517, I_SWAP, [], []); - Prim (518, I_EXEC, [], []); - Prim (519, I_DIG, [Int (520, Z.of_int 2)], []); - Prim (521, I_SWAP, [], []); - Prim (522, I_DUP, [], []); - Prim (523, I_DUG, [Int (524, Z.of_int 2)], []); - Prim (525, I_CDR, [], []); - Prim (526, I_ADD, [], []); - Prim (527, I_SWAP, [], []); - Prim (528, I_CAR, [], []); - Prim (529, I_PAIR, [], []); - Prim (530, I_SWAP, [], []); - Prim (531, I_DUP, [], []); - Prim (532, I_DUG, [Int (533, Z.of_int 2)], []); - Prim (534, I_CDR, [], []); - Prim (535, I_DIG, [Int (536, Z.of_int 2)], []); - Prim (537, I_CAR, [], []); - Prim (538, I_DIG, [Int (539, Z.of_int 2)], []); - Prim (540, I_DIG, [Int (541, Z.of_int 3)], []); - Prim (542, I_SWAP, [], []); - Prim (543, I_SOME, [], []); - Prim (544, I_SWAP, [], []); - Prim (545, I_UPDATE, [], []); - Prim (546, I_PAIR, [], []); - Prim (547, I_SWAP, [], []); - Prim (548, I_PAIR, [], []) ] ) ], + Prim (480, I_PAIR, [], []) ] ) ], [] ) ] ) ], [] ) ] ) diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 7bf35bc3e867..5cdb294e4be0 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -847,11 +847,6 @@ let prepare_first_block ~level ~timestamp ~fitness ctxt = min_proposal_quorum = c.min_proposal_quorum; initial_endorsers = c.initial_endorsers; delay_per_missing_endorsement = c.delay_per_missing_endorsement; - liquidity_baking_cpmm_address = - (* REPLACE AFTER ORIGINATING CPMM CONTRACT ON MAINNET!!! *) - Contract_repr.implicit_contract - (Signature.Public_key_hash.of_b58check_exn - "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU"); liquidity_baking_subsidy = Tez_repr.of_mutez_exn 5_000_000L; liquidity_baking_sunset_duration = 262800l; liquidity_baking_escape_ema_threshold = 500_000l; diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index acc5136609d8..a27e7932db95 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1242,4 +1242,11 @@ module Liquidity_baking = struct let name = ["liquidity_baking_sunset_level"] end) (Int32) + + module Cpmm_address = + Make_single_data_storage (Registered) (Raw_context) + (struct + let name = ["liquidity_baking_cpmm_address"] + end) + (Contract_repr) end diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 7446f8ed5428..a61699aaf3ef 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -496,7 +496,13 @@ module Liquidity_baking : sig Single_data_storage with type t := Raw_context.t and type value = Int32.t (** Level at which liquidity baking automatically shuts off. - Set in stitching to six months from activation of proto 009. **) + Set in stitching to six months from activation of proto 010. **) module Sunset_level : Single_data_storage with type t := Raw_context.t and type value = Int32.t + + (** Constant product market maker contract that receives liquidity baking subsidy. **) + module Cpmm_address : + Single_data_storage + with type t := Raw_context.t + and type value = Contract_repr.t end diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 1da55bca4796..3234150f9880 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -178,6 +178,9 @@ let get_liquidity_baking_subsidy ctxt = >>=? fun {Constants.parametric = {liquidity_baking_subsidy; _}; _} -> return liquidity_baking_subsidy +let get_liquidity_baking_cpmm_address ctxt = + Alpha_services.Liquidity_baking.get_cpmm_address rpc_ctxt ctxt + (* Voting *) module Vote = struct diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 73bedad60a26..624646a332c2 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -65,6 +65,8 @@ val get_endorsing_reward : val get_liquidity_baking_subsidy : t -> Tez.t tzresult Lwt.t +val get_liquidity_baking_cpmm_address : t -> Contract.t tzresult Lwt.t + module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index 681916ea69d4..da4eba713fd1 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -1,7 +1,7 @@ (*****************************************************************************) (* *) (* Open Source License *) -(* Copyright (c) 2020 Tocqueville Group, Inc. *) +(* Copyright (c) 2021 Tocqueville Group, Inc. *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -35,11 +35,8 @@ open Protocol open Test_tez open Micheline_printer -let bootstrap_contracts = - Tezos_protocol_alpha_parameters.Default_parameters.test_bootstrap_contracts - let liquidity_baking_subsidy_param () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> Context.get_constants (B blk) >>=? fun csts -> @@ -73,11 +70,10 @@ let liquidity_baking_subsidy_param () = Assert.equal_tez ~loc:__LOC__ actual_subsidy expected_subsidy let liquidity_baking_subsidies n () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> - Context.get_constants (B blk) - >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> Block.bake_n n blk @@ -95,11 +91,12 @@ let liquidity_baking_subsidies n () = >>=? fun () -> return_unit let liquidity_baking_sunset_level n () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in let sunset = csts.parametric.liquidity_baking_sunset_duration in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> @@ -118,11 +115,10 @@ let liquidity_baking_sunset_level n () = >>=? fun () -> return_unit let liquidity_baking_escape_hatch_100 n () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> - Context.get_constants (B blk) - >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> (* log(1-1/2) / log(0.999) *) let escape_level = 694 in Context.Contract.balance (B blk) liquidity_baking @@ -144,11 +140,10 @@ let liquidity_baking_escape_hatch_100 n () = >>=? fun () -> return_unit let liquidity_baking_escape_hatch_80 n () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> - Context.get_constants (B blk) - >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> (* log(1-1/(2*.8)) / log(0.999) *) let escape_level = 983 in Context.Contract.balance (B blk) liquidity_baking @@ -178,11 +173,10 @@ let liquidity_baking_escape_hatch_80 n () = >>=? fun () -> return_unit let liquidity_baking_escape_hatch_60 n () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> - Context.get_constants (B blk) - >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> (* log(1-1/(2*.6)) / log(0.999) *) let escape_level = 1790 in Context.Contract.balance (B blk) liquidity_baking @@ -212,12 +206,12 @@ let liquidity_baking_escape_hatch_60 n () = >>=? fun () -> return_unit let liquidity_baking_escape_hatch_50 n () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in - (* log(1-1/(2*.6)) / log(0.999) *) let sunset = csts.parametric.liquidity_baking_sunset_duration in Context.Contract.balance (B blk) liquidity_baking >>=? fun old_balance -> @@ -244,17 +238,20 @@ let liquidity_baking_escape_hatch_50 n () = >>=? fun () -> return_unit let liquidity_baking_storage n () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> - Context.get_constants (B blk) - >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> let expected_storage = Expr.from_string (Printf.sprintf - "Pair 0 (Pair False 4000000000000) \ - \"KT1CSKPf2jeLpMmrgKquN2bCjBTkAcAdRVDy\" 2000000000000 %d" - (2000000000000 + (n * 5000000))) + "Pair 0\n\ + \ %d\n\ + \ 0\n\ + \ False\n\ + \ \"KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5\"\n\ + \ \"KT1VqarPDicMFn1ejmQqqshUkUXTCTXwmkCN\"" + (n * 5000000)) in Block.bake_n n blk >>=? fun blk -> @@ -275,11 +272,12 @@ let liquidity_baking_storage n () = >>=? fun () -> return_unit let liquidity_baking_balance_update () = - Context.init ~bootstrap_contracts 1 + Context.init 1 >>=? fun (blk, _contracts) -> + Context.get_liquidity_baking_cpmm_address (B blk) + >>=? fun liquidity_baking -> Context.get_constants (B blk) >>=? fun csts -> - let liquidity_baking = csts.parametric.liquidity_baking_cpmm_address in let sunset = csts.parametric.liquidity_baking_sunset_duration in Block.bake_n_with_all_balance_updates Int32.(to_int (add sunset 100l)) blk >>=? fun (_blk, balance_updates) -> diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out index 8f0c3f4a240c..20af84e5b4fb 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractBigMapOrigination::test_big_map_origination_literal.out @@ -33,8 +33,8 @@ This sequence of operations was run: [CONTRACT_HASH] Storage size: 146 bytes Updated big_maps: - New map(2) of type (big_map int int) - Set map(2)[0] to 0 + New map(0) of type (big_map int int) + Set map(0)[0] to 0 Paid storage size diff: 146 bytes Consumed gas: 1899.428 Balance updates: diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 0 (S.f91eafd1f7.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 0 (S.f91eafd1f7.out new file mode 100644 index 000000000000..c2b4b3b83fe3 --- /dev/null +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 0 (S.f91eafd1f7.out @@ -0,0 +1,46 @@ +tests_alpha/test_contract_opcodes.py::TestContractOpcodes::test_contract_input_output[big_map_mem_nat.tz-(Pair { Elt 0 1 } None)-1-(Pair 0 (Some False))] + +storage + (Pair 0 (Some False)) +emitted operations + +big_map diff + New map(0) of type (big_map nat nat) + Set map(0)[0] to 1 +trace + - location: 11 (remaining gas: 1039977.424 units remaining) + [ (Pair 1 { Elt 0 1 } None) ] + - location: 12 (remaining gas: 1039977.344 units remaining) + [ 1 @parameter + (Pair { Elt 0 1 } None) @storage ] + - location: 15 (remaining gas: 1039977.189 units remaining) + [ { Elt 0 1 } ] + - location: 16 (remaining gas: 1039977.109 units remaining) + [ { Elt 0 1 } + { Elt 0 1 } ] + - location: -1 (remaining gas: 1039977.064 units remaining) + [ { Elt 0 1 } + { Elt 0 1 } ] + - location: 13 (remaining gas: 1039977.064 units remaining) + [ 1 @parameter + { Elt 0 1 } + { Elt 0 1 } ] + - location: 17 (remaining gas: 1039968.208 units remaining) + [ False + { Elt 0 1 } ] + - location: 18 (remaining gas: 1039968.133 units remaining) + [ (Some False) + { Elt 0 1 } ] + - location: 19 (remaining gas: 1039968.063 units remaining) + [ { Elt 0 1 } + (Some False) ] + - location: 20 (remaining gas: 1039967.988 units remaining) + [ (Pair { Elt 0 1 } (Some False)) ] + - location: 21 (remaining gas: 1039967.913 units remaining) + [ {} + (Pair { Elt 0 1 } (Some False)) ] + - location: 23 (remaining gas: 1039967.838 units remaining) + [ (Pair {} { Elt 0 1 } (Some False)) ] + - location: -1 (remaining gas: 1039967.793 units remaining) + [ (Pair {} { Elt 0 1 } (Some False)) ] + diff --git a/tests_python/tests_alpha/test_contract_opcodes.py b/tests_python/tests_alpha/test_contract_opcodes.py index 46cf3fb90e02..edd625c21b3f 100644 --- a/tests_python/tests_alpha/test_contract_opcodes.py +++ b/tests_python/tests_alpha/test_contract_opcodes.py @@ -324,110 +324,110 @@ class TestContractOpcodes: 'big_map_mem_nat.tz', '(Pair { Elt 0 1 } None)', '1', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair {} None)', '1', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 0 } None)', '1', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '1', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '2', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '3', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "foo" 1 } None)', '"bar"', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), ( 'big_map_mem_string.tz', '(Pair {} None)', '"bar"', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "foo" 0 } None)', '"foo"', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)', '"foo"', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)', '"bar"', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_string.tz', '(Pair { Elt "bar" 4 ; Elt "foo" 11 } None)', '"baz"', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), # Memberships in big maps ( 'big_map_mem_nat.tz', '(Pair { Elt 0 1 } None)', '1', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair {} None)', '1', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 0 } None)', '1', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '1', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '2', - '(Pair 2 (Some True))', + '(Pair 0 (Some True))', ), ( 'big_map_mem_nat.tz', '(Pair { Elt 1 4 ; Elt 2 11 } None)', '3', - '(Pair 2 (Some False))', + '(Pair 0 (Some False))', ), # Identity on sets ('set_id.tz', '{}', '{ "a" ; "b" ; "c" }', '{ "a" ; "b" ; "c" }'), @@ -1488,31 +1488,31 @@ class TestContractOpcodes: 'get_big_map_value.tz', '(Pair { Elt "hello" "hi" } None)', '"hello"', - '(Pair 2 (Some "hi"))', + '(Pair 0 (Some "hi"))', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["hello"] to "hi"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["hello"] to "hi"'], ], ), ( 'get_big_map_value.tz', '(Pair { Elt "hello" "hi" } None)', '""', - '(Pair 2 None)', + '(Pair 0 None)', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["hello"] to "hi"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["hello"] to "hi"'], ], ), ( 'get_big_map_value.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } None)', '"1"', - '(Pair 2 (Some "one"))', + '(Pair 0 (Some "one"))', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["2"] to "two"'], - ['Set map(2)["1"] to "one"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["2"] to "two"'], + ['Set map(0)["1"] to "one"'], ], ), # Test updating big maps @@ -1520,68 +1520,68 @@ class TestContractOpcodes: 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{}', - '(Pair 2 Unit)', + '(Pair 0 Unit)', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["2"] to "two"'], - ['Set map(2)["1"] to "one"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["2"] to "two"'], + ['Set map(0)["1"] to "one"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "1" (Some "two") }', - '(Pair 2 Unit)', + '(Pair 0 Unit)', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["2"] to "two"'], - ['Set map(2)["1"] to "two"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["2"] to "two"'], + ['Set map(0)["1"] to "two"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "3" (Some "three") }', - '(Pair 2 Unit)', + '(Pair 0 Unit)', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["2"] to "two"'], - ['Set map(2)["3"] to "three"'], - ['Set map(2)["1"] to "one"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["2"] to "two"'], + ['Set map(0)["3"] to "three"'], + ['Set map(0)["1"] to "one"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "3" None }', - '(Pair 2 Unit)', + '(Pair 0 Unit)', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["2"] to "two"'], - ['Unset map(2)["3"]'], - ['Set map(2)["1"] to "one"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["2"] to "two"'], + ['Unset map(0)["3"]'], + ['Set map(0)["1"] to "one"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "2" None }', - '(Pair 2 Unit)', + '(Pair 0 Unit)', [ - ["New map(2) of type (big_map string string)"], - ['Unset map(2)["2"]'], - ['Set map(2)["1"] to "one"'], + ["New map(0) of type (big_map string string)"], + ['Unset map(0)["2"]'], + ['Set map(0)["1"] to "one"'], ], ), ( 'update_big_map.tz', '(Pair { Elt "1" "one" ; Elt "2" "two" } Unit)', '{ Elt "1" (Some "two") }', - '(Pair 2 Unit)', + '(Pair 0 Unit)', [ - ["New map(2) of type (big_map string string)"], - ['Set map(2)["2"] to "two"'], - ['Set map(2)["1"] to "two"'], + ["New map(0) of type (big_map string string)"], + ['Set map(0)["2"] to "two"'], + ['Set map(0)["1"] to "two"'], ], ), # test the GET_AND_UPDATE instruction on big maps @@ -1590,51 +1590,51 @@ class TestContractOpcodes: 'get_and_update_big_map.tz', '(Pair None {})', '"hello"', - '(Pair None 2)', + '(Pair None 0)', [ - ["New map(2) of type (big_map string nat)"], - ['Unset map(2)["hello"]'], + ["New map(0) of type (big_map string nat)"], + ['Unset map(0)["hello"]'], ], ), ( 'get_and_update_big_map.tz', '(Pair (Some 4) {})', '"hello"', - '(Pair None 2)', + '(Pair None 0)', [ - ["New map(2) of type (big_map string nat)"], - ['Set map(2)["hello"] to 4'], + ["New map(0) of type (big_map string nat)"], + ['Set map(0)["hello"] to 4'], ], ), ( 'get_and_update_big_map.tz', '(Pair None { Elt "hello" 4 })', '"hello"', - '(Pair (Some 4) 2)', + '(Pair (Some 4) 0)', [ - ["New map(2) of type (big_map string nat)"], - ['Unset map(2)["hello"]'], + ["New map(0) of type (big_map string nat)"], + ['Unset map(0)["hello"]'], ], ), ( 'get_and_update_big_map.tz', '(Pair (Some 5) { Elt "hello" 4 })', '"hello"', - '(Pair (Some 4) 2)', + '(Pair (Some 4) 0)', [ - ["New map(2) of type (big_map string nat)"], - ['Set map(2)["hello"] to 5'], + ["New map(0) of type (big_map string nat)"], + ['Set map(0)["hello"] to 5'], ], ), ( 'get_and_update_big_map.tz', '(Pair (Some 5) { Elt "hello" 4 })', '"hi"', - '(Pair None 2)', + '(Pair None 0)', [ - ["New map(2) of type (big_map string nat)"], - ['Set map(2)["hello"] to 4'], - ['Set map(2)["hi"] to 5'], + ["New map(0) of type (big_map string nat)"], + ['Set map(0)["hello"] to 4'], + ['Set map(0)["hi"] to 5'], ], ), ( @@ -1642,11 +1642,11 @@ class TestContractOpcodes: '(Pair None { Elt "1" 1 ; \ Elt "2" 2 })', '"1"', - '(Pair (Some 1) 2)', + '(Pair (Some 1) 0)', [ - ["New map(2) of type (big_map string nat)"], - ['Set map(2)["2"] to 2'], - ['Unset map(2)["1"]'], + ["New map(0) of type (big_map string nat)"], + ['Set map(0)["2"] to 2'], + ['Unset map(0)["1"]'], ], ), ( @@ -1654,11 +1654,11 @@ class TestContractOpcodes: '(Pair None { Elt "1" 1 ; \ Elt "2" 2 })', '"1"', - '(Pair (Some 1) 2)', + '(Pair (Some 1) 0)', [ - ["New map(2) of type (big_map string nat)"], - ['Set map(2)["2"] to 2'], - ['Unset map(2)["1"]'], + ["New map(0) of type (big_map string nat)"], + ['Set map(0)["2"] to 2'], + ['Unset map(0)["1"]'], ], ), ], @@ -1686,12 +1686,12 @@ class TestContractOpcodes: ( '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))', '(Left Unit)', - '(Left (Pair 2 3))', + '(Left (Pair 0 1))', [ - ['New map(3) of type (big_map string string)'], - ['Set map(3)["1"] to "one"'], - ['New map(2) of type (big_map string string)'], - ['Set map(2)["2"] to "two"'], + ['New map(1) of type (big_map string string)'], + ['Set map(1)["1"] to "one"'], + ['New map(0) of type (big_map string string)'], + ['Set map(0)["2"] to "two"'], ], ), # test reset with new map @@ -1699,12 +1699,12 @@ class TestContractOpcodes: '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))', '(Right (Left (Left (Pair { Elt "3" "three" } ' + '{ Elt "4" "four" }))))', - '(Left (Pair 2 3))', + '(Left (Pair 0 1))', [ - ['New map(3) of type (big_map string string)'], - ['Set map(3)["4"] to "four"'], - ['New map(2) of type (big_map string string)'], - ['Set map(2)["3"] to "three"'], + ['New map(1) of type (big_map string string)'], + ['Set map(1)["4"] to "four"'], + ['New map(0) of type (big_map string string)'], + ['Set map(0)["3"] to "three"'], ], ), # test reset to unit @@ -1719,37 +1719,37 @@ class TestContractOpcodes: '(Right Unit)', '(Right (Right (Left (Pair { Pair "foo" "bar" } ' + '{ Pair "gaz" "baz" }) )))', - '(Left (Pair 2 3))', + '(Left (Pair 0 1))', [ - ['New map(3) of type (big_map string string)'], - ['Set map(3)["gaz"] to "baz"'], - ['New map(2) of type (big_map string string)'], - ['Set map(2)["foo"] to "bar"'], + ['New map(1) of type (big_map string string)'], + ['Set map(1)["gaz"] to "baz"'], + ['New map(0) of type (big_map string string)'], + ['Set map(0)["foo"] to "bar"'], ], ), # test add to big_map ( '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }) )', '(Right (Right (Right (Left { Pair "3" "three" }))))', - '(Left (Pair 2 3))', + '(Left (Pair 0 1))', [ - ['New map(3) of type (big_map string string)'], - ['Set map(3)["2"] to "two"'], - ['New map(2) of type (big_map string string)'], - ['Set map(2)["3"] to "three"'], - ['Set map(2)["1"] to "one"'], + ['New map(1) of type (big_map string string)'], + ['Set map(1)["2"] to "two"'], + ['New map(0) of type (big_map string string)'], + ['Set map(0)["3"] to "three"'], + ['Set map(0)["1"] to "one"'], ], ), # test remove from big_map ( '(Left (Pair { Elt "1" "one" } { Elt "2" "two" }))', '(Right (Right (Right (Right { "1" }))))', - '(Left (Pair 2 3))', + '(Left (Pair 0 1))', [ - ['New map(3) of type (big_map string string)'], - ['Set map(3)["2"] to "two"'], - ['New map(2) of type (big_map string string)'], - ['Unset map(2)["1"]'], + ['New map(1) of type (big_map string string)'], + ['Set map(1)["2"] to "two"'], + ['New map(0) of type (big_map string string)'], + ['Unset map(0)["1"]'], ], ), ], diff --git a/tests_python/tests_alpha/test_mockup.py b/tests_python/tests_alpha/test_mockup.py index e598f9840b1d..2b0ce52ad2be 100644 --- a/tests_python/tests_alpha/test_mockup.py +++ b/tests_python/tests_alpha/test_mockup.py @@ -604,11 +604,6 @@ def _test_create_mockup_init_show_roundtrip( "blocks_per_commitment": 5, "blocks_per_cycle": 9, "preserved_cycles": 3, - # switch off black formatter to avoid bug with long strings - # fmt: off - "liquidity_baking_cpmm_address": - "KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG", - # fmt: on "liquidity_baking_escape_ema_threshold": 500000, "liquidity_baking_subsidy": "5000000", "liquidity_baking_sunset_duration": 1024, diff --git a/tests_python/tests_alpha/test_voting_full.py b/tests_python/tests_alpha/test_voting_full.py index fff8707c4a5c..de80df7d1ccc 100644 --- a/tests_python/tests_alpha/test_voting_full.py +++ b/tests_python/tests_alpha/test_voting_full.py @@ -118,7 +118,7 @@ class TestVotingFull: bake_until_next_voting_period(client, BAKER, OFFSET) clients = sandbox.all_clients() wait_until_level(clients, client.get_level()) - assert_all_clients_in_period(clients, 'testing_vote') + assert_all_clients_in_period(clients, 'exploration') def test_delegates_vote_proto_b(self, sandbox: Sandbox): client = sandbox.client(0) @@ -132,14 +132,14 @@ class TestVotingFull: bake_until_next_voting_period(client, BAKER, OFFSET) clients = sandbox.all_clients() wait_until_level(clients, client.get_level()) - assert_all_clients_in_period(clients, 'testing') + assert_all_clients_in_period(clients, 'cooldown') def test_wait_for_promotion_vote_period(self, sandbox: Sandbox): client = sandbox.client(0) bake_until_next_voting_period(client, BAKER, OFFSET) clients = sandbox.all_clients() wait_until_level(clients, client.get_level()) - assert_all_clients_in_period(clients, 'promotion_vote') + assert_all_clients_in_period(clients, 'promotion') def test_vote_in_promotion_phase(self, sandbox: Sandbox): client = sandbox.client(0) diff --git a/tezt/_regressions/rpc/alpha.client.contracts.out b/tezt/_regressions/rpc/alpha.client.contracts.out index 5e83c931a820..d7d123c521e4 100644 --- a/tezt/_regressions/rpc/alpha.client.contracts.out +++ b/tezt/_regressions/rpc/alpha.client.contracts.out @@ -2,9 +2,10 @@ tezt/_regressions/rpc/alpha.client.contracts.out ./tezos-client rpc get /chains/main/blocks/head/context/contracts [ "[PUBLIC_KEY_HASH]", + "[PUBLIC_KEY_HASH]", + "[CONTRACT_HASH]", "[CONTRACT_HASH]", "[CONTRACT_HASH]", - "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]" ] @@ -312,7 +313,7 @@ null "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], "storage": - { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } } + { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } } ./tezos-client rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/balance' "0" @@ -520,10 +521,10 @@ null { "prim": "PAIR" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], - "storage": { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } + "storage": { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } ./tezos-client rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/storage' -{ "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } +{ "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } ./tezos-client rpc post '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/big_map_get' with '{ "key": { diff --git a/tezt/_regressions/rpc/alpha.client.others.out b/tezt/_regressions/rpc/alpha.client.others.out index 2ca1dd23de4d..c43e984d75ea 100644 --- a/tezt/_regressions/rpc/alpha.client.others.out +++ b/tezt/_regressions/rpc/alpha.client.others.out @@ -18,7 +18,6 @@ tezt/_regressions/rpc/alpha.client.others.out "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 1, "delay_per_missing_endorsement": "1", - "liquidity_baking_cpmm_address": "[CONTRACT_HASH]", "liquidity_baking_subsidy": "5000000", "liquidity_baking_sunset_duration": 1024, "liquidity_baking_escape_ema_threshold": 500000 } diff --git a/tezt/_regressions/rpc/alpha.proxy.contracts.out b/tezt/_regressions/rpc/alpha.proxy.contracts.out index d54d32f43701..90850c3f2729 100644 --- a/tezt/_regressions/rpc/alpha.proxy.contracts.out +++ b/tezt/_regressions/rpc/alpha.proxy.contracts.out @@ -3,9 +3,10 @@ tezt/_regressions/rpc/alpha.proxy.contracts.out ./tezos-client --mode proxy rpc get /chains/main/blocks/head/context/contracts protocol of proxy unspecified, using the node's protocol: ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im [ "[PUBLIC_KEY_HASH]", + "[PUBLIC_KEY_HASH]", + "[CONTRACT_HASH]", "[CONTRACT_HASH]", "[CONTRACT_HASH]", - "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]" ] @@ -344,7 +345,7 @@ protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaAL "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], "storage": - { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } } + { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } } ./tezos-client --mode proxy rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/balance' protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK @@ -558,11 +559,11 @@ protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaAL { "prim": "PAIR" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } ] ] } ], - "storage": { "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } } + "storage": { "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } } ./tezos-client --mode proxy rpc get '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/storage' protocol of proxy unspecified, using the node's protocol: ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK -{ "prim": "Pair", "args": [ { "int": "2" }, { "int": "3" } ] } +{ "prim": "Pair", "args": [ { "int": "0" }, { "int": "1" } ] } ./tezos-client --mode proxy rpc post '/chains/main/blocks/head/context/contracts/[CONTRACT_HASH]/big_map_get' with '{ "key": { diff --git a/tezt/_regressions/rpc/alpha.proxy.others.out b/tezt/_regressions/rpc/alpha.proxy.others.out index bebc686f8c75..530a7f794e29 100644 --- a/tezt/_regressions/rpc/alpha.proxy.others.out +++ b/tezt/_regressions/rpc/alpha.proxy.others.out @@ -19,7 +19,6 @@ protocol of proxy unspecified, using the node's protocol: ProtoGenesisGenesisGen "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "initial_endorsers": 1, "delay_per_missing_endorsement": "1", - "liquidity_baking_cpmm_address": "[CONTRACT_HASH]", "liquidity_baking_subsidy": "5000000", "liquidity_baking_sunset_duration": 1024, "liquidity_baking_escape_ema_threshold": 500000 } diff --git a/vendors/flextesa-lib/tezos_protocol.ml b/vendors/flextesa-lib/tezos_protocol.ml index 113ab39ae1a6..99a1536b3a2d 100644 --- a/vendors/flextesa-lib/tezos_protocol.ml +++ b/vendors/flextesa-lib/tezos_protocol.ml @@ -153,9 +153,7 @@ let protocol_parameters_json t : Ezjsonm.t = let alpha_specific_parameters = match subkind with | `Alpha -> - [ ( "liquidity_baking_cpmm_address" - , string "KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG"); - ( "liquidity_baking_subsidy" + [ ( "liquidity_baking_subsidy" , string "5000000" ); ( "liquidity_baking_sunset_duration" , int 262800 ); -- GitLab From 98bb519bd49d1f389e42d9962fabc2759584f22c Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Thu, 25 Mar 2021 19:41:24 -0400 Subject: [PATCH 60/62] bump OPAMSOLVERTIMEOUT to ridiculous value --- scripts/update_opam_repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_opam_repo.sh b/scripts/update_opam_repo.sh index 2d2c1510670a..682a4681dc9b 100755 --- a/scripts/update_opam_repo.sh +++ b/scripts/update_opam_repo.sh @@ -88,7 +88,7 @@ done ## Filtering unrequired packages cd $tmp_dir git reset --hard "$full_opam_repository_tag" -OPAMSOLVERTIMEOUT=6000 opam admin filter --yes --resolve \ +OPAMSOLVERTIMEOUT=600000 opam admin filter --yes --resolve \ $packages,ocaml,ocaml-base-compiler,odoc,opam-depext,js_of_ocaml-ppx,reactiveData,opam-ed ## Adding useful compiler variants -- GitLab From 3dd513b4de4cc9f72b28c48d6f4f267325502928 Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 26 Mar 2021 00:53:10 -0400 Subject: [PATCH 61/62] liquidity baking: use bootstrap origination nonce for test contracts --- .../lib_protocol/liquidity_baking_storage.ml | 24 ++++++++----------- .../test/test_liquidity_baking.ml | 4 ++-- tests_python/tests_alpha/test_migration.py | 18 +++----------- .../rpc/alpha.client.contracts.out | 2 +- .../rpc/alpha.proxy.contracts.out | 2 +- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml b/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml index e67c75564688..3be8fd5c98ea 100644 --- a/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml +++ b/src/proto_alpha/lib_protocol/liquidity_baking_storage.ml @@ -33,10 +33,6 @@ corresponds to tzBTC in the mainnet version and a reference FA1.2 contract in the test version. - The liquidity baking contracts are originated with a contrived origination - nonce similar to origination of bootstrap contracts, but with a different - nonce. - The Michelson and Ligo code, as well as Coq proofs, for the CPMM and liquidity token contracts are available here: https://gitlab.com/dexter2tz/dexter2tz/-/tree/liquidity_baking @@ -81,7 +77,11 @@ let lqt_init_storage cpmm_address = let test_fa12_init_storage = Script_repr.lazy_expr (Micheline.strip_locations - (Prim (0, D_Pair, [Seq (1, []); Int (2, Z.of_int 2000000000000)], []))) + (Prim + ( 0, + D_Pair, + [Seq (1, []); Seq (2, []); Int (3, Z.of_int 2000000000000)], + [] ))) let tzBTC_address = "KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn" @@ -134,19 +134,17 @@ let init_common ctxt token_address = None ) ~delegate:None -let ctxt_with_origination_nonce ctxt = +let init ctxt = + (* origination nonce is unset when stitching from 009 *) let nonce = Operation_hash.hash_bytes [Bytes.of_string "Drip, drip, drip."] in - Raw_context.init_origination_nonce ctxt nonce - -let init ctxt = - let ctxt = ctxt_with_origination_nonce ctxt in + let ctxt = Raw_context.init_origination_nonce ctxt nonce in init_common ctxt tzBTC_address >>=? fun ctxt -> return (Raw_context.unset_origination_nonce ctxt) let init_test ctxt = - let ctxt = ctxt_with_origination_nonce ctxt in + (* when stitching from Genesis origination nonce is set by bootstrap storage *) Contract_storage.fresh_contract_from_current_nonce ctxt >>?= fun (ctxt, fa12_address) -> Contract_storage.raw_originate @@ -163,6 +161,4 @@ let init_test ctxt = }, None ) ~delegate:None - >>=? fun ctxt -> - init_common ctxt (Contract_repr.to_b58check fa12_address) - >>=? fun ctxt -> return (Raw_context.unset_origination_nonce ctxt) + >>=? fun ctxt -> init_common ctxt (Contract_repr.to_b58check fa12_address) diff --git a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml index da4eba713fd1..cc0a1f7e0518 100644 --- a/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml +++ b/src/proto_alpha/lib_protocol/test/test_liquidity_baking.ml @@ -249,8 +249,8 @@ let liquidity_baking_storage n () = \ %d\n\ \ 0\n\ \ False\n\ - \ \"KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5\"\n\ - \ \"KT1VqarPDicMFn1ejmQqqshUkUXTCTXwmkCN\"" + \ \"KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG\"\n\ + \ \"KT1SLWhfqPtQq7f4zLomh8BNgDeprF9B6d2M\"" (n * 5000000)) in Block.bake_n n blk diff --git a/tests_python/tests_alpha/test_migration.py b/tests_python/tests_alpha/test_migration.py index 8df8d26d256e..2908724f656b 100644 --- a/tests_python/tests_alpha/test_migration.py +++ b/tests_python/tests_alpha/test_migration.py @@ -21,20 +21,8 @@ BAKE_ARGS = [ MIGRATION_LEVEL = 3 BAKER = 'bootstrap1' BAKER_PKH = constants.IDENTITIES[BAKER]['identity'] -PREV_DEPOSIT = protocol.PREV_PARAMETERS["block_security_deposit"] DEPOSIT = protocol.PARAMETERS["block_security_deposit"] -PREV_DEPOSIT_RECEIPTS = [ - {"kind": "contract", "contract": BAKER_PKH, "change": "-" + PREV_DEPOSIT}, - { - "kind": "freezer", - "category": "deposits", - "delegate": BAKER_PKH, - "cycle": 0, - "change": PREV_DEPOSIT, - }, -] -# in protocol Alpha, the "origin" field is added DEPOSIT_RECEIPTS = [ { "kind": "contract", @@ -65,7 +53,7 @@ MIGRATION_RECEIPTS = [ # configure user-activate-upgrade at MIGRATION_LEVEL to test migration NODE_CONFIG = { - 'Network': { + 'network': { 'genesis': { 'timestamp': '2018-06-30T16:07:32Z', 'block': 'BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2', @@ -120,7 +108,7 @@ class TestMigration: assert client.get_protocol() == protocol.PREV_HASH assert sandbox.client(0).get_head()['header']['proto'] == 1 metadata = client.get_metadata() - assert metadata['balance_updates'] == PREV_DEPOSIT_RECEIPTS + assert metadata['balance_updates'] == DEPOSIT_RECEIPTS # PROTO_A is using env. V1, metadata hashes should be present _ops_metadata_hash = client.get_operations_metadata_hash() _block_metadata_hash = client.get_block_metadata_hash() @@ -130,7 +118,7 @@ class TestMigration: client.bake(BAKER, BAKE_ARGS) metadata = client.get_metadata() assert metadata['next_protocol'] == protocol.HASH - assert metadata['balance_updates'] == PREV_DEPOSIT_RECEIPTS + assert metadata['balance_updates'] == DEPOSIT_RECEIPTS # PROTO_B is using env. V1, metadata hashes should be present _ops_metadata_hash = client.get_operations_metadata_hash() _block_metadata_hash = client.get_block_metadata_hash() diff --git a/tezt/_regressions/rpc/alpha.client.contracts.out b/tezt/_regressions/rpc/alpha.client.contracts.out index d7d123c521e4..9f5594b9b6f5 100644 --- a/tezt/_regressions/rpc/alpha.client.contracts.out +++ b/tezt/_regressions/rpc/alpha.client.contracts.out @@ -2,9 +2,9 @@ tezt/_regressions/rpc/alpha.client.contracts.out ./tezos-client rpc get /chains/main/blocks/head/context/contracts [ "[PUBLIC_KEY_HASH]", - "[PUBLIC_KEY_HASH]", "[CONTRACT_HASH]", "[CONTRACT_HASH]", + "[PUBLIC_KEY_HASH]", "[CONTRACT_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", diff --git a/tezt/_regressions/rpc/alpha.proxy.contracts.out b/tezt/_regressions/rpc/alpha.proxy.contracts.out index 90850c3f2729..7653024adf2f 100644 --- a/tezt/_regressions/rpc/alpha.proxy.contracts.out +++ b/tezt/_regressions/rpc/alpha.proxy.contracts.out @@ -3,9 +3,9 @@ tezt/_regressions/rpc/alpha.proxy.contracts.out ./tezos-client --mode proxy rpc get /chains/main/blocks/head/context/contracts protocol of proxy unspecified, using the node's protocol: ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im [ "[PUBLIC_KEY_HASH]", - "[PUBLIC_KEY_HASH]", "[CONTRACT_HASH]", "[CONTRACT_HASH]", + "[PUBLIC_KEY_HASH]", "[CONTRACT_HASH]", "[PUBLIC_KEY_HASH]", "[PUBLIC_KEY_HASH]", -- GitLab From 1487100e5fbe23c8ab821ffdf9b3cabf01b0774a Mon Sep 17 00:00:00 2001 From: Sophia Gold Date: Fri, 26 Mar 2021 09:21:20 -0400 Subject: [PATCH 62/62] trying to make opam not timeout in the CI --- docs/introduction/install-opam.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction/install-opam.sh b/docs/introduction/install-opam.sh index 7aa9d6286fe4..ee5f606ae5e0 100644 --- a/docs/introduction/install-opam.sh +++ b/docs/introduction/install-opam.sh @@ -2,7 +2,7 @@ trap 'exit $?' ERR set -x sudo apt-get update export OPAMYES=true -export OPAMSOLVERTIMEOUT=1200 +export OPAMSOLVERTIMEOUT=60000 # [install ocaml compiler] opam switch create for_tezos 4.09.1 eval $(opam env) -- GitLab