Closed matteolimberto-da closed 2 years ago
Please, note that this change make the exercise
function stop the recursion when an election is made (same change as in https://github.com/digital-asset/contingent-claims/pull/74) in order to avoid the bug described in the linked PR. The same considerations apply.
Something I forgot to mention in the main comment is that before this refactoring we were forced to consume the Cond
node in the acquire'
function (for the reason explained in https://github.com/digital-asset/contingent-claims/pull/65).
Now, this is no longer the case and acquire'
does not necessarily have to remove the Cond
node. By not consuming Cond
we avoid creating an additional version of the instrument on the ledger. This might be the object of a subsequent PR.
This is a slight refactoring of the lifecycle code, where I tried to remove some complexity from the process.
Specifically, the
acquire
function wouldCond
nodes and fix acquisition time of stochasticWhen
sEither
and the sub-contracts' acquisition timeFollowing the refactoring, acquire' takes care only of steps 2 and 3 (the "business logic"), which in my opinion simplifies it. It also maintains clear separation between
c
c
The exercise, lifecycle and expire functions take as input an "acquired claim" (that is, a claim where we know if we acquire its sub-contracts and at which time).
The change puts us in a position to separate the acquire into an effectful part and a non-effectful one. I am planning to use the latter as part of the valuation semantics (to propagate a potentially-stochastic acquisition time).
Happy to hear your feedback.