(* Generated by coq-of-rust *)
Require Import CoqOfRust.CoqOfRust.

Module extension.
  Module interest_bearing_mint.
    Axiom BasisPoints :
      (Ty.path "spl_token_2022::extension::interest_bearing_mint::BasisPoints") =
        (Ty.path "spl_pod::primitives::PodI16").
    
    Definition value_ONE_IN_BASIS_POINTS : Value.t := M.run ltac:(M.monadic UnsupportedLiteral).
    
    Definition value_SECONDS_PER_YEAR : Value.t :=
      M.run
        ltac:(M.monadic
          (M.alloc (|
            BinOp.Panic.mul (|
              Integer.Usize,
              BinOp.Panic.mul (|
                Integer.Usize,
                BinOp.Panic.mul (|
                  Integer.Usize,
                  M.read (| UnsupportedLiteral |),
                  M.read (| UnsupportedLiteral |)
                |),
                M.read (| UnsupportedLiteral |)
              |),
              M.read (| UnsupportedLiteral |)
            |)
          |))).
    
    Axiom UnixTimestamp :
      (Ty.path "spl_token_2022::extension::interest_bearing_mint::UnixTimestamp") =
        (Ty.path "spl_pod::primitives::PodI64").
    
    (* StructRecord
      {
        name := "InterestBearingConfig";
        ty_params := [];
        fields :=
          [
            ("rate_authority", Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey");
            ("initialization_timestamp", Ty.path "spl_pod::primitives::PodI64");
            ("pre_update_average_rate", Ty.path "spl_pod::primitives::PodI16");
            ("last_update_timestamp", Ty.path "spl_pod::primitives::PodI64");
            ("current_rate", Ty.path "spl_pod::primitives::PodI16")
          ];
      } *)
    
    Module Impl_core_clone_Clone_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      (* Clone *)
      Definition clone (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            M.read (|
              M.match_operator (|
                Value.DeclaredButUndefined,
                [
                  fun γ =>
                    ltac:(M.monadic
                      (M.match_operator (|
                        Value.DeclaredButUndefined,
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (M.match_operator (|
                                Value.DeclaredButUndefined,
                                [ fun γ => ltac:(M.monadic (M.read (| self |))) ]
                              |)))
                        ]
                      |)))
                ]
              |)
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom Implements :
        M.IsTraitInstance
          "core::clone::Clone"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("clone", InstanceField.Method clone) ].
    End Impl_core_clone_Clone_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_core_marker_Copy_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::Copy"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_Copy_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_core_fmt_Debug_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      (* Debug *)
      Definition fmt (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; f ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let f := M.alloc (| f |) in
            M.call_closure (|
              M.get_associated_function (|
                Ty.path "core::fmt::Formatter",
                "debug_struct_field5_finish",
                []
              |),
              [
                M.read (| f |);
                M.read (| Value.String "InterestBearingConfig" |);
                M.read (| Value.String "rate_authority" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                    "rate_authority"
                  |));
                M.read (| Value.String "initialization_timestamp" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                    "initialization_timestamp"
                  |));
                M.read (| Value.String "pre_update_average_rate" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                    "pre_update_average_rate"
                  |));
                M.read (| Value.String "last_update_timestamp" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                    "last_update_timestamp"
                  |));
                M.read (| Value.String "current_rate" |);
                (* Unsize *)
                M.pointer_coercion
                  (M.alloc (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                      "current_rate"
                    |)
                  |))
              ]
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom Implements :
        M.IsTraitInstance
          "core::fmt::Debug"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
    End Impl_core_fmt_Debug_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_core_default_Default_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      (* Default *)
      Definition default (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [] =>
          ltac:(M.monadic
            (Value.StructRecord
              "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig"
              [
                ("rate_authority",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("initialization_timestamp",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodI64",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("pre_update_average_rate",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodI16",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("last_update_timestamp",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodI64",
                      [],
                      "default",
                      []
                    |),
                    []
                  |));
                ("current_rate",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.path "spl_pod::primitives::PodI16",
                      [],
                      "default",
                      []
                    |),
                    []
                  |))
              ]))
        | _, _ => M.impossible
        end.
      
      Axiom Implements :
        M.IsTraitInstance
          "core::default::Default"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("default", InstanceField.Method default) ].
    End Impl_core_default_Default_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "core::marker::StructuralPartialEq"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_core_marker_StructuralPartialEq_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_core_cmp_PartialEq_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      (* PartialEq *)
      Definition eq (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; other ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let other := M.alloc (| other |) in
            LogicalOp.and (|
              LogicalOp.and (|
                LogicalOp.and (|
                  LogicalOp.and (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::cmp::PartialEq",
                        Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey",
                        [ Ty.path "spl_pod::optional_keys::OptionalNonZeroPubkey" ],
                        "eq",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                          "rate_authority"
                        |);
                        M.SubPointer.get_struct_record_field (|
                          M.read (| other |),
                          "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                          "rate_authority"
                        |)
                      ]
                    |),
                    ltac:(M.monadic
                      (M.call_closure (|
                        M.get_trait_method (|
                          "core::cmp::PartialEq",
                          Ty.path "spl_pod::primitives::PodI64",
                          [ Ty.path "spl_pod::primitives::PodI64" ],
                          "eq",
                          []
                        |),
                        [
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                            "initialization_timestamp"
                          |);
                          M.SubPointer.get_struct_record_field (|
                            M.read (| other |),
                            "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                            "initialization_timestamp"
                          |)
                        ]
                      |)))
                  |),
                  ltac:(M.monadic
                    (M.call_closure (|
                      M.get_trait_method (|
                        "core::cmp::PartialEq",
                        Ty.path "spl_pod::primitives::PodI16",
                        [ Ty.path "spl_pod::primitives::PodI16" ],
                        "eq",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                          "pre_update_average_rate"
                        |);
                        M.SubPointer.get_struct_record_field (|
                          M.read (| other |),
                          "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                          "pre_update_average_rate"
                        |)
                      ]
                    |)))
                |),
                ltac:(M.monadic
                  (M.call_closure (|
                    M.get_trait_method (|
                      "core::cmp::PartialEq",
                      Ty.path "spl_pod::primitives::PodI64",
                      [ Ty.path "spl_pod::primitives::PodI64" ],
                      "eq",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                        "last_update_timestamp"
                      |);
                      M.SubPointer.get_struct_record_field (|
                        M.read (| other |),
                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                        "last_update_timestamp"
                      |)
                    ]
                  |)))
              |),
              ltac:(M.monadic
                (M.call_closure (|
                  M.get_trait_method (|
                    "core::cmp::PartialEq",
                    Ty.path "spl_pod::primitives::PodI16",
                    [ Ty.path "spl_pod::primitives::PodI16" ],
                    "eq",
                    []
                  |),
                  [
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                      "current_rate"
                    |);
                    M.SubPointer.get_struct_record_field (|
                      M.read (| other |),
                      "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                      "current_rate"
                    |)
                  ]
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom Implements :
        M.IsTraitInstance
          "core::cmp::PartialEq"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("eq", InstanceField.Method eq) ].
    End Impl_core_cmp_PartialEq_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::pod::Pod"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_pod_Pod_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      Axiom Implements :
        M.IsTraitInstance
          "bytemuck::zeroable::Zeroable"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [].
    End Impl_bytemuck_zeroable_Zeroable_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      (*
          fn pre_update_timespan(&self) -> Option<i64> {
              i64::from(self.last_update_timestamp).checked_sub(self.initialization_timestamp.into())
          }
      *)
      Definition pre_update_timespan (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            M.call_closure (|
              M.get_associated_function (| Ty.path "i64", "checked_sub", [] |),
              [
                M.call_closure (|
                  M.get_trait_method (|
                    "core::convert::From",
                    Ty.path "i64",
                    [ Ty.path "spl_pod::primitives::PodI64" ],
                    "from",
                    []
                  |),
                  [
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                        "last_update_timestamp"
                      |)
                    |)
                  ]
                |);
                M.call_closure (|
                  M.get_trait_method (|
                    "core::convert::Into",
                    Ty.path "spl_pod::primitives::PodI64",
                    [ Ty.path "i64" ],
                    "into",
                    []
                  |),
                  [
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                        "initialization_timestamp"
                      |)
                    |)
                  ]
                |)
              ]
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_pre_update_timespan :
        M.IsAssociatedFunction Self "pre_update_timespan" pre_update_timespan.
      
      (*
          fn pre_update_exp(&self) -> Option<f64> {
              let numerator = (i16::from(self.pre_update_average_rate) as i128)
                  .checked_mul(self.pre_update_timespan()? as i128)? as f64;
              let exponent = numerator / SECONDS_PER_YEAR / ONE_IN_BASIS_POINTS;
              Some(exponent.exp())
          }
      *)
      Definition pre_update_exp (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let numerator :=
                    M.alloc (|
                      M.rust_cast
                        (M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply (Ty.path "core::option::Option") [ Ty.path "i128" ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "i128",
                                      "checked_mul",
                                      []
                                    |),
                                    [
                                      M.rust_cast
                                        (M.call_closure (|
                                          M.get_trait_method (|
                                            "core::convert::From",
                                            Ty.path "i16",
                                            [ Ty.path "spl_pod::primitives::PodI16" ],
                                            "from",
                                            []
                                          |),
                                          [
                                            M.read (|
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                                "pre_update_average_rate"
                                              |)
                                            |)
                                          ]
                                        |));
                                      M.rust_cast
                                        (M.read (|
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::Try",
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    [ Ty.path "i64" ],
                                                  [],
                                                  "branch",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path
                                                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                                      "pre_update_timespan",
                                                      []
                                                    |),
                                                    [ M.read (| self |) ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Break",
                                                      0
                                                    |) in
                                                  let residual := M.copy (| γ0_0 |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.read (|
                                                        M.return_ (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::try_trait::FromResidual",
                                                              Ty.apply
                                                                (Ty.path "core::option::Option")
                                                                [ Ty.path "f64" ],
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "core::option::Option")
                                                                  [
                                                                    Ty.path
                                                                      "core::convert::Infallible"
                                                                  ]
                                                              ],
                                                              "from_residual",
                                                              []
                                                            |),
                                                            [ M.read (| residual |) ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Continue",
                                                      0
                                                    |) in
                                                  let val := M.copy (| γ0_0 |) in
                                                  val))
                                            ]
                                          |)
                                        |))
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "f64" ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  [ Ty.path "core::convert::Infallible" ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |))
                    |) in
                  let exponent :=
                    M.alloc (|
                      BinOp.Panic.div (|
                        Integer.Usize,
                        BinOp.Panic.div (|
                          Integer.Usize,
                          M.read (| numerator |),
                          M.read (|
                            M.get_constant (|
                              "spl_token_2022::extension::interest_bearing_mint::SECONDS_PER_YEAR"
                            |)
                          |)
                        |),
                        M.read (|
                          M.get_constant (|
                            "spl_token_2022::extension::interest_bearing_mint::ONE_IN_BASIS_POINTS"
                          |)
                        |)
                      |)
                    |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::option::Option::Some"
                      [
                        M.call_closure (|
                          M.get_associated_function (| Ty.path "f64", "exp", [] |),
                          [ M.read (| exponent |) ]
                        |)
                      ]
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_pre_update_exp :
        M.IsAssociatedFunction Self "pre_update_exp" pre_update_exp.
      
      (*
          fn post_update_timespan(&self, unix_timestamp: i64) -> Option<i64> {
              unix_timestamp.checked_sub(self.last_update_timestamp.into())
          }
      *)
      Definition post_update_timespan (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; unix_timestamp ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let unix_timestamp := M.alloc (| unix_timestamp |) in
            M.call_closure (|
              M.get_associated_function (| Ty.path "i64", "checked_sub", [] |),
              [
                M.read (| unix_timestamp |);
                M.call_closure (|
                  M.get_trait_method (|
                    "core::convert::Into",
                    Ty.path "spl_pod::primitives::PodI64",
                    [ Ty.path "i64" ],
                    "into",
                    []
                  |),
                  [
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                        "last_update_timestamp"
                      |)
                    |)
                  ]
                |)
              ]
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_post_update_timespan :
        M.IsAssociatedFunction Self "post_update_timespan" post_update_timespan.
      
      (*
          fn post_update_exp(&self, unix_timestamp: i64) -> Option<f64> {
              let numerator = (i16::from(self.current_rate) as i128)
                  .checked_mul(self.post_update_timespan(unix_timestamp)? as i128)?
                  as f64;
              let exponent = numerator / SECONDS_PER_YEAR / ONE_IN_BASIS_POINTS;
              Some(exponent.exp())
          }
      *)
      Definition post_update_exp (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; unix_timestamp ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let unix_timestamp := M.alloc (| unix_timestamp |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let numerator :=
                    M.alloc (|
                      M.rust_cast
                        (M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply (Ty.path "core::option::Option") [ Ty.path "i128" ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "i128",
                                      "checked_mul",
                                      []
                                    |),
                                    [
                                      M.rust_cast
                                        (M.call_closure (|
                                          M.get_trait_method (|
                                            "core::convert::From",
                                            Ty.path "i16",
                                            [ Ty.path "spl_pod::primitives::PodI16" ],
                                            "from",
                                            []
                                          |),
                                          [
                                            M.read (|
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                                "current_rate"
                                              |)
                                            |)
                                          ]
                                        |));
                                      M.rust_cast
                                        (M.read (|
                                          M.match_operator (|
                                            M.alloc (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::Try",
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    [ Ty.path "i64" ],
                                                  [],
                                                  "branch",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.path
                                                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                                      "post_update_timespan",
                                                      []
                                                    |),
                                                    [ M.read (| self |); M.read (| unix_timestamp |)
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Break",
                                                      0
                                                    |) in
                                                  let residual := M.copy (| γ0_0 |) in
                                                  M.alloc (|
                                                    M.never_to_any (|
                                                      M.read (|
                                                        M.return_ (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::try_trait::FromResidual",
                                                              Ty.apply
                                                                (Ty.path "core::option::Option")
                                                                [ Ty.path "f64" ],
                                                              [
                                                                Ty.apply
                                                                  (Ty.path "core::option::Option")
                                                                  [
                                                                    Ty.path
                                                                      "core::convert::Infallible"
                                                                  ]
                                                              ],
                                                              "from_residual",
                                                              []
                                                            |),
                                                            [ M.read (| residual |) ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)
                                                  |)));
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (let γ0_0 :=
                                                    M.SubPointer.get_struct_tuple_field (|
                                                      γ,
                                                      "core::ops::control_flow::ControlFlow::Continue",
                                                      0
                                                    |) in
                                                  let val := M.copy (| γ0_0 |) in
                                                  val))
                                            ]
                                          |)
                                        |))
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "f64" ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  [ Ty.path "core::convert::Infallible" ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |))
                    |) in
                  let exponent :=
                    M.alloc (|
                      BinOp.Panic.div (|
                        Integer.Usize,
                        BinOp.Panic.div (|
                          Integer.Usize,
                          M.read (| numerator |),
                          M.read (|
                            M.get_constant (|
                              "spl_token_2022::extension::interest_bearing_mint::SECONDS_PER_YEAR"
                            |)
                          |)
                        |),
                        M.read (|
                          M.get_constant (|
                            "spl_token_2022::extension::interest_bearing_mint::ONE_IN_BASIS_POINTS"
                          |)
                        |)
                      |)
                    |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::option::Option::Some"
                      [
                        M.call_closure (|
                          M.get_associated_function (| Ty.path "f64", "exp", [] |),
                          [ M.read (| exponent |) ]
                        |)
                      ]
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_post_update_exp :
        M.IsAssociatedFunction Self "post_update_exp" post_update_exp.
      
      (*
          fn total_scale(&self, decimals: u8, unix_timestamp: i64) -> Option<f64> {
              Some(
                  self.pre_update_exp()? * self.post_update_exp(unix_timestamp)?
                      / 10_f64.powi(decimals as i32),
              )
          }
      *)
      Definition total_scale (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; decimals; unix_timestamp ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let decimals := M.alloc (| decimals |) in
            let unix_timestamp := M.alloc (| unix_timestamp |) in
            M.catch_return (|
              ltac:(M.monadic
                (Value.StructTuple
                  "core::option::Option::Some"
                  [
                    BinOp.Panic.div (|
                      Integer.Usize,
                      BinOp.Panic.mul (|
                        Integer.Usize,
                        M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply (Ty.path "core::option::Option") [ Ty.path "f64" ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path
                                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                      "pre_update_exp",
                                      []
                                    |),
                                    [ M.read (| self |) ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "f64" ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  [ Ty.path "core::convert::Infallible" ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |),
                        M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply (Ty.path "core::option::Option") [ Ty.path "f64" ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path
                                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                      "post_update_exp",
                                      []
                                    |),
                                    [ M.read (| self |); M.read (| unix_timestamp |) ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "f64" ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  [ Ty.path "core::convert::Infallible" ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |)
                      |),
                      M.call_closure (|
                        M.get_associated_function (| Ty.path "f64", "powi", [] |),
                        [ M.read (| UnsupportedLiteral |); M.rust_cast (M.read (| decimals |)) ]
                      |)
                    |)
                  ]))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_total_scale : M.IsAssociatedFunction Self "total_scale" total_scale.
      
      (*
          pub fn amount_to_ui_amount(
              &self,
              amount: u64,
              decimals: u8,
              unix_timestamp: i64,
          ) -> Option<String> {
              let scaled_amount_with_interest =
                  (amount as f64) * self.total_scale(decimals, unix_timestamp)?;
              Some(scaled_amount_with_interest.to_string())
          }
      *)
      Definition amount_to_ui_amount (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; amount; decimals; unix_timestamp ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let amount := M.alloc (| amount |) in
            let decimals := M.alloc (| decimals |) in
            let unix_timestamp := M.alloc (| unix_timestamp |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let scaled_amount_with_interest :=
                    M.alloc (|
                      BinOp.Panic.mul (|
                        Integer.Usize,
                        M.rust_cast (M.read (| amount |)),
                        M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply (Ty.path "core::option::Option") [ Ty.path "f64" ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path
                                        "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                      "total_scale",
                                      []
                                    |),
                                    [
                                      M.read (| self |);
                                      M.read (| decimals |);
                                      M.read (| unix_timestamp |)
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                [ Ty.path "alloc::string::String" ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::option::Option")
                                                  [ Ty.path "core::convert::Infallible" ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |)
                      |)
                    |) in
                  M.alloc (|
                    Value.StructTuple
                      "core::option::Option::Some"
                      [
                        M.call_closure (|
                          M.get_trait_method (|
                            "alloc::string::ToString",
                            Ty.path "f64",
                            [],
                            "to_string",
                            []
                          |),
                          [ scaled_amount_with_interest ]
                        |)
                      ]
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_amount_to_ui_amount :
        M.IsAssociatedFunction Self "amount_to_ui_amount" amount_to_ui_amount.
      
      (*
          pub fn try_ui_amount_into_amount(
              &self,
              ui_amount: &str,
              decimals: u8,
              unix_timestamp: i64,
          ) -> Result<u64, ProgramError> {
              let scaled_amount = ui_amount
                  .parse::<f64>()
                  .map_err(|_| ProgramError::InvalidArgument)?;
              let amount = scaled_amount
                  / self
                      .total_scale(decimals, unix_timestamp)
                      .ok_or(ProgramError::InvalidArgument)?;
              if amount > (u64::MAX as f64) || amount < (u64::MIN as f64) || amount.is_nan() {
                  Err(ProgramError::InvalidArgument)
              } else {
                  // this is important, if you round earlier, you'll get wrong "inf"
                  // answers
                  Ok(amount.round() as u64)
              }
          }
      *)
      Definition try_ui_amount_into_amount (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; ui_amount; decimals; unix_timestamp ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let ui_amount := M.alloc (| ui_amount |) in
            let decimals := M.alloc (| decimals |) in
            let unix_timestamp := M.alloc (| unix_timestamp |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let scaled_amount :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::result::Result")
                                [
                                  Ty.path "f64";
                                  Ty.path "solana_program::program_error::ProgramError"
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [ Ty.path "f64"; Ty.path "core::num::dec2flt::ParseFloatError"
                                    ],
                                  "map_err",
                                  [
                                    Ty.path "solana_program::program_error::ProgramError";
                                    Ty.function
                                      [ Ty.tuple [ Ty.path "core::num::dec2flt::ParseFloatError" ] ]
                                      (Ty.path "solana_program::program_error::ProgramError")
                                  ]
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "str",
                                      "parse",
                                      [ Ty.path "f64" ]
                                    |),
                                    [ M.read (| ui_amount |) ]
                                  |);
                                  M.closure
                                    (fun γ =>
                                      ltac:(M.monadic
                                        match γ with
                                        | [ α0 ] =>
                                          M.match_operator (|
                                            M.alloc (| α0 |),
                                            [
                                              fun γ =>
                                                ltac:(M.monadic
                                                  (Value.StructTuple
                                                    "solana_program::program_error::ProgramError::InvalidArgument"
                                                    []))
                                            ]
                                          |)
                                        | _ => M.impossible (||)
                                        end))
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            [
                                              Ty.path "u64";
                                              Ty.path "solana_program::program_error::ProgramError"
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              [
                                                Ty.path "core::convert::Infallible";
                                                Ty.path
                                                  "solana_program::program_error::ProgramError"
                                              ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let amount :=
                    M.alloc (|
                      BinOp.Panic.div (|
                        Integer.Usize,
                        M.read (| scaled_amount |),
                        M.read (|
                          M.match_operator (|
                            M.alloc (|
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::try_trait::Try",
                                  Ty.apply
                                    (Ty.path "core::result::Result")
                                    [
                                      Ty.path "f64";
                                      Ty.path "solana_program::program_error::ProgramError"
                                    ],
                                  [],
                                  "branch",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply (Ty.path "core::option::Option") [ Ty.path "f64" ],
                                      "ok_or",
                                      [ Ty.path "solana_program::program_error::ProgramError" ]
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path
                                            "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                          "total_scale",
                                          []
                                        |),
                                        [
                                          M.read (| self |);
                                          M.read (| decimals |);
                                          M.read (| unix_timestamp |)
                                        ]
                                      |);
                                      Value.StructTuple
                                        "solana_program::program_error::ProgramError::InvalidArgument"
                                        []
                                    ]
                                  |)
                                ]
                              |)
                            |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Break",
                                      0
                                    |) in
                                  let residual := M.copy (| γ0_0 |) in
                                  M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        M.return_ (|
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::try_trait::FromResidual",
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                [
                                                  Ty.path "u64";
                                                  Ty.path
                                                    "solana_program::program_error::ProgramError"
                                                ],
                                              [
                                                Ty.apply
                                                  (Ty.path "core::result::Result")
                                                  [
                                                    Ty.path "core::convert::Infallible";
                                                    Ty.path
                                                      "solana_program::program_error::ProgramError"
                                                  ]
                                              ],
                                              "from_residual",
                                              []
                                            |),
                                            [ M.read (| residual |) ]
                                          |)
                                        |)
                                      |)
                                    |)
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::ops::control_flow::ControlFlow::Continue",
                                      0
                                    |) in
                                  let val := M.copy (| γ0_0 |) in
                                  val))
                            ]
                          |)
                        |)
                      |)
                    |) in
                  M.match_operator (|
                    M.alloc (| Value.Tuple [] |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ :=
                            M.use
                              (M.alloc (|
                                LogicalOp.or (|
                                  LogicalOp.or (|
                                    BinOp.Pure.gt
                                      (M.read (| amount |))
                                      (M.rust_cast
                                        (M.read (| M.get_constant (| "core::num::MAX" |) |))),
                                    ltac:(M.monadic
                                      (BinOp.Pure.lt
                                        (M.read (| amount |))
                                        (M.rust_cast
                                          (M.read (| M.get_constant (| "core::num::MIN" |) |)))))
                                  |),
                                  ltac:(M.monadic
                                    (M.call_closure (|
                                      M.get_associated_function (| Ty.path "f64", "is_nan", [] |),
                                      [ M.read (| amount |) ]
                                    |)))
                                |)
                              |)) in
                          let _ :=
                            M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                          M.alloc (|
                            Value.StructTuple
                              "core::result::Result::Err"
                              [
                                Value.StructTuple
                                  "solana_program::program_error::ProgramError::InvalidArgument"
                                  []
                              ]
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (M.alloc (|
                            Value.StructTuple
                              "core::result::Result::Ok"
                              [
                                M.rust_cast
                                  (M.call_closure (|
                                    M.get_associated_function (| Ty.path "f64", "round", [] |),
                                    [ M.read (| amount |) ]
                                  |))
                              ]
                          |)))
                    ]
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_try_ui_amount_into_amount :
        M.IsAssociatedFunction Self "try_ui_amount_into_amount" try_ui_amount_into_amount.
      
      (*
          pub fn time_weighted_average_rate(&self, current_timestamp: i64) -> Option<i16> {
              let initialization_timestamp = i64::from(self.initialization_timestamp) as i128;
              let last_update_timestamp = i64::from(self.last_update_timestamp) as i128;
      
              let r_1 = i16::from(self.pre_update_average_rate) as i128;
              let t_1 = last_update_timestamp.checked_sub(initialization_timestamp)?;
              let r_2 = i16::from(self.current_rate) as i128;
              let t_2 = (current_timestamp as i128).checked_sub(last_update_timestamp)?;
              let total_timespan = t_1.checked_add(t_2)?;
              let average_rate = if total_timespan == 0 {
                  // happens in testing situations, just use the new rate since the earlier
                  // one was never practically used
                  r_2
              } else {
                  r_1.checked_mul(t_1)?
                      .checked_add(r_2.checked_mul(t_2)?)?
                      .checked_div(total_timespan)?
              };
              average_rate.try_into().ok()
          }
      *)
      Definition time_weighted_average_rate (τ : list Ty.t) (α : list Value.t) : M :=
        match τ, α with
        | [], [ self; current_timestamp ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let current_timestamp := M.alloc (| current_timestamp |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let initialization_timestamp :=
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_trait_method (|
                            "core::convert::From",
                            Ty.path "i64",
                            [ Ty.path "spl_pod::primitives::PodI64" ],
                            "from",
                            []
                          |),
                          [
                            M.read (|
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                "initialization_timestamp"
                              |)
                            |)
                          ]
                        |))
                    |) in
                  let last_update_timestamp :=
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_trait_method (|
                            "core::convert::From",
                            Ty.path "i64",
                            [ Ty.path "spl_pod::primitives::PodI64" ],
                            "from",
                            []
                          |),
                          [
                            M.read (|
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                "last_update_timestamp"
                              |)
                            |)
                          ]
                        |))
                    |) in
                  let r_1 :=
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_trait_method (|
                            "core::convert::From",
                            Ty.path "i16",
                            [ Ty.path "spl_pod::primitives::PodI16" ],
                            "from",
                            []
                          |),
                          [
                            M.read (|
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                "pre_update_average_rate"
                              |)
                            |)
                          ]
                        |))
                    |) in
                  let t_1 :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply (Ty.path "core::option::Option") [ Ty.path "i128" ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (| Ty.path "i128", "checked_sub", [] |),
                                [
                                  M.read (| last_update_timestamp |);
                                  M.read (| initialization_timestamp |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            [ Ty.path "i16" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let r_2 :=
                    M.alloc (|
                      M.rust_cast
                        (M.call_closure (|
                          M.get_trait_method (|
                            "core::convert::From",
                            Ty.path "i16",
                            [ Ty.path "spl_pod::primitives::PodI16" ],
                            "from",
                            []
                          |),
                          [
                            M.read (|
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig",
                                "current_rate"
                              |)
                            |)
                          ]
                        |))
                    |) in
                  let t_2 :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply (Ty.path "core::option::Option") [ Ty.path "i128" ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (| Ty.path "i128", "checked_sub", [] |),
                                [
                                  M.rust_cast (M.read (| current_timestamp |));
                                  M.read (| last_update_timestamp |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            [ Ty.path "i16" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let total_timespan :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply (Ty.path "core::option::Option") [ Ty.path "i128" ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (| Ty.path "i128", "checked_add", [] |),
                                [ M.read (| t_1 |); M.read (| t_2 |) ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            [ Ty.path "i16" ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  let average_rate :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    BinOp.Pure.eq (M.read (| total_timespan |)) (Value.Integer 0)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              r_2));
                          fun γ =>
                            ltac:(M.monadic
                              (M.match_operator (|
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::try_trait::Try",
                                      Ty.apply (Ty.path "core::option::Option") [ Ty.path "i128" ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.path "i128",
                                          "checked_div",
                                          []
                                        |),
                                        [
                                          M.read (|
                                            M.match_operator (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::try_trait::Try",
                                                    Ty.apply
                                                      (Ty.path "core::option::Option")
                                                      [ Ty.path "i128" ],
                                                    [],
                                                    "branch",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.path "i128",
                                                        "checked_add",
                                                        []
                                                      |),
                                                      [
                                                        M.read (|
                                                          M.match_operator (|
                                                            M.alloc (|
                                                              M.call_closure (|
                                                                M.get_trait_method (|
                                                                  "core::ops::try_trait::Try",
                                                                  Ty.apply
                                                                    (Ty.path "core::option::Option")
                                                                    [ Ty.path "i128" ],
                                                                  [],
                                                                  "branch",
                                                                  []
                                                                |),
                                                                [
                                                                  M.call_closure (|
                                                                    M.get_associated_function (|
                                                                      Ty.path "i128",
                                                                      "checked_mul",
                                                                      []
                                                                    |),
                                                                    [
                                                                      M.read (| r_1 |);
                                                                      M.read (| t_1 |)
                                                                    ]
                                                                  |)
                                                                ]
                                                              |)
                                                            |),
                                                            [
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ0_0 :=
                                                                    M.SubPointer.get_struct_tuple_field (|
                                                                      γ,
                                                                      "core::ops::control_flow::ControlFlow::Break",
                                                                      0
                                                                    |) in
                                                                  let residual :=
                                                                    M.copy (| γ0_0 |) in
                                                                  M.alloc (|
                                                                    M.never_to_any (|
                                                                      M.read (|
                                                                        M.return_ (|
                                                                          M.call_closure (|
                                                                            M.get_trait_method (|
                                                                              "core::ops::try_trait::FromResidual",
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::option::Option")
                                                                                [ Ty.path "i16" ],
                                                                              [
                                                                                Ty.apply
                                                                                  (Ty.path
                                                                                    "core::option::Option")
                                                                                  [
                                                                                    Ty.path
                                                                                      "core::convert::Infallible"
                                                                                  ]
                                                                              ],
                                                                              "from_residual",
                                                                              []
                                                                            |),
                                                                            [ M.read (| residual |)
                                                                            ]
                                                                          |)
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)));
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ0_0 :=
                                                                    M.SubPointer.get_struct_tuple_field (|
                                                                      γ,
                                                                      "core::ops::control_flow::ControlFlow::Continue",
                                                                      0
                                                                    |) in
                                                                  let val := M.copy (| γ0_0 |) in
                                                                  val))
                                                            ]
                                                          |)
                                                        |);
                                                        M.read (|
                                                          M.match_operator (|
                                                            M.alloc (|
                                                              M.call_closure (|
                                                                M.get_trait_method (|
                                                                  "core::ops::try_trait::Try",
                                                                  Ty.apply
                                                                    (Ty.path "core::option::Option")
                                                                    [ Ty.path "i128" ],
                                                                  [],
                                                                  "branch",
                                                                  []
                                                                |),
                                                                [
                                                                  M.call_closure (|
                                                                    M.get_associated_function (|
                                                                      Ty.path "i128",
                                                                      "checked_mul",
                                                                      []
                                                                    |),
                                                                    [
                                                                      M.read (| r_2 |);
                                                                      M.read (| t_2 |)
                                                                    ]
                                                                  |)
                                                                ]
                                                              |)
                                                            |),
                                                            [
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ0_0 :=
                                                                    M.SubPointer.get_struct_tuple_field (|
                                                                      γ,
                                                                      "core::ops::control_flow::ControlFlow::Break",
                                                                      0
                                                                    |) in
                                                                  let residual :=
                                                                    M.copy (| γ0_0 |) in
                                                                  M.alloc (|
                                                                    M.never_to_any (|
                                                                      M.read (|
                                                                        M.return_ (|
                                                                          M.call_closure (|
                                                                            M.get_trait_method (|
                                                                              "core::ops::try_trait::FromResidual",
                                                                              Ty.apply
                                                                                (Ty.path
                                                                                  "core::option::Option")
                                                                                [ Ty.path "i16" ],
                                                                              [
                                                                                Ty.apply
                                                                                  (Ty.path
                                                                                    "core::option::Option")
                                                                                  [
                                                                                    Ty.path
                                                                                      "core::convert::Infallible"
                                                                                  ]
                                                                              ],
                                                                              "from_residual",
                                                                              []
                                                                            |),
                                                                            [ M.read (| residual |)
                                                                            ]
                                                                          |)
                                                                        |)
                                                                      |)
                                                                    |)
                                                                  |)));
                                                              fun γ =>
                                                                ltac:(M.monadic
                                                                  (let γ0_0 :=
                                                                    M.SubPointer.get_struct_tuple_field (|
                                                                      γ,
                                                                      "core::ops::control_flow::ControlFlow::Continue",
                                                                      0
                                                                    |) in
                                                                  let val := M.copy (| γ0_0 |) in
                                                                  val))
                                                            ]
                                                          |)
                                                        |)
                                                      ]
                                                    |)
                                                  ]
                                                |)
                                              |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Break",
                                                        0
                                                      |) in
                                                    let residual := M.copy (| γ0_0 |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          M.return_ (|
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::try_trait::FromResidual",
                                                                Ty.apply
                                                                  (Ty.path "core::option::Option")
                                                                  [ Ty.path "i16" ],
                                                                [
                                                                  Ty.apply
                                                                    (Ty.path "core::option::Option")
                                                                    [
                                                                      Ty.path
                                                                        "core::convert::Infallible"
                                                                    ]
                                                                ],
                                                                "from_residual",
                                                                []
                                                              |),
                                                              [ M.read (| residual |) ]
                                                            |)
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ0_0 :=
                                                      M.SubPointer.get_struct_tuple_field (|
                                                        γ,
                                                        "core::ops::control_flow::ControlFlow::Continue",
                                                        0
                                                      |) in
                                                    let val := M.copy (| γ0_0 |) in
                                                    val))
                                              ]
                                            |)
                                          |);
                                          M.read (| total_timespan |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::ops::control_flow::ControlFlow::Break",
                                          0
                                        |) in
                                      let residual := M.copy (| γ0_0 |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::try_trait::FromResidual",
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    [ Ty.path "i16" ],
                                                  [
                                                    Ty.apply
                                                      (Ty.path "core::option::Option")
                                                      [ Ty.path "core::convert::Infallible" ]
                                                  ],
                                                  "from_residual",
                                                  []
                                                |),
                                                [ M.read (| residual |) ]
                                              |)
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ0_0 :=
                                        M.SubPointer.get_struct_tuple_field (|
                                          γ,
                                          "core::ops::control_flow::ControlFlow::Continue",
                                          0
                                        |) in
                                      let val := M.copy (| γ0_0 |) in
                                      val))
                                ]
                              |)))
                        ]
                      |)
                    |) in
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::result::Result")
                          [ Ty.path "i16"; Ty.path "core::num::error::TryFromIntError" ],
                        "ok",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::convert::TryInto",
                            Ty.path "i128",
                            [ Ty.path "i16" ],
                            "try_into",
                            []
                          |),
                          [ M.read (| average_rate |) ]
                        |)
                      ]
                    |)
                  |)
                |)))
            |)))
        | _, _ => M.impossible
        end.
      
      Axiom AssociatedFunction_time_weighted_average_rate :
        M.IsAssociatedFunction Self "time_weighted_average_rate" time_weighted_average_rate.
    End Impl_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
    
    Module Impl_spl_token_2022_extension_Extension_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
      Definition Self : Ty.t :=
        Ty.path "spl_token_2022::extension::interest_bearing_mint::InterestBearingConfig".
      
      (*     const TYPE: ExtensionType = ExtensionType::InterestBearingConfig; *)
      (* Ty.path "spl_token_2022::extension::ExtensionType" *)
      Definition value_TYPE : Value.t :=
        M.run
          ltac:(M.monadic
            (M.alloc (|
              Value.StructTuple "spl_token_2022::extension::ExtensionType::InterestBearingConfig" []
            |))).
      
      Axiom Implements :
        M.IsTraitInstance
          "spl_token_2022::extension::Extension"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("value_TYPE", InstanceField.Constant value_TYPE) ].
    End Impl_spl_token_2022_extension_Extension_for_spl_token_2022_extension_interest_bearing_mint_InterestBearingConfig.
  End interest_bearing_mint.
End extension.
