package octez-protocol-alpha-libs
Octez protocol alpha libraries
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-protocol-alpha-libs.test-helpers/adaptive_issuance_helpers.ml.html
Source file adaptive_issuance_helpers.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2023 Nomadic Labs <contact@nomadic-labs.com> *) (* *) (* 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. *) (* *) (*****************************************************************************) (** Abstraction of the staking parameters for tests *) type staking_parameters = { limit_of_staking_over_baking : Q.t; edge_of_baking_over_staking : Q.t; } let default_params = let Protocol.Staking_parameters_repr. { limit_of_staking_over_baking_millionth; edge_of_baking_over_staking_billionth; } = Protocol.Staking_parameters_repr.default in { limit_of_staking_over_baking = Q.(Int32.to_int limit_of_staking_over_baking_millionth // 1_000_000); edge_of_baking_over_staking = Q.(Int32.to_int edge_of_baking_over_staking_billionth // 1_000_000_000); } let get_launch_cycle ~loc blk = let open Lwt_result_syntax in let* launch_cycle_opt = Context.get_adaptive_issuance_launch_cycle (B blk) in Assert.get_some ~loc launch_cycle_opt (** AI operations *) let stake ctxt contract amount = Op.transaction ctxt ~entrypoint:Protocol.Alpha_context.Entrypoint.stake ~fee:Tez_helpers.zero contract contract amount let set_delegate_parameters ctxt delegate ~parameters:{limit_of_staking_over_baking; edge_of_baking_over_staking} = let entrypoint = Protocol.Alpha_context.Entrypoint.set_delegate_parameters in let limit_of_staking_over_baking_millionth = Q.mul limit_of_staking_over_baking (Q.of_int 1_000_000) |> Q.to_int in let edge_of_baking_over_staking_billionth = Q.mul edge_of_baking_over_staking (Q.of_int 1_000_000_000) |> Q.to_int in let parameters = Protocol.Alpha_context.Script.lazy_expr (Expr.from_string (Printf.sprintf "Pair %d (Pair %d Unit)" limit_of_staking_over_baking_millionth edge_of_baking_over_staking_billionth)) in Op.transaction ctxt ~entrypoint ~parameters ~fee:Tez_helpers.zero delegate delegate Tez_helpers.zero let unstake ctxt contract amount = Op.transaction ctxt ~entrypoint:Protocol.Alpha_context.Entrypoint.unstake ~fee:Tez_helpers.zero contract contract amount let finalize_unstake ctxt ?(amount = Tez_helpers.zero) contract = Op.transaction ctxt ~entrypoint:Protocol.Alpha_context.Entrypoint.finalize_unstake ~fee:Tez_helpers.zero contract contract amount let portion_of_rewards_to_liquid_for_cycle ?policy ctxt cycle pkh rewards = let open Lwt_result_syntax in let* {frozen; weighted_delegated} = Context.Delegate.stake_for_cycle ?policy ctxt cycle pkh in let portion = Tez_helpers.(ratio weighted_delegated (frozen +! weighted_delegated)) in let to_liquid = Tez_helpers.mul_q rewards portion in return (Tez_helpers.of_q ~round:`Down to_liquid)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>