What I was trying to do
Model TermMaxOrderV2._swapAndUpdateReserves, which takes a function pointer:
// contracts/v2/TermMaxOrderV2.sol:859-867
function _swapAndUpdateReserves(
uint256 tokenAmtInOrOut,
uint256 limitTokenAmt,
OrderConfig memory orderConfig_,
function(
uint256,
uint256,
OrderConfig memory) internal view returns (uint256, uint256, uint256, uint256, bool) func
) private returns (uint256, uint256, int256, int256) {
(uint256 netAmt, uint256 feeAmt, uint256 deltaFt, uint256 deltaXt, bool isNegetiveXt) =
func(tokenAmtInOrOut, limitTokenAmt, orderConfig_);
...
}
https://github.com/term-structure/termmax-contract-v2/blob/64bd47b98e064c7fb91ab4a59b70520e0ec285d5/contracts/v2/TermMaxOrderV2.sol#L859-L884
What I tried
import Contracts.Common
open Verity hiding pure bind
open Verity.EVM.Uint256
verity_contract FnPtrRepro where
storage dummy : Uint256 := slot 0
function addOne (x : Uint256) : Uint256 := do
return (add x 1)
function apply (f : Uint256 -> Uint256, x : Uint256) : Uint256 := do
return (f x)
Why it failed
Verity/Macro/Translate.lean:242 rejects function-typed parameters:
unsupported type 'Uint256 -> Uint256'; expected Uint256, Int256, Uint8,
Address, Bytes32, Bool, String, Bytes, Array <type>, Tuple [...], Unit,
or a user-defined type from the `types` or `inductive` section
Even if the parameter type were accepted, the bind-source checker at
Verity/Macro/Translate.lean:1889 rejects let x ← f ... whose source is
not getStorage or a direct internal helper call:
unsupported bind source; expected getStorage/getStorageAddr/...
or a direct internal helper call
Reproduces on Verity 74d8fe20ffa2f5dbb94959f3dd40a62df6aa8224 (release
v1.0.0).
What I was trying to do
Model
TermMaxOrderV2._swapAndUpdateReserves, which takes a function pointer:https://github.com/term-structure/termmax-contract-v2/blob/64bd47b98e064c7fb91ab4a59b70520e0ec285d5/contracts/v2/TermMaxOrderV2.sol#L859-L884
What I tried
Why it failed
Verity/Macro/Translate.lean:242rejects function-typed parameters:Even if the parameter type were accepted, the bind-source checker at
Verity/Macro/Translate.lean:1889rejectslet x ← f ...whose source isnot
getStorageor a direct internal helper call:Reproduces on Verity
74d8fe20ffa2f5dbb94959f3dd40a62df6aa8224(releasev1.0.0).