[M1: Audit 2: L-10]: CIP112: Add merge and split choices on holdings and document rebalancing

Open
#94 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
blockchain
Domain
blockchain

Research direction

Start by reading packages/token/token-cip112-v1/daml/OpenZeppelin/Token/Cip112/V1/Holding.daml and the reusable function area in packages/token/token-cip112-utils; then inspect the MyHolding choices in examples/token/token-cip112-custom/daml/OpenZeppelin/Examples/Token/Cip112/Custom.daml. Done means merge and split enforce the stated account, instrument, lock, value-conservation and freeze rules, emit the specified event, and the README and integration guide document rebalancing and policy limitations.

Written by the indexing model from the issue text.

Description

Addresses L-10

Changes

Code:

  • Add merge and split choices to TokenHolding. The account parties control them, and the body is a reusable function in token-cip112-utils. They should conserve value, accept only same-account, same-instrument inputs, reject live-locked inputs, and emit a holdings-change event with no transfer legs.
  • Reject any lock, even an expired one, on the holding the choice is exercised on. Its lock holders would otherwise witness the whole merge, including the account's other holdings and the consolidated amount.
  • Add the choices to MyHolding in Custom.daml with a freeze check. Without it, merging a frozen holding would unfreeze it. Related #82

Documentation:

  • The token-cip112-v1 README.md and integration-guide.md should describe rebalancing through the new choices and through a self-transfer. Wallets that only use the HoldingV2.Holding interface cannot see template choices, as with TokenHolding_OwnerUnlock.
  • The README.md should state that merges and splits bypass the registry's transfer policy, so they cannot be gated, charged or paused.
  • The utils documentation should state that custom templates must apply their own spend rules, such as a freeze, to the holding the choice is exercised on.
Dominant language
Haskell
Stars
5
Forks
0
Avg merge
1d 36m
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenZeppelin/canton-contracts

All issues in OpenZeppelin/canton-contracts

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.