Cip 0105 basic sv locks - #6815
Conversation
meiersi-da
left a comment
There was a problem hiding this comment.
Thanks. Seems a bit too WIP for an in-depth review.
| -- in later standards, or on a case-by-case basis between the caller and the | ||
| -- implementer of the interface. | ||
| deriving (Show, Eq) | ||
| deriving (Show, Eq, Serializable) |
There was a problem hiding this comment.
Something is off here. This is part of the commits from staging-0.8.0.
There was a problem hiding this comment.
I don't see it at
https://github.com/canton-network/splice/blob/staging-0.8.0/token-standard/splice-api-token-metadata-v1/daml/Splice/Api/Token/MetadataV1.daml#L84
at least; according to @dbzguy56 the compiler was complaining if it wasn't added, but whether that should be happening is a different question.
There was a problem hiding this comment.
Yeah that was definitely a mistake, I think there were complaints in other areas. Maybe I mistakenly thought it was there. Reverted
There was a problem hiding this comment.
You are right. Explicit serializability is not enabled for that file:https://github.com/canton-network/splice/blob/staging-0.8.0/token-standard/splice-api-token-metadata-v1/daml.yaml, which is fine.
2a751c3 to
8d5135f
Compare
cb1c7f8 to
696ee53
Compare
| values : TextMap Text | ||
| -- ^ Key-value pairs of metadata entries. | ||
| deriving (Eq,Ord, Show) | ||
| deriving (Eq, Ord, Show) |
There was a problem hiding this comment.
this change would be good, but we try to avoid interface changes when possible. Let's revert this one.
| typeKey : Text | ||
| typeKey = "cip-105/type" | ||
| beneficiaryKey : Text | ||
| beneficiaryKey = "cip-105/lockBeneficiary" | ||
| startDateKey : Text | ||
| startDateKey = "cip-105/startDate" | ||
| endDateKey : Text | ||
| endDateKey = "cip-105/endDate" | ||
| initialAmountKey : Text | ||
| initialAmountKey = "cip-105/initialAmount" | ||
| effectiveAtKey : Text | ||
| effectiveAtKey = "cip-105/effectiveAt" | ||
|
|
||
|
|
||
| unlockControllerKey : Text | ||
| unlockControllerKey = "cip-105/unlockControllers" | ||
| withdrawControllerKey : Text | ||
| withdrawControllerKey = "cip-105/withdrawControllers" | ||
| substituteControllerKey : Text | ||
| substituteControllerKey = "cip-105/substituteControllers" |
There was a problem hiding this comment.
nit: please add newlines between the definitions as done in all other files. Also share the prefix and use kebab-case as done for the other metadata keys.
| typeKey : Text | ||
| typeKey = "cip-105/type" | ||
| beneficiaryKey : Text | ||
| beneficiaryKey = "cip-105/lockBeneficiary" |
| expireLockKey : Text | ||
| expireLockKey = "expire-lock" | ||
|
|
||
|
|
|
|
||
| -- TODO: Potentially make return type, it's own data type? | ||
| calculateAvailableWithdrawAmount : Time -> VestingLock -> Decimal -> (Decimal, Decimal) | ||
| calculateAvailableWithdrawAmount currentDateTime (VestingLock {..}) nextIterationFundAmount = max (0.0, 0.0) availAmount |
There was a problem hiding this comment.
why the max here? Can we inline it into the computation of availAmount?
| && all (\a -> any (a ==) set) actors | ||
|
|
||
|
|
||
| -- This will also need to get a configuration template to set the vesting period and potentially other settings. |
There was a problem hiding this comment.
That needs to be passed in via ExternalPartyConfigState.
| checkControllerSpecification arg.actors $ fromOptional (defaultControllerSpecification ownerParty) lock.controllers.unlock | ||
|
|
||
| now <- getFromContextU arg.extraArgs.context effectiveAtKey -- FIXME: read from metadata not context. | ||
| isLedgerTimeLE now >>= require "effectiveAt must not be in the past" |
There was a problem hiding this comment.
use assertWithinDeadline
| let endDate = getEndTime now | ||
| transferLegId = "unlock" | ||
|
|
||
| let alternateAmount = TM.lookup "cip-105/withdraw-amount" arg.extraArgs.meta.values >>= parseDecimal |
There was a problem hiding this comment.
I'd suggest that we define types for the choices that we are effectively implementing and use our normal metadata parsing machinery to parse them.
There was a problem hiding this comment.
Should be doing this as a TODO within latest PR here: #6894
| controllers = lock.controllers | ||
|
|
||
| -- Not easy to call directly into amulet_allocationFactoryV2_allocateImpl or the like here as that would make a circular dependency. | ||
| (withdrawTo : ContractId a, _) <- createUnfundedGovernanceAllocation vestingGovernanceLock $ V2.AllocationFactory_Allocate with |
There was a problem hiding this comment.
@jonored @dbzguy56 : I have the nagging suspicion that we are better off implementing our own templates to represent governance locks, and only using the TSv2 interfaces as a tool to provide a smooth wallet integration. In that case, I'd even go as far as defining internal choices that implement the actual logic, and call them from the interface implementation.
This way we significantly simplify reasoning about the implementation, and avoid polluting the implementation of AmuletAllocationV2 with the concerns of governance locks.
Side note: when I originally proposed to use the "TSv2 allocations" I was thinking about the wallet integration, and less about piggy-backing on AmuletAllocationV2. I was though less clear about it than I am now after having written the high-level implementation spec. Let's dicsuss in our sync.
There was a problem hiding this comment.
Doing that at #6894 - broadly intending to move features over to there in the "incremental delivery" order unless otherwise requested. As noted this and implementing the V2 interfaces for maximum compatibility does align well with our original intentions for our POC approach.
| -- Governance Lock support | ||
| -- ======================= | ||
|
|
||
| template GovernanceLockProposal with |
There was a problem hiding this comment.
can we move this out into the GovernanceLock module?
There was a problem hiding this comment.
Also: do we even need that? The new spec is based on creating locks directly. This should only be used for substitutions.
There was a problem hiding this comment.
I believe you are right, removed this template and portion
WIP, the plan is to have commits be squashed.
Pull Request Checklist
Cluster Testing
/cluster_teston this PR to request it, and ping someone with access to the DA-internal system to approve it./upgrade_teston this PR to request it, and ping someone with access to the DA-internal system to approve it./hdm_teston this PR to request it, and ping someone with access to the DA-internal system to approve it./lsu_teston this PR to request it, and ping someone with access to the DA-internal system to approve it.PR Guidelines
Fixes #n, and mention issues worked on using#nMerge Guidelines