diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c5c491bc..402bb125a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,6 +67,7 @@ commands: - /home/circleci/.nix-channels - /home/circleci/.nix-defexpr - /home/circleci/.config/nix + import_gpg_key: description: "Setup GPG for signing artifacts as part of a release" steps: @@ -272,11 +273,13 @@ jobs: command: | set -euo pipefail + SDK_VERSION="$(yq e '.sdk-version' daml.yaml)" + echo "Persisting DPM environment variables..." echo "export REPO_ROOT=$(pwd)" >> $BASH_ENV echo "export DPM_REGISTRY=europe-docker.pkg.dev/da-images/public-all" >> $BASH_ENV echo "export DPM_HOME=$(pwd)/.dpm" >> $BASH_ENV - echo "export DPM_SDK_VERSION=3.4.9" >> $BASH_ENV + echo "export DPM_SDK_VERSION=${SDK_VERSION}" >> "$BASH_ENV" echo "Configure DPM environment complete." - run: @@ -371,10 +374,28 @@ jobs: - run: name: Build Packell command: | + echo "Building Packell with nix-build" nix-shell tools/packell/default.nix --run 'echo "Done building Packell."' - cp /nix/store/*packell*/bin/packell . + cp /nix/store/*packell-*/bin/packell . + + # Verify Packell works + - run: + name: Verify Packell binary + command: | + echo "[Packell] Running packell --help" + ./packell --help + + # Create tar.gz + - run: + name: Package packell into tar.gz + command: | + mkdir packell-linux + cp ./packell packell-linux/ + tar -czvf packell-x86_64-linux.tar.gz packell-linux + + # Upload tar.gz artifact - store_artifacts: - path: packell + path: packell-x86_64-linux.tar.gz workflows: version: 2 diff --git a/.envrc b/.envrc index 177f0fe07..dc49fa591 100644 --- a/.envrc +++ b/.envrc @@ -5,6 +5,20 @@ PATH_add bin # --- DPM configuration --- export REPO_ROOT=$(pwd) +export DPM_HOME="$REPO_ROOT/.dpm" export DPM_REGISTRY="europe-docker.pkg.dev/da-images/public-all" -export DPM_HOME="${REPO_ROOT}/.dpm/" -export DPM_SDK_VERSION="3.4.9" \ No newline at end of file + +# Single source of truth: daml.yaml +export DPM_SDK_VERSION="$(yq e '.sdk-version' daml.yaml)" + +# Ensure SDK is present in repo-local DPM_HOME +if command -v dpm >/dev/null 2>&1; then + if ! dpm version --all -o json 2>/dev/null \ + | jq -e --arg v "$DPM_SDK_VERSION" \ + 'any(.[]; .version == $v and .installed == true)' \ + >/dev/null 2>&1 + then + echo "Installing DPM SDK $DPM_SDK_VERSION into $DPM_HOME..." + dpm install "$DPM_SDK_VERSION" + fi +fi \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4ec0d48e5..983917960 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,15 @@ *.log **/.DS_Store .cache/ -.lib/ + +# Ignore .lib by default +.lib/* +# Allow required subfolders +!.lib/splice/ +!.lib/splice/* +!.lib/daml-ctl/ +!.lib/daml-ctl/* + .dars/ .vscode/ docs/build/ @@ -14,3 +22,4 @@ __pycache__ .bundle/ .idea log/ +.lib/ diff --git a/Makefile b/Makefile index 22b942353..b485d92e9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ SCRIPTS_DIR := scripts - -########################## -# Project Source (./src) # +########################## +# Project (workspace) # ########################## .PHONY: install @@ -10,11 +9,11 @@ install: .PHONY: build build: install - dpm build + dpm build --all .PHONY: test test: build - dpm test + dpm test --all .PHONY: clean clean: @@ -53,8 +52,8 @@ validate-packages: build-packages update-packages: git fetch packell versioning update - packell data-dependencies update make headers-update +# Remove: packell data-dependencies update ############################### # Project Source and Packages # @@ -64,10 +63,11 @@ update-packages: build-all: build build-packages .PHONY: test-all -test-all: test test-packages +test-all: build + make ci-test .PHONY: clean-all -clean-all: clean clean-packages clean-docs +clean-all: clean clean-packages clean-docs clean-cache .PHONY: generate-docs generate-docs: doc-code @@ -110,7 +110,7 @@ ci-build-js: --run 'dpm codegen-js -o .dars/.js .dars/*' # Find all test projects that contain a daml.yaml in BOTH locations: -daml-test-projects := $(shell find package/test src/test -maxdepth 6 -name daml.yaml -exec dirname {} \; 2>/dev/null) +daml-test-projects := $(shell find package/test -maxdepth 6 -name daml.yaml -exec dirname {} \; 2>/dev/null) .PHONY: ci-test ci-test: @@ -193,25 +193,31 @@ headers-update: # Documentation Generation # ############################ -DAML_SRC := $(shell find src/main/daml -name '*.daml') +DAML_SRC := $(shell \ + find package/main/daml \ + -path '*/.daml' -prune -o \ + -name '*.daml' -print) SDK_VERSION := $(shell yq e '.sdk-version' daml.yaml) +DPM_HOME ?= $(HOME)/.dpm DAML_ROOT := $(shell if [ -z ${DAML_HOME} ]; then echo ~/.daml; else echo ${DAML_HOME}; fi) -DPM_HOME := $(shell if [ -z $${DPM_HOME} ]; then echo $$HOME/.dpm; else echo $${DPM_HOME}; fi) +DOCS_BUILD_DIR := docs/build .PHONY: doc-code-json -doc-code-json: $(DAML_SRC) +doc-code-json: build + @mkdir -p $(DOCS_BUILD_DIR) dpm docs \ - --output=docs/build/daml-finance.json \ + --combine \ --package-name=daml-finance \ --format Json \ - $(DAML_SRC) + --output=$(DOCS_BUILD_DIR)/daml-finance.json \ + $(DAML_SRC) .PHONY: doc-code doc-code: doc-code-json dpm docs \ - --output=docs/build/daml-finance-rst \ - --output-hoogle=docs/build/daml-finance-hoogle.txt \ + --output=$(DOCS_BUILD_DIR)/daml-finance-rst \ + --output-hoogle=$(DOCS_BUILD_DIR)/daml-finance-hoogle.txt \ --input-format=json \ --format=Rst \ --exclude-instances=HasField,HasImplementation,HasFromInterface,HasToInterface,HasInterfaceView,HasExercise,HasExerciseGuarded,HasFromAnyChoice,HasToAnyChoice \ @@ -221,9 +227,10 @@ doc-code: doc-code-json --hoogle-template=docs/code-documentation-templates/base-hoogle-template.txt \ --base-url=https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst \ --input-anchor=$(DAML_ROOT)/sdk/$(SDK_VERSION)/damlc/resources/daml-base-anchors.json \ - docs/build/daml-finance.json - + $(DOCS_BUILD_DIR)/daml-finance.json + @echo "Daml Finance documentation generated successfully" .PHONY: clean-docs clean-docs: ./$(SCRIPTS_DIR)/clean-docs.sh + \ No newline at end of file diff --git a/README.md b/README.md index 0808ca35f..989731630 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,20 @@ When developing please adhere to the [style guide](./STYLEGUIDE.md). ### Releases To perform a release of this project, please follow the guide [here](./RELEASE.MD). + +## Important Compatibility Notice (Canton Network) +The `main` branch of this repository currently targets **Daml SDK 3.x** and uses an **unstable Ledger Fragment (LF) version (`2.dev`)**. + +As a result: + +- Artifacts built from `main` cannot be deployed to the Canton Network / MainNet +- They are not compatible with any production Canton deployment +- This setup is intended for development, experimentation, and forward-looking SDK work only + +The use of `LF 2.dev` is required for ongoing development on Daml 3, but is not supported on Canton MainNet, which only accepts stable LF versions. + +### What should I use instead? + +- For production Canton deployments, use a released version of Daml Finance that targets a stable LF version + +This notice will be updated once Daml 3 and its corresponding LF version are fully supported on Canton MainNet. diff --git a/daml.yaml b/daml.yaml index 16ba794be..f219009b4 100644 --- a/daml.yaml +++ b/daml.yaml @@ -7,7 +7,7 @@ # update the hashes. The sdk-version refers to the release folder names (or tags) found here: # https://github.com/digital-asset/daml/releases # For example 2.9.0-rc1 (in case of a release candidate) or 2.8.0 (for a regular release) -sdk-version: 3.4.9 +sdk-version: 3.4.10 # daml-version is not used by the daml assistant, only by the finance nix config # It refers to the version number of the files of the release folder. # For example, if you use a release candidate like: @@ -16,7 +16,7 @@ sdk-version: 3.4.9 # On the other hand, if you use a regular release like: # https://github.com/digital-asset/daml/releases/tag/v2.8.0 # the daml-version would simply be: 2.8.0 -daml-version: 3.4.9 +daml-version: 3.4.10 # To use a custom daml, you must update the sdk-version across the project to that of the tar you have (likely 0.0.0) # daml-version above will be ignored # and uncomment the below tar path to point to your release tar. @@ -26,7 +26,7 @@ daml-version: 3.4.9 # NOTE: This must be an absolute path to the release tarball. # daml-tar-path: /sdk/bazel-bin/release/sdk-release-tarball-ce.tar.gz name: daml-finance -source: src/test/daml +source: daml # version is independent of the actual sdk-version. It is used to create an assembly artifact here # https://digitalasset.jfrog.io/ui/repos/tree/General/assembly/daml-finance which is referenced by # docs.daml.com (in the docs//version.json files). The purpose of having an independent @@ -39,11 +39,10 @@ dependencies: - daml-script data-dependencies: - .lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar - - .lib/splice/splice-api-token-metadata-v1-1.0.0.dar + - lib/splice-api-token-holding-v1-1.0.0.dar + - lib/splice-api-token-metadata-v1-1.0.0.dar build-options: - - --include=src/main/daml - --target=2.dev - -Wno-upgrade-interfaces - -Wno-upgrade-exceptions diff --git a/dev-protocol.conf b/dev-protocol.conf deleted file mode 100644 index 79f3f1728..000000000 --- a/dev-protocol.conf +++ /dev/null @@ -1,6 +0,0 @@ -canton.participants.sandbox.parameters.alpha-version-support = true -canton.sequencers.sequencer1.parameters.alpha-version-support = true -canton.parameters { - non-standard-config = yes - alpha-version-support = yes -} diff --git a/docs/generated/finance-lifecycling/README.md b/docs/generated/finance-lifecycling/README.md index 45c6db186..0316f634c 100644 --- a/docs/generated/finance-lifecycling/README.md +++ b/docs/generated/finance-lifecycling/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance lifecycling tutor Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/generated/finance-lifecycling/daml.yaml b/docs/generated/finance-lifecycling/daml.yaml index 74837e4d0..6c032246d 100644 --- a/docs/generated/finance-lifecycling/daml.yaml +++ b/docs/generated/finance-lifecycling/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-lifecycling source: daml init-script: Scripts.FixedRateBond:runFixedRateBond diff --git a/docs/generated/finance-payoff-modeling/README.md b/docs/generated/finance-payoff-modeling/README.md index dde7bdd60..4a2c763ba 100644 --- a/docs/generated/finance-payoff-modeling/README.md +++ b/docs/generated/finance-payoff-modeling/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance payoff modeling t Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/generated/finance-payoff-modeling/daml.yaml b/docs/generated/finance-payoff-modeling/daml.yaml index ec551d4b0..bbc28e8c3 100644 --- a/docs/generated/finance-payoff-modeling/daml.yaml +++ b/docs/generated/finance-payoff-modeling/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-payoff-modeling source: daml init-script: PayoffBuilder:runCreateAndLifecycle diff --git a/docs/generated/finance-settlement/README.md b/docs/generated/finance-settlement/README.md index 23dfadaed..a62ad2007 100644 --- a/docs/generated/finance-settlement/README.md +++ b/docs/generated/finance-settlement/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance settlement tutori Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/generated/finance-settlement/daml.yaml b/docs/generated/finance-settlement/daml.yaml index 6c6460a7c..a53e95bab 100644 --- a/docs/generated/finance-settlement/daml.yaml +++ b/docs/generated/finance-settlement/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-settlement source: daml init-script: Scripts.Transfer:runDualControlTransfer diff --git a/docs/generated/finance-upgrades/README.md b/docs/generated/finance-upgrades/README.md index 02ca1c349..cd9e0c851 100644 --- a/docs/generated/finance-upgrades/README.md +++ b/docs/generated/finance-upgrades/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance upgrade tutorials Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/generated/finance-upgrades/daml.yaml b/docs/generated/finance-upgrades/daml.yaml index 9fac0d531..bb33ca2ad 100644 --- a/docs/generated/finance-upgrades/daml.yaml +++ b/docs/generated/finance-upgrades/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-upgrades source: daml init-script: Scripts.UpgradeHolding:upgradeHolding diff --git a/docs/generated/overview/intro.rst b/docs/generated/overview/intro.rst index cad2d9f23..6ce90192f 100644 --- a/docs/generated/overview/intro.rst +++ b/docs/generated/overview/intro.rst @@ -108,7 +108,7 @@ This downloads all required packages and builds the project. You can then run: .. code-block:: shell - daml studio + dpm studio to open the code editor and inspect the code. diff --git a/docs/generated/quickstart-finance/README.md b/docs/generated/quickstart-finance/README.md index 710240b93..16f35c18d 100644 --- a/docs/generated/quickstart-finance/README.md +++ b/docs/generated/quickstart-finance/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance getting started t Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/generated/quickstart-finance/daml.yaml b/docs/generated/quickstart-finance/daml.yaml index dad0a25f8..a7bae2d97 100644 --- a/docs/generated/quickstart-finance/daml.yaml +++ b/docs/generated/quickstart-finance/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: quickstart-finance source: daml init-script: Scripts.Transfer:runTransfer diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Holding-V4-Util.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Holding-V4-Util.rst index c1c6f05c6..1a45d43fc 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Holding-V4-Util.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Holding-V4-Util.rst @@ -39,12 +39,3 @@ Functions \: (`HasCreate `_ t, `HasArchive `_ t, `HasSignatory `_ t, `HasFromInterface `_ t :ref:`I `, `HasToInterface `_ t :ref:`I `, `HasToInterface `_ t :ref:`I `) \=\> :ref:`I ` \-\> (t \-\> `Decimal `_) \-\> (`Decimal `_ \-\> t) \-\> :ref:`Merge ` \-\> `Update `_ (`ContractId `_ :ref:`I `) Default implementation of ``merge`` from the ``Fungible`` interface\. - -.. _function-daml-finance-holding-v4-util-toapiholdingview-88985: - -`toApiHoldingView `_ - \: :ref:`View ` \-\> :ref:`InstrumentKey ` \-\> :ref:`AccountKey ` \-\> `Decimal `_ \-\> HoldingView - - Helper to construct the standard Api\.HoldingV1\.HoldingView shared by - BaseHolding, Fungible, Transferable and TransferableFungible implementations\. - Converts internal holding state into the API\-facing representation\. diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Account.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Account.rst index 7d7364573..1e1b117f7 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Account.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Account.rst @@ -145,8 +145,6 @@ Data Types **instance** `Show `_ `Controllers `_ - **instance** `GetField `_ \"controllers\" :ref:`Account ` `Controllers `_ - **instance** `GetField `_ \"controllers\" `View `_ `Controllers `_ **instance** `GetField `_ \"controllers\" :ref:`Create ` `Controllers `_ @@ -155,8 +153,6 @@ Data Types **instance** `GetField `_ \"outgoing\" `Controllers `_ :ref:`Parties ` - **instance** `SetField `_ \"controllers\" :ref:`Account ` `Controllers `_ - **instance** `SetField `_ \"controllers\" `View `_ `Controllers `_ **instance** `SetField `_ \"controllers\" :ref:`Create ` `Controllers `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Util.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Util.rst index fed205e3d..17c509f90 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Util.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Util.rst @@ -9,13 +9,6 @@ Daml.Finance.Interface.Account.V4.Util Functions --------- -.. _function-daml-finance-interface-account-v4-util-fetchaccount-79234: - -`fetchAccount `_ - \: `HasToInterface `_ t Holding \=\> t \-\> `Update `_ :ref:`I ` - - Fetch the account of a holding\. - .. _function-daml-finance-interface-account-v4-util-getaccount-6084: `getAccount `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Claims-V4-Types.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Claims-V4-Types.rst index fd8d48e1d..3e2212804 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Claims-V4-Types.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Claims-V4-Types.rst @@ -18,20 +18,8 @@ Data Types **instance** `GetField `_ \"claim\" `TaggedClaim `_ `C `_ - **instance** `GetField `_ \"claims\" :ref:`Instrument ` `C `_ - - **instance** `GetField `_ \"claims\" :ref:`Create ` `C `_ - - **instance** `GetField `_ \"claims\" :ref:`View ` `C `_ - **instance** `SetField `_ \"claim\" `TaggedClaim `_ `C `_ - **instance** `SetField `_ \"claims\" :ref:`Instrument ` `C `_ - - **instance** `SetField `_ \"claims\" :ref:`Create ` `C `_ - - **instance** `SetField `_ \"claims\" :ref:`View ` `C `_ - .. _type-daml-finance-interface-claims-v4-types-deliverable-51084: **type** `Deliverable `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Base-V4-Instrument.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Base-V4-Instrument.rst index 4c99cbb88..a510b4a6a 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Base-V4-Instrument.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Base-V4-Instrument.rst @@ -209,13 +209,6 @@ Functions Scale ``Quantity`` by the provided factor\. -.. _function-daml-finance-interface-instrument-base-v4-instrument-fetchinstrument-72799: - -`fetchInstrument `_ - \: `HasToInterface `_ t Holding \=\> t \-\> `Update `_ `Instrument `_ - - Fetch instrument from holding\. - .. _function-daml-finance-interface-instrument-base-v4-instrument-exerciseinterfacebykey-98720: `exerciseInterfaceByKey `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Option-V0-Types.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Option-V0-Types.rst index 93dbe6cd9..bcbec1bcc 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Option-V0-Types.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Option-V0-Types.rst @@ -43,12 +43,8 @@ Data Types **instance** `Show `_ `BarrierTypeEnum `_ - **instance** `GetField `_ \"barrierType\" :ref:`Instrument ` `BarrierTypeEnum `_ - **instance** `GetField `_ \"barrierType\" :ref:`BarrierEuropean ` `BarrierTypeEnum `_ - **instance** `SetField `_ \"barrierType\" :ref:`Instrument ` `BarrierTypeEnum `_ - **instance** `SetField `_ \"barrierType\" :ref:`BarrierEuropean ` `BarrierTypeEnum `_ .. _type-daml-finance-interface-instrument-option-v0-types-optiontypeenum-30036: @@ -73,24 +69,12 @@ Data Types **instance** `Show `_ `OptionTypeEnum `_ - **instance** `GetField `_ \"optionType\" :ref:`Instrument ` `OptionTypeEnum `_ - - **instance** `GetField `_ \"optionType\" :ref:`Instrument ` `OptionTypeEnum `_ - - **instance** `GetField `_ \"optionType\" :ref:`Instrument ` `OptionTypeEnum `_ - **instance** `GetField `_ \"optionType\" :ref:`BarrierEuropean ` `OptionTypeEnum `_ **instance** `GetField `_ \"optionType\" :ref:`European ` `OptionTypeEnum `_ **instance** `GetField `_ \"optionType\" :ref:`European ` `OptionTypeEnum `_ - **instance** `SetField `_ \"optionType\" :ref:`Instrument ` `OptionTypeEnum `_ - - **instance** `SetField `_ \"optionType\" :ref:`Instrument ` `OptionTypeEnum `_ - - **instance** `SetField `_ \"optionType\" :ref:`Instrument ` `OptionTypeEnum `_ - **instance** `SetField `_ \"optionType\" :ref:`BarrierEuropean ` `OptionTypeEnum `_ **instance** `SetField `_ \"optionType\" :ref:`European ` `OptionTypeEnum `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Factory.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Factory.rst index 4faad2734..4df23f36b 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Factory.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Factory.rst @@ -63,10 +63,6 @@ Data Types Type synonym for ``Factory``\. - **instance** `GetField `_ \"assetSwapFactoryCid\" :ref:`DistributionRule ` (`ContractId `_ `I `_) - - **instance** `SetField `_ \"assetSwapFactoryCid\" :ref:`DistributionRule ` (`ContractId `_ `I `_) - .. _type-daml-finance-interface-instrument-swap-v0-asset-factory-v-25068: **type** `V `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Types.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Types.rst index a7be1860a..9b449b234 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Types.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Asset-Types.rst @@ -163,8 +163,6 @@ Data Types **instance** `GetField `_ \"referenceAssetId\" `Underlying `_ `Text `_ - **instance** `GetField `_ \"underlyings\" :ref:`Instrument ` \[`Underlying `_\] - **instance** `GetField `_ \"underlyings\" `Asset `_ \[`Underlying `_\] **instance** `GetField `_ \"weight\" `Underlying `_ `Decimal `_ @@ -175,8 +173,6 @@ Data Types **instance** `SetField `_ \"referenceAssetId\" `Underlying `_ `Text `_ - **instance** `SetField `_ \"underlyings\" :ref:`Instrument ` \[`Underlying `_\] - **instance** `SetField `_ \"underlyings\" `Asset `_ \[`Underlying `_\] **instance** `SetField `_ \"weight\" `Underlying `_ `Decimal `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Fpml-FpmlTypes.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Fpml-FpmlTypes.rst index 38eda85a6..d59880262 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Fpml-FpmlTypes.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Swap-V0-Fpml-FpmlTypes.rst @@ -1732,8 +1732,6 @@ Data Types **instance** `GetField `_ \"stubCalculationPeriodAmount\" `SwapStream `_ (`Optional `_ `StubCalculationPeriodAmount `_) - **instance** `GetField `_ \"swapStreams\" :ref:`Instrument ` \[`SwapStream `_\] - **instance** `GetField `_ \"swapStreams\" :ref:`Fpml ` \[`SwapStream `_\] **instance** `SetField `_ \"calculationPeriodAmount\" `SwapStream `_ `CalculationPeriodAmount `_ @@ -1752,6 +1750,4 @@ Data Types **instance** `SetField `_ \"stubCalculationPeriodAmount\" `SwapStream `_ (`Optional `_ `StubCalculationPeriodAmount `_) - **instance** `SetField `_ \"swapStreams\" :ref:`Instrument ` \[`SwapStream `_\] - **instance** `SetField `_ \"swapStreams\" :ref:`Fpml ` \[`SwapStream `_\] diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Types-V2-FloatingRate.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Types-V2-FloatingRate.rst index 60f5c64ed..58367a9bc 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Types-V2-FloatingRate.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Types-V2-FloatingRate.rst @@ -74,44 +74,12 @@ Data Types **instance** `GetField `_ \"fixingDates\" `FloatingRate `_ `FixingDates `_ - **instance** `GetField `_ \"floatingRate\" :ref:`Instrument ` (`Optional `_ `FloatingRate `_) - - **instance** `GetField `_ \"floatingRate\" :ref:`Instrument ` `FloatingRate `_ - - **instance** `GetField `_ \"floatingRate\" :ref:`Instrument ` (`Optional `_ `FloatingRate `_) - - **instance** `GetField `_ \"floatingRate\" :ref:`Instrument ` `FloatingRate `_ - - **instance** `GetField `_ \"floatingRate\" :ref:`Callable ` (`Optional `_ `FloatingRate `_) - - **instance** `GetField `_ \"floatingRate\" :ref:`FloatingRate ` `FloatingRate `_ - - **instance** `GetField `_ \"floatingRate\" :ref:`Asset ` (`Optional `_ `FloatingRate `_) - - **instance** `GetField `_ \"floatingRate\" :ref:`InterestRate ` `FloatingRate `_ - **instance** `GetField `_ \"referenceRateId\" `FloatingRate `_ `Text `_ **instance** `GetField `_ \"referenceRateType\" `FloatingRate `_ `ReferenceRateTypeEnum `_ **instance** `SetField `_ \"fixingDates\" `FloatingRate `_ `FixingDates `_ - **instance** `SetField `_ \"floatingRate\" :ref:`Instrument ` (`Optional `_ `FloatingRate `_) - - **instance** `SetField `_ \"floatingRate\" :ref:`Instrument ` `FloatingRate `_ - - **instance** `SetField `_ \"floatingRate\" :ref:`Instrument ` (`Optional `_ `FloatingRate `_) - - **instance** `SetField `_ \"floatingRate\" :ref:`Instrument ` `FloatingRate `_ - - **instance** `SetField `_ \"floatingRate\" :ref:`Callable ` (`Optional `_ `FloatingRate `_) - - **instance** `SetField `_ \"floatingRate\" :ref:`FloatingRate ` `FloatingRate `_ - - **instance** `SetField `_ \"floatingRate\" :ref:`Asset ` (`Optional `_ `FloatingRate `_) - - **instance** `SetField `_ \"floatingRate\" :ref:`InterestRate ` `FloatingRate `_ - **instance** `SetField `_ \"referenceRateId\" `FloatingRate `_ `Text `_ **instance** `SetField `_ \"referenceRateType\" `FloatingRate `_ `ReferenceRateTypeEnum `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Election.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Election.rst index fa709a9ba..0caeb1437 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Election.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Election.rst @@ -182,8 +182,6 @@ Data Types Type synonym for ``Election``\. - **instance** HasMethod :ref:`Factory ` \"create'\" (:ref:`Create ` \-\> `Update `_ (`ContractId `_ `I `_)) - **instance** HasMethod :ref:`Factory ` \"create'\" (:ref:`Create ` \-\> `Update `_ (`ContractId `_ `I `_)) .. _type-daml-finance-interface-lifecycle-v4-election-v-12910: diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event-Time.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event-Time.rst index b5c67a578..7ae11e523 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event-Time.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event-Time.rst @@ -47,13 +47,6 @@ Interfaces - `Party `_ - The party retrieving the view\. - + **Method advance \:** `ContractId `_ :ref:`Time ` \-\> :ref:`Advance ` \-\> `Update `_ (`ContractId `_ :ref:`Time `, `ContractId `_ `Event `_) - - Implementation of the ``Advance`` choice\. - - + **Method rewind \:** `ContractId `_ :ref:`Time ` \-\> :ref:`Rewind ` \-\> `Update `_ (`ContractId `_ :ref:`Time `, `ContractId `_ `Event `_) - - Implementation of the ``Rewind`` choice\. Data Types ---------- diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event.rst index 48284bfc9..57cdea7c1 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Lifecycle-V4-Event.rst @@ -57,12 +57,6 @@ Data Types Type synonym for ``Event``\. - **instance** HasMethod :ref:`Instrument ` \"declareDistribution\" (:ref:`DeclareDistribution ` \-\> `Update `_ (`ContractId `_ `I `_)) - - **instance** HasMethod :ref:`Instrument ` \"declareReplacement\" (:ref:`DeclareReplacement ` \-\> `Update `_ (`ContractId `_ `I `_)) - - **instance** HasMethod :ref:`Instrument ` \"declareStockSplit\" (:ref:`DeclareStockSplit ` \-\> `Update `_ (`ContractId `_ `I `_)) - **instance** `GetField `_ \"eventCid\" :ref:`Evolve ` (`ContractId `_ `I `_) **instance** `SetField `_ \"eventCid\" :ref:`Evolve ` (`ContractId `_ `I `_) diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Batch.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Batch.rst index 92cf9ccee..e809d8e7d 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Batch.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Batch.rst @@ -109,10 +109,6 @@ Data Types **instance** HasMethod :ref:`Factory ` \"instruct\" (:ref:`Instruct ` \-\> `Update `_ (`ContractId `_ `I `_, \[`ContractId `_ :ref:`I `\])) - **instance** `GetField `_ \"batchCid\" :ref:`ClaimResult ` (`ContractId `_ `I `_) - - **instance** `SetField `_ \"batchCid\" :ref:`ClaimResult ` (`ContractId `_ `I `_) - .. _type-daml-finance-interface-settlement-v4-batch-v-54326: **type** `V `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Factory.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Factory.rst index 0f2fb3fe8..0a9ae1b2d 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Factory.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Factory.rst @@ -102,14 +102,6 @@ Data Types Type synonym for ``Factory``\. - **instance** `GetField `_ \"settlementFactoryCid\" :ref:`View ` (`ContractId `_ `I `_) - - **instance** `GetField `_ \"settlementFactoryCid\" :ref:`Rule ` (`ContractId `_ `I `_) - - **instance** `SetField `_ \"settlementFactoryCid\" :ref:`View ` (`ContractId `_ `I `_) - - **instance** `SetField `_ \"settlementFactoryCid\" :ref:`Rule ` (`ContractId `_ `I `_) - .. _type-daml-finance-interface-settlement-v4-factory-v-79086: **type** `V `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Instruction.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Instruction.rst index 87696b42a..e9d8f71b8 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Instruction.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Instruction.rst @@ -164,10 +164,6 @@ Data Types **instance** HasMethod :ref:`Factory ` \"instruct\" (:ref:`Instruct ` \-\> `Update `_ (`ContractId `_ :ref:`I `, \[`ContractId `_ `I `_\])) - **instance** `GetField `_ \"instructionCids\" :ref:`ClaimResult ` \[`ContractId `_ `I `_\] - - **instance** `SetField `_ \"instructionCids\" :ref:`ClaimResult ` \[`ContractId `_ `I `_\] - .. _type-daml-finance-interface-settlement-v4-instruction-v-93860: **type** `V `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-RouteProvider.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-RouteProvider.rst index 87a7214b1..21cb642bc 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-RouteProvider.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-RouteProvider.rst @@ -87,14 +87,6 @@ Data Types Type synonym for ``RouteProvider``\. - **instance** `GetField `_ \"routeProviderCid\" :ref:`View ` (`ContractId `_ `I `_) - - **instance** `GetField `_ \"routeProviderCid\" :ref:`Rule ` (`ContractId `_ `I `_) - - **instance** `SetField `_ \"routeProviderCid\" :ref:`View ` (`ContractId `_ `I `_) - - **instance** `SetField `_ \"routeProviderCid\" :ref:`Rule ` (`ContractId `_ `I `_) - .. _type-daml-finance-interface-settlement-v4-routeprovider-v-88198: **type** `V `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Types.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Types.rst index 627575bef..daf05b252 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Types.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Settlement-V4-Types.rst @@ -53,14 +53,10 @@ Data Types **instance** `GetField `_ \"allocation\" :ref:`View ` `Allocation `_ - **instance** `GetField `_ \"allocation\" :ref:`Instruction ` `Allocation `_ - **instance** `SetField `_ \"allocation\" :ref:`Allocate ` `Allocation `_ **instance** `SetField `_ \"allocation\" :ref:`View ` `Allocation `_ - **instance** `SetField `_ \"allocation\" :ref:`Instruction ` `Allocation `_ - .. _type-daml-finance-interface-settlement-v4-types-approval-77821: **data** `Approval `_ @@ -106,14 +102,10 @@ Data Types **instance** `GetField `_ \"approval\" :ref:`View ` `Approval `_ - **instance** `GetField `_ \"approval\" :ref:`Instruction ` `Approval `_ - **instance** `SetField `_ \"approval\" :ref:`Approve ` `Approval `_ **instance** `SetField `_ \"approval\" :ref:`View ` `Approval `_ - **instance** `SetField `_ \"approval\" :ref:`Instruction ` `Approval `_ - .. _type-daml-finance-interface-settlement-v4-types-instructionkey-88375: **data** `InstructionKey `_ @@ -159,20 +151,6 @@ Data Types **instance** `SetField `_ \"instructor\" `InstructionKey `_ `Party `_ - **instance** `HasExerciseByKey `_ :ref:`Instruction ` `InstructionKey `_ `Archive `_ () - - **instance** `HasFetchByKey `_ :ref:`Instruction ` `InstructionKey `_ - - **instance** `HasFromAnyContractKey `_ :ref:`Instruction ` `InstructionKey `_ - - **instance** `HasKey `_ :ref:`Instruction ` `InstructionKey `_ - - **instance** `HasLookupByKey `_ :ref:`Instruction ` `InstructionKey `_ - - **instance** `HasMaintainer `_ :ref:`Instruction ` `InstructionKey `_ - - **instance** `HasToAnyContractKey `_ :ref:`Instruction ` `InstructionKey `_ - .. _type-daml-finance-interface-settlement-v4-types-quantity-86875: **data** `Quantity `_ @@ -269,14 +247,10 @@ Data Types **instance** `GetField `_ \"routedStep\" :ref:`View ` `RoutedStep `_ - **instance** `GetField `_ \"routedStep\" :ref:`Instruction ` `RoutedStep `_ - **instance** `GetField `_ \"routedSteps\" :ref:`View ` \[`RoutedStep `_\] **instance** `GetField `_ \"routedSteps\" :ref:`Instruct ` \[`RoutedStep `_\] - **instance** `GetField `_ \"routedStepsWithInstructionId\" :ref:`Batch ` \[(`RoutedStep `_, :ref:`Id `)\] - **instance** `GetField `_ \"sender\" `RoutedStep `_ `Party `_ **instance** `GetField `_ \"version\" `RoutedStep `_ (`Optional `_ `Text `_) @@ -289,14 +263,10 @@ Data Types **instance** `SetField `_ \"routedStep\" :ref:`View ` `RoutedStep `_ - **instance** `SetField `_ \"routedStep\" :ref:`Instruction ` `RoutedStep `_ - **instance** `SetField `_ \"routedSteps\" :ref:`View ` \[`RoutedStep `_\] **instance** `SetField `_ \"routedSteps\" :ref:`Instruct ` \[`RoutedStep `_\] - **instance** `SetField `_ \"routedStepsWithInstructionId\" :ref:`Batch ` \[(`RoutedStep `_, :ref:`Id `)\] - **instance** `SetField `_ \"sender\" `RoutedStep `_ `Party `_ **instance** `SetField `_ \"version\" `RoutedStep `_ (`Optional `_ `Text `_) diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Common-V3-Types.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Common-V3-Types.rst index d8e910c5e..8acc8ea9e 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Common-V3-Types.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Common-V3-Types.rst @@ -36,76 +36,24 @@ Data Types - `Id `_ - Unique identifier for an account\. - **instance** HasInterfaceKey :ref:`Account ` :ref:`View ` `AccountKey `_ Reference GetCid SetCid SetObservers :ref:`GetView ` - **instance** `Eq `_ `AccountKey `_ **instance** `Ord `_ `AccountKey `_ **instance** `Show `_ `AccountKey `_ - **instance** HasMethod :ref:`Account ` \"getKey\" `AccountKey `_ - - **instance** `GetField `_ \"account\" :ref:`BaseHolding ` `AccountKey `_ - - **instance** `GetField `_ \"account\" :ref:`Fungible ` `AccountKey `_ - - **instance** `GetField `_ \"account\" :ref:`Transferable ` `AccountKey `_ - - **instance** `GetField `_ \"account\" :ref:`TransferableFungible ` `AccountKey `_ - - **instance** `GetField `_ \"account\" :ref:`Create ` `AccountKey `_ - - **instance** `GetField `_ \"account\" :ref:`Create ` `AccountKey `_ - **instance** `GetField `_ \"custodian\" `AccountKey `_ `Party `_ **instance** `GetField `_ \"id\" `AccountKey `_ `Id `_ - **instance** `GetField `_ \"newOwnerAccount\" :ref:`Transfer ` `AccountKey `_ - **instance** `GetField `_ \"owner\" `AccountKey `_ `Party `_ - **instance** `SetField `_ \"account\" :ref:`BaseHolding ` `AccountKey `_ - - **instance** `SetField `_ \"account\" :ref:`Fungible ` `AccountKey `_ - - **instance** `SetField `_ \"account\" :ref:`Transferable ` `AccountKey `_ - - **instance** `SetField `_ \"account\" :ref:`TransferableFungible ` `AccountKey `_ - - **instance** `SetField `_ \"account\" :ref:`Create ` `AccountKey `_ - - **instance** `SetField `_ \"account\" :ref:`Create ` `AccountKey `_ - **instance** `SetField `_ \"custodian\" `AccountKey `_ `Party `_ **instance** `SetField `_ \"id\" `AccountKey `_ `Id `_ - **instance** `SetField `_ \"newOwnerAccount\" :ref:`Transfer ` `AccountKey `_ - **instance** `SetField `_ \"owner\" `AccountKey `_ `Party `_ - **instance** `HasExerciseByKey `_ Reference `AccountKey `_ GetCid (`ContractId `_ :ref:`Account `) - - **instance** `HasExerciseByKey `_ Reference `AccountKey `_ SetCid (`ContractId `_ Reference) - - **instance** `HasExerciseByKey `_ Reference `AccountKey `_ SetObservers (`ContractId `_ Reference) - - **instance** `HasExerciseByKey `_ Reference `AccountKey `_ `Archive `_ () - - **instance** `HasFetchByKey `_ Reference `AccountKey `_ - - **instance** `HasFromAnyContractKey `_ Reference `AccountKey `_ - - **instance** `HasKey `_ Reference `AccountKey `_ - - **instance** `HasLookupByKey `_ Reference `AccountKey `_ - - **instance** `HasMaintainer `_ Reference `AccountKey `_ - - **instance** `HasToAnyContractKey `_ Reference `AccountKey `_ - .. _type-daml-finance-interface-types-common-v3-types-holdingfactorykey-40007: **data** `HoldingFactoryKey `_ @@ -130,52 +78,20 @@ Data Types - `Id `_ - Unique identifier for a holding factory\. - **instance** HasInterfaceKey :ref:`Factory ` :ref:`View ` `HoldingFactoryKey `_ Reference GetCid SetCid SetObservers :ref:`GetView ` - **instance** `Eq `_ `HoldingFactoryKey `_ **instance** `Ord `_ `HoldingFactoryKey `_ **instance** `Show `_ `HoldingFactoryKey `_ - **instance** HasMethod :ref:`Factory ` \"getKey\" `HoldingFactoryKey `_ - - **instance** `GetField `_ \"holdingFactory\" :ref:`Account ` `HoldingFactoryKey `_ - - **instance** `GetField `_ \"holdingFactory\" :ref:`Create ` `HoldingFactoryKey `_ - **instance** `GetField `_ \"id\" `HoldingFactoryKey `_ `Id `_ **instance** `GetField `_ \"provider\" `HoldingFactoryKey `_ `Party `_ - **instance** `SetField `_ \"holdingFactory\" :ref:`Account ` `HoldingFactoryKey `_ - - **instance** `SetField `_ \"holdingFactory\" :ref:`Create ` `HoldingFactoryKey `_ - **instance** `SetField `_ \"id\" `HoldingFactoryKey `_ `Id `_ **instance** `SetField `_ \"provider\" `HoldingFactoryKey `_ `Party `_ - **instance** `HasExerciseByKey `_ Reference `HoldingFactoryKey `_ GetCid (`ContractId `_ :ref:`Factory `) - - **instance** `HasExerciseByKey `_ Reference `HoldingFactoryKey `_ SetCid (`ContractId `_ Reference) - - **instance** `HasExerciseByKey `_ Reference `HoldingFactoryKey `_ SetObservers (`ContractId `_ Reference) - - **instance** `HasExerciseByKey `_ Reference `HoldingFactoryKey `_ `Archive `_ () - - **instance** `HasFetchByKey `_ Reference `HoldingFactoryKey `_ - - **instance** `HasFromAnyContractKey `_ Reference `HoldingFactoryKey `_ - - **instance** `HasKey `_ Reference `HoldingFactoryKey `_ - - **instance** `HasLookupByKey `_ Reference `HoldingFactoryKey `_ - - **instance** `HasMaintainer `_ Reference `HoldingFactoryKey `_ - - **instance** `HasToAnyContractKey `_ Reference `HoldingFactoryKey `_ - .. _type-daml-finance-interface-types-common-v3-types-holdingstandard-63293: **data** `HoldingStandard `_ @@ -227,92 +143,8 @@ Data Types **instance** `Show `_ `HoldingStandard `_ - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `GetField `_ \"holdingStandard\" :ref:`View ` `HoldingStandard `_ - **instance** `GetField `_ \"holdingStandard\" `InstrumentKey `_ `HoldingStandard `_ - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`Instrument ` `HoldingStandard `_ - - **instance** `SetField `_ \"holdingStandard\" :ref:`View ` `HoldingStandard `_ - **instance** `SetField `_ \"holdingStandard\" `InstrumentKey `_ `HoldingStandard `_ .. _type-daml-finance-interface-types-common-v3-types-id-28519: @@ -330,312 +162,18 @@ Data Types **instance** `Show `_ `Id `_ - **instance** `GetField `_ \"batchId\" :ref:`ClaimEffect ` `Id `_ - - **instance** `GetField `_ \"batchId\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"batchId\" :ref:`InstructionKey ` `Id `_ - - **instance** `GetField `_ \"batchId\" :ref:`Instruction ` `Id `_ - - **instance** `GetField `_ \"contextId\" :ref:`View ` (`Optional `_ `Id `_) - - **instance** `GetField `_ \"contextId\" :ref:`Instruct ` (`Optional `_ `Id `_) - - **instance** `GetField `_ \"contextId\" :ref:`Discover ` (`Optional `_ `Id `_) - - **instance** `GetField `_ \"contextId\" :ref:`Batch ` (`Optional `_ `Id `_) - - **instance** `GetField `_ \"eventId\" :ref:`Advance ` `Id `_ - - **instance** `GetField `_ \"eventId\" :ref:`Rewind ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Account ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Observation ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`DateClock ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`DateClockUpdateEvent ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`LedgerTime ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Factory ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`DistributionRule ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Create ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`DeclareDistribution ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`DeclareReplacement ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`DeclareStockSplit ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Create ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Create ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instruct ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`InstructionKey ` `Id `_ - **instance** `GetField `_ \"id\" `AccountKey `_ `Id `_ **instance** `GetField `_ \"id\" `HoldingFactoryKey `_ `Id `_ **instance** `GetField `_ \"id\" `InstrumentKey `_ `Id `_ - **instance** `GetField `_ \"id\" :ref:`Effect ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Election ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`ElectionEffect ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Event ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Event ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Batch ` `Id `_ - - **instance** `GetField `_ \"id\" :ref:`Instruction ` `Id `_ - - **instance** `GetField `_ \"routedStepsWithInstructionId\" :ref:`Batch ` \[(:ref:`RoutedStep `, `Id `_)\] - - **instance** `SetField `_ \"batchId\" :ref:`ClaimEffect ` `Id `_ - - **instance** `SetField `_ \"batchId\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"batchId\" :ref:`InstructionKey ` `Id `_ - - **instance** `SetField `_ \"batchId\" :ref:`Instruction ` `Id `_ - - **instance** `SetField `_ \"contextId\" :ref:`View ` (`Optional `_ `Id `_) - - **instance** `SetField `_ \"contextId\" :ref:`Instruct ` (`Optional `_ `Id `_) - - **instance** `SetField `_ \"contextId\" :ref:`Discover ` (`Optional `_ `Id `_) - - **instance** `SetField `_ \"contextId\" :ref:`Batch ` (`Optional `_ `Id `_) - - **instance** `SetField `_ \"eventId\" :ref:`Advance ` `Id `_ - - **instance** `SetField `_ \"eventId\" :ref:`Rewind ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Account ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Observation ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`DateClock ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`DateClockUpdateEvent ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`LedgerTime ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Factory ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`DistributionRule ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instrument ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Create ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`DeclareDistribution ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`DeclareReplacement ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`DeclareStockSplit ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Create ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Create ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instruct ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`View ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`InstructionKey ` `Id `_ - **instance** `SetField `_ \"id\" `AccountKey `_ `Id `_ **instance** `SetField `_ \"id\" `HoldingFactoryKey `_ `Id `_ **instance** `SetField `_ \"id\" `InstrumentKey `_ `Id `_ - **instance** `SetField `_ \"id\" :ref:`Effect ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Election ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`ElectionEffect ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Event ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Event ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Rule ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Batch ` `Id `_ - - **instance** `SetField `_ \"id\" :ref:`Instruction ` `Id `_ - - **instance** `SetField `_ \"routedStepsWithInstructionId\" :ref:`Batch ` \[(:ref:`RoutedStep `, `Id `_)\] - - **instance** `HasExerciseByKey `_ :ref:`Batch ` (`Party `_, `Id `_) `Archive `_ () - - **instance** `HasFetchByKey `_ :ref:`Batch ` (`Party `_, `Id `_) - - **instance** `HasFromAnyContractKey `_ :ref:`Batch ` (`Party `_, `Id `_) - - **instance** `HasKey `_ :ref:`Batch ` (`Party `_, `Id `_) - - **instance** `HasLookupByKey `_ :ref:`Batch ` (`Party `_, `Id `_) - - **instance** `HasMaintainer `_ :ref:`Batch ` (`Party `_, `Id `_) - - **instance** `HasToAnyContractKey `_ :ref:`Batch ` (`Party `_, `Id `_) - .. _type-daml-finance-interface-types-common-v3-types-instrumentkey-82717: **data** `InstrumentKey `_ @@ -669,1196 +207,54 @@ Data Types - `HoldingStandard `_ - The used holding standard for the instrument\. - **instance** HasInterfaceKey :ref:`Instrument ` :ref:`View ` `InstrumentKey `_ Reference GetCid SetCid SetObservers :ref:`GetView ` - **instance** `Eq `_ `InstrumentKey `_ **instance** `Ord `_ `InstrumentKey `_ **instance** `Show `_ `InstrumentKey `_ - **instance** HasMethod :ref:`Instrument ` \"getKey\" `InstrumentKey `_ + **instance** `GetField `_ \"depository\" `InstrumentKey `_ `Party `_ - **instance** HasMethod :ref:`Election ` \"apply\" (`ContractId `_ :ref:`Election ` \-\> :ref:`Apply ` \-\> `Update `_ (`Optional `_ `InstrumentKey `_, \[`ContractId `_ :ref:`I `\])) + **instance** `GetField `_ \"holdingStandard\" `InstrumentKey `_ `HoldingStandard `_ - **instance** HasMethod :ref:`Exercisable ` \"applyElection\" (:ref:`ApplyElection ` \-\> `Update `_ (`Optional `_ `InstrumentKey `_, \[`ContractId `_ :ref:`I `\])) + **instance** `GetField `_ \"id\" `InstrumentKey `_ `Id `_ - **instance** HasMethod :ref:`Lifecycle ` \"evolve\" (:ref:`Evolve ` \-\> `Update `_ (`Optional `_ `InstrumentKey `_, \[`ContractId `_ :ref:`I `\])) + **instance** `GetField `_ \"issuer\" `InstrumentKey `_ `Party `_ - **instance** `GetField `_ \"baseCurrency\" :ref:`Instrument ` `InstrumentKey `_ + **instance** `GetField `_ \"version\" `InstrumentKey `_ `Text `_ - **instance** `GetField `_ \"baseCurrency\" :ref:`Instrument ` `InstrumentKey `_ + **instance** `SetField `_ \"depository\" `InstrumentKey `_ `Party `_ - **instance** `GetField `_ \"baseCurrency\" :ref:`CurrencySwap ` `InstrumentKey `_ + **instance** `SetField `_ \"holdingStandard\" `InstrumentKey `_ `HoldingStandard `_ - **instance** `GetField `_ \"baseCurrency\" :ref:`ForeignExchange ` `InstrumentKey `_ + **instance** `SetField `_ \"id\" `InstrumentKey `_ `Id `_ - **instance** `GetField `_ \"currencies\" :ref:`Instrument ` \[`InstrumentKey `_\] + **instance** `SetField `_ \"issuer\" `InstrumentKey `_ `Party `_ - **instance** `GetField `_ \"currencies\" :ref:`Fpml ` \[`InstrumentKey `_\] + **instance** `SetField `_ \"version\" `InstrumentKey `_ `Text `_ - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ +.. _type-daml-finance-interface-types-common-v3-types-instrumentquantity-36264: - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ +**type** `InstrumentQuantity `_ + \= `Quantity `_ `InstrumentKey `_ `Decimal `_ - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ +.. _type-daml-finance-interface-types-common-v3-types-parties-67059: - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ +**type** `Parties `_ + \= `Set `_ `Party `_ - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ + A set of parties\. - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ +.. _type-daml-finance-interface-types-common-v3-types-partiesmap-43006: - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ +**type** `PartiesMap `_ + \= `Map `_ `Text `_ `Parties `_ - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ + Parties mapped by a specific key (or context)\. + The textual key is the \"context\" which describes the value set of parties\. + This allows processes to add/remove parties for their specific purpose, without affecting others\. - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`Callable ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`FixedRate ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`FloatingRate ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`InflationLinked ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`ZeroCoupon ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`BarrierEuropean ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`European ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`European ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`AutoCallable ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`BarrierReverseConvertible ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`Asset ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`CreditDefault ` `InstrumentKey `_ - - **instance** `GetField `_ \"currency\" :ref:`InterestRate ` `InstrumentKey `_ - - **instance** `GetField `_ \"depository\" `InstrumentKey `_ `Party `_ - - **instance** `GetField `_ \"foreignCurrency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"foreignCurrency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"foreignCurrency\" :ref:`CurrencySwap ` `InstrumentKey `_ - - **instance** `GetField `_ \"foreignCurrency\" :ref:`ForeignExchange ` `InstrumentKey `_ - - **instance** `GetField `_ \"holdingStandard\" `InstrumentKey `_ `HoldingStandard `_ - - **instance** `GetField `_ \"id\" `InstrumentKey `_ `Id `_ - - **instance** `GetField `_ \"instrument\" :ref:`BaseHolding ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Fungible ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Transferable ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`TransferableFungible ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Callable ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`FixedRate ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`FloatingRate ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`InflationLinked ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`ZeroCoupon ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`BarrierEuropean ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Dividend ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`European ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`European ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`AutoCallable ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`BarrierReverseConvertible ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Asset ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`CreditDefault ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`CurrencySwap ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`ForeignExchange ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Fpml ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`InterestRate ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Token ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Evolve ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Election ` `InstrumentKey `_ - - **instance** `GetField `_ \"instrument\" :ref:`Pending ` `InstrumentKey `_ - - **instance** `GetField `_ \"issuer\" `InstrumentKey `_ `Party `_ - - **instance** `GetField `_ \"newInstrument\" :ref:`DeclareDistribution ` `InstrumentKey `_ - - **instance** `GetField `_ \"newInstrument\" :ref:`DeclareStockSplit ` `InstrumentKey `_ - - **instance** `GetField `_ \"newInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `GetField `_ \"newInstrument\" :ref:`Event ` `InstrumentKey `_ - - **instance** `GetField `_ \"producedInstrument\" :ref:`View ` (`Optional `_ `InstrumentKey `_) - - **instance** `GetField `_ \"producedInstrument\" :ref:`Effect ` (`Optional `_ `InstrumentKey `_) - - **instance** `GetField `_ \"producedInstrument\" :ref:`ElectionEffect ` (`Optional `_ `InstrumentKey `_) - - **instance** `GetField `_ \"quantity\" :ref:`Credit ` (`Quantity `_ `InstrumentKey `_ `Decimal `_) - - **instance** `GetField `_ \"referenceAsset\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `GetField `_ \"referenceAsset\" :ref:`European ` `InstrumentKey `_ - - **instance** `GetField `_ \"referenceAsset\" :ref:`Underlying ` `InstrumentKey `_ - - **instance** `GetField `_ \"targetInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `GetField `_ \"targetInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `GetField `_ \"targetInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `GetField `_ \"targetInstrument\" :ref:`Effect ` `InstrumentKey `_ - - **instance** `GetField `_ \"targetInstrument\" :ref:`ElectionEffect ` `InstrumentKey `_ - - **instance** `GetField `_ \"targetInstrument\" :ref:`Event ` `InstrumentKey `_ - - **instance** `GetField `_ \"targetInstrument\" :ref:`Event ` `InstrumentKey `_ - - **instance** `GetField `_ \"version\" `InstrumentKey `_ `Text `_ - - **instance** `SetField `_ \"baseCurrency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"baseCurrency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"baseCurrency\" :ref:`CurrencySwap ` `InstrumentKey `_ - - **instance** `SetField `_ \"baseCurrency\" :ref:`ForeignExchange ` `InstrumentKey `_ - - **instance** `SetField `_ \"currencies\" :ref:`Instrument ` \[`InstrumentKey `_\] - - **instance** `SetField `_ \"currencies\" :ref:`Fpml ` \[`InstrumentKey `_\] - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Callable ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`FixedRate ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`FloatingRate ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`InflationLinked ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`ZeroCoupon ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`BarrierEuropean ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`European ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`European ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`AutoCallable ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`BarrierReverseConvertible ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`Asset ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`CreditDefault ` `InstrumentKey `_ - - **instance** `SetField `_ \"currency\" :ref:`InterestRate ` `InstrumentKey `_ - - **instance** `SetField `_ \"depository\" `InstrumentKey `_ `Party `_ - - **instance** `SetField `_ \"foreignCurrency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"foreignCurrency\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"foreignCurrency\" :ref:`CurrencySwap ` `InstrumentKey `_ - - **instance** `SetField `_ \"foreignCurrency\" :ref:`ForeignExchange ` `InstrumentKey `_ - - **instance** `SetField `_ \"holdingStandard\" `InstrumentKey `_ `HoldingStandard `_ - - **instance** `SetField `_ \"id\" `InstrumentKey `_ `Id `_ - - **instance** `SetField `_ \"instrument\" :ref:`BaseHolding ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Fungible ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Transferable ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`TransferableFungible ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Callable ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`FixedRate ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`FloatingRate ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`InflationLinked ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`ZeroCoupon ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`BarrierEuropean ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Dividend ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`European ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`European ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`AutoCallable ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`BarrierReverseConvertible ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Asset ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`CreditDefault ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`CurrencySwap ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`ForeignExchange ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Fpml ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`InterestRate ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Token ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Create ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Evolve ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Election ` `InstrumentKey `_ - - **instance** `SetField `_ \"instrument\" :ref:`Pending ` `InstrumentKey `_ - - **instance** `SetField `_ \"issuer\" `InstrumentKey `_ `Party `_ - - **instance** `SetField `_ \"newInstrument\" :ref:`DeclareDistribution ` `InstrumentKey `_ - - **instance** `SetField `_ \"newInstrument\" :ref:`DeclareStockSplit ` `InstrumentKey `_ - - **instance** `SetField `_ \"newInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `SetField `_ \"newInstrument\" :ref:`Event ` `InstrumentKey `_ - - **instance** `SetField `_ \"producedInstrument\" :ref:`View ` (`Optional `_ `InstrumentKey `_) - - **instance** `SetField `_ \"producedInstrument\" :ref:`Effect ` (`Optional `_ `InstrumentKey `_) - - **instance** `SetField `_ \"producedInstrument\" :ref:`ElectionEffect ` (`Optional `_ `InstrumentKey `_) - - **instance** `SetField `_ \"quantity\" :ref:`Credit ` (`Quantity `_ `InstrumentKey `_ `Decimal `_) - - **instance** `SetField `_ \"referenceAsset\" :ref:`Instrument ` `InstrumentKey `_ - - **instance** `SetField `_ \"referenceAsset\" :ref:`European ` `InstrumentKey `_ - - **instance** `SetField `_ \"referenceAsset\" :ref:`Underlying ` `InstrumentKey `_ - - **instance** `SetField `_ \"targetInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `SetField `_ \"targetInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `SetField `_ \"targetInstrument\" :ref:`View ` `InstrumentKey `_ - - **instance** `SetField `_ \"targetInstrument\" :ref:`Effect ` `InstrumentKey `_ - - **instance** `SetField `_ \"targetInstrument\" :ref:`ElectionEffect ` `InstrumentKey `_ - - **instance** `SetField `_ \"targetInstrument\" :ref:`Event ` `InstrumentKey `_ - - **instance** `SetField `_ \"targetInstrument\" :ref:`Event ` `InstrumentKey `_ - - **instance** `SetField `_ \"version\" `InstrumentKey `_ `Text `_ - - **instance** `HasExerciseByKey `_ Reference `InstrumentKey `_ GetCid (`ContractId `_ :ref:`Instrument `) - - **instance** `HasExerciseByKey `_ Reference `InstrumentKey `_ SetCid (`ContractId `_ Reference) - - **instance** `HasExerciseByKey `_ Reference `InstrumentKey `_ SetObservers (`ContractId `_ Reference) - - **instance** `HasExerciseByKey `_ Reference `InstrumentKey `_ `Archive `_ () - - **instance** `HasFetchByKey `_ Reference `InstrumentKey `_ - - **instance** `HasFromAnyContractKey `_ Reference `InstrumentKey `_ - - **instance** `HasKey `_ Reference `InstrumentKey `_ - - **instance** `HasLookupByKey `_ Reference `InstrumentKey `_ - - **instance** `HasMaintainer `_ Reference `InstrumentKey `_ - - **instance** `HasToAnyContractKey `_ Reference `InstrumentKey `_ - -.. _type-daml-finance-interface-types-common-v3-types-instrumentquantity-36264: - -**type** `InstrumentQuantity `_ - \= `Quantity `_ `InstrumentKey `_ `Decimal `_ - - **instance** `GetField `_ \"cashQuantity\" :ref:`Instrument ` `InstrumentQuantity `_ - - **instance** `GetField `_ \"cashQuantity\" :ref:`Dividend ` `InstrumentQuantity `_ - - **instance** `GetField `_ \"consumed\" :ref:`CalculationResult ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"fxQuantity\" :ref:`Instrument ` (`Optional `_ `InstrumentQuantity `_) - - **instance** `GetField `_ \"fxQuantity\" :ref:`Dividend ` (`Optional `_ `InstrumentQuantity `_) - - **instance** `GetField `_ \"otherConsumed\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"otherConsumed\" :ref:`Effect ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"otherConsumed\" :ref:`ElectionEffect ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"otherProduced\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"otherProduced\" :ref:`Effect ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"otherProduced\" :ref:`ElectionEffect ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"perUnitDistribution\" :ref:`DeclareDistribution ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"perUnitDistribution\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"perUnitDistribution\" :ref:`Event ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"perUnitReplacement\" :ref:`DeclareReplacement ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"perUnitReplacement\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"perUnitReplacement\" :ref:`Event ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"produced\" :ref:`CalculationResult ` \[`InstrumentQuantity `_\] - - **instance** `GetField `_ \"quantity\" :ref:`Calculate ` `InstrumentQuantity `_ - - **instance** `GetField `_ \"sharesQuantity\" :ref:`Instrument ` (`Optional `_ `InstrumentQuantity `_) - - **instance** `GetField `_ \"sharesQuantity\" :ref:`Dividend ` (`Optional `_ `InstrumentQuantity `_) - - **instance** `SetField `_ \"cashQuantity\" :ref:`Instrument ` `InstrumentQuantity `_ - - **instance** `SetField `_ \"cashQuantity\" :ref:`Dividend ` `InstrumentQuantity `_ - - **instance** `SetField `_ \"consumed\" :ref:`CalculationResult ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"fxQuantity\" :ref:`Instrument ` (`Optional `_ `InstrumentQuantity `_) - - **instance** `SetField `_ \"fxQuantity\" :ref:`Dividend ` (`Optional `_ `InstrumentQuantity `_) - - **instance** `SetField `_ \"otherConsumed\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"otherConsumed\" :ref:`Effect ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"otherConsumed\" :ref:`ElectionEffect ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"otherProduced\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"otherProduced\" :ref:`Effect ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"otherProduced\" :ref:`ElectionEffect ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"perUnitDistribution\" :ref:`DeclareDistribution ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"perUnitDistribution\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"perUnitDistribution\" :ref:`Event ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"perUnitReplacement\" :ref:`DeclareReplacement ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"perUnitReplacement\" :ref:`View ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"perUnitReplacement\" :ref:`Event ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"produced\" :ref:`CalculationResult ` \[`InstrumentQuantity `_\] - - **instance** `SetField `_ \"quantity\" :ref:`Calculate ` `InstrumentQuantity `_ - - **instance** `SetField `_ \"sharesQuantity\" :ref:`Instrument ` (`Optional `_ `InstrumentQuantity `_) - - **instance** `SetField `_ \"sharesQuantity\" :ref:`Dividend ` (`Optional `_ `InstrumentQuantity `_) - -.. _type-daml-finance-interface-types-common-v3-types-parties-67059: - -**type** `Parties `_ - \= `Set `_ `Party `_ - - A set of parties\. - - **instance** `GetField `_ \"actors\" :ref:`Transfer ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Create ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Create ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Observe ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`GetTime ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Cancel ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Settle ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Allocate ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Approve ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Cancel ` `Parties `_ - - **instance** `GetField `_ \"actors\" :ref:`Execute ` `Parties `_ - - **instance** `GetField `_ \"claimers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"claimers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"consenters\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"consenters\" :ref:`Instruct ` `Parties `_ - - **instance** `GetField `_ \"consenters\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"consenters\" :ref:`Batch ` `Parties `_ - - **instance** `GetField `_ \"consenters\" :ref:`Instruction ` `Parties `_ - - **instance** `GetField `_ \"controllers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"disclosers\" :ref:`AddObservers ` `Parties `_ - - **instance** `GetField `_ \"disclosers\" :ref:`RemoveObservers ` `Parties `_ - - **instance** `GetField `_ \"disclosers\" :ref:`SetObservers ` `Parties `_ - - **instance** `GetField `_ \"disclosureControllers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"discoverors\" :ref:`Discover ` `Parties `_ - - **instance** `GetField `_ \"incoming\" :ref:`Controllers ` `Parties `_ - - **instance** `GetField `_ \"lockers\" :ref:`Lock ` `Parties `_ - - **instance** `GetField `_ \"modifiers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"newInstrumentObservers\" :ref:`DistributionRule ` \[(`Text `_, `Parties `_)\] - - **instance** `GetField `_ \"newLockers\" :ref:`Acquire ` `Parties `_ - - **instance** `GetField `_ \"newProviders\" :ref:`SetProviders ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`DateClock ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`DateClockUpdateEvent ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`LedgerTime ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`DistributionRule ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`Event ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`Event ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`IntermediatedStatic ` `Parties `_ - - **instance** `GetField `_ \"observers\" :ref:`SingleCustodian ` `Parties `_ - - **instance** `GetField `_ \"observersToAdd\" :ref:`AddObservers ` (`Text `_, `Parties `_) - - **instance** `GetField `_ \"observersToRemove\" :ref:`RemoveObservers ` (`Text `_, `Parties `_) - - **instance** `GetField `_ \"outgoing\" :ref:`Controllers ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`DateClock ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`DateClockUpdateEvent ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`LedgerTime ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`DistributionRule ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`Effect ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`ElectionEffect ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`Event ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`Event ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"settlers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"settlers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"settlers\" :ref:`Instruct ` `Parties `_ - - **instance** `GetField `_ \"settlers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"settlers\" :ref:`Rule ` `Parties `_ - - **instance** `GetField `_ \"settlers\" :ref:`Batch ` `Parties `_ - - **instance** `GetField `_ \"settlers\" :ref:`Instruction ` `Parties `_ - - **instance** `GetField `_ \"signedReceivers\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"signedReceivers\" :ref:`Instruction ` `Parties `_ - - **instance** `GetField `_ \"signedSenders\" :ref:`View ` `Parties `_ - - **instance** `GetField `_ \"signedSenders\" :ref:`Instruction ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Transfer ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Create ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Create ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Observe ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`GetTime ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Cancel ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Settle ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Allocate ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Approve ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Cancel ` `Parties `_ - - **instance** `SetField `_ \"actors\" :ref:`Execute ` `Parties `_ - - **instance** `SetField `_ \"claimers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"claimers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"consenters\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"consenters\" :ref:`Instruct ` `Parties `_ - - **instance** `SetField `_ \"consenters\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"consenters\" :ref:`Batch ` `Parties `_ - - **instance** `SetField `_ \"consenters\" :ref:`Instruction ` `Parties `_ - - **instance** `SetField `_ \"controllers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"disclosers\" :ref:`AddObservers ` `Parties `_ - - **instance** `SetField `_ \"disclosers\" :ref:`RemoveObservers ` `Parties `_ - - **instance** `SetField `_ \"disclosers\" :ref:`SetObservers ` `Parties `_ - - **instance** `SetField `_ \"disclosureControllers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"discoverors\" :ref:`Discover ` `Parties `_ - - **instance** `SetField `_ \"incoming\" :ref:`Controllers ` `Parties `_ - - **instance** `SetField `_ \"lockers\" :ref:`Lock ` `Parties `_ - - **instance** `SetField `_ \"modifiers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"newInstrumentObservers\" :ref:`DistributionRule ` \[(`Text `_, `Parties `_)\] - - **instance** `SetField `_ \"newLockers\" :ref:`Acquire ` `Parties `_ - - **instance** `SetField `_ \"newProviders\" :ref:`SetProviders ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`DateClock ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`DateClockUpdateEvent ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`LedgerTime ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`DistributionRule ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`Event ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`Event ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`IntermediatedStatic ` `Parties `_ - - **instance** `SetField `_ \"observers\" :ref:`SingleCustodian ` `Parties `_ - - **instance** `SetField `_ \"observersToAdd\" :ref:`AddObservers ` (`Text `_, `Parties `_) - - **instance** `SetField `_ \"observersToRemove\" :ref:`RemoveObservers ` (`Text `_, `Parties `_) - - **instance** `SetField `_ \"outgoing\" :ref:`Controllers ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`DateClock ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`DateClockUpdateEvent ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`LedgerTime ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`DistributionRule ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`Effect ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`ElectionEffect ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`Event ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`Event ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"providers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"settlers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"settlers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"settlers\" :ref:`Instruct ` `Parties `_ - - **instance** `SetField `_ \"settlers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"settlers\" :ref:`Rule ` `Parties `_ - - **instance** `SetField `_ \"settlers\" :ref:`Batch ` `Parties `_ - - **instance** `SetField `_ \"settlers\" :ref:`Instruction ` `Parties `_ - - **instance** `SetField `_ \"signedReceivers\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"signedReceivers\" :ref:`Instruction ` `Parties `_ - - **instance** `SetField `_ \"signedSenders\" :ref:`View ` `Parties `_ - - **instance** `SetField `_ \"signedSenders\" :ref:`Instruction ` `Parties `_ - -.. _type-daml-finance-interface-types-common-v3-types-partiesmap-43006: - -**type** `PartiesMap `_ - \= `Map `_ `Text `_ `Parties `_ - - Parties mapped by a specific key (or context)\. - The textual key is the \"context\" which describes the value set of parties\. - This allows processes to add/remove parties for their specific purpose, without affecting others\. - - **instance** `GetField `_ \"newObservers\" SetObservers `PartiesMap `_ - - **instance** `GetField `_ \"newObservers\" SetObservers `PartiesMap `_ - - **instance** `GetField `_ \"newObservers\" SetObservers `PartiesMap `_ - - **instance** `GetField `_ \"newObservers\" :ref:`SetObservers ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Account ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Rule ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Observation ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`HolidayCalendar ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`BaseHolding ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Fungible ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Transferable ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`TransferableFungible ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Rule ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" Reference `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" Reference `PartiesMap `_ - - **instance** `GetField `_ \"observers\" Reference `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Effect ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Election ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`ElectionEffect ` `PartiesMap `_ - - **instance** `GetField `_ \"observers\" :ref:`Instruction ` `PartiesMap `_ - - **instance** `SetField `_ \"newObservers\" SetObservers `PartiesMap `_ - - **instance** `SetField `_ \"newObservers\" SetObservers `PartiesMap `_ - - **instance** `SetField `_ \"newObservers\" SetObservers `PartiesMap `_ - - **instance** `SetField `_ \"newObservers\" :ref:`SetObservers ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Account ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Rule ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Observation ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`HolidayCalendar ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`BaseHolding ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Fungible ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Transferable ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`TransferableFungible ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Rule ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instrument ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" Reference `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" Reference `PartiesMap `_ - - **instance** `SetField `_ \"observers\" Reference `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Create ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`View ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Effect ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Election ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Factory ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`ElectionEffect ` `PartiesMap `_ - - **instance** `SetField `_ \"observers\" :ref:`Instruction ` `PartiesMap `_ - -.. _type-daml-finance-interface-types-common-v3-types-quantity-28585: +.. _type-daml-finance-interface-types-common-v3-types-quantity-28585: **data** `Quantity `_ u a @@ -1890,12 +286,8 @@ Data Types **instance** `GetField `_ \"amount\" (`Quantity `_ u a) a - **instance** `GetField `_ \"quantity\" :ref:`Credit ` (`Quantity `_ `InstrumentKey `_ `Decimal `_) - **instance** `GetField `_ \"unit\" (`Quantity `_ u a) u **instance** `SetField `_ \"amount\" (`Quantity `_ u a) a - **instance** `SetField `_ \"quantity\" :ref:`Credit ` (`Quantity `_ `InstrumentKey `_ `Decimal `_) - **instance** `SetField `_ \"unit\" (`Quantity `_ u a) u diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Calendar.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Calendar.rst index e3de0e3ab..789785ecd 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Calendar.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Calendar.rst @@ -101,26 +101,10 @@ Data Types **instance** `Show `_ `BusinessDayConventionEnum `_ - **instance** `GetField `_ \"businessDayConvention\" :ref:`BusinessDayAdjustments ` `BusinessDayConventionEnum `_ - - **instance** `GetField `_ \"businessDayConvention\" :ref:`CalculationPeriodDatesAdjustments ` `BusinessDayConventionEnum `_ - - **instance** `GetField `_ \"businessDayConvention\" :ref:`FixingDates ` `BusinessDayConventionEnum `_ - - **instance** `GetField `_ \"businessDayConvention\" :ref:`ResetDatesAdjustments ` `BusinessDayConventionEnum `_ - **instance** `GetField `_ \"businessDayConvention\" :ref:`DateOffset ` `BusinessDayConventionEnum `_ **instance** `GetField `_ \"convention\" `BusinessDayAdjustment `_ `BusinessDayConventionEnum `_ - **instance** `SetField `_ \"businessDayConvention\" :ref:`BusinessDayAdjustments ` `BusinessDayConventionEnum `_ - - **instance** `SetField `_ \"businessDayConvention\" :ref:`CalculationPeriodDatesAdjustments ` `BusinessDayConventionEnum `_ - - **instance** `SetField `_ \"businessDayConvention\" :ref:`FixingDates ` `BusinessDayConventionEnum `_ - - **instance** `SetField `_ \"businessDayConvention\" :ref:`ResetDatesAdjustments ` `BusinessDayConventionEnum `_ - **instance** `SetField `_ \"businessDayConvention\" :ref:`DateOffset ` `BusinessDayConventionEnum `_ **instance** `SetField `_ \"convention\" `BusinessDayAdjustment `_ `BusinessDayConventionEnum `_ @@ -156,32 +140,14 @@ Data Types **instance** `Show `_ `HolidayCalendarData `_ - **instance** `GetField `_ \"calendar\" :ref:`HolidayCalendar ` `HolidayCalendarData `_ - - **instance** `GetField `_ \"calendar\" :ref:`Create ` `HolidayCalendarData `_ - - **instance** `GetField `_ \"calendar\" :ref:`View ` `HolidayCalendarData `_ - **instance** `GetField `_ \"holidays\" `HolidayCalendarData `_ \[`Date `_\] **instance** `GetField `_ \"id\" `HolidayCalendarData `_ `Text `_ - **instance** `GetField `_ \"newCalendar\" :ref:`UpdateCalendar ` `HolidayCalendarData `_ - **instance** `GetField `_ \"weekend\" `HolidayCalendarData `_ \[`DayOfWeek `_\] - **instance** `SetField `_ \"calendar\" :ref:`HolidayCalendar ` `HolidayCalendarData `_ - - **instance** `SetField `_ \"calendar\" :ref:`Create ` `HolidayCalendarData `_ - - **instance** `SetField `_ \"calendar\" :ref:`View ` `HolidayCalendarData `_ - **instance** `SetField `_ \"holidays\" `HolidayCalendarData `_ \[`Date `_\] **instance** `SetField `_ \"id\" `HolidayCalendarData `_ `Text `_ - **instance** `SetField `_ \"newCalendar\" :ref:`UpdateCalendar ` `HolidayCalendarData `_ - **instance** `SetField `_ \"weekend\" `HolidayCalendarData `_ \[`DayOfWeek `_\] - - **instance** `HasExerciseByKey `_ :ref:`HolidayCalendar ` :ref:`HolidayCalendarKey ` :ref:`GetCalendar ` `HolidayCalendarData `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Classes.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Classes.rst index a005cb892..04b74267f 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Classes.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Classes.rst @@ -19,7 +19,3 @@ Typeclasses `toUTCTime `_ \: a \-\> `Time `_ - - **instance** `HasUTCTimeConversion `_ :ref:`DateClock ` - - **instance** `HasUTCTimeConversion `_ :ref:`Unit ` diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-DayCount.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-DayCount.rst index e0811b17a..5d3998988 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-DayCount.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-DayCount.rst @@ -127,87 +127,3 @@ Data Types **instance** `Eq `_ `DayCountConventionEnum `_ **instance** `Show `_ `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Callable ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`FixedRate ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`FloatingRate ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`InflationLinked ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`AutoCallable ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`BarrierReverseConvertible ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`Asset ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`CreditDefault ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`CurrencySwap ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountConvention\" :ref:`InterestRate ` `DayCountConventionEnum `_ - - **instance** `GetField `_ \"dayCountFraction\" :ref:`Calculation ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Instrument ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Callable ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`FixedRate ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`FloatingRate ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`InflationLinked ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`AutoCallable ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`BarrierReverseConvertible ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`Asset ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`CreditDefault ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`CurrencySwap ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountConvention\" :ref:`InterestRate ` `DayCountConventionEnum `_ - - **instance** `SetField `_ \"dayCountFraction\" :ref:`Calculation ` `DayCountConventionEnum `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-RollConvention.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-RollConvention.rst index fb436a835..dd9d1fd98 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-RollConvention.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-RollConvention.rst @@ -37,20 +37,12 @@ Data Types **instance** `Show `_ `Period `_ - **instance** `GetField `_ \"indexTenor\" :ref:`FloatingRateCalculation ` (`Optional `_ `Period `_) - - **instance** `GetField `_ \"indexTenor\" :ref:`StubFloatingRate ` (`Optional `_ `Period `_) - **instance** `GetField `_ \"period\" `Period `_ `PeriodEnum `_ **instance** `GetField `_ \"period\" :ref:`Frequency ` `Period `_ **instance** `GetField `_ \"periodMultiplier\" `Period `_ `Int `_ - **instance** `SetField `_ \"indexTenor\" :ref:`FloatingRateCalculation ` (`Optional `_ `Period `_) - - **instance** `SetField `_ \"indexTenor\" :ref:`StubFloatingRate ` (`Optional `_ `Period `_) - **instance** `SetField `_ \"period\" `Period `_ `PeriodEnum `_ **instance** `SetField `_ \"period\" :ref:`Frequency ` `Period `_ @@ -91,18 +83,10 @@ Data Types **instance** `Show `_ `PeriodEnum `_ - **instance** `GetField `_ \"period\" :ref:`DateOffset ` `PeriodEnum `_ - - **instance** `GetField `_ \"period\" :ref:`FixingDates ` `PeriodEnum `_ - **instance** `GetField `_ \"period\" :ref:`DateOffset ` `PeriodEnum `_ **instance** `GetField `_ \"period\" `Period `_ `PeriodEnum `_ - **instance** `SetField `_ \"period\" :ref:`DateOffset ` `PeriodEnum `_ - - **instance** `SetField `_ \"period\" :ref:`FixingDates ` `PeriodEnum `_ - **instance** `SetField `_ \"period\" :ref:`DateOffset ` `PeriodEnum `_ **instance** `SetField `_ \"period\" `Period `_ `PeriodEnum `_ @@ -136,10 +120,6 @@ Data Types **instance** `Show `_ `RollConventionEnum `_ - **instance** `GetField `_ \"rollConvention\" :ref:`CalculationPeriodFrequency ` `RollConventionEnum `_ - **instance** `GetField `_ \"rollConvention\" :ref:`Frequency ` `RollConventionEnum `_ - **instance** `SetField `_ \"rollConvention\" :ref:`CalculationPeriodFrequency ` `RollConventionEnum `_ - **instance** `SetField `_ \"rollConvention\" :ref:`Frequency ` `RollConventionEnum `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Schedule.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Schedule.rst index 2608c1bb0..a45cbc293 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Schedule.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Types-Date-V3-Schedule.rst @@ -96,14 +96,6 @@ Data Types **instance** `GetField `_ \"businessDayAdjustment\" `PeriodicSchedule `_ :ref:`BusinessDayAdjustment ` - **instance** `GetField `_ \"callSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"callSchedule\" :ref:`Callable ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"couponSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"couponSchedule\" :ref:`Callable ` `PeriodicSchedule `_ - **instance** `GetField `_ \"effectiveDate\" `PeriodicSchedule `_ `Date `_ **instance** `GetField `_ \"effectiveDateBusinessDayAdjustment\" `PeriodicSchedule `_ (`Optional `_ :ref:`BusinessDayAdjustment `) @@ -114,46 +106,6 @@ Data Types **instance** `GetField `_ \"lastRegularPeriodEndDate\" `PeriodicSchedule `_ (`Optional `_ `Date `_) - **instance** `GetField `_ \"observationSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"observationSchedule\" :ref:`AutoCallable ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`FixedRate ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`FloatingRate ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`InflationLinked ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`AutoCallable ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`BarrierReverseConvertible ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`Asset ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`CreditDefault ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`CurrencySwap ` `PeriodicSchedule `_ - - **instance** `GetField `_ \"periodicSchedule\" :ref:`InterestRate ` `PeriodicSchedule `_ - **instance** `GetField `_ \"stubPeriodType\" `PeriodicSchedule `_ (`Optional `_ `StubPeriodTypeEnum `_) **instance** `GetField `_ \"terminationDate\" `PeriodicSchedule `_ `Date `_ @@ -162,14 +114,6 @@ Data Types **instance** `SetField `_ \"businessDayAdjustment\" `PeriodicSchedule `_ :ref:`BusinessDayAdjustment ` - **instance** `SetField `_ \"callSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"callSchedule\" :ref:`Callable ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"couponSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"couponSchedule\" :ref:`Callable ` `PeriodicSchedule `_ - **instance** `SetField `_ \"effectiveDate\" `PeriodicSchedule `_ `Date `_ **instance** `SetField `_ \"effectiveDateBusinessDayAdjustment\" `PeriodicSchedule `_ (`Optional `_ :ref:`BusinessDayAdjustment `) @@ -180,46 +124,6 @@ Data Types **instance** `SetField `_ \"lastRegularPeriodEndDate\" `PeriodicSchedule `_ (`Optional `_ `Date `_) - **instance** `SetField `_ \"observationSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"observationSchedule\" :ref:`AutoCallable ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Instrument ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`FixedRate ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`FloatingRate ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`InflationLinked ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`AutoCallable ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`BarrierReverseConvertible ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`Asset ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`CreditDefault ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`CurrencySwap ` `PeriodicSchedule `_ - - **instance** `SetField `_ \"periodicSchedule\" :ref:`InterestRate ` `PeriodicSchedule `_ - **instance** `SetField `_ \"stubPeriodType\" `PeriodicSchedule `_ (`Optional `_ `StubPeriodTypeEnum `_) **instance** `SetField `_ \"terminationDate\" `PeriodicSchedule `_ `Date `_ @@ -302,10 +206,6 @@ Data Types **instance** `GetField `_ \"adjustedStartDate\" `SchedulePeriod `_ `Date `_ - **instance** `GetField `_ \"calculationPeriod\" CalculationPeriodData `SchedulePeriod `_ - - **instance** `GetField `_ \"calculationPeriod\" CalculationPeriodStaticData `SchedulePeriod `_ - **instance** `GetField `_ \"stubType\" `SchedulePeriod `_ (`Optional `_ `StubPeriodTypeEnum `_) **instance** `GetField `_ \"unadjustedEndDate\" `SchedulePeriod `_ `Date `_ @@ -316,10 +216,6 @@ Data Types **instance** `SetField `_ \"adjustedStartDate\" `SchedulePeriod `_ `Date `_ - **instance** `SetField `_ \"calculationPeriod\" CalculationPeriodData `SchedulePeriod `_ - - **instance** `SetField `_ \"calculationPeriod\" CalculationPeriodStaticData `SchedulePeriod `_ - **instance** `SetField `_ \"stubType\" `SchedulePeriod `_ (`Optional `_ `StubPeriodTypeEnum `_) **instance** `SetField `_ \"unadjustedEndDate\" `SchedulePeriod `_ `Date `_ diff --git a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Util-V3-Lockable.rst b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Util-V3-Lockable.rst index 9930df25f..d9d550eb7 100644 --- a/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Util-V3-Lockable.rst +++ b/docs/generated/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Util-V3-Lockable.rst @@ -147,16 +147,6 @@ Data Types **instance** `GetField `_ \"context\" `Lock `_ (`Set `_ `Text `_) - **instance** `GetField `_ \"lock\" :ref:`Account ` (`Optional `_ `Lock `_) - - **instance** `GetField `_ \"lock\" :ref:`BaseHolding ` (`Optional `_ `Lock `_) - - **instance** `GetField `_ \"lock\" :ref:`Fungible ` (`Optional `_ `Lock `_) - - **instance** `GetField `_ \"lock\" :ref:`Transferable ` (`Optional `_ `Lock `_) - - **instance** `GetField `_ \"lock\" :ref:`TransferableFungible ` (`Optional `_ `Lock `_) - **instance** `GetField `_ \"lock\" `View `_ (`Optional `_ `Lock `_) **instance** `GetField `_ \"lockType\" `Lock `_ `LockType `_ @@ -165,16 +155,6 @@ Data Types **instance** `SetField `_ \"context\" `Lock `_ (`Set `_ `Text `_) - **instance** `SetField `_ \"lock\" :ref:`Account ` (`Optional `_ `Lock `_) - - **instance** `SetField `_ \"lock\" :ref:`BaseHolding ` (`Optional `_ `Lock `_) - - **instance** `SetField `_ \"lock\" :ref:`Fungible ` (`Optional `_ `Lock `_) - - **instance** `SetField `_ \"lock\" :ref:`Transferable ` (`Optional `_ `Lock `_) - - **instance** `SetField `_ \"lock\" :ref:`TransferableFungible ` (`Optional `_ `Lock `_) - **instance** `SetField `_ \"lock\" `View `_ (`Optional `_ `Lock `_) **instance** `SetField `_ \"lockType\" `Lock `_ `LockType `_ diff --git a/docs/generated/reference/daml-finance-hoogle.txt b/docs/generated/reference/daml-finance-hoogle.txt index 3a5bf6636..fec6b910f 100644 --- a/docs/generated/reference/daml-finance-hoogle.txt +++ b/docs/generated/reference/daml-finance-hoogle.txt @@ -1244,12 +1244,6 @@ splitImpl :: (HasCreate t, HasToInterface t I) => I -> (Decimal -> t) -> Split - @url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Holding-V4-Util.html#function-daml-finance-holding-v4-util-mergeimpl-70989 mergeImpl :: (HasCreate t, HasArchive t, HasSignatory t, HasFromInterface t I, HasToInterface t I, HasToInterface t I) => I -> (t -> Decimal) -> (Decimal -> t) -> Merge -> Update (ContractId I) --- | Helper to construct the standard Api.HoldingV1.HoldingView shared by --- BaseHolding, Fungible, Transferable and TransferableFungible implementations. --- Converts internal holding state into the API-facing representation. -@url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Holding-V4-Util.html#function-daml-finance-holding-v4-util-toapiholdingview-88985 -toApiHoldingView :: View -> InstrumentKey -> AccountKey -> Decimal -> HoldingView - @url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Instrument-Bond-V3-Callable-Factory.html#module-daml-finance-instrument-bond-v3-callable-factory-64026 module Daml.Finance.Instrument.Bond.V3.Callable.Factory @@ -3484,10 +3478,6 @@ observers :: Create -> PartiesMap @url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Util.html#module-daml-finance-interface-account-v4-util-78761 module Daml.Finance.Interface.Account.V4.Util --- | Fetch the account of a holding. -@url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Util.html#function-daml-finance-interface-account-v4-util-fetchaccount-79234 -fetchAccount :: (HasToInterface t Holding) => t -> Update I - -- | Get the account key of a holding. @url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Account-V4-Util.html#function-daml-finance-interface-account-v4-util-getaccount-6084 getAccount :: (HasToInterface t Holding) => t -> AccountKey @@ -4253,10 +4243,6 @@ qty :: Decimal -> InstrumentKey -> Q @url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Base-V4-Instrument.html#function-daml-finance-interface-instrument-base-v4-instrument-scale-95016 scale :: Decimal -> Q -> Q --- | Fetch instrument from holding. -@url https://docs.daml.com/daml-finance/reference/code-documentation/daml-finance-rst/Daml-Finance-Interface-Instrument-Base-V4-Instrument.html#function-daml-finance-interface-instrument-base-v4-instrument-fetchinstrument-72799 -fetchInstrument :: (HasToInterface t Holding) => t -> Update Instrument - -- | Exercise interface by key. -- This method can be used to exercise a choice on an `Instrument` given its `InstrumentKey`. -- Requires as input the `InstrumentKey`, the actor exercising the choice, and the choice arguments. diff --git a/docs/generated/src/main/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml b/docs/generated/src/main/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml deleted file mode 100644 index 6a629de38..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml +++ /dev/null @@ -1,200 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Claims.V3.Lifecycle.Rule where - -import DA.Set (fromList, singleton) -import DA.Text (sha256) -import Daml.Finance.Claims.V3.Util (isZero') -import Daml.Finance.Claims.V3.Util.Lifecycle (electionEvent, lifecycle, lifecycleClaims, netOnTag, splitPending, timeEvent) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (I, getAcquisitionTime) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), GetView(..), I, View) -import Daml.Finance.Interface.Claims.V4.Types (EventData(..), Pending(..), TaggedClaim(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (R, exerciseInterfaceByKey, getKey) -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (ApplyElection(..), Exercisable(..), ExercisableView(..), getElectionTime) -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), InstrumentKey, Parties, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.InterfaceKey (fetchInterfaceByKey) -import Daml.Finance.Lifecycle.V4.Effect (Effect(..)) -import Daml.Finance.Lifecycle.V4.ElectionEffect (ElectionEffect(..)) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Rule to process an event for instruments that are modelled using "on-the-fly" claims --- (the tree is not stored on-ledger but generated dynamically). --- This rule supports both time update events and election events. -template Rule - with - providers : Parties - -- ^ Providers of the lifecycling rule. - lifecycler : Party - -- ^ Party performing the lifecycling. - observers : PartiesMap - -- ^ Observers of the rule. - id : Id - -- ^ Identifier for the rule contract. - description : Text - -- ^ Textual description. - where - signatory providers - observer Disclosure.flattenObservers observers, lifecycler - - -- Process a time update event. - interface instance Lifecycle.I for Rule where - view = Lifecycle.View with lifecycler; id; description - -- BOND_PROCESS_CLOCK_UPDATE_LIFECYCLE_BEGIN - evolve Lifecycle.Evolve{eventCid; observableCids; instrument} = do - v <- view <$> fetch eventCid - - -- Fast-forward the instrument from inception to the timestamp of the last event. - -- Then, perform a time-based lifecycling according to the current event. - (remaining, pending, claims, claimInstrument, dynamicInstrumentView) <- - fastForwardAndLifecycle instrument observableCids v.eventTime lifecycler - - let - pendingAfterNetting = netOnTag pending - (otherConsumed, otherProduced) = splitPending pendingAfterNetting - if remaining == claims && null pendingAfterNetting then - pure (None, []) - else do - let - currentKey = BaseInstrument.getKey $ toInterface claimInstrument - newKey = currentKey with version = sha256 $ mconcat [show v.eventTime, show remaining] - producedInstrument = if isZero' remaining then None else Some newKey - tryCreateNewInstrument lifecycler dynamicInstrumentView.prevEvents v.eventTime None instrument - newKey - effectCid <- toInterfaceContractId <$> create Effect with - providers = singleton currentKey.issuer - id = v.id - description = v.description - targetInstrument = currentKey - producedInstrument - otherConsumed - otherProduced - settlementTime = Some v.eventTime - observers = (.observers) . view $ toInterface @Disclosure.I claimInstrument - pure (Some newKey, [effectCid]) - -- BOND_PROCESS_CLOCK_UPDATE_LIFECYCLE_END - - -- Process an election event. - interface instance Election.Exercisable for Rule where - view = Election.ExercisableView with lifecycler - applyElection Election.ApplyElection{electionCid; observableCids} = do - - -- fetch election - election <- fetch electionCid - let - v = view election - electionTime = Election.getElectionTime election - election = electionEvent electionTime v.electorIsOwner v.claim - - -- Fast-forward the instrument from inception to the timestamp of the last event. - -- Then, perform a time-based lifecycling according to the current event (used to check - -- whether an election is indeed allowed). - (claimsWithoutElection, _, claims, claimInstrument, dynamicInstrumentView) <- - fastForwardAndLifecycle v.instrument observableCids electionTime lifecycler - - -- lifecycle as of the time given by the event, by applying the corresponding election - let acquisitionTime = Claim.getAcquisitionTime claimInstrument - (remaining, pending) <- lifecycleClaims observableCids acquisitionTime claims [election] - - -- Ensure that an election is indeed possible on this date. This is done by verifying that - -- the claims tree after the election is different from what it would have been in case of - -- a time-based lifecycling only. This check is required since election based lifecycling - -- fails silently (if there is no Or-node today, only a time-based lifecycling is performed, - -- without an error message). - assertMsg ("Ensure that an election is indeed possible for the input (date, tag) pair") $ - remaining /= claimsWithoutElection - - -- create new instrument and return effect - if remaining == claims && null pending then - pure (None, []) - else do - let - electionData = Some (v.electorIsOwner, v.claim) - currentKey = BaseInstrument.getKey $ toInterface claimInstrument - newKey = currentKey with version = sha256 $ mconcat [show electionTime, show remaining] - producedInstrument = if isZero' remaining then None else Some newKey - (otherConsumed, otherProduced) = splitPending pending - tryCreateNewInstrument lifecycler dynamicInstrumentView.prevEvents electionTime - electionData v.instrument newKey - effectCid <- toInterfaceContractId <$> - create ElectionEffect with - providers = fromList [v.instrument.issuer, v.instrument.depository] - custodian = if v.electorIsOwner then v.counterparty else v.elector - owner = if v.electorIsOwner then v.elector else v.counterparty - id = v.id - description = v.description - targetInstrument = currentKey - producedInstrument - amount = v.amount - otherConsumed - otherProduced - settlementTime = Some electionTime - observers = v.observers - pure (Some newKey, [effectCid]) - - interface instance Disclosure.I for Rule where - view = Disclosure.View with disclosureControllers = providers; observers - setObservers = setObserversImpl @Rule @Disclosure.I this None - addObservers = addObserversImpl @Rule @Disclosure.I this None - removeObservers = removeObserversImpl @Rule @Disclosure.I this None - --- | HIDE --- Check if an instrument for the new key already exists, otherwise create it. -tryCreateNewInstrument : Party -> [EventData] -> Time -> Optional (Bool, Text) -> InstrumentKey -> - InstrumentKey -> Update () -tryCreateNewInstrument actor prevEvents eventTime electionData oldKey - newKey = do - existingRefCidOpt <- lookupByKey @BaseInstrument.R newKey - case existingRefCidOpt of - Some _ -> pure () - None -> do - -- CREATE_NEW_DYNAMIC_INSTRUMENT_VERSION_BEGIN - BaseInstrument.exerciseInterfaceByKey @DynamicInstrument.I - oldKey - actor - DynamicInstrument.CreateNewVersion with - lastEventTimestamp = eventTime - prevEvents = case electionData of - None -> prevEvents ++ [timeEvent eventTime] - Some (electorIsOwner, claimTag) -> prevEvents ++ [newElection] - where - newElection = EventData with - t = eventTime - election = Some (electorIsOwner, claimTag) - version = newKey.version - -- CREATE_NEW_DYNAMIC_INSTRUMENT_VERSION_END - pure () - --- | HIDE --- Fast-forward to lastEventTimestamp and lifecycle as of the current event time. -fastForwardAndLifecycle : InstrumentKey -> [ContractId NumericObservable.I] -> Time -> Party -> - Update ([TaggedClaim], [Pending], [TaggedClaim], Claim.I, DynamicInstrument.View) -fastForwardAndLifecycle instrument observableCids eventTime lifecycler = do - - -- BOND_PROCESS_CLOCK_UPDATE_INITAL_CLAIMS_BEGIN - claimInstrument <- fetchInterfaceByKey @BaseInstrument.R instrument - -- BOND_PROCESS_CLOCK_UPDATE_INITAL_CLAIMS_END - -- BOND_PROCESS_CLOCK_UPDATE_LIFECYCLE_FASTFORWARD_BEGIN - -- Recover claims tree as of the lastEventTimestamp. For a bond, this just requires - -- lifecycling as of the lastEventTimestamp. - dynamicInstrumentView <- BaseInstrument.exerciseInterfaceByKey @DynamicInstrument.I - instrument - lifecycler - DynamicInstrument.GetView with viewer = lifecycler - - -- fast-forward the claims tree to the current version by replaying the previous events - let - prevEvents = dynamicInstrumentView.prevEvents <> - [timeEvent dynamicInstrumentView.lastEventTimestamp] - claims <- fst <$> lifecycle lifecycler observableCids claimInstrument prevEvents - -- BOND_PROCESS_CLOCK_UPDATE_LIFECYCLE_FASTFORWARD_END - - let acquisitionTime = Claim.getAcquisitionTime claimInstrument - - -- Lifecycle - (remaining, pending) <- lifecycleClaims observableCids acquisitionTime claims - [timeEvent eventTime] - pure (remaining, pending, claims, claimInstrument, dynamicInstrumentView) diff --git a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/BaseHolding.daml b/docs/generated/src/main/daml/Daml/Finance/Holding/V4/BaseHolding.daml deleted file mode 100644 index a4fa81f87..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/BaseHolding.daml +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.BaseHolding where - -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (toApiHoldingView) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `BaseHolding`. -type T = BaseHolding - --- | Implementation of a `BaseHolding`. --- `BaseHolding` implements the interface `Api.HoldingV1.Holding` (which requires `Lockable.I` and --- `Disclosure.I` to be implemented), but neither `Fungible.I` nor `Transferable.I`. -template BaseHolding - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && isValidLock lock && instrument.holdingStandard == HoldingStandard.BaseHolding - - interface instance Disclosure.I for BaseHolding where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for BaseHolding where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance Api.HoldingV1.Holding for BaseHolding where - view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Fungible.daml b/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Fungible.daml deleted file mode 100644 index 6876945d8..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Fungible.daml +++ /dev/null @@ -1,65 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.Fungible where - -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl, toApiHoldingView) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Fungible`. -type T = Fungible - --- | Implementation of a fungible holding. --- The `Fungible` template implements the interface `Fungible.I` (which requires --- `Api.HoldingV1.Holding`, `Lockable.I`, and `Disclosure.I` to be implemented), but not the `Transferable.I`. -template Fungible - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && isValidLock lock && instrument.holdingStandard == HoldingStandard.Fungible - - interface instance Disclosure.I for Fungible where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for Fungible where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance Api.HoldingV1.Holding for Fungible where - view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount - - interface instance Fungible.I for Fungible where - view = Fungible.View with modifiers = singleton account.owner - split = splitImpl (toInterface @Fungible.I this) (\amount -> this with amount) - merge = mergeImpl (toInterface @Fungible.I this) (.amount) (\amount -> this with amount) diff --git a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Transferable.daml b/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Transferable.daml deleted file mode 100644 index 79fa75f66..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Transferable.daml +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.Transferable where - -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (transferImpl, toApiHoldingView) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Transferable`. -type T = Transferable - --- | Implementation of a transferable holding. --- `Transferable` implements the interface `Transferable.I` (which requires `Api.HoldingV1.Holding`, --- `Lockable.I`, and Disclosure.I` to be implemented), but not the `Fungible.I`. -template Transferable - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && isValidLock lock && instrument.holdingStandard == HoldingStandard.Transferable - - interface instance Disclosure.I for Transferable where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for Transferable where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance Api.HoldingV1.Holding for Transferable where - view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount - - interface instance Transferable.I for Transferable where - view = Transferable.View {} - transfer = transferImpl $ toInterface this diff --git a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/TransferableFungible.daml b/docs/generated/src/main/daml/Daml/Finance/Holding/V4/TransferableFungible.daml deleted file mode 100644 index 793b56544..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/TransferableFungible.daml +++ /dev/null @@ -1,72 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.TransferableFungible where - -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl,toApiHoldingView, transferImpl) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `TransferableFungible`. -type T = TransferableFungible - --- | Implementation of a transferable and fungible holding. --- The `TransferableFungible` template implements the interface `Fungible.I` and `Transferable.I` --- (which requires `Api.HoldingV1.Holding`, `Lockable.I`, and `Disclosure.I` to be implemented). -template TransferableFungible - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && - isValidLock lock && - instrument.holdingStandard == HoldingStandard.TransferableFungible - - interface instance Disclosure.I for TransferableFungible where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for TransferableFungible where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance Api.HoldingV1.Holding for TransferableFungible where - view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount - - interface instance Transferable.I for TransferableFungible where - view = Transferable.View {} - transfer = transferImpl $ toInterface this - - interface instance Fungible.I for TransferableFungible where - view = Fungible.View with modifiers = singleton account.owner - split = splitImpl (toInterface @Fungible.I this) (\amount -> this with amount) - merge = mergeImpl (toInterface @Fungible.I this) (.amount) (\amount -> this with amount) diff --git a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Util.daml b/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Util.daml deleted file mode 100644 index 2ad9bcd10..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Util.daml +++ /dev/null @@ -1,169 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.Util where - -import DA.Action (foldlA) -import DA.Foldable qualified as F (all) -import DA.Set (fromList, isSubsetOf, toList) -import DA.Optional (fromOptional) -import DA.Text (intercalate) -import DA.TextMap qualified as TextMap -import DA.Traversable qualified as T (forA) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Credit(..), Debit(..), I, R, exerciseInterfaceByKey) -import Daml.Finance.Interface.Account.V4.Util (getAccount) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, Merge(..), Split(..), SplitResult(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), Id(..) ) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..) ) -import Daml.Finance.Interface.Util.V3.Common (qty, verify) -import Daml.Finance.Interface.Util.V3.InterfaceKey (fetchInterfaceByKey) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, mustNotBeLocked, View(..)) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 -import Splice.Api.Token.MetadataV1 qualified as SpliceMetadata - -instrumentFromSplice : Api.HoldingV1.InstrumentId -> InstrumentKey -instrumentFromSplice Api.HoldingV1.InstrumentId{admin, id} = - InstrumentKey with - issuer = admin - depository = admin - id = Id id - version = "0" - holdingStandard = HoldingStandard.Transferable - -metaLookup : SpliceMetadata.Metadata -> Text -> Text -metaLookup SpliceMetadata.Metadata { values } key = - fromOptional "" (TextMap.lookup key values) - --- | Default implementation of `transfer` for the `Transferable` interface. -transferImpl : Transferable.I -> ContractId Transferable.I -> Transferable.Transfer - -> Update (ContractId Transferable.I) -transferImpl this self Transferable.Transfer{actors; newOwnerAccount} = do - let - holdingCid = toInterfaceContractId @Api.HoldingV1.Holding self - holding = toInterface @Api.HoldingV1.Holding this - vHolding = view holding - lookupMeta = metaLookup (getField @"meta" vHolding) - custodianTxt = lookupMeta "custodian" - accountIdTxt = lookupMeta "accountId" - - Lockable.mustNotBeLocked this - -- Fetch the new owner account - vNewAccount <- view <$> fetchInterfaceByKey @Account.R @Account.I newOwnerAccount - -- Verify actor permissions - vAccount <- view <$> fetchInterfaceByKey @Account.R @Account.I (getAccount this) - - assertMsg "Actors must contain all transfer outgoing of the sender account" - $ vAccount.controllers.outgoing `isSubsetOf` actors - assertMsg "Actors must contain all transfer incoming of the receiving account" - $ vNewAccount.controllers.incoming `isSubsetOf` actors - assertMsg "Custodians must be the same" - $ custodianTxt == partyToText vNewAccount.custodian - -- Perform debit: remove holding from current owner’s account - let oldAccountKey = getAccount this - Account.exerciseInterfaceByKey @Account.I - oldAccountKey - oldAccountKey.custodian - Account.Debit with holdingCid - -- Credit - coerceInterfaceContractId @Transferable.I <$> - Account.exerciseInterfaceByKey @Account.I - newOwnerAccount - newOwnerAccount.custodian - Account.Credit with - quantity = qty vHolding.amount (instrumentFromSplice (getField @"instrumentId" vHolding)) - - --- | Default implementation of `split` from the `Fungible` interface. -splitImpl : - ( HasCreate t - , HasToInterface t Fungible.I - ) => Fungible.I -> (Decimal -> t) -> Fungible.Split -> Update Fungible.SplitResult -splitImpl this setAmount Fungible.Split{amounts} = do - let vHolding = view . toInterface @Api.HoldingV1.Holding $ this - Lockable.mustNotBeLocked this - let spawn = fmap toInterfaceContractId . create . setAmount - splitCids <- forA amounts spawn - restAmount <- getRestAmount amounts vHolding.amount - rest <- T.forA restAmount spawn - pure Fungible.SplitResult with splitCids; rest - --- | Default implementation of `merge` from the `Fungible` interface. -mergeImpl : - forall t. - ( HasCreate t - , HasArchive t - , HasSignatory t - , HasFromInterface t Fungible.I - , HasToInterface t Fungible.I - , HasToInterface t Lockable.I - ) - => Fungible.I - -> (t -> Decimal) - -> (Decimal -> t) - -> Fungible.Merge - -> Update (ContractId Fungible.I) -mergeImpl this getAmount setAmount Fungible.Merge{fungibleCids} = do - let vHolding = view . toInterface @Api.HoldingV1.Holding $ this - Lockable.mustNotBeLocked this - assertMsg "List of fungibles must be non-empty" . not . null $ fungibleCids - let - currentSignatories = fromList . signatory . setAmount $ vHolding.amount - current = view . toInterface @Api.HoldingV1.Holding . toInterface @Fungible.I . setAmount $ vHolding.amount - aggregate aggregatedAmount fungibleCid = do - Some (otherHoldingCid, otherHolding) <- fetchFromInterface @t fungibleCid - let - otherBase = toInterface @Api.HoldingV1.Holding . toInterface @Fungible.I $ otherHolding - other = view otherBase - assertMsg "Instrument must match" $ other.instrumentId == current.instrumentId - assertMsg "Owner must match" $ other.owner == current.owner - assertMsg "Signatories must match" $ fromList (signatory otherHolding) == currentSignatories - Lockable.mustNotBeLocked (toInterface @Lockable.I otherHolding) - archive otherHoldingCid - pure $ aggregatedAmount + getAmount otherHolding - tot <- foldlA aggregate vHolding.amount fungibleCids - fmap toInterfaceContractId . create . setAmount $ tot - --- | Helper to construct the standard Api.HoldingV1.HoldingView shared by --- BaseHolding, Fungible, Transferable and TransferableFungible implementations. --- Converts internal holding state into the API-facing representation. -toApiHoldingView : Lockable.View -> InstrumentKey -> AccountKey -> Decimal -> Api.HoldingV1.HoldingView -toApiHoldingView lockView instrument account amount = - Api.HoldingV1.HoldingView with - owner = account.owner - instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = show instrument.id - amount = amount - lock = case lockView.lock of - None -> None - Some l -> - Some Api.HoldingV1.Lock with - holders = toList l.lockers - expiresAt = None -- Not present in Lockable - expiresAfter = None -- Not present in Lockable - context = Some (intercalate ", " (toList l.context)) - meta = - SpliceMetadata.Metadata with - values = TextMap.fromList - [ ("depository", partyToText instrument.depository) - , ("version", instrument.version) - , ("holdingStandard", show instrument.holdingStandard) - , ("custodian", partyToText account.custodian) - , ("accountId", show account.id) - ] - - --- | HIDE --- Gets the rest amount of a split (if any) and verifies that split amounts are strictly positive --- and don't exceed the current amount. -getRestAmount : CanAssert m => [Decimal] -> Decimal -> m (Optional Decimal) -getRestAmount amounts currentAmount = do - let splitAmountSum = sum amounts - verify (splitAmountSum <= currentAmount && F.all (> 0.0) amounts && amounts /= []) $ "Fungible::" - <> "verifySplit - Amounts must be non-empty, strictly positive, and not exceed current amount. " - <> "amounts=" <> show amounts - <> ", splitAmountSum=" <> show splitAmountSum - <> ", currentAmount=" <> show currentAmount - let rest = currentAmount - splitAmountSum - pure $ if rest == 0.0 then None else Some rest diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml b/docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml deleted file mode 100644 index 2c277174c..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml +++ /dev/null @@ -1,164 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.V0.AutoCallable.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.StructuredProduct.V0.Util (createAutoCallableClaims) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Instrument qualified as AutoCallable (I, View(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Types (AutoCallable(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Date.Calendar (merge) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models an AutoCallable instrument that pays a conditional coupon. --- It is an AutoCallable Barrier Reverse Convertible where the KI barrier is observed at maturity. --- It is a single-underlying product. --- The instrument is automatically called (redeemed early) if the call barrier is hit. --- The conditional coupon is paid in each coupon period unless the coupon barrier has been hit. --- Both the call barrier and the coupon barrier are observed only on the last observation date of --- each period. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an AAPL underlying this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - putStrike : Decimal - -- ^ The strike of the put (as a percentage of the underlying closing price on the first - -- observation date). - couponBarrier : Decimal - -- ^ The coupon barrier (as a percentage of the underlying closing price on the first - -- observation date). - callBarrier : Decimal - -- ^ The barrier used to automatically call the instrument (as a percentage of the underlying - -- closing price on the first observation date). - finalBarrier : Decimal - -- ^ The barrier used to determine the final redemption amount (as a percentage of the - -- underlying closing price on the first observation date). - couponRate : Decimal - -- ^ The fixed coupon rate, either per annum or per coupon period (depending on the - -- dayCountConvention below). - observationSchedule : PeriodicSchedule - -- ^ The schedule for the observation dates. These are used to observe the barrier, determine - -- whether the instrument is automatically called and to determine the final redemption - -- amount. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the product. For example, if the product pays in USD this should be a USD - -- cash instrument. - notional : Decimal - -- ^ The notional of the product. This is the face value corresponding to one unit of the - -- product. For example, if one product unit corresponds to 1000 USD, this should be 1000.0. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous events that have been lifecycled on this instrument so far. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the instrument's acquisition time) - - let - getCalendars = getHolidayCalendars actor calendarDataProvider - floatingRate = None - capRate = None - floorRate = None - fixingBusinessCenters = [] - - assertMsg "Currently only put strike of 100% supported" $ putStrike == 1.00 - fixingCals <- getHolidayCalendars issuer calendarDataProvider fixingBusinessCenters - (schedule, _) <- rollSchedule getCalendars periodicSchedule holidayCalendarIds - (callableSchedule, _) <- rollSchedule getCalendars observationSchedule holidayCalendarIds - assertMsg "The callable schedule must have the same length as the coupon schedule" $ - length schedule == length callableSchedule - let - useAdjustedDatesForDcf = True - callableClaims = createAutoCallableClaims dateToDateClockTime schedule callableSchedule - periodicSchedule useAdjustedDatesForDcf couponRate dayCountConvention notional currency - floatingRate capRate floorRate referenceAssetId couponBarrier callBarrier finalBarrier - putStrike $ merge fixingCals - - pure [callableClaims] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance AutoCallable.I for Instrument where - view = AutoCallable.View with - autoCallable = AutoCallable with - instrument = BaseInstrument.instrumentKey this - description - referenceAssetId - putStrike - couponBarrier - callBarrier - finalBarrier - couponRate - observationSchedule - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - prevEvents - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp; - prevEvents} = do - cid <- create this with version; lastEventTimestamp; prevEvents - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - addObservers = addObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Account/V4/Util.daml b/docs/generated/src/main/daml/Daml/Finance/Interface/Account/V4/Util.daml deleted file mode 100644 index 87d4fa1c5..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Interface/Account/V4/Util.daml +++ /dev/null @@ -1,47 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Account.V4.Util where - -import DA.Optional(fromSome) -import DA.TextMap qualified as TextMap -import Daml.Finance.Interface.Account.V4.Account qualified as Account (I, R) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), Id(..)) -import Daml.Finance.Interface.Util.V3.InterfaceKey (fetchInterfaceByKey) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 -import Splice.Api.Token.MetadataV1 () - --- | Fetch the account of a holding. -fetchAccount : (HasToInterface t Api.HoldingV1.Holding) => t -> Update Account.I -fetchAccount holding = - let accountKey = getAccount holding - in fetchInterfaceByKey @Account.R @Account.I accountKey - --- | Get the account key of a holding. -getAccount : (HasToInterface t Api.HoldingV1.Holding) => t -> AccountKey -getAccount holding = - let - vHolding = view (toInterface @Api.HoldingV1.Holding holding) - metaVals = vHolding.meta.values - - custodianTxt = fromSome (TextMap.lookup "custodian" metaVals) - accountIdTxt = fromSome (TextMap.lookup "accountId" metaVals) - - in - AccountKey with - custodian = fromSome (partyFromText custodianTxt) - owner = vHolding.owner - id = Id accountIdTxt - --- | Get the custodian of a holding. -getCustodian : (HasToInterface t Api.HoldingV1.Holding) => t -> Party -getCustodian holding = - let - metaVals = (view $ toInterface @Api.HoldingV1.Holding holding).meta.values - custodianTxt = fromSome (TextMap.lookup "custodian" metaVals) - in - fromSome (partyFromText custodianTxt) - --- | Get the owner of a holding. -getOwner : (HasToInterface t Api.HoldingV1.Holding) => t -> Party -getOwner = (.owner) . view . toInterface @Api.HoldingV1.Holding diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml b/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml deleted file mode 100644 index 3dbbaea6f..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml +++ /dev/null @@ -1,180 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Interface.Instrument.Base.V4.Instrument where - -import Daml.Finance.Interface.Util.V3.HoldingSplice (getInstrument) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard, Id(..), InstrumentKey(..), PartiesMap, Quantity(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, flattenObservers) -import Daml.Finance.Interface.Util.V3.InterfaceKey (createReferenceHelper, disclosureUpdateReferenceHelper, fetchInterfaceByKey) -import Daml.Finance.Interface.Util.V3.InterfaceKey qualified as InterfaceKey (HasInterfaceKey(..), exerciseInterfaceByKeyHelper) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Instrument quantity. -type Q = Quantity InstrumentKey Decimal - --- | Type synonym for `Reference`. This type is currently used as a work-around given the lack of --- interface keys. -type R = Reference - --- | Type synonym for `View`. -type V = View - --- | View for `Instrument`. -data View = View - with - issuer : Party - -- ^ The instrument's issuer. - depository : Party - -- ^ The instrument's depository. - id : Id - -- ^ The instrument's identifier. - version : Text - -- ^ A textual instrument version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A human readable description of the instrument. - validAsOf : Time - -- ^ Timestamp as of which the instrument is valid. This usually coincides with the timestamp - -- of the event that creates the instrument. It usually does not coincide with ledger time. - -- This is required for lifecycling of some instruments, in order to keep track of the last - -- time the instrument was lifecycled. For instruments where this is not applicable, it can - -- be set to the current time. - deriving (Eq, Show) - --- | Convert the instrument's View to its key. -toKey : V -> InstrumentKey -toKey v = InstrumentKey with - depository = v.depository - issuer = v.issuer - id = v.id - version = v.version - holdingStandard = v.holdingStandard - --- | Retrieves the key of an `Instrument`. -instrumentKey : (HasToInterface i Instrument) => i -> InstrumentKey -instrumentKey = toKey . view . toInterface @Instrument - --- | Base interface for all instruments. This interface does not define any lifecycling logic. -interface Instrument requires Disclosure.I where - viewtype V - - getKey : InstrumentKey - -- ^ Get the unique key for the `Instrument`. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - choice Remove : () - -- ^ Archive the instrument. - controller signatory this - do - (refCid, _) <- fetchByKey @Reference $ getKey this - archive refCid - --- | HIDE --- This template is used to key an Instrument contract. It allows for looking up this contract by --- key then acquiring the Instrument contract by fetching its contract id on this contract. As --- updates are made to an Instrument, this Reference contract is required to be kept in sync. -template Reference - with - instrumentView : V - -- ^ The default view. - cid : ContractId Instrument - -- ^ The contract id of the instrument. - observers : PartiesMap - -- ^ Observers. - where - signatory instrumentView.depository, instrumentView.issuer - observer Disclosure.flattenObservers observers - - key toKey instrumentView : InstrumentKey - maintainer key.issuer - - nonconsuming choice GetCid : ContractId Instrument - -- ^ Get the `Instrument`'s contract id. - with - viewer : Party - -- ^ The party retrieving the instrument. - controller viewer - do - pure cid - - choice SetCid : ContractId Reference - -- ^ Set the instrument cid. This choice should be called only from `Instrument` - -- implementations. - with - newCid : ContractId Instrument - -- ^ The instrument cid. - controller signatory this - do - create this with cid = newCid - - choice SetObservers : ContractId Reference - -- ^ Set observers. This choice should be called only from `Instrument` implementations. - with - newObservers : PartiesMap - -- ^ The new observers. - controller signatory this - do - create this with observers = newObservers - --- | Wraps an amount and an instrument key into an instrument quantity. -qty : Decimal -> InstrumentKey -> Q -qty amount instrument = Quantity with unit = instrument; amount - --- | Scale `Quantity` by the provided factor. -scale : Decimal -> Q -> Q -scale factor quantity = quantity with amount = quantity.amount * factor - --- | Fetch instrument from holding. -fetchInstrument : (HasToInterface t Api.HoldingV1.Holding) => t -> Update Instrument -fetchInstrument = fetchInterfaceByKey @Reference . getInstrument . toInterface @Api.HoldingV1.Holding - --- | Exercise interface by key. --- This method can be used to exercise a choice on an `Instrument` given its `InstrumentKey`. --- Requires as input the `InstrumentKey`, the actor exercising the choice, and the choice arguments. -exerciseInterfaceByKey : forall i c r. - ( HasInterfaceTypeRep i - , HasExercise i c r - ) - => InstrumentKey -- ^ The instrument key. - -> Party -- ^ The actor exercising. - -> c -- ^ The choice arguments. - -> Update r -exerciseInterfaceByKey k actor arg = InterfaceKey.exerciseInterfaceByKeyHelper @Reference @GetCid - @SetCid @SetObservers @GetView @i k actor arg - --- | HIDE --- Create instance of HasInterfaceKey. -instance InterfaceKey.HasInterfaceKey Instrument View InstrumentKey Reference GetCid SetCid - SetObservers GetView where - createReference = Reference - getCid = GetCid - setCid = SetCid - setObservers = SetObservers - getView = GetView - --- | HIDE --- Create Reference for the instrument. -createReference : Party -> ContractId Instrument -> Update (ContractId Reference) -createReference = createReferenceHelper @Reference @GetCid @SetCid @SetObservers @GetView - --- | HIDE --- Update the instrument reference once observers are added to the instrument. -disclosureUpdateReference : InstrumentKey -> PartiesMap -> ContractId Instrument -> - Update (ContractId Disclosure.I) -disclosureUpdateReference = - disclosureUpdateReferenceHelper @Reference @GetCid @SetCid @SetObservers @GetView diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Types.daml b/docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Types.daml deleted file mode 100644 index 1048b3ffc..000000000 --- a/docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Types.daml +++ /dev/null @@ -1,85 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Settlement.V4.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey, Id) -import Splice.Api.Token.HoldingV1 (InstrumentId) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Describes a quantity of a specific instrument to be transferred. -data Quantity = Quantity - with - amount : Decimal - -- ^ The amount of the instrument to be transferred. - unit : InstrumentId - -- ^ The instrument being transferred (identified by Splice InstrumentId). - deriving (Eq, Ord, Show) - --- | Describes a transfer of a position between two parties. -data Step = Step - with - sender : Party - -- ^ Party transferring the asset. - receiver : Party - -- ^ Party receiving the asset. - quantity : Quantity - -- ^ The instrument and amount to be transferred. - deriving (Eq, Ord, Show) - --- | Describes a transfer of a position between two parties. --- The custodian at which the position is held is also specified. -data RoutedStep = RoutedStep - with - sender : Party - -- ^ Party transferring the asset. - receiver : Party - -- ^ Party receiving the asset. - custodian : Party - -- ^ The custodian at which the asset is held. - quantity : Quantity - -- ^ The instrument and amount to be transferred. - version : Optional Text - -- ^ Optional version string. If provided, settlement must match this version; otherwise, the Registry infers it. - - deriving (Eq, Ord, Show) - --- | Describes an allocation of an `Instruction`. -data Allocation - = Unallocated - -- ^ An unallocated instruction. - | Pledge (ContractId Api.HoldingV1.Holding) - -- ^ Settle the instruction with the pledged asset. - | CreditReceiver - -- ^ Settle the instruction by crediting the receiver account (where the sender is custodian). - | SettleOffledger - -- ^ Settle the instruction off-ledger. - | PassThroughFrom (AccountKey, InstructionKey) - -- ^ Settle the instruction with the holding coming from the specified instruction and account. - deriving (Eq, Show) - --- | Describes an approval of an `Instruction`. -data Approval - = Unapproved - -- ^ An unapproved instruction. - | TakeDelivery AccountKey - -- ^ Take delivery to the specified account. - | DebitSender - -- ^ Debit the sender account with the provided asset (where the receiver is custodian). - | SettleOffledgerAcknowledge - -- ^ Acknowledge settlement of the instruction off-ledger. - | PassThroughTo (AccountKey, InstructionKey) - -- ^ Take delivery to the specified account. The holding is then immediately allocated to the - -- specified instruction. - deriving (Eq, Show) - --- | A unique key for Instructions. -data InstructionKey = InstructionKey - with - instructor : Party - -- ^ Party instructing settlement (and the creation of the `Instruction`). - batchId : Id - -- ^ Id of the batch the instruction belongs to. - id : Id - -- ^ A unique identifier for an instruction. - deriving (Eq, Ord, Show) diff --git a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Holding.daml b/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Holding.daml deleted file mode 100644 index 5f5770e15..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Holding.daml +++ /dev/null @@ -1,143 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.Test.Holding where - -import DA.Assert ((===)) -import DA.Map qualified as Map (fromList) -import DA.Set (fromList, singleton) -import Daml.Finance.Account.V4.Account qualified as Account (T) -import Daml.Finance.Holding.Test.Common (TestInitialState(..), TestParties(..), setupInitialState, setupParties) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Debit(..), I) -import Daml.Finance.Interface.Holding.V4.Factory qualified as HoldingFactory (R) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, Split(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I, RemoveObservers(..)) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (Acquire(..), I, LockType(..), Release(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), submitExerciseInterfaceByKeyCmd, submitMustFailExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.HoldingFactory qualified as HoldingFactory (submitExerciseInterfaceByKeyCmd) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - -run : Script () -run = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; locker; locker2} <- setupParties - - -- Initialize state - TestInitialState {investorAccount; issuerAccount; issuerHoldingCid; holdingFactory} <- - setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers = mempty - BaseHolding - [] - Account.Owner - - -- Can disclose holding factory - let - getReference = queryFilter @HoldingFactory.R custodian (\hf -> key hf == holdingFactory) - observers = ("test", singleton investor) - cid <- HoldingFactory.submitExerciseInterfaceByKeyCmd @Disclosure.I [custodian] [] holdingFactory $ - Disclosure.AddObservers with - disclosers = singleton custodian - observersToAdd = observers - Some disclosure <- queryInterfaceContractId @Disclosure.I custodian cid - disclosure.observers === Map.fromList [observers] - [(_, ref)] <- getReference - ref.observers === Map.fromList [observers] - - -- Can undisclose holding factory - Some cid <- HoldingFactory.submitExerciseInterfaceByKeyCmd @Disclosure.I [custodian] [] - holdingFactory $ Disclosure.RemoveObservers with - disclosers = singleton custodian - observersToRemove = observers - Some disclosure <- queryInterfaceContractId @Disclosure.I custodian cid - disclosure.observers === mempty - [(_, ref)] <- getReference - ref.observers === mempty - - -- Cannot split - submitMustFail (actAs [issuer, investor]) do - exerciseCmd (fromInterfaceContractId @Fungible.I issuerHoldingCid) - Fungible.Split with amounts = [100.0] - - -- Cannot transfer - submitMustFail (actAs [issuer, investor]) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with - actors = fromList [issuer, investor]; newOwnerAccount = investorAccount - - -- Cannot lock with empty lockers - submitMustFail issuer do - exerciseCmd (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid) - Lockable.Acquire with - newLockers = mempty; context = "Test Lock"; lockType = Lockable.Semaphore - - -- Lock asset with a one time lock - lockableCid <- submit (actAs [issuer, locker]) do - exerciseCmd (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid) - Lockable.Acquire with - newLockers = singleton locker; context = "Test Lock"; lockType = Lockable.Semaphore - - -- Same Locker attempts locks asset again - submitMustFail (actAs [issuer, locker]) do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = singleton locker; context = "Second attempt"; lockType =Lockable.Semaphore - - -- Another locker attempts to lock this asset - submitMustFail (actAs [issuer, locker2]) do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = singleton locker2; context = "Steal lock"; lockType =Lockable.Semaphore - - -- Cannot debit - Account.submitMustFailExerciseInterfaceByKeyCmd @Account.I [custodian, issuer] [] issuerAccount $ - Account.Debit with holdingCid = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid - - -- Unlock asset - lockableCid <- submit locker do - exerciseCmd lockableCid Lockable.Release with context = "Test Lock" - - -- Lock asset with a reentrant lock - lockableCid <- submit (actAs [issuer, locker]) do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = singleton locker; context = "Lock 1"; lockType = Lockable.Reentrant - - -- Same Locker locks asset again for the same context - submitMustFail (actAs [issuer, locker]) do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = singleton locker; context = "Lock 1"; lockType = Lockable.Reentrant - - -- Lock asset with a reentrant lock for another context - lockableCid <- submit (actAs [issuer, locker]) do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = singleton locker; context = "Lock 2"; lockType = Lockable.Reentrant - - -- Another locker attempts to lock this asset - submitMustFail (actAs [issuer, locker2]) do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = singleton locker2; context = "Steal lock"; lockType = Lockable.Semaphore - submitMustFail (actAs [issuer, locker2]) do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = singleton locker2; context = "Steal lock"; lockType = Lockable.Reentrant - - -- Unlock one lock - lockableCid <- submit locker do exerciseCmd lockableCid Lockable.Release with context = "Lock 2" - - -- Debit fails as the asset is still locked - Account.submitMustFailExerciseInterfaceByKeyCmd @Account.I [custodian, issuer] [] issuerAccount $ - Account.Debit with holdingCid = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid - - -- Unlock the final lock - lockableCid <- submit locker do exerciseCmd lockableCid Lockable.Release with context = "Lock 1" - - -- Make sure the issuer account has no observers - [(accountCid, account)] <- query @Account.T issuer - account.observers === mempty - - -- Debit asset - Account.submitExerciseInterfaceByKeyCmd @Account.I [custodian, issuer] [] issuerAccount $ - Account.Debit with holdingCid = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid - - pure () \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml deleted file mode 100644 index e8621d0fb..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml +++ /dev/null @@ -1,708 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.Test.Intermediated.BondCoupon where - -import ContingentClaims.Core.V3.Claim (andList, at, one, scale, when) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Assert ((===)) -import DA.Date (addDays, toDateUTC) -import DA.Foldable qualified as F (forA_) -import DA.List (head, (!!)) -import DA.Map (Map) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Generic.Test.Util (mapClaimToUTCTime, originateGeneric) -import Daml.Finance.Instrument.Generic.V4.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Interface.Util.V3.HoldingSplice (getInstrument) -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (GetView(..), I, SetProviders(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..), GetView(..)) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..), InstructionKey(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey, HoldingStandard(..), Id(..), InstrumentKey, Parties) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.Hierarchy (Hierarchy(..)) -import Daml.Finance.Settlement.V4.Instruction qualified as Instruction (T) -import Daml.Finance.Settlement.V4.RouteProvider.IntermediatedStatic (IntermediatedStatic(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit, submitExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as BaseInstrument (originate) -import Daml.Finance.Test.Util.Time (createClockUpdateEvent) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - -{- - This script distributes a bond to investors and showcases how the bond can be lifecycled to - trigger (and settle) a coupon payment. - - Bond (security) account structure : - - Issuer - | - CSD - | - Investor - - Cash account structure : - - Central Bank - / | \ - CSD Issuer Bank - \ - Investor - - In the "non-atomic" script, the lifecycling and settlement happen in three steps: - - issuer lifecycles the instrument - - effects are settled between issuer and CSD - - effects are settled between CSD and investor(s) - - The last step involves moving cash through an account hierarchy. - - In the "atomic" script, the last two steps are executed atomically. --} - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ The Bank acts as custodian of the investor's cash holdings. - centralBank : Party - -- ^ The Central Bank is the depository and the issuer of the cash instrument. It also acts - -- as root custodian of the cash holdings. - csd : Party - -- ^ Custodian of the bond holding (from the perspective of an investor). It also acts as - -- depository of the bond instrument. - issuer : Party - -- ^ Acts as issuer, as well as the root custodian, of the bond instrument. It is also the - -- party tasked with lifecycling the bond. - investor : Party - -- ^ Owner of the bond holding. - settlers : Parties - -- ^ Any party of the settlers triggers the settlement of fully allocated settlement - -- instructions. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- | Originate USD cash instrument and define settlement route. -originateCashAndDefineRoute : TestParties -> Time -> Script (InstrumentKey, (Text, Hierarchy)) -originateCashAndDefineRoute TestParties{bank, centralBank, csd, investor, issuer, publicParty} - now = do - let - pp = [("PublicParty", Set.singleton publicParty)] - label = "USD" - -- CREATE_CASH_ROUTE_BEGIN - {- - Cash account structure : - - Central Bank - / | \ - CSD Issuer Bank - \ - Investor - -} - route = - ( label - , Hierarchy with - rootCustodian = centralBank - pathsToRootCustodian = [[investor, bank], [csd], [issuer]] - ) - -- CREATE_CASH_ROUTE_END - instrument <- BaseInstrument.originate centralBank centralBank "USD" TransferableFungible - "United States Dollar" pp now - pure (instrument, route) - - --- | Originate bond instrument and define settlement route. -originateSecurityAndDefineRoute : TestParties -> Time -> InstrumentKey -> - Script (InstrumentKey, (Text, Hierarchy)) -originateSecurityAndDefineRoute TestParties{bank, csd, investor, issuer, publicParty} now - cashInstrument = do - -- CREATE_CC_INSTRUMENT_VARIABLES_BEGIN - let - today = toDateUTC now - expiry = addDays today 180 - bondLabel = "ABC.DE 4% p.a. " <> show expiry <> " Corp" - claims = mapClaimToUTCTime $ andList - [ when (at today) $ scale (Const 0.02) $ one cashInstrument - , when (at expiry) $ scale (Const 0.02) $ one cashInstrument - , when (at expiry) $ scale (Const 1.0) $ one cashInstrument - ] - -- CREATE_CC_INSTRUMENT_VARIABLES_END - let pp = [("PublicParty", Set.singleton publicParty)] - -- CREATE_CC_INSTRUMENT_BEGIN - instrument <- - originateGeneric csd issuer bondLabel TransferableFungible "Bond" now claims pp now - -- CREATE_CC_INSTRUMENT_END - -- CREATE_BOND_ROUTE_BEGIN - {- - Bond (security) account structure : - - Issuer - | - CSD - | - Investor - -} - let - route = - ( bondLabel - , Hierarchy with - rootCustodian = issuer - pathsToRootCustodian = [[investor, csd]] - ) - -- CREATE_BOND_ROUTE_END - pure (instrument, route) - --- | Penultimate coupon payment on a bond showing creation of new instrument version. --- Settlement of effects does not happen atomically. -runIntermediatedLifecyclingNonAtomic : Script () -runIntermediatedLifecyclingNonAtomic = script do - parties@TestParties{..} <- setupParties - - -- Setup security accounts - [investorSecuritiesAccount] <- setupAccounts "Securities Account" csd publicParty [investor] - [csdAccountAtIssuer] <- setupAccounts "Securities Account" issuer publicParty [csd] - - -- Setup cash accounts at central bank - [issuerCashAccount, bankCashAccount, csdCashAccount] <- - setupAccounts "Cash Account" centralBank publicParty [issuer, bank, csd] - - -- Setup investor's cash account at Bank - [investorCashAccount] <- setupAccounts "Cash Account" bank publicParty [investor] - - -- Originate and distribute central-bank cash - now <- getTime - let today = toDateUTC now - - (cashInstrument, cashRoute) <- originateCashAndDefineRoute parties now - issuerCashHoldingCid <- Account.credit [publicParty] cashInstrument 20_000.0 issuerCashAccount - - -- Originate and distribute bond - (bondInstrument, bondRoute) <- originateSecurityAndDefineRoute parties now cashInstrument - csdBondHoldingCid <- Account.credit [publicParty] bondInstrument 1_000_000.0 csdAccountAtIssuer - investorBondHoldingCid <- - Account.credit [publicParty] bondInstrument 1_000_000.0 investorSecuritiesAccount - - -- CREATE_CLOCK_FOR_BOND_LIFECYCLING_BEGIN - -- create clock update event exactly on the first coupon date - let firstCouponDate = addDays (toDateUTC now) 90 - clockEventCid <- createClockUpdateEvent (Set.singleton issuer) firstCouponDate mempty -- Important: need to replace "today" by firstCouponDate when we use Sandbox! - - - -- CREATE_CLOCK_FOR_BOND_LIFECYCLING_END - - -- LIFECYCLE_BOND_CREATE_RULE_BEGIN - -- Create a lifecycle rule - lifecycleRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit csd do - createCmd Lifecycle.Rule with - providers = Set.singleton csd - observers = mempty - lifecycler = issuer - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - -- LIFECYCLE_BOND_CREATE_RULE_END - - -- LIFECYCLE_BOND_BEGIN - -- Try to lifecycle the instrument - (resultInstrument, effectCids) <- submit issuer do - exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids = [] - instrument = bondInstrument - - let - effectCid = - case effectCids of - [x] -> x - [] -> error "No effects produced by Lifecycle.Evolve" - xs -> error ("Unexpected number of effects: " <> show (length xs)) - - - -- LIFECYCLE_BOND_END - - -- Define settlement routes across intermediaries - let routes = Map.fromList [cashRoute, bondRoute] - - -- LIFECYCLE_BOND_ISSUER_CSD_BEGIN - -- Setup settlement contract between issuer and CSD - -- In order for the workflow to be successful, we need to disclose the CSD's cash account to the - -- Issuer. - Account.submitExerciseInterfaceByKeyCmd @Disclosure.I [csd] [] csdCashAccount - Disclosure.AddObservers with - disclosers = Set.singleton csd - observersToAdd = ("Issuer", Set.singleton issuer) - - settle1Cid <- submit [csd, issuer] do - createCmd EffectSettlementService with - csd - issuer - instrumentId = bondInstrument.id - securitiesAccount = csdAccountAtIssuer - issuerCashAccount - csdCashAccount - settlementRoutes = routes - - -- CSD claims and settles effect against issuer - (effectCid, newInstrumentHoldingCid, _) <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd settle1Cid ClaimAndSettle with - instrumentHoldingCid = csdBondHoldingCid - cashHoldingCid = issuerCashHoldingCid - effectCid - -- LIFECYCLE_BOND_ISSUER_CSD_END - - -- Find correct USD holding of CSD after ClaimAndSettle - holdings <- queryInterface @Api.HoldingV1.Holding csd - - let cashHolding = - case [ cid - | (cid, Some v) <- holdings - , v.owner == csd - , v.instrumentId.admin == centralBank - , v.instrumentId.id == "USD" - ] of - cid :: _ -> cid - [] -> error "No USD cash holding found for CSD after ClaimAndSettle" - - -- LIFECYCLE_BOND_SETTLEMENT_FACTORY_BEGIN - -- investor claims effect against CSD - routeProviderCid <- toInterfaceContractId <$> submit csd do - createCmd IntermediatedStatic with - provider = csd - observers = Set.singleton investor - paths = routes - - settlementFactoryCid <- submit csd do - toInterfaceContractId <$> createCmd Factory with - provider = csd; observers = Set.singleton investor - -- LIFECYCLE_BOND_SETTLEMENT_FACTORY_END - - -- LIFECYCLE_BOND_CSD_INVESTOR_BEGIN - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit csd do - createCmd Claim.Rule with - provider = csd - claimers = Set.fromList [csd, investor] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - result <- submit csd do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = csd - holdingCids = [investorBondHoldingCid] - effectCid - batchId = Id "CouponSettlement" - -- LIFECYCLE_BOND_CSD_INVESTOR_END - - -- LIFECYCLE_BOND_ALLOCATE_APPROVE_SETTLE_BEGIN - let - [csdCashInstructionCid, bankCashInstructionCid, investorBondInstructionCid, - csdBondInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorBondInstructionCid, _) <- submit investor do - exerciseCmd investorBondInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = SettlementTypes.Pledge investorBondHoldingCid - - (csdBondInstructionCid, _) <- submit csd do - exerciseCmd csdBondInstructionCid Instruction.Allocate with - actors = Set.singleton csd - allocation = SettlementTypes.CreditReceiver - - (csdCashInstructionCid, _) <- submit csd do - exerciseCmd csdCashInstructionCid Instruction.Allocate with - actors = Set.singleton csd - allocation = SettlementTypes.Pledge cashHolding - - (bankCashInstructionCid, _) <- submit bank do - exerciseCmd bankCashInstructionCid Instruction.Allocate with - actors = Set.singleton bank - allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - investorBondInstructionCid <- submit csd do - exerciseCmd investorBondInstructionCid Instruction.Approve with - actors = Set.singleton csd; approval = SettlementTypes.DebitSender - csdBondInstructionCid <- submit investor do - exerciseCmd csdBondInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorSecuritiesAccount - csdCashInstructionCid <- submit bank do - exerciseCmd csdCashInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = SettlementTypes.TakeDelivery bankCashAccount - bankCashInstructionCid <- submit investor do - exerciseCmd bankCashInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorCashAccount - - -- Settle batch - [bankCashHoldingCid,investorCashHoldingCid ,investorBondHoldingCid ] <- - submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - Holding.verifyOwnerOfHolding - [ (investor, investorBondHoldingCid) - , (investor, investorCashHoldingCid) - , (bank, bankCashHoldingCid) - ] - - pure () - - --- | Penultimate coupon payment on a bond showing creation of new instrument version. --- The effect is claimed and settled atomically across the entire chain. -runIntermediatedLifecyclingAtomic : Script () -runIntermediatedLifecyclingAtomic = script do - parties@TestParties{..} <- setupParties - - -- Setup security accounts - [investorSecuritiesAccount] <- setupAccounts "Securities Account" csd publicParty [investor] - [csdAccountAtIssuer] <- setupAccounts "Securities Account" issuer publicParty [csd] - - -- Setup cash accounts at central bank - [issuerCashAccount, bankCashAccount, csdCashAccount] <- - setupAccounts "Cash Account" centralBank publicParty [issuer, bank, csd] - - -- Setup investor's cash account at Bank - [investorCashAccount] <- setupAccounts "Cash Account" bank publicParty [investor] - - -- Originate and distribute central-bank cash - now <- getTime - let today = toDateUTC now - - (cashInstrument, cashRoute) <- originateCashAndDefineRoute parties now - issuerCashHoldingCid <- Account.credit [publicParty] cashInstrument 20_000.0 issuerCashAccount - - -- Originate and distribute bond - (bondInstrument, bondRoute) <- originateSecurityAndDefineRoute parties now cashInstrument - csdBondHoldingCid <- Account.credit [publicParty] bondInstrument 1_000_000.0 csdAccountAtIssuer - investorBondHoldingCid <- - Account.credit [publicParty] bondInstrument 1_000_000.0 investorSecuritiesAccount - - -- create clock update event - let firstCoupon = addDays (toDateUTC now) 90 - clockEventCid <- createClockUpdateEvent (Set.singleton issuer) firstCoupon mempty - - -- Create a lifecycle rule - lifecycleRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit csd do - createCmd Lifecycle.Rule with - providers = Set.singleton csd - observers = mempty - lifecycler = issuer - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - - -- Try to lifecycle the instrument - (resultInstrument, effectCids) <- submit issuer do - exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids = [] - instrument = bondInstrument - - let - effectCid = - case effectCids of - [x] -> x - [] -> error "Atomic: No effects produced by Lifecycle.Evolve" - xs -> error ("Atomic: Unexpected number of effects: " <> show (length xs)) - - -- Define settlement routes from CSD to Investor and create batch factory - let routes = Map.fromList [cashRoute, bondRoute] - - routeProviderCid <- toInterfaceContractId <$> submit csd do - createCmd IntermediatedStatic with - provider = csd; observers = Set.singleton investor; paths = routes - - settlementFactoryCid <- submit csd do - toInterfaceContractId <$> createCmd Factory with - provider = csd; observers = Set.singleton investor - - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit csd do - createCmd Claim.Rule with - provider = csd - claimers = Set.singleton csd - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - -- LIFECYCLE_BOND_ATOMIC_CLAIMEFFECT_BEGIN - result <- submit csd do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = csd - holdingCids = [csdBondHoldingCid, investorBondHoldingCid] - effectCid - batchId = Id "CouponSettlement" - -- LIFECYCLE_BOND_ATOMIC_CLAIMEFFECT_END - - -- LIFECYCLE_BOND_ATOMIC_INSTRUCTIONS_BEGIN - let - [ issuerCashInstructionCid -- coupon payment from issuer to CSD - , csdCashInstructionCid -- coupon payment from CSD to investor's bank - , bankCashInstructionCid -- coupon payment from investor's bank to investor - - , csdBondInstructionCid1 -- old bond from CSD to issuer - , issuerBondInstructionCid -- new bond from issuer to CSD - , investorBondInstructionCid -- old bond from investor to CSD - , csdBondInstructionCid2 -- new bond from CSD to investor - ] = result.instructionCids - -- LIFECYCLE_BOND_ATOMIC_INSTRUCTIONS_END - - Some issuerCashInstruction <- - queryContractId csd $ fromInterfaceContractId @Instruction.T issuerCashInstructionCid - - let - issuerCashInstructionKey = SettlementTypes.InstructionKey with - instructor = issuerCashInstruction.instructor - batchId = issuerCashInstruction.batchId - id = issuerCashInstruction.id - - Some csdCashInstruction <- - queryContractId csd $ fromInterfaceContractId @Instruction.T csdCashInstructionCid - let - csdCashInstructionKey = SettlementTypes.InstructionKey with - instructor = csdCashInstruction.instructor - batchId = csdCashInstruction.batchId - id = csdCashInstruction.id - - -- Allocate instructions - (csdBondInstructionCid1, _) <- submit csd do - exerciseCmd csdBondInstructionCid1 Instruction.Allocate with - actors = Set.singleton csd; allocation = SettlementTypes.Pledge csdBondHoldingCid - - (issuerBondInstructionCid, _) <- submit issuer do - exerciseCmd issuerBondInstructionCid Instruction.Allocate with - actors = Set.singleton issuer; allocation = SettlementTypes.CreditReceiver - - (issuerCashInstructionCid, _) <- submit issuer do - exerciseCmd issuerCashInstructionCid Instruction.Allocate with - actors = Set.singleton issuer; allocation = SettlementTypes.Pledge issuerCashHoldingCid - - (investorBondInstructionCid, _) <- submit investor do - exerciseCmd investorBondInstructionCid Instruction.Allocate with - actors = Set.singleton investor; allocation = SettlementTypes.Pledge investorBondHoldingCid - - (csdBondInstructionCid2, _) <- submit csd do - exerciseCmd csdBondInstructionCid2 Instruction.Allocate with - actors = Set.singleton csd; allocation = SettlementTypes.CreditReceiver - - (csdCashInstructionCid, _) <- submit csd do - exerciseCmd csdCashInstructionCid Instruction.Allocate with - actors = Set.singleton csd - allocation = SettlementTypes.PassThroughFrom (csdCashAccount, issuerCashInstructionKey) - - (bankCashInstructionCid, _) <- submit bank do - exerciseCmd bankCashInstructionCid Instruction.Allocate with - actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - csdBondInstructionCid1 <- submit issuer do - exerciseCmd csdBondInstructionCid1 Instruction.Approve with - actors = Set.singleton issuer; approval = SettlementTypes.DebitSender - issuerBondInstructionCid <- submit csd do - exerciseCmd issuerBondInstructionCid Instruction.Approve with - actors = Set.singleton csd; approval = SettlementTypes.TakeDelivery csdAccountAtIssuer - issuerCashInstructionCid <- submit csd do - exerciseCmd issuerCashInstructionCid Instruction.Approve with - actors = Set.singleton csd; approval = SettlementTypes.PassThroughTo (csdCashAccount, csdCashInstructionKey) - investorBondInstructionCid <- submit csd do - exerciseCmd investorBondInstructionCid Instruction.Approve with - actors = Set.singleton csd; approval = SettlementTypes.DebitSender - csdBondInstructionCid2 <- submit investor do - exerciseCmd csdBondInstructionCid2 Instruction.Approve with - actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorSecuritiesAccount - csdCashInstructionCid <- submit bank do - exerciseCmd csdCashInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = SettlementTypes.TakeDelivery bankCashAccount - bankCashInstructionCid <- submit investor do - exerciseCmd bankCashInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorCashAccount - - -- Settle batch - [bankCashHoldingCid, investorCashHoldingCid, csdBondHoldingCid , investorBondHoldingCid] <- - submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - -- Assert state - Holding.verifyOwnerOfHolding - [ (csd, csdBondHoldingCid) - , (investor, investorBondHoldingCid) - , (bank, bankCashHoldingCid) - , (investor, investorCashHoldingCid) - ] - - pure () - - --- | Service template that allows to claim an effect and settle the corresponding transactions --- atomically. -template EffectSettlementService - with - csd : Party - -- ^ Owner of the instrument holding. Acts as depository of the instrument. - issuer : Party - -- ^ Counterparty of the instrument holding. Issuer of the instrument. - instrumentId : Id - -- ^ Defines the instrument to which the contract is applicable. - securitiesAccount : AccountKey - -- ^ Security account of CSD @ issuer. - issuerCashAccount : AccountKey - -- ^ Cash account of Issuer @ Central Bank. - csdCashAccount : AccountKey - -- ^ Cash account of CSD @ Central Bank. Needs to be disclosed to the Issuer (ideally as part - -- of the creation of this contract). - settlementRoutes : Map Text Hierarchy - where - signatory csd, issuer - - ensure - securitiesAccount.custodian == issuer && - securitiesAccount.owner == csd && - issuerCashAccount.custodian == csdCashAccount.custodian && - issuerCashAccount.owner == issuer && - csdCashAccount.owner == csd - - nonconsuming choice ClaimAndSettle - : (ContractId Effect.I, Optional (ContractId Api.HoldingV1.Holding), [ContractId Api.HoldingV1.Holding]) - with - instrumentHoldingCid : ContractId Api.HoldingV1.Holding - -- ^ Holding of CSD @ issuer for the old instrument. - cashHoldingCid : ContractId Api.HoldingV1.Holding - -- ^ Cash holding of issuer @ central bank, used to settle the effect's consequences. - effectCid : ContractId Effect.I - -- ^ Effect to claim. - controller issuer - do - effectView <- exercise effectCid Effect.GetView with viewer = issuer - - -- 0. sanity checks - let - oldInstrument = effectView.targetInstrument - newInstrument = effectView.producedInstrument - - oldInstrument.depository === csd - oldInstrument.issuer === issuer - oldInstrument.id === instrumentId - - F.forA_ newInstrument $ (=== csd) . (.depository) - F.forA_ newInstrument $ (=== issuer) . (.issuer) - F.forA_ newInstrument $ (=== instrumentId) . (.id) - - -- fetch instrument fungible - fungible <- fetch instrumentHoldingCid - assertMsg "wrong fungible" $ getInstrument fungible == oldInstrument - - -- 1. csd claims effect against issuer - routeProviderCid <- toInterfaceContractId <$> create IntermediatedStatic with - provider = csd; observers = mempty; paths = settlementRoutes - settlementFactoryCid <- create Factory with provider = csd; observers = mempty - - lifecycleClaimRuleCid <- create Claim.Rule with - provider = issuer - claimers = Set.fromList [issuer, csd] - settlers = Set.singleton csd - routeProviderCid - settlementFactoryCid = toInterfaceContractId settlementFactoryCid - netInstructions = False - - result <- exercise (toInterfaceContractId @Claim.I lifecycleClaimRuleCid) - Claim.ClaimEffect with - claimer = csd - holdingCids = [instrumentHoldingCid] - effectCid - batchId = Id "EffectSettlement" - - - archive settlementFactoryCid - archive lifecycleClaimRuleCid - - let - getUnitCid cid = do - v <- exercise cid Instruction.GetView with viewer = issuer - pure (cid, v.routedStep.quantity.unit.admin) - - instrs <- mapA getUnitCid result.instructionCids - - let - issuerInstrs = [cid | (cid, admin) <- instrs, admin == issuer] - cashInstrs = [cid | (cid, admin) <- instrs, admin == issuerCashAccount.custodian] - - let - csdInstrumentInstructionCid = head issuerInstrs - issuerInstrumentInstructionCid = issuerInstrs !! 1 - issuerCashInstructionCouponCid = head cashInstrs - - csdInstrumentInstruction <- fetch csdInstrumentInstructionCid - issuerInstrumentInstruction <- fetch issuerInstrumentInstructionCid - issuerCashInstructionCoupon <- fetch issuerCashInstructionCouponCid - - -- Allocate instructions - (csdInstrumentInstructionCid, _) <- exercise csdInstrumentInstructionCid - Instruction.Allocate with - actors = Set.singleton csd - allocation = SettlementTypes.Pledge instrumentHoldingCid - - (issuerCashInstructionCouponCid, _) <- exercise issuerCashInstructionCouponCid - Instruction.Allocate with - actors = Set.singleton issuer - allocation = SettlementTypes.Pledge cashHoldingCid - - (issuerInstrumentInstructionCid, _) <- exercise issuerInstrumentInstructionCid - Instruction.Allocate with - actors = Set.singleton issuer - allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - csdInstrumentInstructionCid <- exercise csdInstrumentInstructionCid - Instruction.Approve with - actors = Set.singleton issuer - approval = SettlementTypes.DebitSender - - issuerCashInstructionCouponCid <- exercise issuerCashInstructionCouponCid - Instruction.Approve with - actors = Set.singleton csd - approval = SettlementTypes.TakeDelivery csdCashAccount - - issuerInstrumentInstructionCid <- exercise issuerInstrumentInstructionCid - Instruction.Approve with - actors = Set.singleton csd - approval = SettlementTypes.TakeDelivery securitiesAccount - - -- Settle batch - [newInstrumentHoldingCid, investorCashHoldingCouponCid] <- - exercise result.batchCid Batch.Settle with actors = Set.singleton csd - - -- 2. create effect to be used by investors - newEffectCid <- exercise effectCid Effect.SetProviders with newProviders = Set.singleton csd - - pure (newEffectCid, Some newInstrumentHoldingCid, [investorCashHoldingCouponCid]) - --- | HIDE -setupParties : Script TestParties -setupParties = do - [bank, centralBank, csd, issuer, investor, settler, publicParty] <- - createParties ["Bank", "CentralBank", "CSD", "Issuer", "Investor", "Settler", "PublicParty"] - pure TestParties with - bank; centralBank; csd; issuer; investor; settlers = Set.singleton settler; publicParty - --- | HIDE --- Setup a set of accounts. -setupAccounts : Text -> Party -> Party -> [Party] -> Script [AccountKey] -setupAccounts description custodian publicParty owners = do - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory custodian [] - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with - provider = custodian - id = Id "Holding Factory" - observers = Map.fromList [("PublicParty", Set.singleton publicParty)] - -- Create accounts - forA owners $ Account.createAccount description [] accountFactoryCid holdingFactory [] - Account.Owner custodian diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml deleted file mode 100644 index 5f0535f3f..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml +++ /dev/null @@ -1,240 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.Test.ReverseConvertible where - -import ContingentClaims.Core.V3.Claim (Inequality(..), at, cond, one, scale, when) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Assert ((===)) -import DA.Date (Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (singleton) -import DA.Optional (fromOptional) -import DA.Time (time) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Holding.V4.TransferableFungible() -import Daml.Finance.Instrument.Generic.Test.Util (originateGeneric) -import Daml.Finance.Instrument.Generic.V4.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), Parties) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Lifecycle.V4.Rule.Claim (Rule(..)) -import Daml.Finance.Settlement.V4.Conversion (fromInstrumentKey) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Finance.Test.Util.Time (createClockUpdateEvent) -import Daml.Finance.Util.V4.Date.DayCount (calcDcf) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- This script models a reverse convertible instrument on an FX underlying. Depending on where the --- underlying closes at expiry compared to the strike, the product will either: --- 1. Pay the investment amount and the coupon in the local currency, or --- 2. Pay the investment amount and the coupon in the foreign currency (converted from local --- currency using the strike as FX rate). --- The product is auto-exercising using the Contingent Claims *cond* node, meaning no manual --- election is required by either counterparty. --- The *calcDcf* utility function is used to showcase how day count fractions can be calculated in --- Daml Finance. - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ Acts as custodian in the respective holdings (both cash holdings and instrument - -- holdings). It also acts as depository in the reverse convertible instrument. - broker : Party - -- ^ Acts as issuer of the reverse convertible contract. It is also the party tasked with - -- lifecycling of the contract. - centralBankEU : Party - -- ^ The depository and the issuer of the EUR cash instrument. - centralBankUK : Party - -- ^ The depository and the issuer of the GBP cash instrument. - investor : Party - -- ^ Owner of the reverse convertible holding. - settlers : Parties - -- ^ Any of the parties can trigger the settlement of fully allocated settlement instructions. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- | Physically-settled (inverse) FX reverse convertible trade: lifecycling and settlement -run : Script () -run = script do - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorAccount <- Account.createAccount "Default Account" [] accountFactoryCid holdingFactory - [] Account.Owner bank investor - - -- Define dates and acquisition time (use issue date, not current wallclock) - let - issue = date 2023 Sep 6 - expiry = date 2024 Mar 4 - maturity = date 2024 Mar 6 - acqTime = time issue 0 0 0 - - -- Create cash instruments using acquisition time - localCurrencyInstrument <- Instrument.originate bank centralBankEU "EUR" TransferableFungible - "Euro" pp acqTime - foreignCurrencyInstrument <- Instrument.originate bank centralBankUK "GBP" TransferableFungible - "Pounds" pp acqTime - - -- Create and distribute a generic derivative - let - issue = date 2023 Sep 6 - expiry = date 2024 Mar 4 - maturity = date 2024 Mar 6 - fxObservable = "EUR/GBP" - couponRate = 0.040 - dayCountConvention = Act360 - dcf = calcDcf dayCountConvention issue maturity - redemptionLocal = 1.0 + couponRate * dcf - strike = 0.80 - redemptionForeign = redemptionLocal * strike - notExercised = scale (Const redemptionLocal) $ one localCurrencyInstrument - exercised = scale (Const redemptionForeign) $ one foreignCurrencyInstrument - autoExerciseCondition = Lte (Const strike, ObserveAt fxObservable $ dateToDateClockTime expiry) - claims = when (at $ dateToDateClockTime maturity) - $ cond autoExerciseCondition exercised notExercised - - genericInstrument <- originateGeneric - bank broker "RC-EURGBP" TransferableFungible - "Reverse Convertible" acqTime claims [("PublicParty", Set.singleton publicParty)] acqTime - - investorGenericHoldingCid <- Account.credit [publicParty] genericInstrument 1_000.0 - investorAccount - - -- create clock update event - clockEventCid <- createClockUpdateEvent (Set.singleton broker) maturity mempty - - -- Create observable - let observations = Map.fromList [(dateToDateClockTime expiry, 0.91)] - observableCid <- toInterfaceContractId <$> submit broker do - createCmd Observation with - provider = broker; id = Id fxObservable; observations; observers = mempty - - -- Create lifecycle rule - lifecycleRuleCid <- toInterfaceContractId @Lifecycle.I <$> - submit bank do - createCmd Lifecycle.Rule with - providers = Set.singleton bank - observers = mempty - lifecycler = broker - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - - -- Evolve at expiry first (usually no effect, but registers observable) - expiryEventCid <- createClockUpdateEvent (Set.singleton broker) expiry mempty - (_, expiryEffects) <- submit broker do - exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = expiryEventCid - observableCids = [observableCid] - instrument = genericInstrument - - -- Lifecycle a generic derivative - (maybeFinalKey, effectCids) <- submit broker do - exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids = [observableCid] - instrument = genericInstrument - - -- Use the evolved instrument key if provided, otherwise keep the original - let finalInstrument = fromOptional genericInstrument maybeFinalKey - -- Expect at least one lifecycle effect; take the first - effectCid <- case effectCids of - cid :: _ -> pure cid - [] -> abort "Lifecycle.Evolve returned no effects; cannot proceed" - - - -- Create route provider - routeProviderCid <- toInterfaceContractId <$> - submit investor do - createCmd SingleCustodian with - provider = investor; observers = mempty; custodian = bank - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId <$> - submit investor do createCmd Factory with provider = investor; observers = mempty - - -- Create claim rule - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> - submit [bank, investor] do - createCmd Rule with - provider = bank - claimers = Set.singleton investor - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - -- Claim effect - result <- submit (actAs investor <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorGenericHoldingCid] - effectCid - batchId = Id "ReverseConvertiblePhysicalSettlement" - - let [investorInstrumentInstructionCid, bankEquityInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = SettlementTypes.Pledge investorGenericHoldingCid - - (bankEquityInstructionCid, _) <- submit bank do - exerciseCmd bankEquityInstructionCid Instruction.Allocate with - actors = Set.singleton bank - allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit bank do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank - approval = SettlementTypes.DebitSender - - bankEquityInstructionCid <- submit investor do - exerciseCmd bankEquityInstructionCid Instruction.Approve with - actors = Set.singleton investor - approval = SettlementTypes.TakeDelivery investorAccount - - -- Settle batch - [investorCashHoldingCid : ContractId Api.HoldingV1.Holding] <- submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - -- Verify result - Some investorCash <- queryInterfaceContractId @Api.HoldingV1.Holding @Api.HoldingV1.HoldingView investor investorCashHoldingCid - - -- Verify using plain equality - investorCash.amount === 816.1777778 - investorCash.instrumentId === fromInstrumentKey foreignCurrencyInstrument - investorCash.owner === investor - - pure () - -setupParties : Script TestParties -setupParties = do - [bank, broker, centralBankEU, centralBankUK, investor, settler, publicParty] <- createParties - ["Bank", "Broker", "EU Central Bank", "UK Central Bank", "Investor", "Settler", "PublicParty"] - pure TestParties with - bank; broker; centralBankEU; centralBankUK; investor; settlers = Set.singleton settler - publicParty diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml deleted file mode 100644 index 98a637ac3..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml +++ /dev/null @@ -1,282 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.Test.BarrierEuropeanCash where - -import DA.Date (Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Option.Test.Util (originateBarrierEuropeanCashOption) -import Daml.Finance.Interface.Instrument.Option.V0.Types (BarrierTypeEnum(..), OptionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Define and lifecycle barrier call/put options, which are automatically exercised and cash --- settled. -run : Script () -run = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute option - let - barrierLow : Decimal = 20.0 - barrierHigh : Decimal = 50.0 - -- CREATE_BARRIER_EUROPEAN_OPTION_VARIABLES_BEGIN - barrier = 30.0 - barrierType = DownAndOut - barrierStartDate = date 2019 Jan 20 - strike = 40.0 - expiryDate = date 2019 May 15 - referenceAssetId = "AAPL-CLOSE" - -- CREATE_BARRIER_EUROPEAN_OPTION_VARIABLES_END - longOption = True - - -- CREATE_BARRIER_EUROPEAN_OPTION_OBSERVATIONS_BEGIN - let - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 May 13, 28.78) - , (dateToDateClockTime $ date 2019 May 14, 49.78) - , (dateToDateClockTime $ date 2019 May 15, 48.78) - , (dateToDateClockTime $ date 2019 May 16, 18.78) - , (dateToDateClockTime $ date 2019 May 17, 48.78) - , (dateToDateClockTime $ date 2019 May 20, 58.78) - , (dateToDateClockTime $ date 2019 May 21, 48.78) - ] - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - -- CREATE_BARRIER_EUROPEAN_OPTION_OBSERVATIONS_END - - ------------------------------------ - -- 1. Down-And-Out barrier option -- - ------------------------------------ - - -- Test option with barrier hit (on May 13) - downAndOutLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer "DownAndOut" - TransferableFungible "Option" observers now expiryDate Call strike barrier barrierType - barrierStartDate cashInstrument referenceAssetId longOption publicParty - - let - expectedConsumed = [] - expectedProduced = [] - - -- Barrier hit date: lifecycle and verify there are no payments yet - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 13) downAndOutLongCallInstrument issuer [observableCid] expectedConsumed - expectedProduced - - -- One day later: verify that there are no lifecycle effects - verifyNoLifecycleEffects [publicParty] (date 2019 May 14) - optionInstrumentAfterBarrierHit issuer [observableCid] - - -- Expiry date: Lifecycle and verify that no lifecycle effects occur - let - expectedConsumed = [] - expectedProduced = [] - lifecycleAndVerifyPaymentEffects [publicParty] expiryDate optionInstrumentAfterBarrierHit issuer - [observableCid] expectedConsumed expectedProduced - - -- Test option without barrier hit. Also test a barrier hit after expiry. - downAndOutLowBarrierLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer - "DownAndOutLow" TransferableFungible "Option" observers now expiryDate Call strike barrierLow - DownAndOut barrierStartDate cashInstrument referenceAssetId longOption publicParty - - verifyNoLifecycleEffects [publicParty] (date 2019 May 13) downAndOutLowBarrierLongCallInstrument - issuer [observableCid] - - verifyNoLifecycleEffects [publicParty] (date 2019 May 14) downAndOutLowBarrierLongCallInstrument - issuer [observableCid] - - let - expectedConsumed = [] - expectedProduced = [qty 8.78 cashInstrument] - Some optionInstrumentAfterExpiry <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - downAndOutLowBarrierLongCallInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Lifecycle after expiry (should have no further effect) - let - expectedConsumed = [] - expectedProduced = [] - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 16) optionInstrumentAfterExpiry issuer [observableCid] expectedConsumed - expectedProduced - - verifyNoLifecycleEffects [publicParty] (date 2019 May 17) optionInstrumentAfterBarrierHit - issuer [observableCid] - - ----------------------------------- - -- 2. Down-And-In barrier option -- - ----------------------------------- - - -- Test option with barrier hit (on May 13) - downAndInLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer "DownAndIn" - TransferableFungible "Option" observers now expiryDate Call strike barrier DownAndIn - barrierStartDate cashInstrument referenceAssetId longOption publicParty - - let - expectedConsumed = [] - expectedProduced = [] - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 13) downAndInLongCallInstrument issuer [observableCid] expectedConsumed - expectedProduced - - verifyNoLifecycleEffects [publicParty] (date 2019 May 14) optionInstrumentAfterBarrierHit issuer - [observableCid] - - -- Verify no lifecycle effects the next day - verifyNoLifecycleEffects [publicParty] (date 2019 May 14) - optionInstrumentAfterBarrierHit issuer [observableCid] - - -- Lifecycle at expiry (expecting payout) - let - expectedConsumed = [] - expectedProduced = [qty 8.78 cashInstrument] - lifecycleAndVerifyPaymentEffects [publicParty] expiryDate optionInstrumentAfterBarrierHit issuer - [observableCid] expectedConsumed expectedProduced - - -- Test option without barrier hit. Also test a barrier hit after expiry. - downAndInLowBarrierLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer - "DownAndInLow" TransferableFungible "Option" observers now expiryDate Call strike barrierLow - DownAndIn barrierStartDate cashInstrument referenceAssetId longOption publicParty - - verifyNoLifecycleEffects [publicParty] (date 2019 May 13) downAndInLowBarrierLongCallInstrument - issuer [observableCid] - - verifyNoLifecycleEffects [publicParty] (date 2019 May 14) downAndInLowBarrierLongCallInstrument - issuer [observableCid] - - verifyNoLifecycleEffects [publicParty] expiryDate downAndInLowBarrierLongCallInstrument issuer - [observableCid] - - let - expectedConsumed = [] - expectedProduced = [] - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 16) downAndInLowBarrierLongCallInstrument issuer [observableCid] expectedConsumed - expectedProduced - - verifyNoLifecycleEffects [publicParty] (date 2019 May 17) optionInstrumentAfterBarrierHit - issuer [observableCid] - - ---------------------------------- - -- 3. Up-And-Out barrier option -- - ---------------------------------- - - -- Test option with barrier hit (on May 14) - upAndOutLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer "UpAndOut" - TransferableFungible "Option" observers now expiryDate Call strike barrier UpAndOut - barrierStartDate cashInstrument referenceAssetId longOption publicParty - - verifyNoLifecycleEffects [publicParty] (date 2019 May 13) upAndOutLongCallInstrument issuer - [observableCid] - - let - expectedConsumed = [] - expectedProduced = [] - - -- Lifecycle at barrier hit date (Up-and-Out should knock out the option) - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 14) upAndOutLongCallInstrument issuer [observableCid] expectedConsumed - expectedProduced - - -- Lifecycle at expiry date (should not trigger any event after knock-out) - let - expectedConsumed = [] - expectedProduced = [] - lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - optionInstrumentAfterBarrierHit issuer [observableCid] expectedConsumed expectedProduced - - -- Test option without barrier hit. Also test a barrier hit after expiry. - upAndOutHighBarrierLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer - "UpAndOutHigh" TransferableFungible "Option" observers now expiryDate Call strike barrierHigh - UpAndOut barrierStartDate cashInstrument referenceAssetId longOption publicParty - - verifyNoLifecycleEffects [publicParty] (date 2019 May 13) upAndOutHighBarrierLongCallInstrument - issuer [observableCid] - - verifyNoLifecycleEffects [publicParty] (date 2019 May 14) upAndOutHighBarrierLongCallInstrument - issuer [observableCid] - - let - expectedConsumed = [] - expectedProduced = [qty 8.78 cashInstrument] - Some optionInstrumentAfterExpiry <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - upAndOutHighBarrierLongCallInstrument issuer [observableCid] expectedConsumed expectedProduced - - let - expectedConsumed = [] - expectedProduced = [] - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 20) optionInstrumentAfterExpiry issuer [observableCid] expectedConsumed - expectedProduced - - verifyNoLifecycleEffects [publicParty] (date 2019 May 21) optionInstrumentAfterBarrierHit - issuer [observableCid] - - - verifyNoLifecycleEffects [publicParty] (date 2019 May 21) optionInstrumentAfterBarrierHit - issuer [observableCid] - - ---------------------------------- - -- 4. Up-And-In barrier option -- - ---------------------------------- - - -- Test option with barrier hit (on May 14) - upAndInLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer "UpAndIn" - TransferableFungible "Option" observers now expiryDate Call strike barrier UpAndIn - barrierStartDate cashInstrument referenceAssetId longOption publicParty - - verifyNoLifecycleEffects [publicParty] (date 2019 May 13) upAndInLongCallInstrument issuer - [observableCid] - - let - expectedConsumed = [] - expectedProduced = [] - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 14) upAndInLongCallInstrument issuer [observableCid] expectedConsumed - expectedProduced - - let - expectedConsumed = [] - expectedProduced = [qty 8.78 cashInstrument] - lifecycleAndVerifyPaymentEffects [publicParty] expiryDate optionInstrumentAfterBarrierHit issuer - [observableCid] expectedConsumed expectedProduced - - -- Test option without barrier hit. Also test a barrier hit after expiry. - upAndInHighBarrierLongCallInstrument <- originateBarrierEuropeanCashOption issuer issuer - "UpAndInHigh" TransferableFungible "Option" observers now expiryDate Call strike barrierHigh - UpAndIn barrierStartDate cashInstrument referenceAssetId longOption publicParty - - verifyNoLifecycleEffects [publicParty] (date 2019 May 13) upAndInHighBarrierLongCallInstrument - issuer [observableCid] - - verifyNoLifecycleEffects [publicParty] (date 2019 May 14) upAndInHighBarrierLongCallInstrument - issuer [observableCid] - - verifyNoLifecycleEffects [publicParty] expiryDate upAndInHighBarrierLongCallInstrument issuer - [observableCid] - - let - expectedConsumed = [] - expectedProduced = [] - Some optionInstrumentAfterBarrierHit <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 20) upAndInHighBarrierLongCallInstrument issuer [observableCid] expectedConsumed - expectedProduced - - verifyNoLifecycleEffects [publicParty] (date 2019 May 21) optionInstrumentAfterBarrierHit - issuer [observableCid] - - - pure () diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml deleted file mode 100644 index fc3e7701f..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml +++ /dev/null @@ -1,254 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.Test.BarrierReverseConvertible where - -import DA.Date (DayOfWeek(..), Month(..), date) -import DA.Time () -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.StructuredProduct.Test.Util (originateBarrierReverseConvertible) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Finance.Test.Util.Time (createPaymentPeriodicSchedule) -import Daml.Script - --- Define and lifecycle a barrier reverse convertible (BRC). -run : Script () -run = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", Set.singleton publicParty)] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute option - let - barrierLow = 20.0 - strikeLow = 35.0 - -- CREATE_BARRIER_REVERSE_CONVERTIBLE_VARIABLES_BEGIN - barrier = 30.0 - barrierStartDate = date 2019 Jan 16 - strike = 40.0 - expiryDate = date 2019 May 15 - referenceAssetId = "AAPL-CLOSE" - couponRate = 0.05 - issueDate = date 2019 Jan 16 - firstCouponDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - -- CREATE_BARRIER_REVERSE_CONVERTIBLE_VARIABLES_END - businessDayConvention = Following - couponPeriod = M - couponPeriodMultiplier = 3 - dayCountConvention = Act360 - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - notional = 1.0 - - -- CREATE_BARRIER_REVERSE_CONVERTIBLE_OBSERVATIONS_BEGIN - let - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Feb 13, 28.78) - , (dateToDateClockTime $ date 2019 Feb 15, 39.78) - , (dateToDateClockTime $ date 2019 May 15, 38.78) - , (dateToDateClockTime $ date 2019 May 16, 18.78) - , (dateToDateClockTime $ date 2019 May 17, 38.78) - , (dateToDateClockTime $ date 2019 Oct 09, 38.78) - , (now, 38.78) - ] - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - -- CREATE_BARRIER_REVERSE_CONVERTIBLE_OBSERVATIONS_END - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - -------------------------------- - -- 1. BRC with barrier event -- - -------------------------------- - - -- Test option with barrier hit (on Feb 13). Option expires in the money. - brcInstrument <- originateBarrierReverseConvertible issuer issuer "BRC" TransferableFungible - "Option" observers now expiryDate strike barrier barrierStartDate cashInstrument - referenceAssetId couponRate couponSchedule holidayCalendarIds dayCountConvention notional - calendarDataProvider publicParty - - -- Barrier hit date: Lifecycle and verify that no payments occur yet. - let - expectedConsumed = [] - expectedProduced = [] - - maybeBrcInstrumentAfterBarrierHit <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 Feb 13) brcInstrument issuer [observableCid] - expectedConsumed expectedProduced - - brcInstrumentAfterBarrierHit <- case maybeBrcInstrumentAfterBarrierHit of - Some key -> pure key - None -> pure brcInstrument - - -- First coupon date: Lifecycle and verify coupon payment. - let - expectedConsumed = [] - expectedProduced = [qty 0.0041666667 cashInstrument] - - maybeBrcInstrumentAfterCouponPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstCouponDate brcInstrumentAfterBarrierHit issuer [observableCid] - expectedConsumed expectedProduced - - brcInstrumentAfterCouponPayment <- case maybeBrcInstrumentAfterCouponPayment of - Some key -> pure key - None -> pure brcInstrumentAfterBarrierHit - - -- Expiry date: Lifecycle and verify redemption and final payments. - let - expectedConsumed = [qty 0.0305 cashInstrument] - expectedProduced = - [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] - - maybeBrcInstrumentAfterExpiry <- - lifecycleAndVerifyPaymentEffects [publicParty] - expiryDate brcInstrumentAfterCouponPayment issuer [observableCid] - expectedConsumed expectedProduced - - case maybeBrcInstrumentAfterExpiry of - Some key -> pure key - None -> pure brcInstrumentAfterCouponPayment - - - -- Test option with barrier hit (on Feb 13). Option expires out of the money. - brcLowStrikeInstrument <- originateBarrierReverseConvertible issuer issuer "BRCLowStrike" - TransferableFungible "Option" observers now expiryDate strikeLow barrier barrierStartDate - cashInstrument referenceAssetId couponRate couponSchedule holidayCalendarIds dayCountConvention - notional calendarDataProvider publicParty - - -- Barrier hit date for low-strike BRC - let - expectedConsumed = [] - expectedProduced = [] - - maybeBrcLowStrikeAfterBarrierHit <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 Feb 13) brcLowStrikeInstrument issuer [observableCid] - expectedConsumed expectedProduced - - brcLowStrikeAfterBarrierHit <- case maybeBrcLowStrikeAfterBarrierHit of - Some key -> pure key - None -> pure brcLowStrikeInstrument - - -- First coupon date for low-strike BRC - let - expectedConsumed = [] - expectedProduced = [qty 0.0041666667 cashInstrument] - - maybeBrcLowStrikeAfterCouponPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstCouponDate brcLowStrikeAfterBarrierHit issuer [observableCid] - expectedConsumed expectedProduced - - brcLowStrikeAfterCouponPayment <- case maybeBrcLowStrikeAfterCouponPayment of - Some key -> pure key - None -> pure brcLowStrikeAfterBarrierHit - - -- Expiry date for low-strike BRC - let - expectedConsumed = [] - expectedProduced = - [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] - - maybeBrcLowStrikeAfterExpiry <- - lifecycleAndVerifyPaymentEffects [publicParty] - expiryDate brcLowStrikeAfterCouponPayment issuer [observableCid] - expectedConsumed expectedProduced - - case maybeBrcLowStrikeAfterExpiry of - Some key -> pure key - None -> pure brcLowStrikeAfterCouponPayment - - -------------------------------------------------- - -- 2. BRC without barrier event (before expiry) -- - -------------------------------------------------- - - -- Test option without barrier hit. Also test a barrier hit after expiry. - brcLowBarrierInstrument <- originateBarrierReverseConvertible issuer issuer "DownAndInLow" - TransferableFungible "Option" observers now expiryDate strike barrierLow barrierStartDate - cashInstrument referenceAssetId couponRate couponSchedule holidayCalendarIds dayCountConvention - notional calendarDataProvider publicParty - - verifyNoLifecycleEffects [publicParty] (date 2019 Feb 13) brcLowBarrierInstrument - issuer [observableCid] - - -- First coupon date: Lifecycle and verify coupon payment. - let - expectedConsumed = [] - expectedProduced = [qty 0.0041666667 cashInstrument] - - maybeBrcInstrumentAfterCouponPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstCouponDate brcLowBarrierInstrument issuer [observableCid] - expectedConsumed expectedProduced - - brcInstrumentAfterCouponPayment <- case maybeBrcInstrumentAfterCouponPayment of - Some key -> pure key - None -> pure brcLowBarrierInstrument - - -- Expiry date: Lifecycle and verify redemption and final payments. - let - expectedConsumed = [] - expectedProduced = - [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] - - maybeBrcInstrumentAfterExpiry <- - lifecycleAndVerifyPaymentEffects [publicParty] - expiryDate brcInstrumentAfterCouponPayment issuer [observableCid] - expectedConsumed expectedProduced - - brcInstrumentAfterExpiry <- case maybeBrcInstrumentAfterExpiry of - Some key -> pure key - None -> pure brcInstrumentAfterCouponPayment - - -- Post-expiry date (May 16): Lifecycle and verify no further effects. - let - expectedConsumed = [] - expectedProduced = [] - - maybeBrcAfterPostExpiry <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 16) brcInstrumentAfterExpiry issuer [observableCid] - expectedConsumed expectedProduced - - brcAfterPostExpiry <- case maybeBrcAfterPostExpiry of - Some key -> pure key - None -> pure brcInstrumentAfterExpiry - - -- One more day: must still be no effects. - verifyNoLifecycleEffects [publicParty] (date 2019 May 17) brcAfterPostExpiry - issuer [observableCid] - - pure () diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml deleted file mode 100644 index 14f01f20b..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml +++ /dev/null @@ -1,401 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.Test.CreditDefault where - -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Time (time, wholeDays, subTime) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Swap.Test.Util (originateCreditDefaultSwap) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- | Parties involved in the test script. -data TestParties = TestParties - with - calendarDataProvider : Party - -- ^ Publishes the holiday calendar. - custodian : Party - -- ^ Acts as custodian in the respective holdings (both cash holdings and instrument - -- holdings). It also acts as depository in the option instrument. - issuer : Party - -- ^ Acts as issuer of the instrument. It is also the party tasked with lifecycling the - -- contract. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- Economics of the Credit Default Swap --- CREATE_CREDIT_DEFAULT_SWAP_VARIABLES_BEGIN -issueDate = date 2019 Jan 16 -firstPaymentDate = date 2019 Feb 15 -maturityDate = date 2019 May 15 -defaultProbabilityReferenceId = "TSLA-DEFAULT-PROB" -recoveryRateReferenceId = "TSLA-RECOVERY-RATE" -ownerReceivesFix = False -fixRate = 0.0201 -paymentPeriod = M -paymentPeriodMultiplier = 3 -dayCountConvention = Act360 -businessDayConvention = ModifiedFollowing --- CREATE_CREDIT_DEFAULT_SWAP_VARIABLES_END - --- Calculate credit default swap payments (test case with a credit event), including lifecycling and --- creation of new instrument version. -runCreditEvent : Script () -runCreditEvent = script do - parties@TestParties{..} <- setupParties - - -- Public party observer - let pp = [("PublicParty", singleton publicParty)] - - -- Distribute commercial-bank cash - now <- getTime - let - epochDate = date 1970 Jan 1 - epochTime = time epochDate 0 0 0 - daysSinceEpoch = wholeDays (subTime now epochTime) - todayDate = addDays epochDate daysSinceEpoch - - cashInstrument <- setupCash parties now - - -- Populate holiday calendar and observations. - setupCalendar parties - let - creditEventDate = date 2019 Mar 15 - defaultProbabilityObservations = Map.fromList - [ (dateToDateClockTime $ subtractDays firstPaymentDate 1, 0.2) - , (dateToDateClockTime firstPaymentDate , 0.2) - , (dateToDateClockTime $ addDays firstPaymentDate 1 , 0.2) - , (dateToDateClockTime creditEventDate , 1.0) - , (dateToDateClockTime issueDate , 0.2) - , (dateToDateClockTime maturityDate , 0.2) - , (dateToDateClockTime $ date 2025 Oct 09 , 0.2) - , (now, 0.2) - ] - recoveryRateObservations = Map.fromList - [(dateToDateClockTime creditEventDate, 0.6)] - - -- Create and distribute swap - swapInstrument <- setupSwap parties now cashInstrument - - observableDefaultProbabilityCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id defaultProbabilityReferenceId - observations = defaultProbabilityObservations; observers = mempty - observableRecoveryRateCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id recoveryRateReferenceId; observations = recoveryRateObservations - observers = mempty - let observableCids = [observableDefaultProbabilityCid, observableRecoveryRateCid] - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - observableCids - - -- First payment date: Lifecycle and verify the lifecycle effects for the fix payment. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- Credit event date: Lifecycle and verify that there is a lifecycle effect for the - let - expectedConsumed = [] - expectedProduced = [qty 0.4 cashInstrument] - - maybeSwapInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects [publicParty] - creditEventDate swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - case maybeSwapInstrumentAfterMaturity of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () - --- | Verify that no coupon is paid if credit event happens on a payment date. -runCreditEventOnPaymentDate : Script () -runCreditEventOnPaymentDate = script do - parties@TestParties{..} <- setupParties - - -- Public party observer - let pp = [("PublicParty", singleton publicParty)] - - -- Distribute commercial-bank cash - now <- getTime - cashInstrument <- setupCash parties now - - -- Populate holiday calendar and observations. - setupCalendar parties - let - creditEventDate = maturityDate - defaultProbabilityObservations = Map.fromList - [ (dateToDateClockTime $ subtractDays firstPaymentDate 1, 0.2) - , (dateToDateClockTime firstPaymentDate , 0.2) - , (dateToDateClockTime $ addDays firstPaymentDate 1 , 0.2) - , (dateToDateClockTime creditEventDate , 1.0) -- credit event - ] - recoveryRateObservations = Map.fromList - [(dateToDateClockTime creditEventDate, 0.6)] - - -- Create and distribute swap - swapInstrument <- setupSwap parties now cashInstrument - - observableDefaultProbabilityCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id defaultProbabilityReferenceId - observations = defaultProbabilityObservations; observers = mempty - observableRecoveryRateCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id recoveryRateReferenceId; observations = recoveryRateObservations - observers = mempty - let observableCids = [observableDefaultProbabilityCid, observableRecoveryRateCid] - - -- First payment date: Lifecycle and verify the lifecycle effects for the fixed payment. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- Credit event date: Lifecycle and verify that there is a lifecycle effect for the (1-recoveryRate) payment. - let - expectedConsumed = [] - expectedProduced = [qty 0.4 cashInstrument] - - maybeSwapInstrumentAfterCreditEvent <- - lifecycleAndVerifyPaymentEffects [publicParty] - creditEventDate swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterCreditEvent <- case maybeSwapInstrumentAfterCreditEvent of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - pure () - --- Calculate credit default swap payments (test case without a credit event), including lifecycling --- and creation of new instrument version. -runNoCreditEvent : Script () -runNoCreditEvent = script do - parties@TestParties{..} <- setupParties - - -- Public party observer - let pp = [("PublicParty", singleton publicParty)] - - -- Distribute commercial-bank cash - now <- getTime - cashInstrument <- setupCash parties now - - -- Populate holiday calendar and observations. - setupCalendar parties - let - defaultProbabilityObservations = Map.fromList - [ (dateToDateClockTime $ subtractDays firstPaymentDate 1, 0.2) - , (dateToDateClockTime firstPaymentDate , 0.2) - , (dateToDateClockTime $ addDays firstPaymentDate 1 , 0.2) - , (dateToDateClockTime maturityDate , 0.2) - , (dateToDateClockTime $ addDays maturityDate 1 , 0.2) - , (dateToDateClockTime maturityDate , 0.2) - , (dateToDateClockTime $ date 2025 Oct 09 , 0.2) - , (now, 0.2) - ] - - -- Create and distribute swap - swapInstrument <- setupSwap parties now cashInstrument - - observableDefaultProbabilityCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id defaultProbabilityReferenceId - observations = defaultProbabilityObservations; observers = mempty - let observableCids = [observableDefaultProbabilityCid] - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - observableCids - - -- First payment date: Lifecycle and verify the lifecycle effects for the fixed payment. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- Second payment date: Lifecycle and verify the lifecycle effects for the fixed payment. - let - expectedConsumed = [qty 0.0049691667 cashInstrument] - expectedProduced = [] - - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - -- One day after the maturity date: verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (addDays maturityDate 1) - swapInstrumentAfterSecondPayment issuer observableCids - - pure () - --- | Verify that a credit event after maturity does not pay the recovery rate. -runCreditEventAfterMaturity : Script () -runCreditEventAfterMaturity = script do - parties@TestParties{..} <- setupParties - - -- Public party observer - let pp = [("PublicParty", singleton publicParty)] - - -- Distribute commercial-bank cash - now <- getTime - cashInstrument <- setupCash parties now - - -- Populate holiday calendar and observations. - setupCalendar parties - let - defaultProbabilityObservations = Map.fromList - [ (dateToDateClockTime firstPaymentDate, 0.2) - , (dateToDateClockTime maturityDate, 0.2) - , (dateToDateClockTime $ addDays maturityDate 1, 1.0) -- credit event - , (dateToDateClockTime maturityDate , 0.2) - , (dateToDateClockTime $ date 2025 Oct 09 , 0.2) - , (now, 0.2) - ] - - -- Create and distribute swap - swapInstrument <- setupSwap parties now cashInstrument - - observableDefaultProbabilityCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id defaultProbabilityReferenceId - observations = defaultProbabilityObservations; observers = mempty - let observableCids = [observableDefaultProbabilityCid] - - -- First payment date: Lifecycle and verify the lifecycle effects for the fixed payment. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- Second payment date: Lifecycle and verify the lifecycle effects for the fixed payment. - let - expectedConsumed = [qty 0.0049691667 cashInstrument] - expectedProduced = [] - - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - -- One day after the maturity date: verify that no payment is made (instrument expires). - let - expectedConsumed = [] - expectedProduced = [] - - maybeSwapInstrumentAfterExpiry <- - lifecycleAndVerifyPaymentEffects [publicParty] - (addDays maturityDate 1) swapInstrumentAfterSecondPayment issuer observableCids - expectedConsumed expectedProduced - - pure () - --- | Setup parties. -setupParties : Script TestParties -setupParties = do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - pure TestParties with custodian; issuer; calendarDataProvider; publicParty - --- | Setup holiday calendar. -holidayCalendarData = HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - --- | Create holiday calendar on ledger. -setupCalendar : TestParties -> Script (ContractId HolidayCalendar) -setupCalendar TestParties{..} = do - let pp = [("PublicParty", singleton publicParty)] - submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar = holidayCalendarData - observers = Map.fromList pp - --- | Setup cash instrument. -setupCash : TestParties -> Time -> Script InstrumentKey -setupCash TestParties{..} now = do - let pp = [("PublicParty", singleton publicParty)] - originate custodian issuer "USD" TransferableFungible "US Dollars" pp now - --- | Setup Credit Default Swap instrument. -setupSwap : TestParties -> Time -> InstrumentKey -> Script InstrumentKey -setupSwap TestParties{..} now cashInstrument = do - let pp = [("PublicParty", singleton publicParty)] - originateCreditDefaultSwap issuer issuer "SwapTest1" BaseHolding "Credit default swap" pp now - issueDate [holidayCalendarData.id] calendarDataProvider firstPaymentDate maturityDate - dayCountConvention businessDayConvention fixRate paymentPeriod paymentPeriodMultiplier - cashInstrument defaultProbabilityReferenceId recoveryRateReferenceId ownerReceivesFix - publicParty diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml deleted file mode 100644 index 3241d72f2..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml +++ /dev/null @@ -1,253 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.Test.InterestRate where - -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Swap.Test.Util (originateInterestRateSwap) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (DateRelativeToEnum(..), FloatingRate(..), ReferenceRateTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DateOffset (DateOffset(..), DayTypeEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Calculate interest rate payment on an interest rate swap, including lifecycling and creation of --- new instrument version. -run : Script () -run = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Fix vs floating interest rate swap: Libor 3M vs 2.01% p.a. payment every 3M - -- CREATE_INTEREST_RATE_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceRateId = "USD/LIBOR/3M" - floatingRate = FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = 0 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - ownerReceivesFix = False - fixRate = 0.0201 - paymentPeriod = M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - -- CREATE_INTEREST_RATE_SWAP_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 0.0027406) - , (dateToDateClockTime $ date 2019 Feb 15, 0.002035) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - - swapInstrument <- originateInterestRateSwap issuer issuer "SwapTest1" Transferable - "Interest rate swap" observers now issueDate holidayCalendarIds calendarDataProvider - firstPaymentDate maturityDate dayCountConvention businessDayConvention fixRate paymentPeriod - paymentPeriodMultiplier cashInstrument floatingRate ownerReceivesFix publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - [observableCid] - - -- First payment date: Lifecycle and verify the lifecycle effects for fix and floating payments. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [qty 0.0002283833 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects - [publicParty] - firstPaymentDate - swapInstrument - issuer - [observableCid] - expectedConsumed - expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - -- Second payment date (also expiry): Lifecycle and verify the lifecycle effects for fix and floating payments. - let - expectedConsumed = [qty 0.0049691667 cashInstrument] - expectedProduced = [qty 0.0005030972 cashInstrument] - maybeSwapInstrumentAfterSecondPayment <- lifecycleAndVerifyPaymentEffects - [publicParty] - maturityDate - swapInstrumentAfterFirstPayment - issuer - [observableCid] - expectedConsumed - expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () - --- Calculate interest rate payment on an interest rate swap using compounded SOFR (calculated via --- SOFR Index) -runSofr : Script () -runSofr = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Fix vs floating interest rate swap: compounded SOFR vs 2.01% p.a. payment every 3M - -- CREATE_SOFR-INTEREST_RATE_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceRateId = "SOFR/INDEX" - floatingRate = FloatingRate with - referenceRateId - referenceRateType = CompoundedIndex Act360 - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - ownerReceivesFix = False - fixRate = 0.0201 - paymentPeriod = M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - -- CREATE_SOFR-INTEREST_RATE_SWAP_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 14, 1.04240111) - , (dateToDateClockTime $ date 2019 Feb 13, 1.04509941) - , (dateToDateClockTime $ date 2019 May 13, 1.06145226) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - - swapInstrument <- originateInterestRateSwap issuer issuer "SwapTest1" Transferable - "Interest rate swap" observers now issueDate holidayCalendarIds calendarDataProvider - firstPaymentDate maturityDate dayCountConvention businessDayConvention fixRate paymentPeriod - paymentPeriodMultiplier cashInstrument floatingRate ownerReceivesFix publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - [observableCid] - - -- First payment date: Lifecycle and verify the lifecycle effects for fix and floating payments. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [qty 0.0025885429 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects - [publicParty] - firstPaymentDate - swapInstrument - issuer - [observableCid] - expectedConsumed - expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - -- Lifecycle on the second payment date, which is also the expiry date. Verify the lifecycle - -- effects for fix and floating payments. - let - expectedConsumed = [qty 0.0049691667 cashInstrument] - expectedProduced = [qty 0.0156471718 cashInstrument] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects - [publicParty] - maturityDate - swapInstrumentAfterFirstPayment - issuer - [observableCid] - expectedConsumed - expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Token/Test/Token.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/Token/Test/Token.daml deleted file mode 100644 index 02ccb9646..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Token/Test/Token.daml +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Token.Test.Token where - -import Daml.Finance.Instrument.Token.Test.Util (originateToken) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, Remove(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Script -import Prelude hiding (and, or) - --- This script tests the ability to create and remove an Instrument.Token. - --- | Parties involved in the test script. -data TestParties = TestParties - with - issuer : Party - -- ^ Acts as issuer of the token instrument. - -run : Script () -run = script do - - -- Setup parties - TestParties{..} <- setupParties - - -- Originate token - now <- getTime - tokenInstrument <- originateToken issuer issuer "Token A" TransferableFungible "Token Issuer" now - [] - - -- Remove the token - Instrument.submitExerciseInterfaceByKeyCmd @BaseInstrument.I [issuer] [] tokenInstrument - BaseInstrument.Remove - - pure () - -setupParties : Script TestParties -setupParties = do - [issuer] <- createParties ["Issuer"] - pure TestParties with issuer diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Token/Test/Util.daml b/docs/generated/src/test/daml/Daml/Finance/Instrument/Token/Test/Util.daml deleted file mode 100644 index 0e84a5117..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Token/Test/Util.daml +++ /dev/null @@ -1,32 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Token.Test.Util where - -import DA.Map (fromList) -import Daml.Finance.Instrument.Token.V4.Factory (Factory(..)) -import Daml.Finance.Interface.Instrument.Token.V4.Factory qualified as TokenFactory (Create(..), I) -import Daml.Finance.Interface.Instrument.Token.V4.Types (Token(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard, Id(..), InstrumentKey(..), Parties) -import Daml.Script - --- | Originate token instrument. -originateToken : Party -> Party -> Text -> HoldingStandard -> Text -> Time -> [(Text, Parties)] -> - Script InstrumentKey -originateToken depository issuer label holdingStandard description validAsOf observers = do - - -- Create a token instrument factory - tokenFactoryCid <- toInterfaceContractId @TokenFactory.I <$> submit issuer do - createCmd Factory with provider = issuer; observers = mempty - - -- Create instrument - let - token = Token with - instrument = - InstrumentKey with issuer; depository; id = Id label; version = "0"; holdingStandard - description - validAsOf - submit [issuer, depository] do - exerciseCmd tokenFactoryCid TokenFactory.Create with token; observers = fromList observers - - pure token.instrument diff --git a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml b/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml deleted file mode 100644 index b53ed944d..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml +++ /dev/null @@ -1,280 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.Test.BatchWithIntermediaries where - -import DA.Date (addDays, toDateUTC) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import DA.Time (time) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Factory qualified as SettlementFactory (I, Instruct(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..), I, GetView(..)) -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (Discover(..), I) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..), Step(..), Quantity(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, AddObservers(..)) -import Daml.Finance.Settlement.V4.Conversion (fromInstrumentKey) -import Daml.Finance.Settlement.V4.Factory qualified as Settlement (Factory(..)) -import Daml.Finance.Settlement.V4.Hierarchy (Hierarchy(..)) -import Daml.Finance.Settlement.V4.RouteProvider.IntermediatedStatic (IntermediatedStatic(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyNoObservers, verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingDuplicates.Factory qualified as HoldingV2 (Factory(..)) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Safe head function returning an Optional value. -headOpt : [a] -> Optional a -headOpt xs = case xs of - x :: _ -> Some x - [] -> None - --- | Parties involved in the test script. -data TestParties = TestParties - with - buyer : Party - -- ^ Receives the equity instrument in exchange for cash. - seller : Party - -- ^ Seller of the equity instrument. Receives cash in exchange for units of equity. - bank : Party - -- ^ Custodian of the issuer's cash holdings. - cb : Party - -- ^ Depository and issuer of the cash instrument. Custodian of the cash holdings of Bank 1 - -- and Bank 2. - csd : Party - -- ^ Depository of the equity instrument. Custodian of the equity holdings of Bank 1 and - -- Issuer. - issuer : Party - -- ^ Issuer of the equity instrument. Receives cash in exchange for units of equity. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- DvP via settlement chain and instructions. --- The Buyer transfers cash to Seller in exchange for an equity instrument (detained by issuer at --- depository). --- Seller transfers equity to Buyer in exchange for cash. --- +------------------------------------------------------+ --- | Accounts | --- +-----------------------------+------------------------+ --- | structure: | used for: | --- +-----------------------------+------------------------+ --- | Central Bank | | --- | / \ | central bank money | --- | Buyer Bank | | --- | / | commercial bank money | --- | Buyer Seller | | --- | \ / | securities | --- | Central Security Depository | | --- +-----------------------------+------------------------+ -run : Script () -run = script do - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Setup security accounts at CB (utilising non-fungible holdings) - -- Create account factory - csdAccountFactoryCid <- toInterfaceContractId <$> Account.createFactory csd [] - -- Create holding factory - csdHoldingFactory <- createHoldingFactory - Holding.Factory with - provider = csd; id = Id "Holding Factory @ CSD"; observers = Map.fromList pp - -- Create accounts - [buyerSecurityAccount, sellerSecurityAccount] <- mapA (Account.createAccount "Security Account" [] - csdAccountFactoryCid csdHoldingFactory [] Account.Owner csd) [buyer, seller] - - -- Setup cash accounts at CB (utilising fungible holdings) - -- Create account factory - cbAccountFactoryCid <- toInterfaceContractId <$> Account.createFactory cb [] - -- Create holding factory - cbHoldingFactory <- createHoldingFactory - Holding.Factory with - provider = cb; id = Id "Holding Factory @ CB"; observers = Map.fromList pp - -- Create accounts - [buyerCashAccount, bankCashAccount] <- mapA (Account.createAccount "Cash Account" [] - cbAccountFactoryCid cbHoldingFactory [] Account.Owner cb) [buyer, bank] - - -- Setup cash accounts at Bank - -- Create account factory - bankAccountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank [] - -- Create holding factory - bankHoldingFactory <- - createHoldingFactory - HoldingV2.Factory with - provider = bank; id = Id "HoldingV2 Factory @ Bank"; observers = Map.fromList pp - -- Create accounts - [sellerCashAccount] <- mapA (Account.createAccount "Cash Account" [] bankAccountFactoryCid - bankHoldingFactory [] Account.Owner bank) [seller] - - -- Distribute assets - now <- getTime - equityInstrument <- - Instrument.originate csd issuer "AAPL" TransferableFungible "Apple Inc." [] now - equityHoldingCid <- Account.credit [] equityInstrument 1_000.0 sellerSecurityAccount - cashInstrument <- Instrument.originate cb cb "USD" TransferableFungible "United States Dollar" - [] now - buyerCashHoldingCid <- Account.credit [] cashInstrument 200_000.0 buyerCashAccount - - -- Settlement steps - let - steps = - [SettlementTypes.Step with - sender = seller - receiver = buyer - quantity = SettlementTypes.Quantity - with unit = fromInstrumentKey equityInstrument; amount = 1_000.0 - , SettlementTypes.Step with - sender = buyer - receiver = seller - quantity = SettlementTypes.Quantity - with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 - ] - settlementTime = time (addDays (toDateUTC now) 1) 0 0 0 - - -- Discover settlement routes (by first creating a route provider with intermediaries from Buyer - -- to Seller) - let - paths = Map.fromList - [ ("USD", Hierarchy with rootCustodian = cb; pathsToRootCustodian = [[buyer], [seller, bank]]) - , ("AAPL", Hierarchy with rootCustodian = csd; pathsToRootCustodian = [[seller], [buyer]])] - - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit buyer do - createCmd IntermediatedStatic with - provider = buyer - paths - observers = mempty - routedSteps <- submit buyer do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton buyer; contextId = None; steps - - -- Instruct settlement - -- Before settlement: identifies which instructions correspond to which asset type (AAPL vs USD) - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> submit buyer do - createCmd Settlement.Factory with provider = buyer; observers = mempty - - (batchCid, instructionCids) <- - submit [buyer, seller] do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = buyer - consenters = Set.singleton seller - settlers = Set.fromList [buyer, seller] - id = Id "APPL 1000@200.0USD"; description = "DVP"; contextId = None - routedSteps; settlementTime = Some settlementTime - - -- Inspect each instruction to determine its asset type - instrViews <- forA instructionCids $ \cid -> - submit buyer do - exerciseCmd cid Instruction.GetView with viewer = buyer - - let - zipped = zip instructionCids instrViews - - -- Identify by unit id - Some equityInstructionCid = - headOpt [ cid | (cid, v) <- zipped, v.routedStep.quantity.unit.id == "AAPL" ] - cashInstructionCids = - [ cid | (cid, v) <- zipped, v.routedStep.quantity.unit.id == "USD" ] - Some cashInstruction1Cid = headOpt cashInstructionCids - Some cashInstruction2Cid = headOpt (drop 1 cashInstructionCids) - - -- Ensure the custodian (CSD) can see the instruction and the holding - -- 1) Ensure CSD sees the instruction - equityInstructionCid <- fromInterfaceContractId @Instruction.I <$> submit seller do - exerciseCmd (toInterfaceContractId @Disclosure.I equityInstructionCid) - Disclosure.AddObservers with - disclosers = Set.singleton seller - observersToAdd = ("csd_allocation", Set.singleton csd) - - -- 2) Ensure CSD sees the pledged holding, too - equityHoldingCid <- coerceInterfaceContractId @Api.HoldingV1.Holding @Disclosure.I <$> submit seller do - exerciseCmd (coerceInterfaceContractId @Disclosure.I @Api.HoldingV1.Holding equityHoldingCid) - Disclosure.AddObservers with - disclosers = Set.singleton seller - observersToAdd = ("csd_allocation", Set.singleton csd) - - -- Allocate instructions - (equityInstructionCid, _) <- submit seller do - exerciseCmd equityInstructionCid - Instruction.Allocate with - actors = Set.singleton seller - allocation = SettlementTypes.Pledge equityHoldingCid - - (cashInstruction1Cid, _) <- submit buyer do - exerciseCmd cashInstruction1Cid - Instruction.Allocate with - actors = Set.singleton buyer - allocation = SettlementTypes.Pledge buyerCashHoldingCid - - (cashInstruction2Cid, _) <- submit bank do - exerciseCmd cashInstruction2Cid - Instruction.Allocate with - actors = Set.singleton bank - allocation = SettlementTypes.CreditReceiver - - submitMustFail buyer do - exerciseCmd cashInstruction1Cid - Instruction.Allocate with - actors = Set.singleton buyer - allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - equityInstructionCid <- submit buyer do - exerciseCmd equityInstructionCid - Instruction.Approve with - actors = Set.singleton buyer; approval = SettlementTypes.TakeDelivery buyerSecurityAccount - - cashInstruction1Cid <- submit bank do - exerciseCmd cashInstruction1Cid - Instruction.Approve with actors = Set.singleton bank; approval = SettlementTypes.TakeDelivery bankCashAccount - - cashInstruction2Cid <- submit seller do - exerciseCmd cashInstruction2Cid - Instruction.Approve with - actors = Set.singleton seller; approval = SettlementTypes.TakeDelivery sellerCashAccount - - submitMustFail buyer do - exerciseCmd equityInstructionCid - Instruction.Approve with actors = Set.singleton buyer; approval = SettlementTypes.DebitSender - - settledHoldings <- - submit (actAs buyer <> readAs publicParty) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton buyer - - - -- Identify holdings based on instrument and owner - -- After settlement: identifies which new holdings correspond to which owner/instrument - let identifyHolding instr owner = do - cids <- forA settledHoldings \cid -> do - mView <- queryInterfaceContractId @Api.HoldingV1.Holding owner cid - case mView of - Some v -> - if v.instrumentId.id == instr && v.owner == owner - then pure [cid] -- return directly - else pure [] - None -> pure [] - pure (concat cids) -- flatten [[cid]] to [cid] - - -- Extract each desired holding - Some equityHoldingCid <- headOpt <$> identifyHolding "AAPL" buyer - Some bankCashHoldingCid <- headOpt <$> identifyHolding "USD" bank - Some sellerCashHoldingCid <- headOpt <$> identifyHolding "USD" seller - - - -- Assert state - let ts = [(buyer, equityHoldingCid), (bank, bankCashHoldingCid), (seller, sellerCashHoldingCid)] - - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - -setupParties : Script TestParties -setupParties = do - [buyer, seller, cb, csd, bank, issuer, publicParty] <- createParties - ["Buyer", "Seller", "CentralBank", "CentralSecurityDepository", "Bank", "Issuer", "PublicParty"] - pure TestParties with buyer; seller; cb; csd; bank; issuer; publicParty diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Lifecycle.daml b/docs/generated/src/test/daml/Daml/Finance/Test/Util/Lifecycle.daml deleted file mode 100644 index 134f9d91e..000000000 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Lifecycle.daml +++ /dev/null @@ -1,186 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Test.Util.Lifecycle where - -import DA.Date () -import DA.List (sort) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Claims.V3.Lifecycle.Rule (Rule(..)) -import Daml.Finance.Claims.V3.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (GetView(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (Apply(..), Exercisable, I) -import Daml.Finance.Interface.Lifecycle.V4.Election.Factory qualified as ElectionFactory (Create(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), InstrumentKey, InstrumentQuantity) -import Daml.Finance.Lifecycle.V4.Election qualified as Election (Factory(..)) -import Daml.Finance.Test.Util.Time (createClockUpdateEvent) -import Daml.Script - --- | Lifecycle the instrument as of this date. This is a general function that can be used for --- different kinds of instruments. -lifecycleInstrument : [Party] -> Date -> InstrumentKey -> Party -> - [ContractId NumericObservable.I] -> Script (Optional InstrumentKey, [ContractId Effect.I]) -lifecycleInstrument readers today instrument issuer observableCids = do - -- Create a clock update event - clockEventCid <- createClockUpdateEvent (Set.singleton issuer) today mempty - - -- Create a lifecycle rule - lifecycleRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit issuer do - createCmd Rule with - providers = Set.singleton issuer - observers = mempty - lifecycler = issuer - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument" - - -- Try to lifecycle the instrument - (lifecycleCid, effectCids) <- submit (actAs issuer <> readAs readers) do - exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids - instrument - - pure (lifecycleCid, effectCids) - --- | Verify that the consumed/produced quantities match the expected ones. -verifyConsumedAndProduced : [InstrumentQuantity] -> [InstrumentQuantity] -> ContractId Effect.I - -> Party -> Script () -verifyConsumedAndProduced expectedConsumed expectedProduced effectCid - issuer = do - -- Get the effect - effectView <- submit issuer do - exerciseCmd effectCid Effect.GetView with viewer = issuer - - -- Sort the instrument quantities for a more robust comparison - let - sortedConsumed = sort effectView.otherConsumed - sortedProduced = sort effectView.otherProduced - sortedExpectedConsumed = sort expectedConsumed - sortedExpectedProduced = sort expectedProduced - - assertMsg ("The consumed quantities " <> show sortedConsumed <> - " do not match the expected ones " <> show sortedExpectedConsumed) $ - sortedExpectedConsumed == sortedConsumed - assertMsg ("The produced quantities " <> show sortedProduced <> - " do not match the expected ones " <> show sortedExpectedProduced) $ - sortedExpectedProduced == sortedProduced - --- | Verify a that there are no lifecycle effects of the instrument on this date. -verifyNoLifecycleEffects : [Party] -> Date -> InstrumentKey -> Party -> - [ContractId NumericObservable.I] -> Script (Optional InstrumentKey) -verifyNoLifecycleEffects readAs today instrument issuer observableCids = do - (newInstrumentKey, effectCids) <- lifecycleInstrument readAs today instrument issuer - observableCids - assertMsg ("There should be no lifecycle effects on " <> show today) (null effectCids) - pure newInstrumentKey - --- | Verify the payments from a payment date of an instrument (excluding settlement) -lifecycleAndVerifyPaymentEffects : [Party] -> Date -> InstrumentKey -> Party -> - [ContractId NumericObservable.I] -> [InstrumentQuantity] -> [InstrumentQuantity] -> - Script (Optional InstrumentKey) -lifecycleAndVerifyPaymentEffects readAs today instrument issuer - observableCids expectedConsumed expectedProduced = do - (maybeNewInstrumentKey, effectCids) <- - lifecycleInstrument readAs today instrument issuer observableCids - - case (maybeNewInstrumentKey, effectCids) of - (Some newKey, [effectCid]) -> do - verifyConsumedAndProduced expectedConsumed expectedProduced effectCid issuer - pure (Some newKey) - (Some newKey, []) -> pure (Some newKey) - (Some newKey, manyEffects) -> pure (Some newKey) - (None, [effectCid]) -> pure None - (None, []) -> pure None - (maybeKey, manyEffects) -> pure maybeKey - - --- | Create the Election and the lifecycle rule. -createElectionAndLifecycleRule : Date -> Decimal -> InstrumentKey -> Bool -> Party -> Party -> Text - -> Script (ContractId Election.I, ContractId Election.Exercisable) -createElectionAndLifecycleRule today amount instrument electorIsOwner issuer elector electedTag = do - -- Create election factory to allow holders to create elections - electionFactoryCid <- submit issuer do - toInterfaceContractId @ElectionFactory.I <$> createCmd Election.Factory with - provider = issuer - observers = Map.fromList [("Observers", Set.fromList [elector, issuer])] - - -- Create a lifecycle rule - lifecycleRuleCid <- toInterfaceContractId <$> submit issuer do - createCmd Lifecycle.Rule with - providers = Set.singleton issuer - observers = mempty - lifecycler = issuer - id = Id "LifecycleRule" - description = "Rule to lifecycle an Election based instrument" - - -- Create the Election - let - counterparty = issuer - description = "election for a callable bond" - electionCid <- submit elector do - exerciseCmd electionFactoryCid ElectionFactory.Create with - actors = Set.singleton elector - id = Id "election id" - description - claim = electedTag - electionTime = dateToDateClockTime today - electorIsOwner - elector - counterparty - instrument - amount - observers = Map.fromList [("Holders", Set.fromList [issuer, elector, counterparty])] - provider = issuer - - pure (electionCid, lifecycleRuleCid) - --- | Apply an election and verify that the election effect matches the expected result. -applyElectionAndVerify : Party -> [Party] -> [ContractId NumericObservable.I] -> - [InstrumentQuantity] -> [InstrumentQuantity] -> ContractId Election.I -> - ContractId Election.Exercisable -> Script (Optional InstrumentKey, ContractId Effect.I) -applyElectionAndVerify issuer readers observableCids - expectedConsumed expectedProduced electionCid - lifecycleRuleCid = do - -- Apply election to generate new instrument version + effects - (newInstrumentKey, [effectCid]) <- submit (actAs issuer <> readAs readers) do - exerciseCmd electionCid Election.Apply with - observableCids - exercisableCid = lifecycleRuleCid - - -- Verify that the consumed/produced quantities match the expected ones - verifyConsumedAndProduced expectedConsumed expectedProduced effectCid issuer - - pure (newInstrumentKey, effectCid) - --- | Verify the payments of an instrument after an election (excluding settlement). -electAndVerifyPaymentEffects : Date -> Decimal -> InstrumentKey -> Bool -> Party -> Party -> [Party] - -> Text -> [ContractId NumericObservable.I] -> [InstrumentQuantity] -> [InstrumentQuantity] - -> Script (Optional InstrumentKey, ContractId Effect.I) -electAndVerifyPaymentEffects today amount instrument electorIsOwner issuer elector readers - electedTag observableCids expectedConsumed expectedProduced = do - -- Create the Election and the lifecycle rule - (electionCid, lifecycleRuleCid) <- createElectionAndLifecycleRule today amount instrument - electorIsOwner issuer elector electedTag - - applyElectionAndVerify issuer readers observableCids expectedConsumed expectedProduced - electionCid lifecycleRuleCid - --- | Try to lifecycle an election and verify that this is not possible. -ensureElectionNotPossible : Date -> Decimal -> InstrumentKey -> Bool -> Party -> Party -> [Party] - -> Text -> [ContractId NumericObservable.I] -> Script () -ensureElectionNotPossible today amount instrument electorIsOwner issuer elector readers - electedTag observableCids = do - -- Create the Election and the lifecycle rule - (electionCid, lifecycleRuleCid) <- createElectionAndLifecycleRule today amount instrument - electorIsOwner issuer elector electedTag - - -- Try to apply the election and verify that this does not work - submitMustFail (actAs [issuer] <> readAs readers )do - exerciseCmd electionCid Election.Apply with - observableCids - exercisableCid = lifecycleRuleCid - diff --git a/docs/generated/tutorials/getting-started/intro.rst b/docs/generated/tutorials/getting-started/intro.rst index e5266dd20..1f0878671 100644 --- a/docs/generated/tutorials/getting-started/intro.rst +++ b/docs/generated/tutorials/getting-started/intro.rst @@ -56,7 +56,7 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio .. _structure-of-code-dependencies: diff --git a/docs/generated/tutorials/lifecycling/intro.rst b/docs/generated/tutorials/lifecycling/intro.rst index a83c9777e..91d1edad2 100644 --- a/docs/generated/tutorials/lifecycling/intro.rst +++ b/docs/generated/tutorials/lifecycling/intro.rst @@ -51,4 +51,4 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio \ No newline at end of file + dpm studio \ No newline at end of file diff --git a/docs/generated/tutorials/payoff-modeling/intro.rst b/docs/generated/tutorials/payoff-modeling/intro.rst index 5d8acee5e..77e2d1c63 100644 --- a/docs/generated/tutorials/payoff-modeling/intro.rst +++ b/docs/generated/tutorials/payoff-modeling/intro.rst @@ -56,7 +56,7 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio .. TODO explain the role of acquisition date in the observations section (together with path-dependent payoffs) .. TODO Elections (options, callable bonds) diff --git a/docs/generated/tutorials/settlement/intro.rst b/docs/generated/tutorials/settlement/intro.rst index 8d9cb4310..d427c88cd 100644 --- a/docs/generated/tutorials/settlement/intro.rst +++ b/docs/generated/tutorials/settlement/intro.rst @@ -58,4 +58,4 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio diff --git a/docs/generated/tutorials/upgrade/intro.rst b/docs/generated/tutorials/upgrade/intro.rst index f1852bcab..286321539 100644 --- a/docs/generated/tutorials/upgrade/intro.rst +++ b/docs/generated/tutorials/upgrade/intro.rst @@ -72,4 +72,4 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio diff --git a/docs/scripts/generate-docs.sh b/docs/scripts/generate-docs.sh index f810e1207..d0d509233 100755 --- a/docs/scripts/generate-docs.sh +++ b/docs/scripts/generate-docs.sh @@ -14,10 +14,8 @@ if [[ -d ${docs_dir}/generated ]]; then rm -rf ${docs_dir}/generated fi mkdir ${docs_dir}/generated -mkdir ${docs_dir}/generated/src cp -a ${docs_dir}/source/* ${docs_dir}/generated/ -cp -a ${root_dir}/src/* ${docs_dir}/generated/src/ mkdir -p ${docs_dir}/generated/reference/code-documentation cp -r ${docs_dir}/build/daml-finance-rst ${docs_dir}/generated/reference/code-documentation/daml-finance-rst diff --git a/docs/source/finance-lifecycling/README.md b/docs/source/finance-lifecycling/README.md index 45c6db186..0316f634c 100644 --- a/docs/source/finance-lifecycling/README.md +++ b/docs/source/finance-lifecycling/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance lifecycling tutor Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/source/finance-lifecycling/daml.yaml b/docs/source/finance-lifecycling/daml.yaml index 74837e4d0..6c032246d 100644 --- a/docs/source/finance-lifecycling/daml.yaml +++ b/docs/source/finance-lifecycling/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-lifecycling source: daml init-script: Scripts.FixedRateBond:runFixedRateBond diff --git a/docs/source/finance-payoff-modeling/README.md b/docs/source/finance-payoff-modeling/README.md index dde7bdd60..4a2c763ba 100644 --- a/docs/source/finance-payoff-modeling/README.md +++ b/docs/source/finance-payoff-modeling/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance payoff modeling t Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/source/finance-payoff-modeling/daml.yaml b/docs/source/finance-payoff-modeling/daml.yaml index ec551d4b0..bbc28e8c3 100644 --- a/docs/source/finance-payoff-modeling/daml.yaml +++ b/docs/source/finance-payoff-modeling/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-payoff-modeling source: daml init-script: PayoffBuilder:runCreateAndLifecycle diff --git a/docs/source/finance-settlement/README.md b/docs/source/finance-settlement/README.md index 23dfadaed..a62ad2007 100644 --- a/docs/source/finance-settlement/README.md +++ b/docs/source/finance-settlement/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance settlement tutori Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/source/finance-settlement/daml.yaml b/docs/source/finance-settlement/daml.yaml index 6c6460a7c..a53e95bab 100644 --- a/docs/source/finance-settlement/daml.yaml +++ b/docs/source/finance-settlement/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-settlement source: daml init-script: Scripts.Transfer:runDualControlTransfer diff --git a/docs/source/finance-upgrades/README.md b/docs/source/finance-upgrades/README.md index 02ca1c349..cd9e0c851 100644 --- a/docs/source/finance-upgrades/README.md +++ b/docs/source/finance-upgrades/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance upgrade tutorials Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/source/finance-upgrades/daml.yaml b/docs/source/finance-upgrades/daml.yaml index 9fac0d531..bb33ca2ad 100644 --- a/docs/source/finance-upgrades/daml.yaml +++ b/docs/source/finance-upgrades/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: finance-upgrades source: daml init-script: Scripts.UpgradeHolding:upgradeHolding diff --git a/docs/source/overview/intro.rst b/docs/source/overview/intro.rst index cad2d9f23..6ce90192f 100644 --- a/docs/source/overview/intro.rst +++ b/docs/source/overview/intro.rst @@ -108,7 +108,7 @@ This downloads all required packages and builds the project. You can then run: .. code-block:: shell - daml studio + dpm studio to open the code editor and inspect the code. diff --git a/docs/source/quickstart-finance/README.md b/docs/source/quickstart-finance/README.md index 710240b93..16f35c18d 100644 --- a/docs/source/quickstart-finance/README.md +++ b/docs/source/quickstart-finance/README.md @@ -5,6 +5,6 @@ This project contains the source code used in the Daml Finance getting started t Before opening Visual Studio Code you should run `./get-dependencies.sh` (or `get-dependencies.bat` for Windows users) to download the required Daml packages. -You can then open Daml Studio by running `daml studio`, or build the project using `daml build`. +You can then open Daml Studio by running `dpm studio`, or build the project using `dpm build`. -To run the project, run `daml start` (which also builds the project). +To run the project, run `dpm start` (which also builds the project). diff --git a/docs/source/quickstart-finance/daml.yaml b/docs/source/quickstart-finance/daml.yaml index dad0a25f8..a7bae2d97 100644 --- a/docs/source/quickstart-finance/daml.yaml +++ b/docs/source/quickstart-finance/daml.yaml @@ -3,7 +3,7 @@ # *** DO NOT COPY THIS FILE TO THE DAML REPO *** -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: quickstart-finance source: daml init-script: Scripts.Transfer:runTransfer diff --git a/docs/source/tutorials/getting-started/intro.rst b/docs/source/tutorials/getting-started/intro.rst index e5266dd20..1f0878671 100644 --- a/docs/source/tutorials/getting-started/intro.rst +++ b/docs/source/tutorials/getting-started/intro.rst @@ -56,7 +56,7 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio .. _structure-of-code-dependencies: diff --git a/docs/source/tutorials/lifecycling/intro.rst b/docs/source/tutorials/lifecycling/intro.rst index a83c9777e..91d1edad2 100644 --- a/docs/source/tutorials/lifecycling/intro.rst +++ b/docs/source/tutorials/lifecycling/intro.rst @@ -51,4 +51,4 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio \ No newline at end of file + dpm studio \ No newline at end of file diff --git a/docs/source/tutorials/payoff-modeling/intro.rst b/docs/source/tutorials/payoff-modeling/intro.rst index 5d8acee5e..77e2d1c63 100644 --- a/docs/source/tutorials/payoff-modeling/intro.rst +++ b/docs/source/tutorials/payoff-modeling/intro.rst @@ -56,7 +56,7 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio .. TODO explain the role of acquisition date in the observations section (together with path-dependent payoffs) .. TODO Elections (options, callable bonds) diff --git a/docs/source/tutorials/settlement/intro.rst b/docs/source/tutorials/settlement/intro.rst index 8d9cb4310..d427c88cd 100644 --- a/docs/source/tutorials/settlement/intro.rst +++ b/docs/source/tutorials/settlement/intro.rst @@ -58,4 +58,4 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio diff --git a/docs/source/tutorials/upgrade/intro.rst b/docs/source/tutorials/upgrade/intro.rst index f1852bcab..286321539 100644 --- a/docs/source/tutorials/upgrade/intro.rst +++ b/docs/source/tutorials/upgrade/intro.rst @@ -72,4 +72,4 @@ Finally, you can start Daml Studio to inspect the code and run the project's scr .. code-block:: shell - daml studio + dpm studio diff --git a/multi-package.yaml b/multi-package.yaml new file mode 100644 index 000000000..ab0e0cee3 --- /dev/null +++ b/multi-package.yaml @@ -0,0 +1,53 @@ +# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +packages: +- package/main/daml/ContingentClaims.Core.V3 +- package/main/daml/ContingentClaims.Lifecycle.V3 +- package/main/daml/ContingentClaims.Valuation.V0 +- package/main/daml/Daml.Finance.Account.V4 +- package/main/daml/Daml.Finance.Claims.V3 +- package/main/daml/Daml.Finance.Data.V4 +- package/main/daml/Daml.Finance.Holding.V4 +- package/main/daml/Daml.Finance.Instrument.Bond.V3 +- package/main/daml/Daml.Finance.Instrument.Equity.V0 +- package/main/daml/Daml.Finance.Instrument.Generic.V4 +- package/main/daml/Daml.Finance.Instrument.Option.V0 +- package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0 +- package/main/daml/Daml.Finance.Instrument.Swap.V0 +- package/main/daml/Daml.Finance.Instrument.Token.V4 +- package/main/daml/Daml.Finance.Interface.Account.V4 +- package/main/daml/Daml.Finance.Interface.Claims.V4 +- package/main/daml/Daml.Finance.Interface.Data.V4 +- package/main/daml/Daml.Finance.Interface.Holding.V4 +- package/main/daml/Daml.Finance.Interface.Instrument.Base.V4 +- package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3 +- package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0 +- package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4 +- package/main/daml/Daml.Finance.Interface.Instrument.Option.V0 +- package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0 +- package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0 +- package/main/daml/Daml.Finance.Interface.Instrument.Token.V4 +- package/main/daml/Daml.Finance.Interface.Instrument.Types.V2 +- package/main/daml/Daml.Finance.Interface.Lifecycle.V4 +- package/main/daml/Daml.Finance.Interface.Settlement.V4 +- package/main/daml/Daml.Finance.Interface.Types.Common.V3 +- package/main/daml/Daml.Finance.Interface.Types.Date.V3 +- package/main/daml/Daml.Finance.Interface.Util.V3 +- package/main/daml/Daml.Finance.Lifecycle.V4 +- package/main/daml/Daml.Finance.Settlement.V4 +- package/main/daml/Daml.Finance.Util.V4 +- package/test/daml/ContingentClaims.Test +- package/test/daml/Daml.Finance.Account.Test +- package/test/daml/Daml.Finance.Data.Test +- package/test/daml/Daml.Finance.Holding.Test +- package/test/daml/Daml.Finance.Instrument.Bond.Test +- package/test/daml/Daml.Finance.Instrument.Equity.Test +- package/test/daml/Daml.Finance.Instrument.Generic.Test +- package/test/daml/Daml.Finance.Instrument.Option.Test +- package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test +- package/test/daml/Daml.Finance.Instrument.Swap.Test +- package/test/daml/Daml.Finance.Settlement.Test +- package/test/daml/Daml.Finance.Test.Util +- package/test/daml/Daml.Finance.Util.Test + diff --git a/package/main/daml/ContingentClaims.Core.V3/daml.yaml b/package/main/daml/ContingentClaims.Core.V3/daml.yaml index a26a3434d..8e3322a0d 100644 --- a/package/main/daml/ContingentClaims.Core.V3/daml.yaml +++ b/package/main/daml/ContingentClaims.Core.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: contingent-claims-core-v3 source: daml version: 3.99.0.20251211.0 @@ -9,7 +9,7 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar + - ../../../../.lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar build-options: - --target=2.dev diff --git a/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core b/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core deleted file mode 120000 index 7a9b95c4c..000000000 --- a/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core +++ /dev/null @@ -1 +0,0 @@ -../../../../../../src/main/daml/ContingentClaims/Core/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/ContingentClaims/Core/V3/Builders.daml b/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Builders.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Core/V3/Builders.daml rename to package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Builders.daml diff --git a/docs/generated/src/main/daml/ContingentClaims/Core/V3/Claim.daml b/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Claim.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Core/V3/Claim.daml rename to package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Claim.daml diff --git a/docs/generated/src/main/daml/ContingentClaims/Core/V3/Internal/Claim.daml b/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Internal/Claim.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Core/V3/Internal/Claim.daml rename to package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Internal/Claim.daml diff --git a/docs/generated/src/main/daml/ContingentClaims/Core/V3/Observation.daml b/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Observation.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Core/V3/Observation.daml rename to package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Observation.daml diff --git a/docs/generated/src/main/daml/ContingentClaims/Core/V3/Util/Recursion.daml b/package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Util/Recursion.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Core/V3/Util/Recursion.daml rename to package/main/daml/ContingentClaims.Core.V3/daml/ContingentClaims/Core/V3/Util/Recursion.daml diff --git a/package/main/daml/ContingentClaims.Lifecycle.V3/daml.yaml b/package/main/daml/ContingentClaims.Lifecycle.V3/daml.yaml index b48505188..5742dc87b 100644 --- a/package/main/daml/ContingentClaims.Lifecycle.V3/daml.yaml +++ b/package/main/daml/ContingentClaims.Lifecycle.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: contingent-claims-lifecycle-v3 source: daml version: 3.99.0.20251211.0 @@ -9,7 +9,8 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../../../../.lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar + - ../ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/ContingentClaims.Lifecycle.V3/daml/ContingentClaims/Lifecycle b/package/main/daml/ContingentClaims.Lifecycle.V3/daml/ContingentClaims/Lifecycle deleted file mode 120000 index 4da96b26f..000000000 --- a/package/main/daml/ContingentClaims.Lifecycle.V3/daml/ContingentClaims/Lifecycle +++ /dev/null @@ -1 +0,0 @@ -../../../../../../src/main/daml/ContingentClaims/Lifecycle/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/ContingentClaims/Lifecycle/V3/Lifecycle.daml b/package/main/daml/ContingentClaims.Lifecycle.V3/daml/ContingentClaims/Lifecycle/V3/Lifecycle.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Lifecycle/V3/Lifecycle.daml rename to package/main/daml/ContingentClaims.Lifecycle.V3/daml/ContingentClaims/Lifecycle/V3/Lifecycle.daml diff --git a/docs/generated/src/main/daml/ContingentClaims/Lifecycle/V3/Util.daml b/package/main/daml/ContingentClaims.Lifecycle.V3/daml/ContingentClaims/Lifecycle/V3/Util.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Lifecycle/V3/Util.daml rename to package/main/daml/ContingentClaims.Lifecycle.V3/daml/ContingentClaims/Lifecycle/V3/Util.daml diff --git a/package/main/daml/ContingentClaims.Valuation.V0/daml.yaml b/package/main/daml/ContingentClaims.Valuation.V0/daml.yaml index 752690428..8fe8b6f5b 100644 --- a/package/main/daml/ContingentClaims.Valuation.V0/daml.yaml +++ b/package/main/daml/ContingentClaims.Valuation.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: contingent-claims-valuation-v0 source: daml version: 0.99.0.20251211.0 @@ -9,7 +9,8 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../../../../.lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar + - ../ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/ContingentClaims.Valuation.V0/daml/ContingentClaims/Valuation b/package/main/daml/ContingentClaims.Valuation.V0/daml/ContingentClaims/Valuation deleted file mode 120000 index ee86f00b4..000000000 --- a/package/main/daml/ContingentClaims.Valuation.V0/daml/ContingentClaims/Valuation +++ /dev/null @@ -1 +0,0 @@ -../../../../../../src/main/daml/ContingentClaims/Valuation/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/ContingentClaims/Valuation/V0/MathML.daml b/package/main/daml/ContingentClaims.Valuation.V0/daml/ContingentClaims/Valuation/V0/MathML.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Valuation/V0/MathML.daml rename to package/main/daml/ContingentClaims.Valuation.V0/daml/ContingentClaims/Valuation/V0/MathML.daml diff --git a/docs/generated/src/main/daml/ContingentClaims/Valuation/V0/Stochastic.daml b/package/main/daml/ContingentClaims.Valuation.V0/daml/ContingentClaims/Valuation/V0/Stochastic.daml similarity index 100% rename from docs/generated/src/main/daml/ContingentClaims/Valuation/V0/Stochastic.daml rename to package/main/daml/ContingentClaims.Valuation.V0/daml/ContingentClaims/Valuation/V0/Stochastic.daml diff --git a/package/main/daml/Daml.Finance.Account.V4/daml.yaml b/package/main/daml/Daml.Finance.Account.V4/daml.yaml index 95823154f..71624812b 100644 --- a/package/main/daml/Daml.Finance.Account.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Account.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-account-v4 source: daml version: 4.99.0.20251211.0 @@ -9,13 +9,14 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Holding.V4/4.99.0.20251211.0/daml-finance-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar - - .lib/splice/splice-api-token-metadata-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-metadata-v1-1.0.0.dar + - ../Daml.Finance.Holding.V4/.daml/dist/daml-finance-holding-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Account.V4/daml/Daml/Finance/Account b/package/main/daml/Daml.Finance.Account.V4/daml/Daml/Finance/Account deleted file mode 120000 index 4b565a190..000000000 --- a/package/main/daml/Daml.Finance.Account.V4/daml/Daml/Finance/Account +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../src/main/daml/Daml/Finance/Account/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Account/V4/Account.daml b/package/main/daml/Daml.Finance.Account.V4/daml/Daml/Finance/Account/V4/Account.daml similarity index 97% rename from docs/generated/src/main/daml/Daml/Finance/Account/V4/Account.daml rename to package/main/daml/Daml.Finance.Account.V4/daml/Daml/Finance/Account/V4/Account.daml index 431e48044..a5537c942 100644 --- a/docs/generated/src/main/daml/Daml/Finance/Account/V4/Account.daml +++ b/package/main/daml/Daml.Finance.Account.V4/daml/Daml/Finance/Account/V4/Account.daml @@ -69,8 +69,9 @@ template Account (view holding).owner == owner -- Metadata lookup helper - let holdingView = view (toInterface @Api.HoldingV1.Holding holding) - let holdingMeta = metaLookup holdingView.meta + let + holdingView = view (toInterface @Api.HoldingV1.Holding holding) + holdingMeta = metaLookup holdingView.meta -- Custodian assertMsg "Holding custodian must match account custodian" $ diff --git a/package/main/daml/Daml.Finance.Claims.V3/daml.yaml b/package/main/daml/Daml.Finance.Claims.V3/daml.yaml index 9cab53c70..b10628cb1 100644 --- a/package/main/daml/Daml.Finance.Claims.V3/daml.yaml +++ b/package/main/daml/Daml.Finance.Claims.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-claims-v3 source: daml version: 3.99.0.20251211.0 @@ -9,16 +9,17 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/ContingentClaims.Lifecycle.V3/3.99.0.20251211.0/contingent-claims-lifecycle-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../ContingentClaims.Lifecycle.V3/.daml/dist/contingent-claims-lifecycle-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims b/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims deleted file mode 120000 index 32bf28d93..000000000 --- a/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../src/main/daml/Daml/Finance/Claims/ \ No newline at end of file diff --git a/src/main/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml b/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml similarity index 96% rename from src/main/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml rename to package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml index 6a629de38..8eda04401 100644 --- a/src/main/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml +++ b/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Lifecycle/Rule.daml @@ -65,13 +65,8 @@ template Rule tryCreateNewInstrument lifecycler dynamicInstrumentView.prevEvents v.eventTime None instrument newKey effectCid <- toInterfaceContractId <$> create Effect with - providers = singleton currentKey.issuer - id = v.id - description = v.description - targetInstrument = currentKey - producedInstrument - otherConsumed - otherProduced + providers = singleton currentKey.issuer; id = v.id; description = v.description + targetInstrument = currentKey; producedInstrument; otherConsumed; otherProduced settlementTime = Some v.eventTime observers = (.observers) . view $ toInterface @Disclosure.I claimInstrument pure (Some newKey, [effectCid]) @@ -162,8 +157,7 @@ tryCreateNewInstrument actor prevEvents eventTime electionData oldKey Some (electorIsOwner, claimTag) -> prevEvents ++ [newElection] where newElection = EventData with - t = eventTime - election = Some (electorIsOwner, claimTag) + t = eventTime; election = Some (electorIsOwner, claimTag) version = newKey.version -- CREATE_NEW_DYNAMIC_INSTRUMENT_VERSION_END pure () diff --git a/docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util.daml b/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util.daml rename to package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util/Builders.daml b/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util/Builders.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util/Builders.daml rename to package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util/Builders.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util/Date.daml b/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util/Date.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util/Date.daml rename to package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util/Date.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util/Lifecycle.daml b/package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util/Lifecycle.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Claims/V3/Util/Lifecycle.daml rename to package/main/daml/Daml.Finance.Claims.V3/daml/Daml/Finance/Claims/V3/Util/Lifecycle.daml diff --git a/package/main/daml/Daml.Finance.Data.V4/daml.yaml b/package/main/daml/Daml.Finance.Data.V4/daml.yaml index 01463f31f..43983bb61 100644 --- a/package/main/daml/Daml.Finance.Data.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Data.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-data-v4 source: daml version: 4.99.0.20251211.0 @@ -9,11 +9,12 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Data.V4/4.99.0.20251211.0/daml-finance-interface-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Data.V4/.daml/dist/daml-finance-interface-data-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data b/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data deleted file mode 120000 index 7f29ca469..000000000 --- a/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../src/main/daml/Daml/Finance/Data/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Data/V4/Numeric/Observation.daml b/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Numeric/Observation.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Data/V4/Numeric/Observation.daml rename to package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Numeric/Observation.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Data/V4/Reference/HolidayCalendar.daml b/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Reference/HolidayCalendar.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Data/V4/Reference/HolidayCalendar.daml rename to package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Reference/HolidayCalendar.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/DateClock.daml b/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/DateClock.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/DateClock.daml rename to package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/DateClock.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/DateClock/Types.daml b/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/DateClock/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/DateClock/Types.daml rename to package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/DateClock/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/DateClockUpdate.daml b/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/DateClockUpdate.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/DateClockUpdate.daml rename to package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/DateClockUpdate.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/LedgerTime.daml b/package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/LedgerTime.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Data/V4/Time/LedgerTime.daml rename to package/main/daml/Daml.Finance.Data.V4/daml/Daml/Finance/Data/V4/Time/LedgerTime.daml diff --git a/package/main/daml/Daml.Finance.Holding.V4/daml.yaml b/package/main/daml/Daml.Finance.Holding.V4/daml.yaml index d912d7781..23f1a76e2 100644 --- a/package/main/daml/Daml.Finance.Holding.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Holding.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-holding-v4 source: daml version: 4.99.0.20251211.0 @@ -9,12 +9,13 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar - - .lib/splice/splice-api-token-metadata-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-metadata-v1-1.0.0.dar + - ../Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding deleted file mode 120000 index 91c4ac9e7..000000000 --- a/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../src/main/daml/Daml/Finance/Holding \ No newline at end of file diff --git a/src/main/daml/Daml/Finance/Holding/V4/BaseHolding.daml b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/BaseHolding.daml similarity index 65% rename from src/main/daml/Daml/Finance/Holding/V4/BaseHolding.daml rename to package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/BaseHolding.daml index a4fa81f87..fccd21f8d 100644 --- a/src/main/daml/Daml/Finance/Holding/V4/BaseHolding.daml +++ b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/BaseHolding.daml @@ -3,8 +3,9 @@ module Daml.Finance.Holding.V4.BaseHolding where -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (toApiHoldingView) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) +import DA.TextMap qualified as TextMap import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) @@ -12,6 +13,7 @@ import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(.. import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 +import Splice.Api.Token.MetadataV1 qualified as SpliceMetadata -- | Type synonym for `BaseHolding`. type T = BaseHolding @@ -50,10 +52,29 @@ template BaseHolding acquire = acquireImpl this.lock (\lock -> this with lock) release = releaseImpl this.lock (\lock -> this with lock) + -- interface instance Holding.I for BaseHolding where interface instance Api.HoldingV1.Holding for BaseHolding where view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount \ No newline at end of file + let lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with + owner = account.owner + instrumentId = Api.HoldingV1.InstrumentId with + admin = instrument.issuer; id = show instrument.id + amount = amount + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] diff --git a/docs/generated/src/main/daml/Daml/Finance/Holding/V4/Factory.daml b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Holding/V4/Factory.daml rename to package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Factory.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Fungible.daml similarity index 70% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml rename to package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Fungible.daml index 928e3a06e..f368f088e 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml +++ b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Fungible.daml @@ -1,18 +1,14 @@ -- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 -module Daml.Finance.Test.Util.HoldingDuplicates.Fungible where +module Daml.Finance.Holding.V4.Fungible where --- | Test Implementation. --- This module contains a copy of the code from the Daml.Finance.Holding package. It is used --- specifically for testing purposes, allowing the instantiation of an alternate implementation of --- holdings. - -import DA.Set (fromList, singleton) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) import DA.TextMap qualified as TextMap import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl) import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) @@ -26,7 +22,7 @@ type T = Fungible -- | Implementation of a fungible holding. -- The `Fungible` template implements the interface `Fungible.I` (which requires --- `Holding.I`, `Lockable.I`, and `Disclosure.I` to be implemented), but not the `Transferable.I`. +-- `Api.HoldingV1.Holding`, `Lockable.I`, and `Disclosure.I` to be implemented), but not the `Transferable.I`. template Fungible with instrument : InstrumentKey @@ -59,15 +55,32 @@ template Fungible release = releaseImpl this.lock (\lock -> this with lock) interface instance Api.HoldingV1.Holding for Fungible where - view = Api.HoldingV1.HoldingView - with + view = + let lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with owner = account.owner instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t + admin = instrument.issuer; id = show instrument.id amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty + + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] interface instance Fungible.I for Fungible where view = Fungible.View with modifiers = singleton account.owner diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Transferable.daml similarity index 69% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml rename to package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Transferable.daml index f01294a2b..7ec986f03 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml +++ b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Transferable.daml @@ -1,18 +1,14 @@ -- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 -module Daml.Finance.Test.Util.HoldingDuplicates.Transferable where +module Daml.Finance.Holding.V4.Transferable where --- | Test Implementation. --- This module contains a copy of the code from the Daml.Finance.Holding package. It is used --- specifically for testing purposes, allowing the instantiation of an alternate implementation of --- holdings. - -import DA.Set (fromList, singleton) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) import DA.TextMap qualified as TextMap import Daml.Finance.Holding.V4.Util (transferImpl) import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) @@ -24,8 +20,8 @@ import Splice.Api.Token.MetadataV1 qualified as SpliceMetadata -- | Type synonym for `Transferable`. type T = Transferable --- | Implementation of a non-fungible holding. --- `Transferable` implements the interface `Transferable.I` (which requires `Holding.I`, +-- | Implementation of a transferable holding. +-- `Transferable` implements the interface `Transferable.I` (which requires `Api.HoldingV1.Holding`, -- `Lockable.I`, and Disclosure.I` to be implemented), but not the `Fungible.I`. template Transferable with @@ -59,15 +55,32 @@ template Transferable release = releaseImpl this.lock (\lock -> this with lock) interface instance Api.HoldingV1.Holding for Transferable where - view = Api.HoldingV1.HoldingView - with + view = + let lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with owner = account.owner instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t + admin = instrument.issuer; id = show instrument.id amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty + + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] interface instance Transferable.I for Transferable where view = Transferable.View {} diff --git a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/TransferableFungible.daml similarity index 72% rename from src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml rename to package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/TransferableFungible.daml index 6194c2672..8206c174c 100644 --- a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml +++ b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/TransferableFungible.daml @@ -1,19 +1,15 @@ -- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 -module Daml.Finance.Test.Util.HoldingDuplicates.TransferableFungible where +module Daml.Finance.Holding.V4.TransferableFungible where --- | Test Implementation. --- This module contains a copy of the code from the Daml.Finance.Holding package. It is used --- specifically for testing purposes, allowing the instantiation of an alternate implementation of --- holdings. - -import DA.Set (fromList, singleton) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) import DA.TextMap qualified as TextMap import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl, transferImpl) import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) @@ -27,7 +23,7 @@ type T = TransferableFungible -- | Implementation of a transferable and fungible holding. -- The `TransferableFungible` template implements the interface `Fungible.I` and `Transferable.I` --- (which requires `Holding.I`, `Lockable.I`, and `Disclosure.I` to be implemented). +-- (which requires `Api.HoldingV1.Holding`, `Lockable.I`, and `Disclosure.I` to be implemented). template TransferableFungible with instrument : InstrumentKey @@ -62,15 +58,32 @@ template TransferableFungible release = releaseImpl this.lock (\lock -> this with lock) interface instance Api.HoldingV1.Holding for TransferableFungible where - view = Api.HoldingV1.HoldingView - with + view = + let lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with owner = account.owner instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t + admin = instrument.issuer; id = show instrument.id amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty + + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] interface instance Transferable.I for TransferableFungible where view = Transferable.View {} diff --git a/src/main/daml/Daml/Finance/Holding/V4/Util.daml b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Util.daml similarity index 74% rename from src/main/daml/Daml/Finance/Holding/V4/Util.daml rename to package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Util.daml index 2ad9bcd10..4f2e81a18 100644 --- a/src/main/daml/Daml/Finance/Holding/V4/Util.daml +++ b/package/main/daml/Daml.Finance.Holding.V4/daml/Daml/Finance/Holding/V4/Util.daml @@ -5,20 +5,19 @@ module Daml.Finance.Holding.V4.Util where import DA.Action (foldlA) import DA.Foldable qualified as F (all) -import DA.Set (fromList, isSubsetOf, toList) +import DA.Set (fromList, isSubsetOf) import DA.Optional (fromOptional) -import DA.Text (intercalate) import DA.TextMap qualified as TextMap import DA.Traversable qualified as T (forA) import Daml.Finance.Interface.Account.V4.Account qualified as Account (Credit(..), Debit(..), I, R, exerciseInterfaceByKey) import Daml.Finance.Interface.Account.V4.Util (getAccount) import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, Merge(..), Split(..), SplitResult(..)) import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), Id(..) ) +import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..), Id(..) ) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..) ) import Daml.Finance.Interface.Util.V3.Common (qty, verify) import Daml.Finance.Interface.Util.V3.InterfaceKey (fetchInterfaceByKey) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, mustNotBeLocked, View(..)) +import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (mustNotBeLocked, I) import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 import Splice.Api.Token.MetadataV1 qualified as SpliceMetadata @@ -32,8 +31,7 @@ instrumentFromSplice Api.HoldingV1.InstrumentId{admin, id} = holdingStandard = HoldingStandard.Transferable metaLookup : SpliceMetadata.Metadata -> Text -> Text -metaLookup SpliceMetadata.Metadata { values } key = - fromOptional "" (TextMap.lookup key values) +metaLookup SpliceMetadata.Metadata { values } key = fromOptional "" (TextMap.lookup key values) -- | Default implementation of `transfer` for the `Transferable` interface. transferImpl : Transferable.I -> ContractId Transferable.I -> Transferable.Transfer @@ -108,52 +106,34 @@ mergeImpl this getAmount setAmount Fungible.Merge{fungibleCids} = do Lockable.mustNotBeLocked this assertMsg "List of fungibles must be non-empty" . not . null $ fungibleCids let - currentSignatories = fromList . signatory . setAmount $ vHolding.amount - current = view . toInterface @Api.HoldingV1.Holding . toInterface @Fungible.I . setAmount $ vHolding.amount + currentSignatories = + fromList . signatory . setAmount $ vHolding.amount + + current = + view + . toInterface @Api.HoldingV1.Holding + . toInterface @Fungible.I + . setAmount + $ vHolding.amount + aggregate aggregatedAmount fungibleCid = do Some (otherHoldingCid, otherHolding) <- fetchFromInterface @t fungibleCid let - otherBase = toInterface @Api.HoldingV1.Holding . toInterface @Fungible.I $ otherHolding + otherBase = + toInterface @Api.HoldingV1.Holding + . toInterface @Fungible.I + $ otherHolding other = view otherBase assertMsg "Instrument must match" $ other.instrumentId == current.instrumentId assertMsg "Owner must match" $ other.owner == current.owner - assertMsg "Signatories must match" $ fromList (signatory otherHolding) == currentSignatories + assertMsg "Signatories must match" $ + fromList (signatory otherHolding) == currentSignatories Lockable.mustNotBeLocked (toInterface @Lockable.I otherHolding) archive otherHoldingCid pure $ aggregatedAmount + getAmount otherHolding tot <- foldlA aggregate vHolding.amount fungibleCids fmap toInterfaceContractId . create . setAmount $ tot --- | Helper to construct the standard Api.HoldingV1.HoldingView shared by --- BaseHolding, Fungible, Transferable and TransferableFungible implementations. --- Converts internal holding state into the API-facing representation. -toApiHoldingView : Lockable.View -> InstrumentKey -> AccountKey -> Decimal -> Api.HoldingV1.HoldingView -toApiHoldingView lockView instrument account amount = - Api.HoldingV1.HoldingView with - owner = account.owner - instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = show instrument.id - amount = amount - lock = case lockView.lock of - None -> None - Some l -> - Some Api.HoldingV1.Lock with - holders = toList l.lockers - expiresAt = None -- Not present in Lockable - expiresAfter = None -- Not present in Lockable - context = Some (intercalate ", " (toList l.context)) - meta = - SpliceMetadata.Metadata with - values = TextMap.fromList - [ ("depository", partyToText instrument.depository) - , ("version", instrument.version) - , ("holdingStandard", show instrument.holdingStandard) - , ("custodian", partyToText account.custodian) - , ("accountId", show account.id) - ] - - -- | HIDE -- Gets the rest amount of a split (if any) and verifies that split amounts are strictly positive -- and don't exceed the current amount. diff --git a/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml.yaml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml.yaml index 48bcf83b1..8ac0fe8bd 100644 --- a/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml.yaml +++ b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-bond-v3 source: daml version: 3.99.0.20251211.0 @@ -9,16 +9,17 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Bond.V3/3.99.0.20251211.0/daml-finance-interface-instrument-bond-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Bond.V3/.daml/dist/daml-finance-interface-instrument-bond-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond deleted file mode 120000 index 7a2f640e4..000000000 --- a/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Instrument/Bond \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/Callable/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/Callable/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/Callable/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/Callable/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/Util.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/Util.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/Util.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/Util.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Bond.V3/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Instrument.daml diff --git a/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml.yaml b/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml.yaml index 653acba27..e0b87655a 100644 --- a/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-equity-v0 source: daml version: 0.99.0.20251211.0 @@ -9,11 +9,12 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Equity.V0/0.99.0.20251211.0/daml-finance-interface-instrument-equity-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Equity.V0/.daml/dist/daml-finance-interface-instrument-equity-v0-0.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml/Daml/Finance/Instrument/Equity b/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml/Daml/Finance/Instrument/Equity deleted file mode 120000 index 38baa88ae..000000000 --- a/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml/Daml/Finance/Instrument/Equity +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Instrument/Equity \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Equity/V0/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml/Daml/Finance/Instrument/Equity/V0/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Equity/V0/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Equity.V0/daml/Daml/Finance/Instrument/Equity/V0/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Equity/V0/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Equity.V0/daml/Daml/Finance/Instrument/Equity/V0/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Equity/V0/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Equity.V0/daml/Daml/Finance/Instrument/Equity/V0/Instrument.daml diff --git a/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml.yaml b/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml.yaml index 1b6e432db..56ed8a8d9 100644 --- a/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-generic-v4 source: daml version: 4.99.0.20251211.0 @@ -9,14 +9,15 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Generic.V4/4.99.0.20251211.0/daml-finance-interface-instrument-generic-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Generic.V4/.daml/dist/daml-finance-interface-instrument-generic-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic b/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic deleted file mode 120000 index fdfb42757..000000000 --- a/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Instrument/Generic \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Generic/V4/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Generic/V4/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic/V4/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Generic/V4/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic/V4/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Generic/V4/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic/V4/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Generic/V4/Lifecycle/Rule.daml b/package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic/V4/Lifecycle/Rule.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Generic/V4/Lifecycle/Rule.daml rename to package/main/daml/Daml.Finance.Instrument.Generic.V4/daml/Daml/Finance/Instrument/Generic/V4/Lifecycle/Rule.daml diff --git a/package/main/daml/Daml.Finance.Instrument.Option.V0/daml.yaml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml.yaml index 721487f0d..c8a59a6eb 100644 --- a/package/main/daml/Daml.Finance.Instrument.Option.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-option-v0 source: daml version: 0.99.0.20251211.0 @@ -9,14 +9,15 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Option.V0/0.99.0.20251211.0/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Option.V0/.daml/dist/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option deleted file mode 120000 index d25d4106a..000000000 --- a/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Instrument/Option \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Election.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/Dividend/Election.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Election.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/Dividend/Election.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/Dividend/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/Dividend/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/Dividend/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/Dividend/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Option.V0/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Instrument.daml diff --git a/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml.yaml b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml.yaml index 069958b79..77ae60fdf 100644 --- a/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-structuredproduct-v0 source: daml version: 0.99.0.20251211.0 @@ -9,17 +9,18 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Option.V0/0.99.0.20251211.0/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.StructuredProduct.V0/0.99.0.20251211.0/daml-finance-interface-instrument-structuredproduct-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Option.V0/.daml/dist/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.StructuredProduct.V0/.daml/dist/daml-finance-interface-instrument-structuredproduct-v0-0.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct deleted file mode 120000 index e9a45666d..000000000 --- a/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Instrument/StructuredProduct \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml diff --git a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml similarity index 99% rename from src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml index 2c277174c..46735954b 100644 --- a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml +++ b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml @@ -96,7 +96,6 @@ template Instrument view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 getClaims Claim.GetClaims{actor} = do -- get the initial claims tree (as of the instrument's acquisition time) - let getCalendars = getHolidayCalendars actor calendarDataProvider floatingRate = None diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/Util.daml b/package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/Util.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/Util.daml rename to package/main/daml/Daml.Finance.Instrument.StructuredProduct.V0/daml/Daml/Finance/Instrument/StructuredProduct/V0/Util.daml diff --git a/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml.yaml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml.yaml index bc4ac1b87..a1d0e949c 100644 --- a/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-swap-v0 source: daml version: 0.99.0.20251211.0 @@ -9,18 +9,19 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Swap.V0/0.99.0.20251211.0/daml-finance-interface-instrument-swap-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Swap.V0/.daml/dist/daml-finance-interface-instrument-swap-v0-0.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap deleted file mode 120000 index 46e083edb..000000000 --- a/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Instrument/Swap \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/DistributionRule.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Asset/DistributionRule.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/DistributionRule.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Asset/DistributionRule.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Asset/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Asset/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Asset/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Asset/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Currency/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Currency/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Currency/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Currency/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Util.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Util.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Util.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Util.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Swap.V0/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Instrument.daml diff --git a/package/main/daml/Daml.Finance.Instrument.Token.V4/daml.yaml b/package/main/daml/Daml.Finance.Instrument.Token.V4/daml.yaml index 11fb8ae94..bc4567800 100644 --- a/package/main/daml/Daml.Finance.Instrument.Token.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Instrument.Token.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-token-v4 source: daml version: 4.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Token.V4/4.99.0.20251211.0/daml-finance-interface-instrument-token-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Token.V4/.daml/dist/daml-finance-interface-instrument-token-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Instrument.Token.V4/daml/Daml/Finance/Instrument/Token b/package/main/daml/Daml.Finance.Instrument.Token.V4/daml/Daml/Finance/Instrument/Token deleted file mode 120000 index ce34f4aea..000000000 --- a/package/main/daml/Daml.Finance.Instrument.Token.V4/daml/Daml/Finance/Instrument/Token +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Instrument/Token \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Token/V4/Factory.daml b/package/main/daml/Daml.Finance.Instrument.Token.V4/daml/Daml/Finance/Instrument/Token/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Token/V4/Factory.daml rename to package/main/daml/Daml.Finance.Instrument.Token.V4/daml/Daml/Finance/Instrument/Token/V4/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Instrument/Token/V4/Instrument.daml b/package/main/daml/Daml.Finance.Instrument.Token.V4/daml/Daml/Finance/Instrument/Token/V4/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Instrument/Token/V4/Instrument.daml rename to package/main/daml/Daml.Finance.Instrument.Token.V4/daml/Daml/Finance/Instrument/Token/V4/Instrument.daml diff --git a/package/main/daml/Daml.Finance.Interface.Account.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Account.V4/daml.yaml index 91c05a61b..ca5c6070e 100644 --- a/package/main/daml/Daml.Finance.Interface.Account.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Account.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-account-v4 source: daml version: 4.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar - - .lib/splice/splice-api-token-metadata-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-metadata-v1-1.0.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account b/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account deleted file mode 120000 index 093d05649..000000000 --- a/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Interface/Account/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Account/V4/Account.daml b/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account/V4/Account.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Account/V4/Account.daml rename to package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account/V4/Account.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Account/V4/Factory.daml b/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Account/V4/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account/V4/Factory.daml diff --git a/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account/V4/Util.daml b/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account/V4/Util.daml new file mode 100644 index 000000000..708a06705 --- /dev/null +++ b/package/main/daml/Daml.Finance.Interface.Account.V4/daml/Daml/Finance/Interface/Account/V4/Util.daml @@ -0,0 +1,34 @@ +-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +-- SPDX-License-Identifier: Apache-2.0 + +module Daml.Finance.Interface.Account.V4.Util where + +import DA.Optional(fromSome) +import DA.TextMap qualified as TextMap +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), Id(..)) +import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 +import Splice.Api.Token.MetadataV1 () + +-- | Get the account key of a holding. +getAccount : (HasToInterface t Api.HoldingV1.Holding) => t -> AccountKey +getAccount holding = + let + vHolding = view (toInterface @Api.HoldingV1.Holding holding) + metaVals = vHolding.meta.values + custodianTxt = fromSome (TextMap.lookup "custodian" metaVals) + accountIdTxt = fromSome (TextMap.lookup "accountId" metaVals) + in AccountKey with + custodian = fromSome (partyFromText custodianTxt) + owner = vHolding.owner + id = Id accountIdTxt + +-- | Get the custodian of a holding. +getCustodian : (HasToInterface t Api.HoldingV1.Holding) => t -> Party +getCustodian holding = + let metaVals = (view $ toInterface @Api.HoldingV1.Holding holding).meta.values + custodianTxt = fromSome (TextMap.lookup "custodian" metaVals) + in fromSome (partyFromText custodianTxt) + +-- | Get the owner of a holding. +getOwner : (HasToInterface t Api.HoldingV1.Holding) => t -> Party +getOwner = (.owner) . view . toInterface @Api.HoldingV1.Holding diff --git a/package/main/daml/Daml.Finance.Interface.Claims.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Claims.V4/daml.yaml index 525804925..bb9ef84ca 100644 --- a/package/main/daml/Daml.Finance.Interface.Claims.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Claims.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-claims-v4 source: daml version: 4.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims b/package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims deleted file mode 120000 index 88eb159e7..000000000 --- a/package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Interface/Claims \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Claims/V4/Claim.daml b/package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims/V4/Claim.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Claims/V4/Claim.daml rename to package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims/V4/Claim.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Claims/V4/Dynamic/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims/V4/Dynamic/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Claims/V4/Dynamic/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims/V4/Dynamic/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Claims/V4/Types.daml b/package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims/V4/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Claims/V4/Types.daml rename to package/main/daml/Daml.Finance.Interface.Claims.V4/daml/Daml/Finance/Interface/Claims/V4/Types.daml diff --git a/package/main/daml/Daml.Finance.Interface.Data.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Data.V4/daml.yaml index dbc2005e8..0120b4ba7 100644 --- a/package/main/daml/Daml.Finance.Interface.Data.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Data.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-data-v4 source: daml version: 4.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data b/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data deleted file mode 120000 index 6db646c15..000000000 --- a/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Interface/Data \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation.daml b/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation.daml rename to package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation/Factory.daml b/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar.daml b/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar.daml rename to package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar/Factory.daml b/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/Time.daml b/package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Reference/Time.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/Time.daml rename to package/main/daml/Daml.Finance.Interface.Data.V4/daml/Daml/Finance/Interface/Data/V4/Reference/Time.daml diff --git a/package/main/daml/Daml.Finance.Interface.Holding.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Holding.V4/daml.yaml index 9f1972a99..fa707bb9b 100644 --- a/package/main/daml/Daml.Finance.Interface.Holding.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Holding.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-holding-v4 source: daml version: 4.99.0.20251211.0 @@ -9,9 +9,10 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding b/package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding deleted file mode 120000 index 3caa1567b..000000000 --- a/package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Interface/Holding \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Holding/V4/Factory.daml b/package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Holding/V4/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding/V4/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Holding/V4/Fungible.daml b/package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding/V4/Fungible.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Holding/V4/Fungible.daml rename to package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding/V4/Fungible.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Holding/V4/Transferable.daml b/package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding/V4/Transferable.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Holding/V4/Transferable.daml rename to package/main/daml/Daml.Finance.Interface.Holding.V4/daml/Daml/Finance/Interface/Holding/V4/Transferable.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml.yaml index 50137b40a..7ffb057c0 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-base-v4 source: daml version: 4.99.0.20251211.0 @@ -9,9 +9,10 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml/Daml/Finance/Interface/Instrument/Base b/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml/Daml/Finance/Interface/Instrument/Base deleted file mode 120000 index 8be210f0c..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml/Daml/Finance/Interface/Instrument/Base +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Base \ No newline at end of file diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml similarity index 93% rename from src/main/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml index 3dbbaea6f..d2566bccb 100644 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Base.V4/daml/Daml/Finance/Interface/Instrument/Base/V4/Instrument.daml @@ -5,12 +5,11 @@ module Daml.Finance.Interface.Instrument.Base.V4.Instrument where -import Daml.Finance.Interface.Util.V3.HoldingSplice (getInstrument) +import Daml.Finance.Interface.Util.V3.HoldingSplice () import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard, Id(..), InstrumentKey(..), PartiesMap, Quantity(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, flattenObservers) -import Daml.Finance.Interface.Util.V3.InterfaceKey (createReferenceHelper, disclosureUpdateReferenceHelper, fetchInterfaceByKey) +import Daml.Finance.Interface.Util.V3.InterfaceKey (createReferenceHelper, disclosureUpdateReferenceHelper) import Daml.Finance.Interface.Util.V3.InterfaceKey qualified as InterfaceKey (HasInterfaceKey(..), exerciseInterfaceByKeyHelper) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 -- | Type synonym for `Instrument`. type I = Instrument @@ -139,10 +138,6 @@ qty amount instrument = Quantity with unit = instrument; amount scale : Decimal -> Q -> Q scale factor quantity = quantity with amount = quantity.amount * factor --- | Fetch instrument from holding. -fetchInstrument : (HasToInterface t Api.HoldingV1.Holding) => t -> Update Instrument -fetchInstrument = fetchInterfaceByKey @Reference . getInstrument . toInterface @Api.HoldingV1.Holding - -- | Exercise interface by key. -- This method can be used to exercise a choice on an `Instrument` given its `InstrumentKey`. -- Requires as input the `InstrumentKey`, the actor exercising the choice, and the choice arguments. diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml.yaml index 0151d2845..afd45a44f 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-bond-v3 source: daml version: 3.99.0.20251211.0 @@ -9,12 +9,13 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond deleted file mode 120000 index 941fdc249..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Bond \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Bond.V3/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Types.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml.yaml index 5f3ce3058..c8f9697c9 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-equity-v0 source: daml version: 0.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml/Daml/Finance/Interface/Instrument/Equity b/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml/Daml/Finance/Interface/Instrument/Equity deleted file mode 120000 index 0d5d78014..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml/Daml/Finance/Interface/Instrument/Equity +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Equity \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml/Daml/Finance/Interface/Instrument/Equity/V0/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml/Daml/Finance/Interface/Instrument/Equity/V0/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml/Daml/Finance/Interface/Instrument/Equity/V0/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Equity.V0/daml/Daml/Finance/Interface/Instrument/Equity/V0/Instrument.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml.yaml index d41d03ad5..ca4737207 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-generic-v4 source: daml version: 4.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml/Daml/Finance/Interface/Instrument/Generic b/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml/Daml/Finance/Interface/Instrument/Generic deleted file mode 120000 index a50f9491f..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml/Daml/Finance/Interface/Instrument/Generic +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Generic \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml/Daml/Finance/Interface/Instrument/Generic/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml/Daml/Finance/Interface/Instrument/Generic/V4/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml/Daml/Finance/Interface/Instrument/Generic/V4/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Generic.V4/daml/Daml/Finance/Interface/Instrument/Generic/V4/Instrument.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml.yaml index 87ae8e85d..4367ca457 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-option-v0 source: daml version: 0.99.0.20251211.0 @@ -9,11 +9,12 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option deleted file mode 120000 index 49461bdc7..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Option \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Election/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Election/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Election/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Election/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Option.V0/daml/Daml/Finance/Interface/Instrument/Option/V0/Types.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml.yaml index dead1592c..e78f045d7 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-structuredproduct-v0 source: daml version: 0.99.0.20251211.0 @@ -9,11 +9,12 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct deleted file mode 120000 index 25dad3837..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/Types.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml.yaml index b3fbee584..9bc0205b4 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-swap-v0 source: daml version: 0.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap deleted file mode 120000 index eee9b18b5..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Swap \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/FpmlTypes.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/FpmlTypes.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/FpmlTypes.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/FpmlTypes.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Types.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Swap.V0/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Types.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml.yaml index f19c86c52..4a77eb022 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-token-v4 source: daml version: 4.99.0.20251211.0 @@ -9,9 +9,10 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token b/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token deleted file mode 120000 index 0bc7e1792..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Token \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Factory.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token/V4/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Instrument.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token/V4/Instrument.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Instrument.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token/V4/Instrument.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Types.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token/V4/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Types.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Token.V4/daml/Daml/Finance/Interface/Instrument/Token/V4/Types.daml diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml.yaml b/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml.yaml index 403945317..97a313080 100644 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-instrument-types-v2 source: daml version: 2.99.0.20251211.0 @@ -9,7 +9,8 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml/Daml/Finance/Interface/Instrument/Types b/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml/Daml/Finance/Interface/Instrument/Types deleted file mode 120000 index a7f4da8f3..000000000 --- a/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml/Daml/Finance/Interface/Instrument/Types +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Instrument/Types \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Types/V2/FloatingRate.daml b/package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml/Daml/Finance/Interface/Instrument/Types/V2/FloatingRate.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Instrument/Types/V2/FloatingRate.daml rename to package/main/daml/Daml.Finance.Interface.Instrument.Types.V2/daml/Daml/Finance/Interface/Instrument/Types/V2/FloatingRate.daml diff --git a/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml.yaml index cc8bd6d4c..6dd67b313 100644 --- a/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-lifecycle-v4 source: daml version: 4.99.0.20251211.0 @@ -9,10 +9,11 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Settlement.V4/4.99.0.20251211.0/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../Daml.Finance.Interface.Settlement.V4/.daml/dist/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle deleted file mode 120000 index d9965a88e..000000000 --- a/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Interface/Lifecycle/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Effect.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Effect.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Effect.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Effect.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Election.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Election.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election/Factory.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Election/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Election/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Distribution.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Distribution.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Distribution.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Distribution.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Replacement.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Replacement.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Replacement.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Replacement.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Time.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Time.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Time.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Time.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/NumericObservable.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/NumericObservable.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/NumericObservable.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/NumericObservable.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/TimeObservable.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/TimeObservable.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/TimeObservable.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/TimeObservable.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Claim.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Claim.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Claim.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Claim.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Lifecycle.daml b/package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Lifecycle.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Lifecycle.daml rename to package/main/daml/Daml.Finance.Interface.Lifecycle.V4/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Lifecycle.daml diff --git a/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml.yaml b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml.yaml index 826331750..f112066be 100644 --- a/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-settlement-v4 source: daml version: 4.99.0.20251211.0 @@ -9,9 +9,10 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement deleted file mode 120000 index 82013393b..000000000 --- a/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Interface/Settlement/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Batch.daml b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Batch.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Batch.daml rename to package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Batch.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Factory.daml b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Factory.daml rename to package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Instruction.daml b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Instruction.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/Instruction.daml rename to package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Instruction.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/RouteProvider.daml b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/RouteProvider.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Settlement/V4/RouteProvider.daml rename to package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/RouteProvider.daml diff --git a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Types.daml b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Types.daml similarity index 96% rename from src/main/daml/Daml/Finance/Interface/Settlement/V4/Types.daml rename to package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Types.daml index 1048b3ffc..b9498f377 100644 --- a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Types.daml +++ b/package/main/daml/Daml.Finance.Interface.Settlement.V4/daml/Daml/Finance/Interface/Settlement/V4/Types.daml @@ -44,6 +44,9 @@ data RoutedStep = RoutedStep deriving (Eq, Ord, Show) +-- If version is provided, use it +-- if not provided, use time to infer which version should be allocated + -- | Describes an allocation of an `Instruction`. data Allocation = Unallocated diff --git a/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml.yaml b/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml.yaml index c87b2d560..59e872a3d 100644 --- a/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-types-common-v3 source: daml version: 3.99.0.20251211.0 diff --git a/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml/Daml/Finance/Interface/Types/Common b/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml/Daml/Finance/Interface/Types/Common deleted file mode 120000 index ea28f2942..000000000 --- a/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml/Daml/Finance/Interface/Types/Common +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Types/Common \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Types/Common/V3/Types.daml b/package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml/Daml/Finance/Interface/Types/Common/V3/Types.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Types/Common/V3/Types.daml rename to package/main/daml/Daml.Finance.Interface.Types.Common.V3/daml/Daml/Finance/Interface/Types/Common/V3/Types.daml diff --git a/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml.yaml b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml.yaml index f1a446d4e..6a1099703 100644 --- a/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-types-date-v3 source: daml version: 3.99.0.20251211.0 diff --git a/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date deleted file mode 120000 index 4d8a087ce..000000000 --- a/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/main/daml/Daml/Finance/Interface/Types/Date \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Calendar.daml b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/Calendar.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Calendar.daml rename to package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/Calendar.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Classes.daml b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/Classes.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Classes.daml rename to package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/Classes.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DateOffset.daml b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/DateOffset.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DateOffset.daml rename to package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/DateOffset.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DayCount.daml b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/DayCount.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DayCount.daml rename to package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/DayCount.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/RollConvention.daml b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/RollConvention.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/RollConvention.daml rename to package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/RollConvention.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Schedule.daml b/package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/Schedule.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Schedule.daml rename to package/main/daml/Daml.Finance.Interface.Types.Date.V3/daml/Daml/Finance/Interface/Types/Date/V3/Schedule.daml diff --git a/package/main/daml/Daml.Finance.Interface.Util.V3/daml.yaml b/package/main/daml/Daml.Finance.Interface.Util.V3/daml.yaml index 496db9864..db00cec88 100644 --- a/package/main/daml/Daml.Finance.Interface.Util.V3/daml.yaml +++ b/package/main/daml/Daml.Finance.Interface.Util.V3/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-interface-util-v3 source: daml version: 3.99.0.20251211.0 @@ -9,8 +9,9 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-upgrade-interfaces + diff --git a/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util b/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util deleted file mode 120000 index 048047aa0..000000000 --- a/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/main/daml/Daml/Finance/Interface/Util \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/Common.daml b/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/Common.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/Common.daml rename to package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/Common.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/Disclosure.daml b/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/Disclosure.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/Disclosure.daml rename to package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/Disclosure.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml b/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml similarity index 99% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml rename to package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml index 7937d9bd1..6b06547ab 100644 --- a/docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml +++ b/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml @@ -25,7 +25,6 @@ parseHoldingStandard t = "BaseHolding" -> BaseHolding s -> error ("Unknown HoldingStandard: " <> s) - -- | Extract the `InstrumentKey` from a Holding, provided the appropriate metadata are populated. getInstrument : Api.HoldingV1.Holding -> InstrumentKey getInstrument holding = diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/InterfaceKey.daml b/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/InterfaceKey.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/InterfaceKey.daml rename to package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/InterfaceKey.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/Lockable.daml b/package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/Lockable.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Interface/Util/V3/Lockable.daml rename to package/main/daml/Daml.Finance.Interface.Util.V3/daml/Daml/Finance/Interface/Util/V3/Lockable.daml diff --git a/package/main/daml/Daml.Finance.Lifecycle.V4/daml.yaml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml.yaml index bfc03df17..663cfa2e0 100644 --- a/package/main/daml/Daml.Finance.Lifecycle.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Lifecycle.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-lifecycle-v4 source: daml version: 4.99.0.20251211.0 @@ -9,13 +9,14 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Settlement.V4/4.99.0.20251211.0/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Settlement.V4/4.99.0.20251211.0/daml-finance-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Settlement.V4/.daml/dist/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Settlement.V4/.daml/dist/daml-finance-settlement-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle deleted file mode 120000 index 3a0685955..000000000 --- a/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../src/main/daml/Daml/Finance/Lifecycle/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Effect.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Effect.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Effect.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Effect.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Election.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Election.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Election.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Election.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/ElectionEffect.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/ElectionEffect.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/ElectionEffect.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/ElectionEffect.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Distribution.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Event/Distribution.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Distribution.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Event/Distribution.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Replacement.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Event/Replacement.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Replacement.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Event/Replacement.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Claim.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Claim.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Claim.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Claim.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Distribution.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Distribution.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Distribution.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Distribution.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Replacement.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Replacement.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Replacement.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Replacement.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Util.daml b/package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Util.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Util.daml rename to package/main/daml/Daml.Finance.Lifecycle.V4/daml/Daml/Finance/Lifecycle/V4/Rule/Util.daml diff --git a/package/main/daml/Daml.Finance.Settlement.V4/daml.yaml b/package/main/daml/Daml.Finance.Settlement.V4/daml.yaml index 5be32ac36..30e6427e7 100644 --- a/package/main/daml/Daml.Finance.Settlement.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Settlement.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-settlement-v4 source: daml version: 4.99.0.20251211.0 @@ -9,12 +9,13 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Settlement.V4/4.99.0.20251211.0/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Settlement.V4/.daml/dist/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement deleted file mode 120000 index 0edad35f0..000000000 --- a/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../src/main/daml/Daml/Finance/Settlement/ \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Batch.daml b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Batch.daml similarity index 98% rename from docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Batch.daml rename to package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Batch.daml index 54d012b8b..74fffd7c5 100644 --- a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Batch.daml +++ b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Batch.daml @@ -64,7 +64,6 @@ template Batch (instructionCid, instruction) <- fetchByKey @Instruction instructionKey settledCid <- exercise (toInterfaceContractId @Instruction.I instructionCid) Instruction.Execute with actors = actors <> Set.singleton instructor <> consenters - --join <$> T.mapA (undisclose (context, settlers) actors) settledCid pure settledCid -- execute instructions orderedSettledCids <- mapA settleInstruction orderedInstructions diff --git a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Conversion.daml b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Conversion.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Conversion.daml rename to package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Conversion.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Factory.daml b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Factory.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Factory.daml rename to package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Factory.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Hierarchy.daml b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Hierarchy.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Hierarchy.daml rename to package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Hierarchy.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Instruction.daml b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Instruction.daml similarity index 95% rename from docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Instruction.daml rename to package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Instruction.daml index e98d1ed85..ec093640d 100644 --- a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/Instruction.daml +++ b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/Instruction.daml @@ -83,17 +83,13 @@ template Instruction -- allocate newAllocation <- case allocation of - Pledge oldHoldingCid -> do - newHoldingCid <- disclosePledge this oldHoldingCid actors - holding <- fetch newHoldingCid - let holdingI = toInterface @Api.HoldingV1.Holding holding - - -- Sender account (linked to the investor, not custodian) - let senderAccountKey = getAccount holdingI - + let + holdingI = toInterface @Api.HoldingV1.Holding holding + -- Sender account (linked to the investor, not custodian) + senderAccountKey = getAccount holdingI senderAccount <- view <$> fetchInterfaceByKey @Account.R @Account.I senderAccountKey discloseAccount this senderAccountKey actors @@ -104,12 +100,12 @@ template Instruction assertMsg ("Pledged amount must match. " <> context this) $ Holding.getAmount holdingI == routedStep.quantity.amount - let holdingView = view holdingI - let expectedInstr = routedStep.quantity.unit + let + holdingView = view holdingI + expectedInstr = routedStep.quantity.unit assertMsg ("Pledged instrument ID mismatch. " <> context this) $ holdingView.instrumentId.id == expectedInstr.id - assertMsg ("Pledged instrument issuer mismatch. " <> context this) $ holdingView.instrumentId.admin == expectedInstr.admin @@ -119,7 +115,6 @@ template Instruction newLockers = Set.singleton instructor <> senderAccount.controllers.outgoing context = context this lockType = Lockable.Semaphore - pure $ Pledge newLockedCid PassThroughFrom (passThroughAccountKey, fromInstructionKey) -> do @@ -160,7 +155,6 @@ template Instruction atLeastOneMustAuthorize $ Set.fromList [routedStep.custodian, routedStep.receiver] assertMsg ("Approval must be new. " <> context this) $ approval /= this.approval releasePreviousApproval this actors - -- approve case approval of @@ -193,6 +187,7 @@ template Instruction toInterfaceContractId <$> create this with approval signedReceivers = if approval == Unapproved then mempty else actors + execute Instruction.Execute{actors} = do let allMustAuthorize = mustAuthorizeHelper True actors allMustAuthorize $ Set.insert instructor consenters @@ -206,11 +201,8 @@ template Instruction case (allocation, approval) of (Unallocated, Unapproved) -> abort $ "Instruction must be allocated and approved. " <> context this - (Unallocated, _) -> abort $ "Instruction must be allocated. " <> context this - (_, Unapproved) -> abortUnapproved - (PassThroughFrom _, _) -> do -- Pass-throughs are consumed by the routedStep (*) below abort $ "Holding has not been passed through. " <> context this @@ -219,10 +211,10 @@ template Instruction holdingCid <- coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I <$> exercise (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) Lockable.Release with context = context this - holding <- fetch holdingCid - let holdingI = toInterface @Api.HoldingV1.Holding holding - let senderAccountKey = getAccount holdingI + let + holdingI = toInterface @Api.HoldingV1.Holding holding + senderAccountKey = getAccount holdingI case a of TakeDelivery receiverAccountKey -> do @@ -262,6 +254,7 @@ template Instruction pure None SettleOffledgerAcknowledge -> abortOnOffledgerMix Unapproved -> abortUnapproved + (CreditReceiver, a) -> case a of TakeDelivery receiverAccountKey -> do @@ -286,6 +279,7 @@ template Instruction case a of SettleOffledgerAcknowledge -> pure None _ -> abortOnOffledgerMix + cancel Instruction.Cancel{actors} = do let allMustAuthorize = mustAuthorizeHelper True actors allMustAuthorize $ Set.insert instructor consenters @@ -353,21 +347,24 @@ releasePreviousAllocation this@Instruction {allocation; signedSenders} actors = case allocation of Pledge holdingCid -> do -- Convert Holding → Lockable - let lockableCid : ContractId Lockable.I = coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid + let + lockableCid : ContractId Lockable.I = + coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid -- Release the lock (returns Lockable CID) - releasedLockableCid <- - exercise lockableCid Lockable.Release with - context = context this + releasedLockableCid <- exercise lockableCid Lockable.Release with context = context this -- Convert Lockable → Holding - let releasedHoldingCid : ContractId Api.HoldingV1.Holding = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I releasedLockableCid + let + releasedHoldingCid : ContractId Api.HoldingV1.Holding = + coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I releasedLockableCid -- Fetch holding to get account holding <- fetch releasedHoldingCid - let holdingI = toInterface @Api.HoldingV1.Holding holding - let senderAccountKey = getAccount holdingI + let + holdingI = toInterface @Api.HoldingV1.Holding holding + senderAccountKey = getAccount holdingI undiscloseAccount this senderAccountKey actors mUndisclosed <- undisclosePledge this releasedHoldingCid actors diff --git a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/IntermediatedStatic.daml b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/RouteProvider/IntermediatedStatic.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/IntermediatedStatic.daml rename to package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/RouteProvider/IntermediatedStatic.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/SingleCustodian.daml b/package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/RouteProvider/SingleCustodian.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/SingleCustodian.daml rename to package/main/daml/Daml.Finance.Settlement.V4/daml/Daml/Finance/Settlement/V4/RouteProvider/SingleCustodian.daml diff --git a/package/main/daml/Daml.Finance.Util.V4/daml.yaml b/package/main/daml/Daml.Finance.Util.V4/daml.yaml index a21400cb3..103a48fa6 100644 --- a/package/main/daml/Daml.Finance.Util.V4/daml.yaml +++ b/package/main/daml/Daml.Finance.Util.V4/daml.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-util-v4 source: daml version: 4.99.0.20251211.0 @@ -9,8 +9,9 @@ dependencies: - daml-prim - daml-stdlib data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar build-options: - --target=2.dev + diff --git a/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util deleted file mode 120000 index 3bdb38003..000000000 --- a/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../src/main/daml/Daml/Finance/Util \ No newline at end of file diff --git a/docs/generated/src/main/daml/Daml/Finance/Util/V4/Common.daml b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Common.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Util/V4/Common.daml rename to package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Common.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/Calendar.daml b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/Calendar.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/Calendar.daml rename to package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/Calendar.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/DayCount.daml b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/DayCount.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/DayCount.daml rename to package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/DayCount.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/RollConvention.daml b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/RollConvention.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/RollConvention.daml rename to package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/RollConvention.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/Schedule.daml b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/Schedule.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Util/V4/Date/Schedule.daml rename to package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Date/Schedule.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Util/V4/Disclosure.daml b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Disclosure.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Util/V4/Disclosure.daml rename to package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Disclosure.daml diff --git a/docs/generated/src/main/daml/Daml/Finance/Util/V4/Lockable.daml b/package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Lockable.daml similarity index 100% rename from docs/generated/src/main/daml/Daml/Finance/Util/V4/Lockable.daml rename to package/main/daml/Daml.Finance.Util.V4/daml/Daml/Finance/Util/V4/Lockable.daml diff --git a/package/packages.yaml b/package/packages.yaml index 31aba0bc5..28e10d87c 100644 --- a/package/packages.yaml +++ b/package/packages.yaml @@ -13,24 +13,6 @@ remote: base-module: Daml.Control tag: v4.0.0 dar-name: daml-ctl-4.0.0.dar - - package: - name: Splice.Api.Token.HoldingV1 - repo: - host: github.com # we don't care as it's bypassed - organisation: digital-asset # we don't care as it's bypassed - name: splice - base-module: Splice.Api.Token.HoldingV1 - tag: "" - dar-name: splice-api-token-holding-v1-1.0.0.dar - - package: - name: Splice.Api.Token.MetadataV1 - repo: - host: github.com # we don't care as it's bypassed - organisation: digital-asset # we don't care as it's bypassed - name: splice - base-module: Splice.Api.Token.MetadataV1 - tag: "" - dar-name: splice-api-token-metadata-v1-1.0.0.dar local: repo: host: github.com diff --git a/package/test/daml/ContingentClaims.Test/daml.yaml b/package/test/daml/ContingentClaims.Test/daml.yaml index deb7142b8..554bbabfd 100644 --- a/package/test/daml/ContingentClaims.Test/daml.yaml +++ b/package/test/daml/ContingentClaims.Test/daml.yaml @@ -1,19 +1,20 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: contingent-claims-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/ContingentClaims.Lifecycle.V3/3.99.0.20251211.0/contingent-claims-lifecycle-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/ContingentClaims.Valuation.V0/0.99.0.20251211.0/contingent-claims-valuation-v0-0.99.0.20251211.0.dar + - ../../../../.lib/daml-ctl/v4.0.0/daml-ctl-4.0.0.dar + - ../../../main/daml/ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../../../main/daml/ContingentClaims.Lifecycle.V3/.daml/dist/contingent-claims-lifecycle-v3-3.99.0.20251211.0.dar + - ../../../main/daml/ContingentClaims.Valuation.V0/.daml/dist/contingent-claims-valuation-v0-0.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/ContingentClaims.Test/daml/ContingentClaims b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims deleted file mode 120000 index 0b9301ef7..000000000 --- a/package/test/daml/ContingentClaims.Test/daml/ContingentClaims +++ /dev/null @@ -1 +0,0 @@ -../../../../../src/test/daml/ContingentClaims/ \ No newline at end of file diff --git a/docs/generated/src/test/daml/ContingentClaims/Test/Currency.daml b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Currency.daml similarity index 100% rename from docs/generated/src/test/daml/ContingentClaims/Test/Currency.daml rename to package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Currency.daml diff --git a/docs/generated/src/test/daml/ContingentClaims/Test/FinancialContract.daml b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/FinancialContract.daml similarity index 100% rename from docs/generated/src/test/daml/ContingentClaims/Test/FinancialContract.daml rename to package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/FinancialContract.daml diff --git a/docs/generated/src/test/daml/ContingentClaims/Test/Initialization.daml b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Initialization.daml similarity index 100% rename from docs/generated/src/test/daml/ContingentClaims/Test/Initialization.daml rename to package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Initialization.daml diff --git a/docs/generated/src/test/daml/ContingentClaims/Test/Lifecycle.daml b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Lifecycle.daml similarity index 100% rename from docs/generated/src/test/daml/ContingentClaims/Test/Lifecycle.daml rename to package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Lifecycle.daml diff --git a/docs/generated/src/test/daml/ContingentClaims/Test/Pricing.daml b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Pricing.daml similarity index 100% rename from docs/generated/src/test/daml/ContingentClaims/Test/Pricing.daml rename to package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Pricing.daml diff --git a/docs/generated/src/test/daml/ContingentClaims/Test/Templating.daml b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Templating.daml similarity index 100% rename from docs/generated/src/test/daml/ContingentClaims/Test/Templating.daml rename to package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Templating.daml diff --git a/docs/generated/src/test/daml/ContingentClaims/Test/Util.daml b/package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Util.daml similarity index 100% rename from docs/generated/src/test/daml/ContingentClaims/Test/Util.daml rename to package/test/daml/ContingentClaims.Test/daml/ContingentClaims/Test/Util.daml diff --git a/package/test/daml/Daml.Finance.Account.Test/daml.yaml b/package/test/daml/Daml.Finance.Account.Test/daml.yaml index d94cd2a38..d783cac06 100644 --- a/package/test/daml/Daml.Finance.Account.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Account.Test/daml.yaml @@ -1,22 +1,23 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-account-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Holding.Test/0.99.0.20251211.0/daml-finance-holding-test-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Holding.V4/4.99.0.20251211.0/daml-finance-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Holding.V4/.daml/dist/daml-finance-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Holding.Test/.daml/dist/daml-finance-holding-test-1.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test b/package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test deleted file mode 120000 index 43f590d8d..000000000 --- a/package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/test/daml/Daml/Finance/Account/Test/ \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Account/Test/Account.daml b/package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test/Account.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Account/Test/Account.daml rename to package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test/Account.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Account/Test/Controllers.daml b/package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test/Controllers.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Account/Test/Controllers.daml rename to package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test/Controllers.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Account/Test/Lock.daml b/package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test/Lock.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Account/Test/Lock.daml rename to package/test/daml/Daml.Finance.Account.Test/daml/Daml/Finance/Account/Test/Lock.daml diff --git a/package/test/daml/Daml.Finance.Data.Test/daml.yaml b/package/test/daml/Daml.Finance.Data.Test/daml.yaml index 464912ba8..fbf3bb72a 100644 --- a/package/test/daml/Daml.Finance.Data.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Data.Test/daml.yaml @@ -1,23 +1,24 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-data-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Data.V4/4.99.0.20251211.0/daml-finance-interface-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Data.V4/.daml/dist/daml-finance-interface-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wupgrade-exceptions - -Wno-upgrade-exceptions - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test b/package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test deleted file mode 120000 index 8051ff9f2..000000000 --- a/package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/test/daml/Daml/Finance/Data/Test \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Data/Test/DateClock.daml b/package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test/DateClock.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Data/Test/DateClock.daml rename to package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test/DateClock.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Data/Test/HolidayCalendar.daml b/package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test/HolidayCalendar.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Data/Test/HolidayCalendar.daml rename to package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test/HolidayCalendar.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Data/Test/Observation.daml b/package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test/Observation.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Data/Test/Observation.daml rename to package/test/daml/Daml.Finance.Data.Test/daml/Daml/Finance/Data/Test/Observation.daml diff --git a/package/test/daml/Daml.Finance.Holding.Test/daml.yaml b/package/test/daml/Daml.Finance.Holding.Test/daml.yaml index 6698fe61a..ea4514eac 100644 --- a/package/test/daml/Daml.Finance.Holding.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Holding.Test/daml.yaml @@ -1,23 +1,24 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-holding-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Account.V4/4.99.0.20251211.0/daml-finance-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Holding.V4/4.99.0.20251211.0/daml-finance-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../../../main/daml/Daml.Finance.Account.V4/.daml/dist/daml-finance-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Holding.V4/.daml/dist/daml-finance-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test deleted file mode 120000 index 6dc73b71d..000000000 --- a/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/test/daml/Daml/Finance/Holding/Test \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Common.daml b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Common.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Holding/Test/Common.daml rename to package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Common.daml diff --git a/src/test/daml/Daml/Finance/Holding/Test/Holding.daml b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Holding.daml similarity index 97% rename from src/test/daml/Daml/Finance/Holding/Test/Holding.daml rename to package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Holding.daml index 5f5770e15..0036f0887 100644 --- a/src/test/daml/Daml/Finance/Holding/Test/Holding.daml +++ b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Holding.daml @@ -76,7 +76,7 @@ run = script do newLockers = mempty; context = "Test Lock"; lockType = Lockable.Semaphore -- Lock asset with a one time lock - lockableCid <- submit (actAs [issuer, locker]) do + lockableCid <- submit [issuer, locker] do exerciseCmd (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid) Lockable.Acquire with newLockers = singleton locker; context = "Test Lock"; lockType = Lockable.Semaphore @@ -100,7 +100,7 @@ run = script do exerciseCmd lockableCid Lockable.Release with context = "Test Lock" -- Lock asset with a reentrant lock - lockableCid <- submit (actAs [issuer, locker]) do + lockableCid <- submit [issuer, locker] do exerciseCmd lockableCid Lockable.Acquire with newLockers = singleton locker; context = "Lock 1"; lockType = Lockable.Reentrant @@ -110,7 +110,7 @@ run = script do newLockers = singleton locker; context = "Lock 1"; lockType = Lockable.Reentrant -- Lock asset with a reentrant lock for another context - lockableCid <- submit (actAs [issuer, locker]) do + lockableCid <- submit [issuer, locker] do exerciseCmd lockableCid Lockable.Acquire with newLockers = singleton locker; context = "Lock 2"; lockType = Lockable.Reentrant diff --git a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Transfer.daml b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Transfer.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Holding/Test/Transfer.daml rename to package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Transfer.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Transferable.daml b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Transferable.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Holding/Test/Transferable.daml rename to package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Transferable.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml similarity index 89% rename from docs/generated/src/test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml rename to package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml index fe553ff96..d865583bf 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml +++ b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml @@ -41,26 +41,45 @@ run = script do Account.Owner -- Lock asset - let lockableCid = coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid + let + lockableCid = + coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid lockableCid <- submit [issuer, locker] do exerciseCmd lockableCid Lockable.Acquire with - newLockers = Set.singleton locker; context = "Test Lock"; lockType = Lockable.Semaphore + newLockers = Set.singleton locker + context = "Test Lock" + lockType = Lockable.Semaphore -- Cannot split submitMustFail issuer do - exerciseCmd (fromInterfaceContractId @Fungible.I (coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid)) Fungible.Split with + let holdingCid = + fromInterfaceContractId @Fungible.I + (coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid) + exerciseCmd holdingCid Fungible.Split with amounts = [500.0, 250.0] -- Cannot transfer submitMustFail (actAs [issuer, investor]) do - exerciseCmd (fromInterfaceContractId @Transferable.I (coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid)) - Transferable.Transfer with - actors = Set.fromList [issuer, investor]; newOwnerAccount = investorAccount + let holdingCid = + fromInterfaceContractId @Transferable.I + (coerceInterfaceContractId + @Api.HoldingV1.Holding + @Lockable.I + lockableCid + ) + exerciseCmd holdingCid Transferable.Transfer with + actors = Set.fromList [issuer, investor] + newOwnerAccount = investorAccount -- Cannot debit - Account.submitMustFailExerciseInterfaceByKeyCmd @Account.I [custodian, issuer] [] issuerAccount $ - Account.Debit with holdingCid = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid - + Account.submitMustFailExerciseInterfaceByKeyCmd @Account.I + [custodian, issuer] + [] + issuerAccount + (Account.Debit with + holdingCid = + coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid + ) -- Unlock asset fungibleCid <- fromInterfaceContractId @Fungible.I <$> submit locker do exerciseCmd lockableCid Lockable.Release with context = "Test Lock" @@ -96,7 +115,8 @@ run = script do [fungible1, fungible2, rest] <- forA [splitCid1, splitCid2, restCid] \cid -> do - Some fungible <- queryContractId @TransferableFungible.T issuer $ fromInterfaceContractId cid + Some fungible <- + queryContractId @TransferableFungible.T issuer $ fromInterfaceContractId cid pure $ toInterface @Fungible.I fungible -- Test utility function `verifyAmountPreserving` diff --git a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Upgrade.daml b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Upgrade.daml similarity index 96% rename from docs/generated/src/test/daml/Daml/Finance/Holding/Test/Upgrade.daml rename to package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Upgrade.daml index 6aecbd477..145292b65 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Holding/Test/Upgrade.daml +++ b/package/test/daml/Daml.Finance.Holding.Test/daml/Daml/Finance/Holding/Test/Upgrade.daml @@ -36,25 +36,21 @@ run = do -- 3. Remove old holding factory submitExerciseInterfaceByKeyCmd @HoldingFactory.I [custodian] [] holdingFactory HoldingFactory.Remove - -- 4. Check if the old holding still exists - maybeOldHolding <- queryContractId custodian (fromInterfaceContractId @Transferable.T issuerHoldingCid) - + maybeOldHolding <- + queryContractId custodian (fromInterfaceContractId @Transferable.T issuerHoldingCid) assertMsg "Old transferable holding not found after factory removal (may be expected if factory removal cascades)." (isSome maybeOldHolding) - -- 5. Create the new holding factory createHoldingFactory $ HoldingNew.Factory with provider = custodian; id = Id "Holding Factory"; observers - -- 6. Perform a transfer to self to trigger upgrade newCid <- submit (actAs issuer <> readAs publicParty) do exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) Transferable.Transfer with actors = singleton issuer newOwnerAccount = issuerAccount - -- 7. Inspect the new upgraded holding maybeNew <- queryContractId custodian (fromInterfaceContractId @TransferableNew.T newCid) diff --git a/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml.yaml b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml.yaml index a15e05228..1e39325df 100644 --- a/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml.yaml @@ -1,24 +1,25 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-bond-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Bond.V3/3.99.0.20251211.0/daml-finance-instrument-bond-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Bond.V3/3.99.0.20251211.0/daml-finance-interface-instrument-bond-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Instrument.Bond.V3/.daml/dist/daml-finance-instrument-bond-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Bond.V3/.daml/dist/daml-finance-interface-instrument-bond-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test deleted file mode 120000 index 6563b7da5..000000000 --- a/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/test/daml/Daml/Finance/Instrument/Bond/Test \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml similarity index 93% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml rename to package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml index a617ed6e5..95f6db2dc 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml +++ b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml @@ -5,6 +5,7 @@ module Daml.Finance.Instrument.Bond.Test.Callable where import DA.Date (DayOfWeek(..), Month(..), date, subtractDays) import DA.Map qualified as Map (fromList) +import DA.Optional (fromOptional) import DA.Set (singleton) import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) @@ -23,6 +24,15 @@ import Daml.Finance.Test.Util.Lifecycle (electAndVerifyPaymentEffects, ensureEle import Daml.Finance.Test.Util.Time (createPaymentPeriodicSchedule, createPeriodicSchedule) import Daml.Script +-- | Lifecycle the instrument and verify expected payment effects. +-- Returns the updated instrument, or the original one if nothing changed. +lifecycleAndGet publicParty atDate bondInstrument issuer observableCids expectedConsumed expectedProduced = do + maybeNext <- + lifecycleAndVerifyPaymentEffects [publicParty] atDate + bondInstrument issuer observableCids expectedConsumed expectedProduced + pure $ fromOptional bondInstrument maybeNext + + -- Create and lifecycle a fixed coupon callable bond. run : Script () run = script do @@ -677,15 +687,10 @@ runFloatingFloorCapCallable6M = script do -- Coupon date 1 (not a call date): Lifecycle and verify that there is an effect for one coupon. let expectedConsumed = [] - expectedProduced = [qty 0.0026888889 cashInstrument]; - maybeBondInstrumentAfterCoupon1 <- lifecycleAndVerifyPaymentEffects [publicParty] (date 2022 Apr 15) - bondInstrument issuer [observableCid] expectedConsumed expectedProduced; - - bondInstrumentAfterCoupon1 <- case maybeBondInstrumentAfterCoupon1 of - Some key -> do - pure key - None -> do - pure bondInstrument + expectedProduced = [qty 0.0026888889 cashInstrument] + bondInstrumentAfterCoupon1 <- + lifecycleAndGet publicParty (date 2022 Apr 15) bondInstrument issuer [observableCid] + expectedConsumed expectedProduced -- Call date before Coupon date 2: Lifecycle to get the new instrument. @@ -700,29 +705,18 @@ runFloatingFloorCapCallable6M = script do let expectedConsumed = [] expectedProduced = [qty 0.0037916667 cashInstrument] - maybeBondInstrumentAfterCoupon2 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 15) bondInstrumentAfterCallDate2 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon2 <- case maybeBondInstrumentAfterCoupon2 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCallDate2 + bondInstrumentAfterCoupon2 <- + lifecycleAndGet publicParty (date 2022 Jul 15) bondInstrumentAfterCallDate2 issuer [observableCid] + expectedConsumed expectedProduced -- Coupon date 3 (not a call date): Lifecycle and verify that there are no effects (0% coupon due to floor) let expectedConsumed = [] expectedProduced = [] - maybeBondInstrumentAfterCoupon3 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Oct 17) bondInstrumentAfterCoupon2 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon3 <- case maybeBondInstrumentAfterCoupon3 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCoupon2 - + bondInstrumentAfterCoupon3 <- + lifecycleAndGet publicParty (date 2022 Oct 17) bondInstrumentAfterCoupon2 issuer [observableCid] + expectedConsumed expectedProduced -- Call date before Coupon date 4: Lifecycle to get the new instrument. let @@ -736,14 +730,9 @@ runFloatingFloorCapCallable6M = script do let expectedConsumed = [] expectedProduced = [qty 0.0027805556 cashInstrument] - maybeBondInstrumentAfterCoupon4 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jan 16) bondInstrumentAfterCallDate4 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon4 <- case maybeBondInstrumentAfterCoupon4 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCallDate4 + bondInstrumentAfterCoupon4 <- + lifecycleAndGet publicParty (date 2023 Jan 16) bondInstrumentAfterCallDate4 issuer [observableCid] + expectedConsumed expectedProduced -- 5 business days before coupon date 5 (not a call date): Try to call the bond and verify that -- this is not possible. @@ -758,14 +747,9 @@ runFloatingFloorCapCallable6M = script do let expectedConsumed = [] expectedProduced = [qty 0.0027805556 cashInstrument] - maybeBondInstrumentAfterCoupon5 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Apr 17) bondInstrumentAfterCoupon4 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon5 <- case maybeBondInstrumentAfterCoupon5 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCoupon4 + bondInstrumentAfterCoupon5 <- + lifecycleAndGet publicParty (date 2023 Apr 17) bondInstrumentAfterCoupon4 issuer [observableCid] + expectedConsumed expectedProduced -- Coupon date 6 (call date): Call the bond and get the new instrument. let @@ -779,14 +763,9 @@ runFloatingFloorCapCallable6M = script do let expectedConsumed = [] expectedProduced = [qty 1.0027805556 cashInstrument] - maybeBondInstrumentAfterCoupon6 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jul 17) bondInstrumentAfterCallDate6 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon6 <- case maybeBondInstrumentAfterCoupon6 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCallDate6 + bondInstrumentAfterCoupon6 <- + lifecycleAndGet publicParty (date 2023 Jul 17) bondInstrumentAfterCallDate6 issuer [observableCid] + expectedConsumed expectedProduced pure () @@ -966,14 +945,9 @@ runFixCouponUnadjustedCallable6M = script do let expectedConsumed = [] expectedProduced = [qty 22.5 cashInstrument] - maybeBondInstrumentAfterCoupon1 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 15) bondInstrument issuer [] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon1 <- case maybeBondInstrumentAfterCoupon1 of - Some key -> do - pure key - None -> do - pure bondInstrument + bondInstrumentAfterCoupon1 <- + lifecycleAndGet publicParty (date 2022 Jul 15) bondInstrument issuer [] + expectedConsumed expectedProduced -- Coupon date 2 (call date): Lifecycle and verify that there is an effect for one coupon. let @@ -996,14 +970,9 @@ runFixCouponUnadjustedCallable6M = script do let expectedConsumed = [] expectedProduced = [qty 1022.5 cashInstrument] - maybeBondInstrumentAfterRedemption <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2024 Jan 15) bondInstrumentAfterCoupon3 issuer [] expectedConsumed expectedProduced - - bondInstrumentAfterRedemption <- case maybeBondInstrumentAfterRedemption of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCoupon3 + bondInstrumentAfterRedemption <- + lifecycleAndGet publicParty (date 2024 Jan 15) bondInstrumentAfterCoupon3 issuer [] + expectedConsumed expectedProduced pure () @@ -1108,14 +1077,9 @@ runSofrFloorCapCallable6M = script do let expectedConsumed = [] expectedProduced = [qty 7.5885429 cashInstrument] - maybeBondInstrumentAfterCoupon1 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 15) bondInstrument issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon1 <- case maybeBondInstrumentAfterCoupon1 of - Some key -> do - pure key - None -> do - pure bondInstrument + bondInstrumentAfterCoupon1 <- + lifecycleAndGet publicParty (date 2022 Jul 15) bondInstrument issuer [observableCid] + expectedConsumed expectedProduced -- Coupon date 2 (call date): Lifecycle and verify that there is an effect for one coupon. let diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/FixedRate.daml b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/FixedRate.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/FixedRate.daml rename to package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/FixedRate.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml similarity index 99% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml rename to package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml index 8592801bc..48dc25bd1 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml +++ b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml @@ -233,7 +233,6 @@ runSofr = script do None -> do pure bondInstrument - -- Coupon date 2: Lifecycle and verify that there is an effect for one coupon. let expectedConsumed = [] @@ -254,5 +253,4 @@ runSofr = script do None -> do pure bondInstrumentAfterFirstCoupon - pure () diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/InflationLinked.daml b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/InflationLinked.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/InflationLinked.daml rename to package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/InflationLinked.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/Util.daml b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/Util.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/Util.daml rename to package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/Util.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/ZeroCoupon.daml b/package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/ZeroCoupon.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Bond/Test/ZeroCoupon.daml rename to package/test/daml/Daml.Finance.Instrument.Bond.Test/daml/Daml/Finance/Instrument/Bond/Test/ZeroCoupon.daml diff --git a/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml.yaml b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml.yaml index bd674ed15..6ad810ea1 100644 --- a/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml.yaml @@ -1,27 +1,28 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-equity-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Holding.V4/4.99.0.20251211.0/daml-finance-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Equity.V0/0.99.0.20251211.0/daml-finance-instrument-equity-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Option.Test/0.99.0.20251211.0/daml-finance-instrument-option-test-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Equity.V0/0.99.0.20251211.0/daml-finance-interface-instrument-equity-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Option.V0/0.99.0.20251211.0/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Settlement.V4/4.99.0.20251211.0/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Settlement.V4/4.99.0.20251211.0/daml-finance-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Holding.V4/.daml/dist/daml-finance-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Instrument.Equity.V0/.daml/dist/daml-finance-instrument-equity-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Equity.V0/.daml/dist/daml-finance-interface-instrument-equity-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Option.V0/.daml/dist/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Settlement.V4/.daml/dist/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Settlement.V4/.daml/dist/daml-finance-settlement-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Instrument.Option.Test/.daml/dist/daml-finance-instrument-option-test-1.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test deleted file mode 120000 index 270a77d97..000000000 --- a/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/test/daml/Daml/Finance/Instrument/Equity/Test \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/DivOption.daml b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/DivOption.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/DivOption.daml rename to package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/DivOption.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/Dividend.daml b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/Dividend.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/Dividend.daml rename to package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/Dividend.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/Merger.daml b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/Merger.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/Merger.daml rename to package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/Merger.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/RightsIssue.daml b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/RightsIssue.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/RightsIssue.daml rename to package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/RightsIssue.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml similarity index 95% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml rename to package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml index cba83a65c..255d45444 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml +++ b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml @@ -25,10 +25,6 @@ import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) import Daml.Script --- import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I) --- import Daml.Finance.Interface.Types.Common.V3.Types (Quantity(..)) --- import Daml.Finance.Lifecycle.V4.Event.Replacement as ReplacementEvent - -- Stock split lifecycling and settlement run : Script () run = script do @@ -41,7 +37,10 @@ run = script do -- Create holding factory holdingFactory <- createHoldingFactory - Holding.Factory with provider = issuer; id = Id "Holding Factory"; observers = Map.fromList pp + Holding.Factory with + provider = issuer + id = Id "Holding Factory" + observers = Map.fromList pp -- Create accounts investorSecuritiesAccount <- Account.createAccount "Securities Account" [] accountFactoryCid diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/Util.daml b/package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/Util.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Equity/Test/Util.daml rename to package/test/daml/Daml.Finance.Instrument.Equity.Test/daml/Daml/Finance/Instrument/Equity/Test/Util.daml diff --git a/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml.yaml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml.yaml index 0240617f2..c3913df95 100644 --- a/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml.yaml @@ -1,34 +1,35 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-generic-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/ContingentClaims.Core.V3/3.99.0.20251211.0/contingent-claims-core-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Holding.V4/4.99.0.20251211.0/daml-finance-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Generic.V4/4.99.0.20251211.0/daml-finance-instrument-generic-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Claims.V4/4.99.0.20251211.0/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Generic.V4/4.99.0.20251211.0/daml-finance-interface-instrument-generic-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Settlement.V4/4.99.0.20251211.0/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Settlement.V4/4.99.0.20251211.0/daml-finance-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../../../main/daml/ContingentClaims.Core.V3/.daml/dist/contingent-claims-core-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Holding.V4/.daml/dist/daml-finance-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Instrument.Generic.V4/.daml/dist/daml-finance-instrument-generic-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Claims.V4/.daml/dist/daml-finance-interface-claims-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Generic.V4/.daml/dist/daml-finance-interface-instrument-generic-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Settlement.V4/.daml/dist/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Settlement.V4/.daml/dist/daml-finance-settlement-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test deleted file mode 120000 index 36d71492f..000000000 --- a/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/test/daml/Daml/Finance/Instrument/Generic/Test/ \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/CallableBond.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/CallableBond.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/CallableBond.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/CallableBond.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/Election/Workflow.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/Election/Workflow.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/Election/Workflow.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/Election/Workflow.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/EuropeanOption.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/EuropeanOption.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/EuropeanOption.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/EuropeanOption.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardCash.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/ForwardCash.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardCash.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/ForwardCash.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardPhysical.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/ForwardPhysical.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardPhysical.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/ForwardPhysical.daml diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml similarity index 92% rename from src/test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml index e8621d0fb..46d6738ac 100644 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml +++ b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/Intermediated/BondCoupon.daml @@ -195,7 +195,6 @@ runIntermediatedLifecyclingNonAtomic = script do let firstCouponDate = addDays (toDateUTC now) 90 clockEventCid <- createClockUpdateEvent (Set.singleton issuer) firstCouponDate mempty -- Important: need to replace "today" by firstCouponDate when we use Sandbox! - -- CREATE_CLOCK_FOR_BOND_LIFECYCLING_END -- LIFECYCLE_BOND_CREATE_RULE_BEGIN @@ -236,8 +235,7 @@ runIntermediatedLifecyclingNonAtomic = script do -- Issuer. Account.submitExerciseInterfaceByKeyCmd @Disclosure.I [csd] [] csdCashAccount Disclosure.AddObservers with - disclosers = Set.singleton csd - observersToAdd = ("Issuer", Set.singleton issuer) + disclosers = Set.singleton csd; observersToAdd = ("Issuer", Set.singleton issuer) settle1Cid <- submit [csd, issuer] do createCmd EffectSettlementService with @@ -252,31 +250,29 @@ runIntermediatedLifecyclingNonAtomic = script do -- CSD claims and settles effect against issuer (effectCid, newInstrumentHoldingCid, _) <- submit (actAs issuer <> readAs publicParty) do exerciseCmd settle1Cid ClaimAndSettle with - instrumentHoldingCid = csdBondHoldingCid - cashHoldingCid = issuerCashHoldingCid - effectCid + instrumentHoldingCid = csdBondHoldingCid; cashHoldingCid = issuerCashHoldingCid; effectCid -- LIFECYCLE_BOND_ISSUER_CSD_END -- Find correct USD holding of CSD after ClaimAndSettle holdings <- queryInterface @Api.HoldingV1.Holding csd - let cashHolding = - case [ cid - | (cid, Some v) <- holdings - , v.owner == csd - , v.instrumentId.admin == centralBank - , v.instrumentId.id == "USD" - ] of - cid :: _ -> cid - [] -> error "No USD cash holding found for CSD after ClaimAndSettle" + let + cashHolding = + case + [ cid + | (cid, Some v) <- holdings + , v.owner == csd + , v.instrumentId.admin == centralBank + , v.instrumentId.id == "USD" + ] of + cid :: _ -> cid + [] -> error "No USD cash holding found for CSD after ClaimAndSettle" -- LIFECYCLE_BOND_SETTLEMENT_FACTORY_BEGIN -- investor claims effect against CSD routeProviderCid <- toInterfaceContractId <$> submit csd do createCmd IntermediatedStatic with - provider = csd - observers = Set.singleton investor - paths = routes + provider = csd; observers = Set.singleton investor; paths = routes settlementFactoryCid <- submit csd do toInterfaceContractId <$> createCmd Factory with @@ -309,23 +305,16 @@ runIntermediatedLifecyclingNonAtomic = script do -- Allocate instructions (investorBondInstructionCid, _) <- submit investor do exerciseCmd investorBondInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = SettlementTypes.Pledge investorBondHoldingCid - + actors = Set.singleton investor; allocation = SettlementTypes.Pledge investorBondHoldingCid (csdBondInstructionCid, _) <- submit csd do exerciseCmd csdBondInstructionCid Instruction.Allocate with - actors = Set.singleton csd - allocation = SettlementTypes.CreditReceiver - + actors = Set.singleton csd; allocation = SettlementTypes.CreditReceiver (csdCashInstructionCid, _) <- submit csd do exerciseCmd csdCashInstructionCid Instruction.Allocate with - actors = Set.singleton csd - allocation = SettlementTypes.Pledge cashHolding - + actors = Set.singleton csd; allocation = SettlementTypes.Pledge cashHolding (bankCashInstructionCid, _) <- submit bank do exerciseCmd bankCashInstructionCid Instruction.Allocate with - actors = Set.singleton bank - allocation = SettlementTypes.CreditReceiver + actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver -- Approve instructions investorBondInstructionCid <- submit csd do @@ -401,9 +390,7 @@ runIntermediatedLifecyclingAtomic = script do -- Try to lifecycle the instrument (resultInstrument, effectCids) <- submit issuer do exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids = [] - instrument = bondInstrument + eventCid = clockEventCid; observableCids = []; instrument = bondInstrument let effectCid = @@ -446,7 +433,6 @@ runIntermediatedLifecyclingAtomic = script do [ issuerCashInstructionCid -- coupon payment from issuer to CSD , csdCashInstructionCid -- coupon payment from CSD to investor's bank , bankCashInstructionCid -- coupon payment from investor's bank to investor - , csdBondInstructionCid1 -- old bond from CSD to issuer , issuerBondInstructionCid -- new bond from issuer to CSD , investorBondInstructionCid -- old bond from investor to CSD @@ -475,28 +461,22 @@ runIntermediatedLifecyclingAtomic = script do (csdBondInstructionCid1, _) <- submit csd do exerciseCmd csdBondInstructionCid1 Instruction.Allocate with actors = Set.singleton csd; allocation = SettlementTypes.Pledge csdBondHoldingCid - (issuerBondInstructionCid, _) <- submit issuer do exerciseCmd issuerBondInstructionCid Instruction.Allocate with actors = Set.singleton issuer; allocation = SettlementTypes.CreditReceiver - (issuerCashInstructionCid, _) <- submit issuer do exerciseCmd issuerCashInstructionCid Instruction.Allocate with actors = Set.singleton issuer; allocation = SettlementTypes.Pledge issuerCashHoldingCid - (investorBondInstructionCid, _) <- submit investor do exerciseCmd investorBondInstructionCid Instruction.Allocate with actors = Set.singleton investor; allocation = SettlementTypes.Pledge investorBondHoldingCid - (csdBondInstructionCid2, _) <- submit csd do exerciseCmd csdBondInstructionCid2 Instruction.Allocate with actors = Set.singleton csd; allocation = SettlementTypes.CreditReceiver - (csdCashInstructionCid, _) <- submit csd do exerciseCmd csdCashInstructionCid Instruction.Allocate with actors = Set.singleton csd allocation = SettlementTypes.PassThroughFrom (csdCashAccount, issuerCashInstructionKey) - (bankCashInstructionCid, _) <- submit bank do exerciseCmd bankCashInstructionCid Instruction.Allocate with actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver @@ -618,7 +598,6 @@ template EffectSettlementService effectCid batchId = Id "EffectSettlement" - archive settlementFactoryCid archive lifecycleClaimRuleCid @@ -630,13 +609,12 @@ template EffectSettlementService instrs <- mapA getUnitCid result.instructionCids let - issuerInstrs = [cid | (cid, admin) <- instrs, admin == issuer] - cashInstrs = [cid | (cid, admin) <- instrs, admin == issuerCashAccount.custodian] - - let - csdInstrumentInstructionCid = head issuerInstrs - issuerInstrumentInstructionCid = issuerInstrs !! 1 - issuerCashInstructionCouponCid = head cashInstrs + issuerInstrs = [cid | (cid, admin) <- instrs, admin == issuer] + cashInstrs = [cid | (cid, admin) <- instrs, admin == issuerCashAccount.custodian] + + csdInstrumentInstructionCid = head issuerInstrs + issuerInstrumentInstructionCid = issuerInstrs !! 1 + issuerCashInstructionCouponCid = head cashInstrs csdInstrumentInstruction <- fetch csdInstrumentInstructionCid issuerInstrumentInstruction <- fetch issuerInstrumentInstructionCid @@ -644,35 +622,24 @@ template EffectSettlementService -- Allocate instructions (csdInstrumentInstructionCid, _) <- exercise csdInstrumentInstructionCid - Instruction.Allocate with - actors = Set.singleton csd - allocation = SettlementTypes.Pledge instrumentHoldingCid - + Instruction.Allocate with actors = Set.singleton csd; allocation = SettlementTypes.Pledge instrumentHoldingCid (issuerCashInstructionCouponCid, _) <- exercise issuerCashInstructionCouponCid Instruction.Allocate with - actors = Set.singleton issuer - allocation = SettlementTypes.Pledge cashHoldingCid - + actors = Set.singleton issuer; allocation = SettlementTypes.Pledge cashHoldingCid (issuerInstrumentInstructionCid, _) <- exercise issuerInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton issuer - allocation = SettlementTypes.CreditReceiver + actors = Set.singleton issuer; allocation = SettlementTypes.CreditReceiver -- Approve instructions csdInstrumentInstructionCid <- exercise csdInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton issuer - approval = SettlementTypes.DebitSender - + actors = Set.singleton issuer; approval = SettlementTypes.DebitSender issuerCashInstructionCouponCid <- exercise issuerCashInstructionCouponCid Instruction.Approve with - actors = Set.singleton csd - approval = SettlementTypes.TakeDelivery csdCashAccount - + actors = Set.singleton csd; approval = SettlementTypes.TakeDelivery csdCashAccount issuerInstrumentInstructionCid <- exercise issuerInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton csd - approval = SettlementTypes.TakeDelivery securitiesAccount + actors = Set.singleton csd; approval = SettlementTypes.TakeDelivery securitiesAccount -- Settle batch [newInstrumentHoldingCid, investorCashHoldingCouponCid] <- diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml similarity index 95% rename from src/test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml index 5f0535f3f..45e143855 100644 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml +++ b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/ReverseConvertible.daml @@ -118,7 +118,6 @@ run = script do genericInstrument <- originateGeneric bank broker "RC-EURGBP" TransferableFungible "Reverse Convertible" acqTime claims [("PublicParty", Set.singleton publicParty)] acqTime - investorGenericHoldingCid <- Account.credit [publicParty] genericInstrument 1_000.0 investorAccount @@ -158,12 +157,10 @@ run = script do -- Use the evolved instrument key if provided, otherwise keep the original let finalInstrument = fromOptional genericInstrument maybeFinalKey - -- Expect at least one lifecycle effect; take the first effectCid <- case effectCids of cid :: _ -> pure cid [] -> abort "Lifecycle.Evolve returned no effects; cannot proceed" - -- Create route provider routeProviderCid <- toInterfaceContractId <$> submit investor do @@ -198,24 +195,19 @@ run = script do -- Allocate instructions (investorInstrumentInstructionCid, _) <- submit investor do exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = SettlementTypes.Pledge investorGenericHoldingCid - + actors = Set.singleton investor; allocation = SettlementTypes.Pledge investorGenericHoldingCid (bankEquityInstructionCid, _) <- submit bank do exerciseCmd bankEquityInstructionCid Instruction.Allocate with - actors = Set.singleton bank - allocation = SettlementTypes.CreditReceiver + actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver -- Approve instructions investorInstrumentInstructionCid <- submit bank do exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank - approval = SettlementTypes.DebitSender + actors = Set.singleton bank; approval = SettlementTypes.DebitSender bankEquityInstructionCid <- submit investor do exerciseCmd bankEquityInstructionCid Instruction.Approve with - actors = Set.singleton investor - approval = SettlementTypes.TakeDelivery investorAccount + actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorAccount -- Settle batch [investorCashHoldingCid : ContractId Api.HoldingV1.Holding] <- submit (actAs settlers <> readAs publicParty) do diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/Util.daml b/package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/Util.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Generic/Test/Util.daml rename to package/test/daml/Daml.Finance.Instrument.Generic.Test/daml/Daml/Finance/Instrument/Generic/Test/Util.daml diff --git a/package/test/daml/Daml.Finance.Instrument.Option.Test/daml.yaml b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml.yaml index b65b50cbe..596dd2a2f 100644 --- a/package/test/daml/Daml.Finance.Instrument.Option.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml.yaml @@ -1,23 +1,24 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-option-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Option.V0/0.99.0.20251211.0/daml-finance-instrument-option-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Option.V0/0.99.0.20251211.0/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Instrument.Option.V0/.daml/dist/daml-finance-instrument-option-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Option.V0/.daml/dist/daml-finance-interface-instrument-option-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test deleted file mode 120000 index f840cb0fc..000000000 --- a/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/test/daml/Daml/Finance/Instrument/Option/Test \ No newline at end of file diff --git a/src/test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml similarity index 99% rename from src/test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml rename to package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml index 98a637ac3..cdfd846b4 100644 --- a/src/test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml +++ b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/BarrierEuropeanCash.daml @@ -278,5 +278,4 @@ run = script do verifyNoLifecycleEffects [publicParty] (date 2019 May 21) optionInstrumentAfterBarrierHit issuer [observableCid] - pure () diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/Dividend.daml b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/Dividend.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/Dividend.daml rename to package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/Dividend.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanCash.daml b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/EuropeanCash.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanCash.daml rename to package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/EuropeanCash.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanPhysical.daml b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/EuropeanPhysical.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanPhysical.daml rename to package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/EuropeanPhysical.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/Util.daml b/package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/Util.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Option/Test/Util.daml rename to package/test/daml/Daml.Finance.Instrument.Option.Test/daml/Daml/Finance/Instrument/Option/Test/Util.daml diff --git a/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml.yaml b/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml.yaml index 0b6600db6..31b2a9047 100644 --- a/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml.yaml @@ -1,22 +1,23 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-structuredproduct-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.StructuredProduct.V0/0.99.0.20251211.0/daml-finance-instrument-structuredproduct-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.StructuredProduct.V0/0.99.0.20251211.0/daml-finance-interface-instrument-structuredproduct-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Instrument.StructuredProduct.V0/.daml/dist/daml-finance-instrument-structuredproduct-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.StructuredProduct.V0/.daml/dist/daml-finance-interface-instrument-structuredproduct-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test b/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test deleted file mode 120000 index 39bd277bc..000000000 --- a/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/AutoCallable.daml b/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test/AutoCallable.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/AutoCallable.daml rename to package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test/AutoCallable.daml diff --git a/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml b/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml similarity index 84% rename from src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml rename to package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml index fc3e7701f..04af83abb 100644 --- a/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml +++ b/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test/BarrierReverseConvertible.daml @@ -4,8 +4,8 @@ module Daml.Finance.Instrument.StructuredProduct.Test.BarrierReverseConvertible where import DA.Date (DayOfWeek(..), Month(..), date) -import DA.Time () import DA.Map qualified as Map (fromList) +import DA.Optional (fromOptional) import DA.Set qualified as Set (singleton) import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) @@ -108,9 +108,8 @@ run = script do (date 2019 Feb 13) brcInstrument issuer [observableCid] expectedConsumed expectedProduced - brcInstrumentAfterBarrierHit <- case maybeBrcInstrumentAfterBarrierHit of - Some key -> pure key - None -> pure brcInstrument + brcInstrumentAfterBarrierHit <- + pure $ fromOptional brcInstrument maybeBrcInstrumentAfterBarrierHit -- First coupon date: Lifecycle and verify coupon payment. let @@ -122,25 +121,21 @@ run = script do firstCouponDate brcInstrumentAfterBarrierHit issuer [observableCid] expectedConsumed expectedProduced - brcInstrumentAfterCouponPayment <- case maybeBrcInstrumentAfterCouponPayment of - Some key -> pure key - None -> pure brcInstrumentAfterBarrierHit + brcInstrumentAfterCouponPayment <- + pure $ fromOptional brcInstrumentAfterBarrierHit maybeBrcInstrumentAfterCouponPayment -- Expiry date: Lifecycle and verify redemption and final payments. let expectedConsumed = [qty 0.0305 cashInstrument] - expectedProduced = - [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] + expectedProduced = [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] maybeBrcInstrumentAfterExpiry <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate brcInstrumentAfterCouponPayment issuer [observableCid] expectedConsumed expectedProduced - case maybeBrcInstrumentAfterExpiry of - Some key -> pure key - None -> pure brcInstrumentAfterCouponPayment - + brcInstrumentAfterExpiry <- + pure $ fromOptional brcInstrumentAfterCouponPayment maybeBrcInstrumentAfterExpiry -- Test option with barrier hit (on Feb 13). Option expires out of the money. brcLowStrikeInstrument <- originateBarrierReverseConvertible issuer issuer "BRCLowStrike" @@ -158,9 +153,8 @@ run = script do (date 2019 Feb 13) brcLowStrikeInstrument issuer [observableCid] expectedConsumed expectedProduced - brcLowStrikeAfterBarrierHit <- case maybeBrcLowStrikeAfterBarrierHit of - Some key -> pure key - None -> pure brcLowStrikeInstrument + brcLowStrikeAfterBarrierHit <- + pure $ fromOptional brcLowStrikeInstrument maybeBrcLowStrikeAfterBarrierHit -- First coupon date for low-strike BRC let @@ -172,24 +166,21 @@ run = script do firstCouponDate brcLowStrikeAfterBarrierHit issuer [observableCid] expectedConsumed expectedProduced - brcLowStrikeAfterCouponPayment <- case maybeBrcLowStrikeAfterCouponPayment of - Some key -> pure key - None -> pure brcLowStrikeAfterBarrierHit + brcLowStrikeAfterCouponPayment <- + pure $ fromOptional brcLowStrikeAfterBarrierHit maybeBrcLowStrikeAfterCouponPayment -- Expiry date for low-strike BRC let expectedConsumed = [] - expectedProduced = - [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] + expectedProduced = [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] maybeBrcLowStrikeAfterExpiry <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate brcLowStrikeAfterCouponPayment issuer [observableCid] expectedConsumed expectedProduced - case maybeBrcLowStrikeAfterExpiry of - Some key -> pure key - None -> pure brcLowStrikeAfterCouponPayment + brcLowStrikeAfterExpiry <- + pure $ fromOptional brcLowStrikeAfterCouponPayment maybeBrcLowStrikeAfterExpiry -------------------------------------------------- -- 2. BRC without barrier event (before expiry) -- @@ -214,24 +205,21 @@ run = script do firstCouponDate brcLowBarrierInstrument issuer [observableCid] expectedConsumed expectedProduced - brcInstrumentAfterCouponPayment <- case maybeBrcInstrumentAfterCouponPayment of - Some key -> pure key - None -> pure brcLowBarrierInstrument + brcInstrumentAfterCouponPayment <- + pure $ fromOptional brcLowBarrierInstrument maybeBrcInstrumentAfterCouponPayment -- Expiry date: Lifecycle and verify redemption and final payments. let expectedConsumed = [] - expectedProduced = - [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] + expectedProduced = [qty 0.0123611111 cashInstrument, qty 1.0 cashInstrument] maybeBrcInstrumentAfterExpiry <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate brcInstrumentAfterCouponPayment issuer [observableCid] expectedConsumed expectedProduced - - brcInstrumentAfterExpiry <- case maybeBrcInstrumentAfterExpiry of - Some key -> pure key - None -> pure brcInstrumentAfterCouponPayment + + brcInstrumentAfterExpiry <- + pure $ fromOptional brcInstrumentAfterCouponPayment maybeBrcInstrumentAfterExpiry -- Post-expiry date (May 16): Lifecycle and verify no further effects. let @@ -243,9 +231,8 @@ run = script do (date 2019 May 16) brcInstrumentAfterExpiry issuer [observableCid] expectedConsumed expectedProduced - brcAfterPostExpiry <- case maybeBrcAfterPostExpiry of - Some key -> pure key - None -> pure brcInstrumentAfterExpiry + brcAfterPostExpiry <- + pure $ fromOptional brcInstrumentAfterExpiry maybeBrcAfterPostExpiry -- One more day: must still be no effects. verifyNoLifecycleEffects [publicParty] (date 2019 May 17) brcAfterPostExpiry diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/Util.daml b/package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test/Util.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/Util.daml rename to package/test/daml/Daml.Finance.Instrument.StructuredProduct.Test/daml/Daml/Finance/Instrument/StructuredProduct/Test/Util.daml diff --git a/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml.yaml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml.yaml index c7dbdff84..173cb5a2a 100644 --- a/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml.yaml @@ -1,26 +1,27 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-instrument-swap-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Equity.Test/0.99.0.20251211.0/daml-finance-instrument-equity-test-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Swap.V0/0.99.0.20251211.0/daml-finance-instrument-swap-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Equity.V0/0.99.0.20251211.0/daml-finance-interface-instrument-equity-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Swap.V0/0.99.0.20251211.0/daml-finance-interface-instrument-swap-v0-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Types.V2/2.99.0.20251211.0/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Instrument.Swap.V0/.daml/dist/daml-finance-instrument-swap-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Equity.V0/.daml/dist/daml-finance-interface-instrument-equity-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Swap.V0/.daml/dist/daml-finance-interface-instrument-swap-v0-0.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Types.V2/.daml/dist/daml-finance-interface-instrument-types-v2-2.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../Daml.Finance.Instrument.Equity.Test/.daml/dist/daml-finance-instrument-equity-test-1.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test deleted file mode 120000 index b0ad5b82a..000000000 --- a/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../../src/test/daml/Daml/Finance/Instrument/Swap/Test \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Asset.daml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Asset.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Asset.daml rename to package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Asset.daml diff --git a/src/test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml similarity index 96% rename from src/test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml rename to package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml index 14f01f20b..009ded7ed 100644 --- a/src/test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml +++ b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/CreditDefault.daml @@ -227,12 +227,12 @@ runNoCreditEvent = script do let defaultProbabilityObservations = Map.fromList [ (dateToDateClockTime $ subtractDays firstPaymentDate 1, 0.2) - , (dateToDateClockTime firstPaymentDate , 0.2) - , (dateToDateClockTime $ addDays firstPaymentDate 1 , 0.2) - , (dateToDateClockTime maturityDate , 0.2) - , (dateToDateClockTime $ addDays maturityDate 1 , 0.2) - , (dateToDateClockTime maturityDate , 0.2) - , (dateToDateClockTime $ date 2025 Oct 09 , 0.2) + , (dateToDateClockTime firstPaymentDate, 0.2) + , (dateToDateClockTime $ addDays firstPaymentDate 1, 0.2) + , (dateToDateClockTime maturityDate, 0.2) + , (dateToDateClockTime $ addDays maturityDate 1, 0.2) + , (dateToDateClockTime maturityDate, 0.2) + , (dateToDateClockTime $ date 2025 Oct 09, 0.2) , (now, 0.2) ] @@ -307,8 +307,8 @@ runCreditEventAfterMaturity = script do [ (dateToDateClockTime firstPaymentDate, 0.2) , (dateToDateClockTime maturityDate, 0.2) , (dateToDateClockTime $ addDays maturityDate 1, 1.0) -- credit event - , (dateToDateClockTime maturityDate , 0.2) - , (dateToDateClockTime $ date 2025 Oct 09 , 0.2) + , (dateToDateClockTime maturityDate, 0.2) + , (dateToDateClockTime $ date 2025 Oct 09, 0.2) , (now, 0.2) ] diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Currency.daml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Currency.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Currency.daml rename to package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Currency.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/ForeignExchange.daml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/ForeignExchange.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/ForeignExchange.daml rename to package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/ForeignExchange.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml similarity index 99% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml rename to package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml index 056e2774a..24f1f516b 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml +++ b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml @@ -1257,7 +1257,6 @@ runCurrencySwapSampleTrade = script do swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - let settlers = singleton custodian -- Lifecycle and verify initial exchange of principal let @@ -1597,7 +1596,6 @@ runAmortizingNotionalSampleTrade = script do swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - let settlers = singleton custodian -- First payment date: Lifecycle and verify the fix and floating payments (stub period). let @@ -1611,7 +1609,6 @@ runAmortizingNotionalSampleTrade = script do Some key -> pure key None -> pure swapInstrument - -- Second payment date: Lifecycle and verify the floating payment (regular period, 3M). let expectedConsumed = [qty 11500.0002 cashInstrument] @@ -1624,7 +1621,6 @@ runAmortizingNotionalSampleTrade = script do Some key -> pure key None -> pure swapInstrumentAfterFirstPayment - -- Third payment date: Lifecycle and verify the fix and floating payments (regular period, 3M float vs 6M fix). let expectedConsumed = [qty 11250.0 cashInstrument] @@ -2110,7 +2106,6 @@ runFpml2 = script do Some key -> pure key None -> pure swapInstrument - -- Second payment date: Lifecycle and verify the fix and floating payments -- (regular 6M float period, short stub fix period). let @@ -2124,7 +2119,6 @@ runFpml2 = script do Some key -> pure key None -> pure swapInstrumentAfterFirstPayment - -- Third payment date: Lifecycle and verify the floating payment -- (regular 6M period, amortized notional). let @@ -2138,7 +2132,6 @@ runFpml2 = script do Some key -> pure key None -> pure swapInstrumentAfterSecondPayment - -- Fourth payment date: Lifecycle and verify the fix and floating payments -- (regular periods: 6M float / 1Y fix, amortized notional). let @@ -2381,7 +2374,6 @@ runFpml3 = script do Some key -> pure key None -> pure swapInstrument - -- Second payment date: Lifecycle and verify the fix and floating payments (regular 6M period) let expectedConsumed = [qty 2925000.0 cashInstrument] @@ -3100,12 +3092,10 @@ runFpml4 = script do -- A reference data provider publishes the holiday calendars on the ledger calendarCid <- submit calendarDataProvider do createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers + provider = calendarDataProvider; calendar; observers = Map.fromList observers fixingCalendarCid <- submit calendarDataProvider do createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers + provider = calendarDataProvider; calendar = fixingCal; observers = Map.fromList observers observableCid <- toInterfaceContractId <$> submit issuer do createCmd Observation with @@ -3129,7 +3119,6 @@ runFpml4 = script do Some key -> pure key None -> pure swapInstrument - -- Second payment date: Lifecycle and verify the fix (6M) and floating payments (3M) let expectedConsumed = [qty 3000000.0 cashInstrument] @@ -3144,7 +3133,6 @@ runFpml4 = script do Some key -> pure key None -> pure swapInstrumentAfterFirstPayment - -- Third payment date: Lifecycle and verify a floating payment (regular 3M period) let expectedConsumed = [] @@ -3159,7 +3147,6 @@ runFpml4 = script do Some key -> pure key None -> pure swapInstrumentAfterSecondPayment - -- Fourth payment date: Lifecycle and verify the fix (6M) and floating payments (3M) let expectedConsumed = [qty 3000000.0 cashInstrument] @@ -3174,7 +3161,6 @@ runFpml4 = script do Some key -> pure key None -> pure swapInstrumentAfterThirdPayment - -- Fifth payment date: Lifecycle and verify a floating payment (regular 3M period) let expectedConsumed = [] @@ -3189,7 +3175,6 @@ runFpml4 = script do Some key -> pure key None -> pure swapInstrumentAfterFourthPayment - -- Sixth payment date: Lifecycle and verify the fix (6M) and floating payments (3M) -- The fix rate is now higher, as configured in the step-up FpML element let @@ -3244,7 +3229,6 @@ runFpml4a = script do , (dateToDateClockTime $ date 2020 Nov 13, 1.03745) , (dateToDateClockTime $ date 2020 Nov 16, 1.03845) ] - primaryBusinessCenters = ["USNY"] calendar = HolidayCalendarData with @@ -3257,7 +3241,6 @@ runFpml4a = script do id = "USGS" weekend = [Saturday, Sunday] holidays = [] - issuerPartyRef = "partyB" clientPartyRef = "partyA" @@ -3403,12 +3386,10 @@ runFpml4a = script do -- A reference data provider publishes the holiday calendars on the ledger calendarCid <- submit calendarDataProvider do createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers + provider = calendarDataProvider; calendar; observers = Map.fromList observers fixingCalendarCid <- submit calendarDataProvider do createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers + provider = calendarDataProvider; calendar = fixingCal; observers = Map.fromList observers observableCid <- toInterfaceContractId <$> submit issuer do createCmd Observation with @@ -3432,7 +3413,6 @@ runFpml4a = script do Some key -> pure key None -> pure swapInstrument - -- Second payment date: Lifecycle and verify the fix (6M) and floating payments (3M) let expectedConsumed = [qty 562105.5546 cashInstrument] @@ -3447,7 +3427,6 @@ runFpml4a = script do Some key -> pure key None -> pure swapInstrumentAfterFirstPayment - -- Third payment date: Lifecycle and verify a floating payment (regular 3M period) let expectedConsumed = [] @@ -3956,7 +3935,6 @@ runFpml6 = script do swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - let settlers = singleton custodian -- Issue date: Lifecycle initial exchange of principal let diff --git a/src/test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml similarity index 94% rename from src/test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml rename to package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml index 3241d72f2..faa7937f2 100644 --- a/src/test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml +++ b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/InterestRate.daml @@ -72,9 +72,7 @@ run = script do -- A reference data provider publishes the holiday calendar on the ledger calendarCid <- submit calendarDataProvider do createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers + provider = calendarDataProvider; calendar; observers = Map.fromList observers observableCid <- toInterfaceContractId <$> submit issuer do createCmd Observation with @@ -94,14 +92,8 @@ run = script do let expectedConsumed = [qty 0.001675 cashInstrument] expectedProduced = [qty 0.0002283833 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects - [publicParty] - firstPaymentDate - swapInstrument - issuer - [observableCid] - expectedConsumed - expectedProduced + maybeSwapInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] + firstPaymentDate swapInstrument issuer [observableCid] expectedConsumed expectedProduced swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of Some key -> pure key @@ -208,15 +200,8 @@ runSofr = script do let expectedConsumed = [qty 0.001675 cashInstrument] expectedProduced = [qty 0.0025885429 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects - [publicParty] - firstPaymentDate - swapInstrument - issuer - [observableCid] - expectedConsumed - expectedProduced + maybeSwapInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects + [publicParty] firstPaymentDate swapInstrument issuer [observableCid] expectedConsumed expectedProduced swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of Some key -> pure key @@ -236,8 +221,7 @@ runSofr = script do let expectedConsumed = [qty 0.0049691667 cashInstrument] expectedProduced = [qty 0.0156471718 cashInstrument] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects + maybeSwapInstrumentAfterSecondPayment <- lifecycleAndVerifyPaymentEffects [publicParty] maturityDate swapInstrumentAfterFirstPayment diff --git a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml similarity index 94% rename from docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml rename to package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml index fbd167de8..d9b117861 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml +++ b/package/test/daml/Daml.Finance.Instrument.Swap.Test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml @@ -92,11 +92,7 @@ originateFpmlSwap depository issuer label holdingStandard description observers -- CREATE_FPML_SWAP_INSTRUMENT_BEGIN let instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard + issuer; depository; id = Id label; version = "0"; holdingStandard cid <- submit (actAs issuer <> readAs publicParty) do exerciseCmd fpmlSwapFactoryCid FpmlSwapFactory.Create with @@ -129,17 +125,12 @@ originateAssetSwap depository issuer label holdingStandard description observers -- Create an asset swap factory assetSwapFactoryCid <- toInterfaceContractId @AssetSwapFactory.I <$> submit issuer do createCmd AssetSwap.Factory with - provider = issuer - observers = mempty + provider = issuer; observers = mempty -- CREATE_ASSET_SWAP_INSTRUMENT_BEGIN let instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard + issuer; depository; id = Id label; version = "0"; holdingStandard cid <- submit (actAs issuer <> readAs publicParty) do exerciseCmd assetSwapFactoryCid AssetSwapFactory.Create with @@ -177,17 +168,12 @@ originateCreditDefaultSwap depository issuer label holdingStandard description creditDefaultSwapFactoryCid <- toInterfaceContractId @CreditDefaultSwapFactory.I <$> submit issuer do createCmd CreditDefaultSwap.Factory with - provider = issuer - observers = mempty + provider = issuer; observers = mempty -- CREATE_CREDIT_DEFAULT_SWAP_INSTRUMENT_BEGIN let instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard + issuer; depository; id = Id label; version = "0"; holdingStandard cid <- submit (actAs issuer <> readAs publicParty) do exerciseCmd creditDefaultSwapFactoryCid CreditDefaultSwapFactory.Create with @@ -224,17 +210,12 @@ originateCurrencySwap depository issuer label holdingStandard description observ -- Create a currency swap factory currencySwapFactoryCid <- toInterfaceContractId @CurrencySwapFactory.I <$> submit issuer do createCmd CurrencySwap.Factory with - provider = issuer - observers = mempty + provider = issuer; observers = mempty -- CREATE_CURRENCY_SWAP_INSTRUMENT_BEGIN let instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard + issuer; depository; id = Id label; version = "0"; holdingStandard cid <- submit (actAs issuer <> readAs publicParty) do exerciseCmd currencySwapFactoryCid CurrencySwapFactory.Create with @@ -267,17 +248,12 @@ originateForeignExchangeSwap depository issuer label holdingStandard description foreignExchangeSwapFactoryCid <- toInterfaceContractId @ForeignExchangeSwapFactory.I <$> submit issuer do createCmd ForeignExchangeSwap.Factory with - provider = issuer - observers = mempty + provider = issuer; observers = mempty -- CREATE_FOREIGN_EXCHANGE_SWAP_INSTRUMENT_BEGIN let instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard + issuer; depository; id = Id label; version = "0"; holdingStandard cid <- submit (actAs issuer <> readAs publicParty) do exerciseCmd foreignExchangeSwapFactoryCid ForeignExchangeSwapFactory.Create with diff --git a/package/test/daml/Daml.Finance.Settlement.Test/daml.yaml b/package/test/daml/Daml.Finance.Settlement.Test/daml.yaml index 2c5142233..4dc6edfcd 100644 --- a/package/test/daml/Daml.Finance.Settlement.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Settlement.Test/daml.yaml @@ -1,27 +1,28 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-settlement-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Account.V4/4.99.0.20251211.0/daml-finance-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Holding.V4/4.99.0.20251211.0/daml-finance-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Settlement.V4/4.99.0.20251211.0/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Settlement.V4/4.99.0.20251211.0/daml-finance-settlement-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../../../main/daml/Daml.Finance.Account.V4/.daml/dist/daml-finance-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Holding.V4/.daml/dist/daml-finance-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Settlement.V4/.daml/dist/daml-finance-interface-settlement-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Settlement.V4/.daml/dist/daml-finance-settlement-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wupgrade-exceptions - -Wno-upgrade-exceptions - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test deleted file mode 120000 index 140c2c81c..000000000 --- a/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/test/daml/Daml/Finance/Settlement/Test/ \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Batch.daml b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Batch.daml similarity index 95% rename from docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Batch.daml rename to package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Batch.daml index 7857c3542..6f1a736a7 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Batch.daml +++ b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Batch.daml @@ -158,19 +158,23 @@ run settleCashOnledger bankIsInstructor = script do cashHoldingCid <- Account.credit [publicParty] cashInstrument 200_000.0 buyerCashAccount (cashInstructionCid, _) <- submit buyer do exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton buyer; allocation = SettlementTypes.Pledge cashHoldingCid + actors = Set.singleton buyer + allocation = SettlementTypes.Pledge cashHoldingCid submit seller do exerciseCmd cashInstructionCid Instruction.Approve with - actors = Set.singleton seller; approval = SettlementTypes.TakeDelivery sellerCashAccount + actors = Set.singleton seller + approval = SettlementTypes.TakeDelivery sellerCashAccount else do -- Settle by off ledger transfer (cashInstructionCid, _) <- submit [buyer, bank] do exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.fromList [buyer, bank]; allocation = SettlementTypes.SettleOffledger + actors = Set.fromList [buyer, bank] + allocation = SettlementTypes.SettleOffledger submit [seller, bank] do exerciseCmd cashInstructionCid Instruction.Approve with - actors = Set.fromList [seller, bank]; approval = SettlementTypes.SettleOffledgerAcknowledge + actors = Set.fromList [seller, bank] + approval = SettlementTypes.SettleOffledgerAcknowledge -- Settle batch -- neither the bank, nor seller, nor buyer can execute an instruction diff --git a/src/test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml similarity index 89% rename from src/test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml rename to package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml index b53ed944d..0bbb61471 100644 --- a/src/test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml +++ b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/BatchWithIntermediaries.daml @@ -145,9 +145,7 @@ run = script do routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit buyer do createCmd IntermediatedStatic with - provider = buyer - paths - observers = mempty + provider = buyer; paths; observers = mempty routedSteps <- submit buyer do exerciseCmd routeProviderCid RouteProvider.Discover with discoverors = Set.singleton buyer; contextId = None; steps @@ -173,7 +171,6 @@ run = script do let zipped = zip instructionCids instrViews - -- Identify by unit id Some equityInstructionCid = headOpt [ cid | (cid, v) <- zipped, v.routedStep.quantity.unit.id == "AAPL" ] @@ -187,60 +184,50 @@ run = script do equityInstructionCid <- fromInterfaceContractId @Instruction.I <$> submit seller do exerciseCmd (toInterfaceContractId @Disclosure.I equityInstructionCid) Disclosure.AddObservers with - disclosers = Set.singleton seller - observersToAdd = ("csd_allocation", Set.singleton csd) + disclosers = Set.singleton seller; observersToAdd = ("csd_allocation", Set.singleton csd) -- 2) Ensure CSD sees the pledged holding, too equityHoldingCid <- coerceInterfaceContractId @Api.HoldingV1.Holding @Disclosure.I <$> submit seller do exerciseCmd (coerceInterfaceContractId @Disclosure.I @Api.HoldingV1.Holding equityHoldingCid) Disclosure.AddObservers with - disclosers = Set.singleton seller - observersToAdd = ("csd_allocation", Set.singleton csd) + disclosers = Set.singleton seller; observersToAdd = ("csd_allocation", Set.singleton csd) -- Allocate instructions (equityInstructionCid, _) <- submit seller do exerciseCmd equityInstructionCid Instruction.Allocate with - actors = Set.singleton seller - allocation = SettlementTypes.Pledge equityHoldingCid - + actors = Set.singleton seller; allocation = SettlementTypes.Pledge equityHoldingCid (cashInstruction1Cid, _) <- submit buyer do exerciseCmd cashInstruction1Cid Instruction.Allocate with - actors = Set.singleton buyer - allocation = SettlementTypes.Pledge buyerCashHoldingCid - + actors = Set.singleton buyer; allocation = SettlementTypes.Pledge buyerCashHoldingCid (cashInstruction2Cid, _) <- submit bank do exerciseCmd cashInstruction2Cid Instruction.Allocate with - actors = Set.singleton bank - allocation = SettlementTypes.CreditReceiver - + actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver submitMustFail buyer do exerciseCmd cashInstruction1Cid Instruction.Allocate with - actors = Set.singleton buyer - allocation = SettlementTypes.CreditReceiver + actors = Set.singleton buyer; allocation = SettlementTypes.CreditReceiver -- Approve instructions equityInstructionCid <- submit buyer do exerciseCmd equityInstructionCid Instruction.Approve with actors = Set.singleton buyer; approval = SettlementTypes.TakeDelivery buyerSecurityAccount - cashInstruction1Cid <- submit bank do exerciseCmd cashInstruction1Cid - Instruction.Approve with actors = Set.singleton bank; approval = SettlementTypes.TakeDelivery bankCashAccount + Instruction.Approve with + actors = Set.singleton bank; approval = SettlementTypes.TakeDelivery bankCashAccount cashInstruction2Cid <- submit seller do exerciseCmd cashInstruction2Cid Instruction.Approve with actors = Set.singleton seller; approval = SettlementTypes.TakeDelivery sellerCashAccount - submitMustFail buyer do exerciseCmd equityInstructionCid - Instruction.Approve with actors = Set.singleton buyer; approval = SettlementTypes.DebitSender - + Instruction.Approve with + actors = Set.singleton buyer; approval = SettlementTypes.DebitSender settledHoldings <- submit (actAs buyer <> readAs publicParty) do exerciseCmd batchCid Batch.Settle with actors = Set.singleton buyer @@ -248,23 +235,22 @@ run = script do -- Identify holdings based on instrument and owner -- After settlement: identifies which new holdings correspond to which owner/instrument - let identifyHolding instr owner = do - cids <- forA settledHoldings \cid -> do - mView <- queryInterfaceContractId @Api.HoldingV1.Holding owner cid - case mView of - Some v -> - if v.instrumentId.id == instr && v.owner == owner - then pure [cid] -- return directly - else pure [] - None -> pure [] - pure (concat cids) -- flatten [[cid]] to [cid] + let + identifyHolding instr owner = do + cids <- forA settledHoldings \cid -> do + mView <- queryInterfaceContractId @Api.HoldingV1.Holding owner cid + case mView of + Some v -> + if v.instrumentId.id == instr && v.owner == owner + then pure [cid] + else pure [] + None -> pure [] + pure (concat cids) - -- Extract each desired holding Some equityHoldingCid <- headOpt <$> identifyHolding "AAPL" buyer Some bankCashHoldingCid <- headOpt <$> identifyHolding "USD" bank Some sellerCashHoldingCid <- headOpt <$> identifyHolding "USD" seller - -- Assert state let ts = [(buyer, equityHoldingCid), (bank, bankCashHoldingCid), (seller, sellerCashHoldingCid)] diff --git a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Hierarchy.daml b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Hierarchy.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Hierarchy.daml rename to package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Hierarchy.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Intermediated.daml b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Intermediated.daml similarity index 94% rename from docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Intermediated.daml rename to package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Intermediated.daml index f22be159a..06b7cda50 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Intermediated.daml +++ b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Intermediated.daml @@ -244,38 +244,31 @@ run useDelegatee = script do else submit buyer do exerciseCmd buyerInstructionCid Instruction.Allocate with - actors = Set.singleton buyer - allocation = SettlementTypes.Pledge buyerCashCid + actors = Set.singleton buyer; allocation = SettlementTypes.Pledge buyerCashCid buyerInstructionCid <- submit bank1 do exerciseCmd buyerInstructionCid Instruction.Approve with - actors = Set.singleton bank1 - approval = SettlementTypes.DebitSender + actors = Set.singleton bank1; approval = SettlementTypes.DebitSender bank2InstructionCid <- submit seller do exerciseCmd bank2InstructionCid Instruction.Approve with - actors = Set.singleton seller - approval = SettlementTypes.TakeDelivery sellerCashAccount + actors = Set.singleton seller; approval = SettlementTypes.TakeDelivery sellerCashAccount (bank2InstructionCid, _) <- submit bank2 do exerciseCmd bank2InstructionCid Instruction.Allocate with - actors = Set.singleton bank2 - allocation = SettlementTypes.CreditReceiver + actors = Set.singleton bank2; allocation = SettlementTypes.CreditReceiver (bank1InstructionCid, _) <- submit [bank1, cb] do exerciseCmd bank1InstructionCid Instruction.Allocate with - actors = Set.fromList [bank1, cb] - allocation = SettlementTypes.SettleOffledger + actors = Set.fromList [bank1, cb]; allocation = SettlementTypes.SettleOffledger bank1InstructionCid <- submit [bank2, cb] do exerciseCmd bank1InstructionCid Instruction.Approve with - actors = Set.fromList [bank2, cb] - approval = SettlementTypes.SettleOffledgerAcknowledge + actors = Set.fromList [bank2, cb]; approval = SettlementTypes.SettleOffledgerAcknowledge (sellerInstructionCid, _) <- submit seller do exerciseCmd sellerInstructionCid Instruction.Allocate with - actors = Set.singleton seller - allocation = SettlementTypes.Pledge sellerAssetCid + actors = Set.singleton seller; allocation = SettlementTypes.Pledge sellerAssetCid sellerInstructionCid <- submit custodian1 do exerciseCmd sellerInstructionCid Instruction.Approve with @@ -309,10 +302,6 @@ run useDelegatee = script do exerciseCmd custodian2InstructionCid Instruction.Approve with actors = Set.singleton buyer; approval = SettlementTypes.TakeDelivery buyerDepoAccount - -- Set time - --setTime settlementTime - -- In wallclock mode, we skip manual time advancement - -- Settle batch [sellerCashCid, custodian2AssetCid, buyerAssetCid] <- submit (actAs agent <> readAs publicParty) do @@ -361,11 +350,10 @@ template AllocationDelegation coerceInterfaceContractId @Disclosure.I @Api.HoldingV1.Holding holdingCid -- Undisclose the delegatee (removes their observation context) - Some undisclosedDiscCid <- - Disclosure.undisclose - (id, Set.singleton delegatee) - (Set.singleton delegator) - holdingDisclosureCid + Some undisclosedDiscCid <- Disclosure.undisclose + (id, Set.singleton delegatee) + (Set.singleton delegator) + holdingDisclosureCid -- Convert the new Disclosure.I CID back into Api.HoldingV1.Holding let undisclosedHoldingCid : ContractId Api.HoldingV1.Holding = diff --git a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Transfer.daml b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Transfer.daml similarity index 94% rename from docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Transfer.daml rename to package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Transfer.daml index 25295e88c..53bd52f4e 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Settlement/Test/Transfer.daml +++ b/package/test/daml/Daml.Finance.Settlement.Test/daml/Daml/Finance/Settlement/Test/Transfer.daml @@ -95,10 +95,7 @@ run = script do sender = sender receiver = receiver quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 - + with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 -- Discover settlement route for the step routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do @@ -122,13 +119,14 @@ run = script do -- Allocate instruction (cashInstructionCid, _) <- submit sender do exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid + actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid -- Holding is locked Some cashInstruction <- queryInterfaceContractId sender cashInstructionCid let SettlementTypes.Pledge holdingCid = cashInstruction.allocation - Some lockable <- queryInterfaceContractId sender (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) + Some lockable <- + queryInterfaceContractId sender + (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) assertMsg "holding is locked" $ isSome lockable.lock -- Can't split the holding (as it is locked) @@ -139,11 +137,12 @@ run = script do -- Cancel allocation (cashInstructionCid, Some holdingCid) <- submit sender do exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Unallocated + actors = Set.singleton sender; allocation = SettlementTypes.Unallocated -- Holding is not locked - Some lockable <- queryInterfaceContractId sender (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) + Some lockable <- + queryInterfaceContractId sender + (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) assertMsg "holding is not locked" $ isNone lockable.lock -- Allocate instruction @@ -312,14 +311,11 @@ run2 = script do -- first (cashInstructionCid1, _) <- submit sender do exerciseCmd cashInstructionCid1 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid1 + actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid1 verifyAccountDisclosureContexts senderAccount [cashInstructionCid1] - (cashInstructionCid1, mAlloc) <- submit sender do exerciseCmd cashInstructionCid1 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Unallocated + actors = Set.singleton sender; allocation = SettlementTypes.Unallocated let releasedHoldingCid = @@ -330,23 +326,18 @@ run2 = script do verifyAccountDisclosureContexts senderAccount [] (cashInstructionCid1, _) <- submit sender do exerciseCmd cashInstructionCid1 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge releasedHoldingCid - + actors = Set.singleton sender; allocation = SettlementTypes.Pledge releasedHoldingCid verifyAccountDisclosureContexts senderAccount [cashInstructionCid1] -- second (cashInstructionCid2, _) <- submit sender do exerciseCmd cashInstructionCid2 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid2 - + actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid2 verifyAccountDisclosureContexts senderAccount [cashInstructionCid1, cashInstructionCid2] -- third (cashInstructionCid3, _) <- submit sender do exerciseCmd cashInstructionCid3 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid3 - + actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid3 + verifyAccountDisclosureContexts senderAccount [cashInstructionCid1, cashInstructionCid2, cashInstructionCid3] @@ -434,9 +425,7 @@ run3 = script do sender = sender receiver = receiver quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 + with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do @@ -522,17 +511,13 @@ run4 = script do sender = sender receiver = receiver quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument1 - amount = 200_000.0 + with unit = fromInstrumentKey cashInstrument1; amount = 200_000.0 step2 = SettlementTypes.Step with sender = sender receiver = receiver quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument1 - amount = 100_000.0 + with unit = fromInstrumentKey cashInstrument1; amount = 100_000.0 -- Discover settlement routes routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do @@ -623,17 +608,13 @@ run5 = script do sender = sender receiver = ccp quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 + with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 step2 = SettlementTypes.Step with sender = ccp receiver = receiver quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 + with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 -- Discover settlement routes routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do @@ -642,7 +623,7 @@ run5 = script do exerciseCmd routeProviderCid RouteProvider.Discover with discoverors = Set.singleton bank contextId = None - steps = [step2, step1] -- order does not matter + steps = [step2, step1] -- Instruct transfer (batchCid, [instructionCid2, instructionCid1]) <- submit bank do @@ -659,8 +640,7 @@ run5 = script do -- Approve instruction instructionCid2 <- submit receiver do exerciseCmd instructionCid2 Instruction.Approve with - actors = Set.singleton receiver - approval = SettlementTypes.TakeDelivery receiverAccount + actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount -- Approve with passthrough instructionCid1 <- submit ccp do diff --git a/package/test/daml/Daml.Finance.Test.Util/daml.yaml b/package/test/daml/Daml.Finance.Test.Util/daml.yaml index d1ff55be1..95cc7071d 100644 --- a/package/test/daml/Daml.Finance.Test.Util/daml.yaml +++ b/package/test/daml/Daml.Finance.Test.Util/daml.yaml @@ -1,34 +1,35 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-test-util source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Account.V4/4.99.0.20251211.0/daml-finance-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Claims.V3/3.99.0.20251211.0/daml-finance-claims-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Data.V4/4.99.0.20251211.0/daml-finance-data-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Holding.V4/4.99.0.20251211.0/daml-finance-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Instrument.Token.V4/4.99.0.20251211.0/daml-finance-instrument-token-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Account.V4/4.99.0.20251211.0/daml-finance-interface-account-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Holding.V4/4.99.0.20251211.0/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Base.V4/4.99.0.20251211.0/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Instrument.Token.V4/4.99.0.20251211.0/daml-finance-interface-instrument-token-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Lifecycle.V4/4.99.0.20251211.0/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Lifecycle.V4/4.99.0.20251211.0/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar - - .lib/splice/splice-api-token-holding-v1-1.0.0.dar - - .lib/splice/splice-api-token-metadata-v1-1.0.0.dar + - ../../../../lib/splice-api-token-holding-v1-1.0.0.dar + - ../../../../lib/splice-api-token-metadata-v1-1.0.0.dar + - ../../../main/daml/Daml.Finance.Account.V4/.daml/dist/daml-finance-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Claims.V3/.daml/dist/daml-finance-claims-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Data.V4/.daml/dist/daml-finance-data-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Holding.V4/.daml/dist/daml-finance-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Instrument.Token.V4/.daml/dist/daml-finance-instrument-token-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Account.V4/.daml/dist/daml-finance-interface-account-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Holding.V4/.daml/dist/daml-finance-interface-holding-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Base.V4/.daml/dist/daml-finance-interface-instrument-base-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Instrument.Token.V4/.daml/dist/daml-finance-interface-instrument-token-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Lifecycle.V4/.daml/dist/daml-finance-interface-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Lifecycle.V4/.daml/dist/daml-finance-lifecycle-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar build-options: - --target=2.dev - -Wupgrade-exceptions - -Wno-upgrade-exceptions - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util deleted file mode 120000 index 12f0a5810..000000000 --- a/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/test/daml/Daml/Finance/Test/Util/ \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Account.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Account.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/Account.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Account.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Common.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Common.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/Common.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Common.daml index 4a9a47c05..357ee307e 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Common.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Common.daml @@ -5,8 +5,8 @@ module Daml.Finance.Test.Util.Common where -import Daml.Script import DA.Text (replace) +import Daml.Script -- | Replace invalid PartyIdHint characters with underscores. makeSafePartyHint : Text -> Text diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Holding.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Holding.daml similarity index 96% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/Holding.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Holding.daml index 76f7dc5da..9427eb66a 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Holding.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Holding.daml @@ -25,7 +25,6 @@ verifyOwnerAndAmountOfHolding triples = forA triples \(expectedOwner, expectedAm verifyNoObservers : [(Party, ContractId Api.HoldingV1.Holding)] -> Script [()] verifyNoObservers pairs = forA pairs \(expectedOwner, holdingCid) -> do Some view <- queryInterfaceContractId @Api.HoldingV1.Holding expectedOwner holdingCid - -- Splice holdings do not have observers, so we just ensure ownership consistency. view.owner === expectedOwner -- Helper: find exactly one holding owned by expectedOwner for (admin,instrId) diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml similarity index 68% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml index f787780ab..8ab9d1dc5 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml @@ -7,16 +7,16 @@ module Daml.Finance.Test.Util.HoldingDuplicates.BaseHolding where -- This module contains a copy of the code from the Daml.Finance.Holding package. It is used -- specifically for testing purposes, allowing the instantiation of an alternate implementation of -- holdings. - -import DA.Set (fromList, singleton) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) import DA.TextMap qualified as TextMap -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as SpliceHolding +import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 import Splice.Api.Token.MetadataV1 qualified as SpliceMetadata -- | Type synonym for `BaseHolding`. @@ -56,13 +56,31 @@ template BaseHolding acquire = acquireImpl this.lock (\lock -> this with lock) release = releaseImpl this.lock (\lock -> this with lock) - interface instance SpliceHolding.Holding for BaseHolding where - view = SpliceHolding.HoldingView - with + interface instance Api.HoldingV1.Holding for BaseHolding where + view = + let + lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with owner = account.owner - instrumentId = SpliceHolding.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t + instrumentId = Api.HoldingV1.InstrumentId with + admin = instrument.issuer; id = show instrument.id amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty \ No newline at end of file + + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Factory.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Factory.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Factory.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Factory.daml diff --git a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml similarity index 75% rename from src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml index 928e3a06e..e0dfbc227 100644 --- a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Fungible.daml @@ -8,11 +8,12 @@ module Daml.Finance.Test.Util.HoldingDuplicates.Fungible where -- specifically for testing purposes, allowing the instantiation of an alternate implementation of -- holdings. -import DA.Set (fromList, singleton) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) import DA.TextMap qualified as TextMap import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl) import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) @@ -59,15 +60,33 @@ template Fungible release = releaseImpl this.lock (\lock -> this with lock) interface instance Api.HoldingV1.Holding for Fungible where - view = Api.HoldingV1.HoldingView - with + view = + let + lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with owner = account.owner instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t + admin = instrument.issuer; id = show instrument.id amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty + + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] interface instance Fungible.I for Fungible where view = Fungible.View with modifiers = singleton account.owner diff --git a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml similarity index 74% rename from src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml index f01294a2b..c2c0dc7bd 100644 --- a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/Transferable.daml @@ -8,11 +8,12 @@ module Daml.Finance.Test.Util.HoldingDuplicates.Transferable where -- specifically for testing purposes, allowing the instantiation of an alternate implementation of -- holdings. -import DA.Set (fromList, singleton) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) import DA.TextMap qualified as TextMap import Daml.Finance.Holding.V4.Util (transferImpl) import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) @@ -59,15 +60,33 @@ template Transferable release = releaseImpl this.lock (\lock -> this with lock) interface instance Api.HoldingV1.Holding for Transferable where - view = Api.HoldingV1.HoldingView - with + view = + let + lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with owner = account.owner instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t + admin = instrument.issuer; id = show instrument.id amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty + + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] interface instance Transferable.I for Transferable where view = Transferable.View {} diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml similarity index 77% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml index 6194c2672..69c31514a 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingDuplicates/TransferableFungible.daml @@ -8,12 +8,13 @@ module Daml.Finance.Test.Util.HoldingDuplicates.TransferableFungible where -- specifically for testing purposes, allowing the instantiation of an alternate implementation of -- holdings. -import DA.Set (fromList, singleton) +import DA.Set (fromList, singleton, toList) +import DA.Text (intercalate) import DA.TextMap qualified as TextMap import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl, transferImpl) import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) +import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) @@ -62,15 +63,33 @@ template TransferableFungible release = releaseImpl this.lock (\lock -> this with lock) interface instance Api.HoldingV1.Holding for TransferableFungible where - view = Api.HoldingV1.HoldingView - with + view = + let + lockView : Lockable.View = view (toInterface @Lockable.I this) + + in Api.HoldingV1.HoldingView with owner = account.owner instrumentId = Api.HoldingV1.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t + admin = instrument.issuer; id = show instrument.id amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty + + lock = case lockView.lock of + None -> None + Some l -> + Some Api.HoldingV1.Lock with + holders = toList l.lockers + expiresAt = None -- Not present in Lockable + expiresAfter = None -- Not present in Lockable + context = Some (intercalate ", " (toList l.context)) + + meta = SpliceMetadata.Metadata with + values = TextMap.fromList + [ ("depository", partyToText instrument.depository) + , ("version", instrument.version) + , ("holdingStandard", show instrument.holdingStandard) + , ("custodian", partyToText account.custodian) + , ("accountId", show account.id) + ] interface instance Transferable.I for TransferableFungible where view = Transferable.View {} diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingFactory.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingFactory.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/HoldingFactory.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/HoldingFactory.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Instrument.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Instrument.daml similarity index 91% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/Instrument.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Instrument.daml index 1f53af6cc..bb904ecb6 100644 --- a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Instrument.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Instrument.daml @@ -23,19 +23,12 @@ originate depository issuer label holdingStandard description observers timestam createCmd Token.Factory with provider = issuer; observers = mempty let instrumentKey = InstrumentKey with - depository - issuer - id = Id label - version = "0" - holdingStandard + depository; issuer; id = Id label; version = "0"; holdingStandard token = Token with - instrument = instrumentKey - validAsOf = timestamp - description + instrument = instrumentKey; validAsOf = timestamp; description submit [depository, issuer] do exerciseCmd tokenFactoryCid TokenFactory.Create with - token - observers = fromList observers + token; observers = fromList observers submit [depository, issuer] do archiveCmd tokenFactoryCid pure instrumentKey diff --git a/src/test/daml/Daml/Finance/Test/Util/Lifecycle.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Lifecycle.daml similarity index 97% rename from src/test/daml/Daml/Finance/Test/Util/Lifecycle.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Lifecycle.daml index 134f9d91e..486d7ea11 100644 --- a/src/test/daml/Daml/Finance/Test/Util/Lifecycle.daml +++ b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Lifecycle.daml @@ -40,9 +40,7 @@ lifecycleInstrument readers today instrument issuer observableCids = do -- Try to lifecycle the instrument (lifecycleCid, effectCids) <- submit (actAs issuer <> readAs readers) do exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids - instrument + eventCid = clockEventCid; observableCids; instrument pure (lifecycleCid, effectCids) @@ -148,8 +146,7 @@ applyElectionAndVerify issuer readers observableCids -- Apply election to generate new instrument version + effects (newInstrumentKey, [effectCid]) <- submit (actAs issuer <> readAs readers) do exerciseCmd electionCid Election.Apply with - observableCids - exercisableCid = lifecycleRuleCid + observableCids; exercisableCid = lifecycleRuleCid -- Verify that the consumed/produced quantities match the expected ones verifyConsumedAndProduced expectedConsumed expectedProduced effectCid issuer @@ -181,6 +178,5 @@ ensureElectionNotPossible today amount instrument electorIsOwner issuer elector -- Try to apply the election and verify that this does not work submitMustFail (actAs [issuer] <> readAs readers )do exerciseCmd electionCid Election.Apply with - observableCids - exercisableCid = lifecycleRuleCid + observableCids; exercisableCid = lifecycleRuleCid diff --git a/docs/generated/src/test/daml/Daml/Finance/Test/Util/Time.daml b/package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Time.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Test/Util/Time.daml rename to package/test/daml/Daml.Finance.Test.Util/daml/Daml/Finance/Test/Util/Time.daml diff --git a/package/test/daml/Daml.Finance.Util.Test/daml.yaml b/package/test/daml/Daml.Finance.Util.Test/daml.yaml index 9e5e2e3cc..135203a0a 100644 --- a/package/test/daml/Daml.Finance.Util.Test/daml.yaml +++ b/package/test/daml/Daml.Finance.Util.Test/daml.yaml @@ -1,22 +1,23 @@ # Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -sdk-version: 3.4.9 +sdk-version: 3.4.10 name: daml-finance-util-test source: daml -version: 0.99.0.20251211.0 +version: 1.99.0.20251211.0 dependencies: - daml-prim - daml-stdlib - daml-script data-dependencies: - - .lib/daml-finance/Daml.Finance.Interface.Types.Common.V3/3.99.0.20251211.0/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Types.Date.V3/3.99.0.20251211.0/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Interface.Util.V3/3.99.0.20251211.0/daml-finance-interface-util-v3-3.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Test.Util/0.99.0.20251211.0/daml-finance-test-util-0.99.0.20251211.0.dar - - .lib/daml-finance/Daml.Finance.Util.V4/4.99.0.20251211.0/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Common.V3/.daml/dist/daml-finance-interface-types-common-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Types.Date.V3/.daml/dist/daml-finance-interface-types-date-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Interface.Util.V3/.daml/dist/daml-finance-interface-util-v3-3.99.0.20251211.0.dar + - ../../../main/daml/Daml.Finance.Util.V4/.daml/dist/daml-finance-util-v4-4.99.0.20251211.0.dar + - ../Daml.Finance.Test.Util/.daml/dist/daml-finance-test-util-1.99.0.20251211.0.dar build-options: - --target=2.dev - -Wupgrade-exceptions - -Wno-upgrade-exceptions - -Wno-template-interface-depends-on-daml-script + diff --git a/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test b/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test deleted file mode 120000 index d502648db..000000000 --- a/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../../src/test/daml/Daml/Finance/Util/Test \ No newline at end of file diff --git a/docs/generated/src/test/daml/Daml/Finance/Util/Test/Common.daml b/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Common.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Util/Test/Common.daml rename to package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Common.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/Calendar.daml b/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/Calendar.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/Calendar.daml rename to package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/Calendar.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/DayCount.daml b/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/DayCount.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/DayCount.daml rename to package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/DayCount.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/RollConvention.daml b/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/RollConvention.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/RollConvention.daml rename to package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/RollConvention.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/Schedule.daml b/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/Schedule.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Util/Test/Date/Schedule.daml rename to package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Date/Schedule.daml diff --git a/docs/generated/src/test/daml/Daml/Finance/Util/Test/Disclosure.daml b/package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Disclosure.daml similarity index 100% rename from docs/generated/src/test/daml/Daml/Finance/Util/Test/Disclosure.daml rename to package/test/daml/Daml.Finance.Util.Test/daml/Daml/Finance/Util/Test/Disclosure.daml diff --git a/scripts/build-package.sh b/scripts/build-package.sh index d6031dd47..042525a7a 100755 --- a/scripts/build-package.sh +++ b/scripts/build-package.sh @@ -26,6 +26,6 @@ echo -e "${boldWhite}Extracting dependencies for library ${project_name}...${col ${script_dir}/get-dependencies.sh ${project}/daml.yaml echo -e "${boldWhite}Compiling ${project_name}...${colour_off}" -DAML_PROJECT=${project} daml build +(cd "${project}" && dpm build --all) echo -e "\n${cyan}Successfully built package ${project_name}.${colour_off}" diff --git a/scripts/get-dependencies.sh b/scripts/get-dependencies.sh index 0334b7a6c..bb2d6f7de 100755 --- a/scripts/get-dependencies.sh +++ b/scripts/get-dependencies.sh @@ -43,20 +43,6 @@ else fi continue fi - - # TODO: Adjust the regex to match the new major-version-in-path structure - # isValidPath=`awk '{ match($0, /^.lib\/[a-zA-Z\-]*\/([a-zA-Z\.]*\/v?[0-9\.]*|v?[0-9\.]*)\/[a-zA-Z0-9\.\-]*\.dar$/); print RLENGTH }' <<< ${dependency_path}` - # if [[ ${isValidPath} -eq -1 ]]; then - # echo -e "${red}ERROR: Dependency ${dependency_path} does not match the expected format. - - # Dependency syntax : - # .lib/// - # syntax : - # | / - - # Regex format : ^\.lib\/[a-zA-Z\-]*\/([a-zA-Z\.]*\/v?[0-9\.]*|v?[0-9\.]*)\/[a-zA-Z0-9\.\-]*\.dar$ ${colour_off}" - # exit 1 - # fi if [[ -a ${project_root_dir}/${dependency_path} ]]; then echo -e "Dependency ${dependency_path} already setup. Skipping.\n" diff --git a/scripts/test-packages.sh b/scripts/test-packages.sh index 09235e8e1..3d7c10b23 100755 --- a/scripts/test-packages.sh +++ b/scripts/test-packages.sh @@ -14,9 +14,7 @@ test_package_paths=($(yq e '.local.packages | to_entries | .[].value.package.pat for test_package_path in "${test_package_paths[@]}"; do pkg="${root_dir}/package/${test_package_path}" - echo "----------------------------------------" echo "Testing package: $pkg" - echo "----------------------------------------" (cd "$pkg" && dpm test) done diff --git a/shell.nix b/shell.nix index 1708f960b..2de7fd552 100644 --- a/shell.nix +++ b/shell.nix @@ -41,19 +41,52 @@ let arch = arch; osJFrog = "${os}-${arch}"; hashes = { - #base64 hashes from update-daml-hashes - linux = "zPPJJfor22GHpovh2HOJH7AKQLfSW9p0UPgcZCdhSGM="; - macos = "hITo4qlasMbhuLGfUwGMhuvkwVRaNgWQLdl6mEDx2Ew="; + linux = "07Pcs/OIYNnkSeK4wPSLz61sAqtA4wEl5oTh8rouhdY="; + macos = "CNYJOM9SdfnWZfRwyBh5EQq98JHcwzNcmlB2nAL13jE="; }; }; in pkgs.mkShell { SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; + + shellHook = '' + set -euo pipefail + export DPM_HOME="$PWD/.dpm" + mkdir -p "$DPM_HOME" + + export PATH="${dpm}/bin:$PATH" + + export XDG_CONFIG_HOME="$PWD/.xdg-config" + mkdir -p "$XDG_CONFIG_HOME" + + export DOCKER_CONFIG="$PWD/.docker" + mkdir -p "$DOCKER_CONFIG" + cat > "$DOCKER_CONFIG/config.json" <<'JSON' + { "auths": {} } + JSON + + export DPM_REGISTRY="europe-docker.pkg.dev/da-images/public-all" + + SDK_VERSION="${damlYaml."sdk-version"}" + + if ! dpm version --all -o json 2>/dev/null \ + | ${pkgs.jq}/bin/jq -e --arg v "$SDK_VERSION" \ + 'any(.[]; .version == $v and .installed == true)' >/dev/null 2>&1; then + echo "Installing SDK $SDK_VERSION into $DPM_HOME (registry=$DPM_REGISTRY)..." + dpm install "$SDK_VERSION" + fi + + echo "Using dpm: $(command -v dpm || true)" + echo "DPM_HOME=$DPM_HOME" + echo "DPM_REGISTRY=$DPM_REGISTRY" + dpm version + ''; + buildInputs = [ daml dpm - (packell { pkgs = pkgsGhc; stdenv = pkgsGhc.stdenv; version = "0.0.2"; }) + (packell { pkgs = pkgsGhc; stdenv = pkgsGhc.stdenv; version = "0.0.3"; }) pkgs.bash pkgs.binutils # cp, grep, etc. pkgs.cacert diff --git a/show b/show deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/main/daml/ContingentClaims/Core/V3/Builders.daml b/src/main/daml/ContingentClaims/Core/V3/Builders.daml deleted file mode 100644 index 02938d1c9..000000000 --- a/src/main/daml/ContingentClaims/Core/V3/Builders.daml +++ /dev/null @@ -1,74 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Core.V3.Builders where - -import ContingentClaims.Core.V3.Claim (Claim, anytime, at, give, one, or, scale, upTo, when, zero) -import ContingentClaims.Core.V3.Observation (Observation) -import ContingentClaims.Core.V3.Observation qualified as O -import DA.Date (Month, date) -import DA.Foldable (foldMap) -import DA.List.Total (last) -import Prelude hiding (and, or, zero) - --- | Helper function to generate a series of fixing dates, e.g. for coupon payments in `fixed`. --- This assumes `fixingMonths` and `fixingDates` are ordered. --- The [Daml Finance library](https://github.com/digital-asset/daml-finance) has more --- feature-complete date handling functions. -unrollDates : Int -> Int -> [Month] -> Int -> [Date] -unrollDates issueYear maturityYear fixingMonths fixingDay = - date <$> [issueYear .. maturityYear] <*> fixingMonths <*> [fixingDay] - --- | Forward agreement. Discounted by (potentially stochastic) interest rate `r`. -forward : t -> Observation t x o -> Claim t x a o -> Claim t x a o -forward maturity r payoff = when (at maturity) $ scale r payoff - --- | Forward rate agreement. -fra : t -> t -> Observation t x o -> Observation t x o -> Claim t x a o -> Claim t x a o -fra t₁ t₂ r₀ r₁ = forward t₁ r₀ . forward t₂ r₁ - --- | Zero Coupon Bond. -zcb : forall t x ccy o. t -> x -> ccy -> Claim t x ccy o -zcb maturity principal ccy = forward maturity (O.pure principal) (one ccy) - --- | A floating rate bond. -floating : forall t x ccy o. Observation t x o -> Observation t x o -> ccy -> [t] -> Claim t x ccy o -floating principal coupon asset fixings = - (mconcat (mkCoupon <$> fixings)) <> mkPrincipal (last fixings : Optional t) - where mkCoupon t = forward t coupon (one asset) - mkPrincipal = foldMap \t -> forward t principal (one asset) - --- | A (fixed rate) coupon paying bond. -fixed : forall t x ccy o. x -> x -> ccy -> [t] -> Claim t x ccy o -fixed principal coupon = floating (O.pure principal) (O.pure coupon) - --- | European option on the input claim. At maturity, the holder must `EXERCISE` or `EXPIRE` --- the claim. e.g. call option on S&P 500: --- ``` --- european (date 2021 05 14) (observe "SPX" - pure 4200) --- ``` -european : t -> Claim t x a o -> Claim t x a o -european maturity payoff = when (at maturity) (("EXERCISE", payoff) `or` ("EXPIRE", zero)) - --- | Bermudan option on the input claim. Given a pre-defined set of times --- {t_1, t_2, .., t_N}, it allows the holder to acquire the underlying claim on at --- most one of these times. --- At each election time before maturity, the holder must `EXERCISE` the option or `POSTPONE`. --- At maturity, the holder must `EXERCISE` or `EXPIRE`. -bermudan : [t] -> Claim t x a o -> Claim t x a o -bermudan [] _ = zero -bermudan [t] c = european t c -bermudan (t :: ts) c = when (at t) (("EXERCISE", c) `or` ("POSTPONE", bermudan ts c)) - --- | American option (knock-in). The lead parameter is the first possible acquisition date. -american : t -> t -> Claim t x a o -> Claim t x a o -american start maturity payoff = when (at start) $ anytime (upTo maturity) "EXERCISE" payoff - --- | Asset swap on specific fixing dates `[t]`. For example: --- ``` --- fixedUsdVsFloatingEur : [t] -> Serializable.Claim Text --- fixedUsdVsFloatingEur = --- fixed 100.0 0.02 "USD" `swap` floating (observe "USDEUR" * pure 100.0) (observe "EUR1M") "EUR" --- ``` -swap : ([t] -> Claim t x a o) -> ([t] -> Claim t x a o) -> [t] -> Claim t x a o -swap receive pay ts = receive ts <> give (pay ts) diff --git a/src/main/daml/ContingentClaims/Core/V3/Claim.daml b/src/main/daml/ContingentClaims/Core/V3/Claim.daml deleted file mode 100644 index 6e5b077a8..000000000 --- a/src/main/daml/ContingentClaims/Core/V3/Claim.daml +++ /dev/null @@ -1,169 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Core.V3.Claim - ( Claim - , F - , Inequality(..) - , T - , (<=) - , and - , andList - , anytime - , at - , compare - , cond - , give - , mapParams - , one - , or - , orList - , scale - , until - , upTo - , when - , zero - ) where - -import ContingentClaims.Core.V3.Internal.Claim (Claim(..), ClaimF(..), Electable, Inequality(..)) -import ContingentClaims.Core.V3.Observation (Observation, eval) -import ContingentClaims.Core.V3.Observation qualified as Observation (mapParams) -import Daml.Control.Recursion -import Prelude hiding (and, compare, or, zero, (<=)) -import qualified Prelude ((<=)) - --- | HIDE -type T = Claim - --- | HIDE -type F = ClaimF - --- | Constructs a claim without rights or obligations. -zero : forall t x a o . Claim t x a o -zero = Zero - --- | Constructs a claim that delivers one unit of `a` immediately to the bearer. -one : a -> Claim t x a o -one = One - --- | Constructs a claim that reverses the obligations of the bearer and their counterparty. -give : Claim t x a o -> Claim t x a o -give = Give - --- | Used to additively combine two claims together. In order to use this, --- you must import this module qualified or hide the `and` operator from `Prelude`. -and : Claim t x a o -> Claim t x a o -> Claim t x a o -and (And a b cs) (And d e fs) = And a b (cs ++ d :: e :: fs) -and x Zero = x -and (And a b cs) claim = And a b (cs ++ [claim]) -and Zero x = x -and claim (And a b cs) = And claim a (b :: cs) -and claim claim' = And claim claim' [] - --- | Gives the bearer the right to choose between the input claims. In order to use this, --- you must import this module qualified or hide the `or` operator from `Prelude`. -or : Electable t x a o -> Electable t x a o -> Claim t x a o -or (_, Or a b cs) (_, Or d e fs) = Or a b (cs ++ d :: e :: fs) -or (_, Or a b cs) (tag2, claim) = Or a b (cs ++ [(tag2, claim)]) -or (tag1, claim) (_, (Or a b cs)) = Or (tag1, claim) a (b :: cs) -or (tag1, claim) (tag2, claim') = Or (tag1, claim) (tag2, claim') [] - --- | Used to additively combine a list of claims together. It is equivalent to --- applying the `and` builder recursively. -andList : [Claim t x a o] -> Claim t x a o -andList = mconcat - --- | Gives the bearer the right to choose between the input claims. It is equivalent to --- applying the `or` builder recursively. -orList : [Electable t x a o] -> Claim t x a o -orList (c1 :: c2 :: cs) = Or c1 c2 cs -orList _ = error "orList: at least 2 choices required" - --- | Gives the bearer the right to the first claim if predicate is true, else the second --- claim. -cond : Inequality t x o -> Claim t x a o -> Claim t x a o -> Claim t x a o -cond = Cond - --- | Multiplies the input claim by a scaling factor (which can be non-deterministic). -scale : Observation t x o -> Claim t x a o -> Claim t x a o -scale = Scale - --- | Acquires the input claim on *the first instant* that `predicate` is true. -when : Inequality t x o -> Claim t x a o -> Claim t x a o -when = When - --- | Gives the bearer the right to enter a claim at any time `predicate` is true. -anytime : Inequality t x o -> Text -> Claim t x a o -> Claim t x a o -anytime pred tag subTree = Anytime pred (tag, subTree) - --- | Expires the input claim on the *first instant* that `predicate` is true. -until : Inequality t x o -> Claim t x a o -> Claim t x a o -until = Until - --- | `Claim` semigroup under `And`. -instance Semigroup (Claim t x a o) where - (<>) = and - --- | `Claim` monoid under `And`. -instance Monoid (Claim t x a o) where - mempty = Zero - mconcat [] = mempty - mconcat [c] = c - mconcat (c :: c' :: cs) = And c c' cs - -- ^ A more efficient `O(1)` version of (<>) for lists. - --- | Replaces parameters in a claims using the input mapping functions. --- This can be used to e.g. map the time parameter in a claim from `Date` to `Time`, or --- to map the asset type parameter from an abstract `Text` to a concrete `InstrumentKey`. -mapParams : (t -> i) - -> (i -> t) - -> (a -> a') - -> (o -> o') - -> (x -> x') - -> Claim i x a o -> Claim t x' a' o' -mapParams ft' ft fa fk fv = - let f = Observation.mapParams ft fk fv - in cata \case - ZeroF -> Zero - OneF a -> One $ fa a - GiveF c -> Give c - AndF c c' cs -> And c c' cs - OrF c c' cs -> Or c c' cs - CondF (Lte (x, x')) c c' -> Cond (Lte(f x, f x')) c c' - CondF (TimeGte t) c c' -> Cond (TimeGte (ft t)) c c' - CondF (TimeLte t) c c' -> Cond (TimeLte (ft t)) c c' - ScaleF k c -> Scale (f k) c - WhenF (Lte (x, x')) c -> When (Lte (f x, f x')) c - WhenF (TimeGte t) c -> When (TimeGte (ft t)) c - WhenF (TimeLte t) c -> When (TimeLte (ft t)) c - AnytimeF (Lte (x, x')) e -> Anytime (Lte (f x, f x')) e - AnytimeF (TimeGte t) e -> Anytime (TimeGte (ft t)) e - AnytimeF (TimeLte t) e -> Anytime (TimeLte (ft t)) e - UntilF (Lte (x, x')) c -> Until (Lte (f x, f x')) c - UntilF (TimeGte t) c -> Until (TimeGte (ft t)) c - UntilF (TimeLte t) c -> Until (TimeLte (ft t)) c - --- Inequality -- - --- | Given `t`, constructs a predicate that is `True` for time ≥ `t`, `False` otherwise. -at : t -> Inequality t x o -at t = TimeGte t - --- | Given `t`, constructs a predicate that is `True` for time ≤ `t`, `False` otherwise. -upTo : t -> Inequality t x a -upTo t = TimeLte t - -infix 4 <= --- | Given observations `o1` and `o2`, constructs the predicate `o1 ≤ o2`. In order to use this, --- you must import this module qualified or hide the `(<=)` operator from `Prelude`. -(<=) : Observation t x o -> Observation t x o -> Inequality t x o -(<=) = curry Lte - --- | Reify the `Inequality` into an observation function. --- This function is used to convert an abstract predicate, e.g. `S ≤ 50.0` to the actual boolean --- observation function `t -> m Bool`. -compare : (Ord t, Ord x, Number x, Divisible x, CanAbort m) => - (o -> t -> m x) -> Inequality t x o -> t -> m Bool -compare doObserve (Lte (f, f')) t = liftA2 (Prelude.<=) (eval doObserve f t) (eval doObserve f' t) -compare _ (TimeGte s) t = pure $ t >= s -compare _ (TimeLte s) t = pure $ s >= t diff --git a/src/main/daml/ContingentClaims/Core/V3/Internal/Claim.daml b/src/main/daml/ContingentClaims/Core/V3/Internal/Claim.daml deleted file mode 100644 index 6d7201006..000000000 --- a/src/main/daml/ContingentClaims/Core/V3/Internal/Claim.daml +++ /dev/null @@ -1,156 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Core.V3.Internal.Claim - ( Claim(..) - , ClaimF(..) - , Electable - , Inequality(..) - ) where - -import ContingentClaims.Core.V3.Observation (Observation) -import DA.Foldable (Foldable(..)) -import DA.Text (intercalate, unwords) -import DA.Traversable (Traversable(..)) -import Daml.Control.Recursion (Corecursive(..), Recursive(..)) -import Prelude hiding (mapA, sequence) - --- | Core data type used to model cashflows of instruments. --- In the reference paper from Peyton-Jones this is called 'Contract'. --- We renamed it to avoid ambiguity. --- * `t` corresponds to the time parameter. --- * `x` corresponds to the `Observation` output type. An observation is a function from `t` to `x`. --- A common choice is to use `Time` and `Decimal`, respectively. --- * `a` is the representation of a deliverable asset, e.g. a `Text` ISIN code or --- an `InstrumentKey`. --- * `o` is the representation of an observable, e.g. a `Text`. --- --- You should build the `Claim` using the smart constructors (e.g. `zero`, `and`) instead of using --- the data constructors directly (`Zero`, `And`). -data Claim t x a o - = Zero - -- ^ Represents an absence of claims. Monoid `And` identity. - | One a - -- ^ The bearer acquires one unit of `a` *immediately*. - | Give (Claim t x a o) - -- ^ The obligations of the bearer and the counterparty are reversed. - | And with a1: Claim t x a o, a2: Claim t x a o, as: [Claim t x a o] - -- ^ Used to combine multiple rights together. - | Or with or1: Electable t x a o, or2: Electable t x a o, ors: [Electable t x a o] - -- ^ Gives the bearer the right to choose between several claims. - | Cond with predicate: Inequality t x o, success: Claim t x a o, failure: Claim t x a o - -- ^ Gives the bearer the right to the first claim if `predicate` is true, else the second - -- claim. - | Scale with k: Observation t x o, claim: Claim t x a o - -- ^ Multiplies the `claim` by `k` (which can be non-deterministic). - | When with predicate: Inequality t x o, claim: Claim t x a o - -- ^ Defers the acquisition of `claim` until *the first instant* that `predicate` is true. - | Anytime with predicate: Inequality t x o, electable: Electable t x a o - -- ^ Gives the bearer the right to enter a claim at any time the predicate is true. - | Until with predicate: Inequality t x o, claim: Claim t x a o - -- ^ Expires said claim on the *first instant* that `predicate` is true. - deriving (Eq) - --- | Type synonym for sub-trees that can be elected in an `Or` or `Anytime` node. --- The textual tag is used to identify each sub-tree when an election is made. -type Electable t x a o = (Text, Claim t x a o) - --- | HIDE --- Unfixed version of `Claim`, for use with `Daml.Control.Recursion`. -data ClaimF t x a o b - = ZeroF - | OneF a - | GiveF b - | AndF with a1: b, a2: b, as : [b] - | OrF with or1: ElectableF b, or2: ElectableF b, ors : [ElectableF b] - | CondF with predicate: Inequality t x o, success: b, failure: b - | ScaleF with k: Observation t x o, claim: b - | WhenF with predicate: Inequality t x o, claim: b - | AnytimeF with predicate: Inequality t x o, electable: ElectableF b - | UntilF with predicate: Inequality t x o, claim: b - deriving (Functor) - --- | HIDE Unfixed version of `Electable`. -type ElectableF b = (Text, b) - -instance Recursive (Claim t x a o) (ClaimF t x a o) where - project Zero = ZeroF - project (One a) = OneF a - project (Give c) = GiveF c - project (And c1 c2 cs) = AndF c1 c2 cs - project (Or c1 c2 cs) = (OrF c1 c2 cs) - project (Cond p c c') = CondF p c c' - project (Scale k c) = ScaleF k c - project (When p c) = WhenF p c - project (Anytime p e) = AnytimeF p e - project (Until p c) = UntilF p c - -instance Corecursive (Claim t x a o) (ClaimF t x a o) where - embed ZeroF = Zero - embed (OneF x) = One x - embed (GiveF a) = Give a - embed (AndF c c' cs) = And c c' cs - embed (OrF c c' cs) = (Or c c' cs) - embed (CondF p c c') = Cond p c c' - embed (ScaleF k c) = Scale k c - embed (WhenF p c) = When p c - embed (AnytimeF p e) = Anytime p e - embed (UntilF p c) = Until p c - -instance Foldable (ClaimF t x a o) where - foldr _ seed ZeroF = seed - foldr _ seed (OneF _) = seed - foldr f seed (GiveF c) = f c seed - foldr f seed (WhenF _ c) = f c seed - foldr f seed (ScaleF _ c) = f c seed - foldr f seed (AndF c c' cs) = Prelude.foldr f seed $ c :: c' :: cs - foldr f seed (OrF c c' cs) = Prelude.foldr f seed $ snd c :: snd c' :: fmap snd cs - foldr f seed (CondF _ c c') = f c $ f c' seed - foldr f seed (AnytimeF _ (_, c)) = f c seed - foldr f seed (UntilF _ c) = f c seed - -instance Traversable (ClaimF t x a o) where - sequence ZeroF = pure ZeroF - sequence (OneF asset) = pure $ OneF asset - sequence (GiveF fa) = GiveF <$> fa - sequence (WhenF p fa) = WhenF p <$> fa - sequence (ScaleF p fa) = ScaleF p <$> fa - sequence (AndF fa fa' fas) = AndF <$> fa <*> fa' <*> sequence fas - sequence (OrF (ta, fa) (ta', fa') fas) = - OrF <$> sequence (ta, fa) <*> sequence (ta', fa') <*> mapA sequence fas - sequence (CondF p fa fa') = CondF p <$> fa <*> fa' - sequence (AnytimeF p fa) = AnytimeF p <$> sequence fa - sequence (UntilF p fa) = UntilF p <$> fa - -instance (Show t, Show x, Show a, Show o) => Show (Claim t x a o) where - show = cata \case - ZeroF -> "Zero" - OneF a -> unwords ["One", show a] - GiveF s -> unwords ["Give", bracket s] - AndF s s' cs -> print3 "And" s s' cs - OrF s s' cs -> print3 "Or" (printElectable s) (printElectable s') $ fmap printElectable cs - CondF b s s' -> unwords ["Cond", bracket (show b), bracket s, bracket s'] - ScaleF x s -> print2 "Scale" x s - WhenF b s -> print2 "When" b s - AnytimeF b e -> print2 "Anytime" b $ printElectable e - UntilF b s -> print2 "Until" b s - where - printElectable (t, s) = t <> ": " <> s - print3 c s s' cs = unwords [c, bracket s, bracket s', "[" <> intercalate ", " cs <> "]"] - print2 c x s = unwords [c, bracket (show x), bracket s] - bracket "Zero" = "Zero" - bracket s = "(" <> s <> ")" - --- Inequality -- - --- | Data type for boolean predicates supported by the library. --- A boolean predicate is a generic function with signature `t -> Bool`. However, a limited --- set of predicates is currently supported. -data Inequality t x o - = TimeGte t - -- ^ `True` when `time ≥ t`, `False` otherwise. - | TimeLte t - -- ^ `True` when `time ≤ t`, `False` otherwise. - | Lte (Observation t x o, Observation t x o) - -- ^ `True` when `o(t) ≤ o'(t)`, `False` otherwise, for a pair of observations `o`, `o'`. - deriving (Eq, Show) diff --git a/src/main/daml/ContingentClaims/Core/V3/Observation.daml b/src/main/daml/ContingentClaims/Core/V3/Observation.daml deleted file mode 100644 index 1e6a2ba5d..000000000 --- a/src/main/daml/ContingentClaims/Core/V3/Observation.daml +++ /dev/null @@ -1,152 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Core.V3.Observation where - -import DA.Foldable (Foldable(..)) -import DA.Traversable (Traversable(..)) -import Daml.Control.Recursion (Corecursive(..), Recursive(..), cataM, embed, project) -import Prelude hiding (key, pure, (.)) -import qualified Prelude (pure) - --- | HIDE -type T = Observation - --- | Implementation of market observables. --- Conceptually it is helpful to think of this as the type `t -> x`, or `t -> Update x`. -data Observation t x o - = Const with value: x - -- ^ A numerical constant, e.g. `10.0`. - | Observe with key: o - -- ^ A named parameter, e.g. "LIBOR 3M". - | ObserveAt with key: o, t: t - -- ^ A named parameter, e.g. "LIBOR 3M", observed at an explicit point in time. - | Add (Observation t x o, Observation t x o) - -- ^ Sum of two observations. - | Neg (Observation t x o) - -- ^ Opposite of an observation. - | Mul (Observation t x o, Observation t x o) - -- ^ Product of two observations. - | Div (Observation t x o, Observation t x o) - -- ^ Division of two observations. - deriving (Eq, Functor) - --- | HIDE -data ObservationF t x o b - = ConstF with value: x - | ObserveF with key: o - | AddF (b, b) - | NegF (b) - | MulF (b, b) - | DivF (b, b) - | ObserveAtF with key: o, t: t - deriving (Eq, Show, Functor) - -instance Recursive (Observation t x o) (ObservationF t x o) where - project (Const value) = ConstF value - project (Observe key) = ObserveF key - project (ObserveAt key t) = ObserveAtF key t - project (Add (x, x')) = AddF (x, x') - project (Neg x) = NegF x - project (Mul (x, x')) = MulF (x, x') - project (Div (x, x')) = DivF (x, x') - -instance Corecursive (Observation t x o) (ObservationF t x o) where - embed (ConstF value) = Const value - embed (ObserveF key) = Observe key - embed (ObserveAtF key t) = ObserveAt key t - embed (AddF (x, x')) = Add (x, x) - embed (NegF x) = Neg x - embed (MulF (x, x')) = Mul (x, x') - embed (DivF (x, x')) = Div (x, x') - --- | Smart constructor for `Const`. Lifts a constant to an observation. -pure : x -> Observation t x o -pure = Const - --- | Smart constructor for `Observe`. Looks up the value of `o`. -observe : o -> Observation t x o -observe = Observe - --- | Reify the `Observation` into an observation function. --- This function is used to convert an abstract observation, e.g. `LIBOR 3M + 0.005` to the actual --- observation function `t -> m x`. -eval : (Ord t, Number x, Divisible x, CanAbort m) - => (o -> t -> m x) -> Observation t x o -> t -> m x -eval doObserve obs t = cataM alg obs - where - alg = \case - ConstF x -> Prelude.pure x - ObserveF key -> doObserve key t - ObserveAtF key t' | t' > t -> abort "Trying to observe in the future." - ObserveAtF key t' -> doObserve key t' - AddF (x, x') -> Prelude.pure $ x Prelude.+ x' - NegF x -> Prelude.pure $ negate x - MulF (x, x') -> Prelude.pure $ x * x' - DivF (x, x') -> Prelude.pure $ x / x' - --- | The functor map operation _and_ also map any parameters to keys. --- For example, could map the param "spot" to an ISIN code "GB123456789". --- Also contra-maps time parameter, i.e. from relative time values to absolute ones. --- --- @ mapParams identity = bimap --- -mapParams : (i -> t) - -> (o -> o') - -> (x -> x') - -> Observation i x o -> Observation t x' o' -mapParams h g f = cata \case - ConstF x -> Const (f x) - ObserveF key -> Observe (g key) - ObserveAtF key i -> ObserveAt (g key) (h i) - AddF (b, b') -> Add (b, b') - NegF b -> Neg b - MulF (b, b') -> Mul (b, b') - DivF (b, b') -> Div (b, b') - -instance Additive x => Additive (Observation t x o) where - aunit = Const aunit - (+) = curry Add - negate = Neg - -instance Multiplicative x => Multiplicative (Observation t x o) where - munit = Const munit - (*) = curry Mul - x ^ 0 = munit - x ^ 1 = x - x ^ 2 = x * x - x ^ _ = error "Observation: power operator < 0 and > 2 not implemented" - -instance (Additive x, Multiplicative x) => Number (Observation t x o) where - -instance Multiplicative x => Divisible (Observation t x o) where - (/) = curry Div - -instance Foldable (ObservationF t x o) where - foldr f seed (ConstF _) = seed - foldr f seed (ObserveF _) = seed - foldr f seed (ObserveAtF _ _) = seed - foldr f seed (NegF b) = f b seed - foldr f seed (AddF (b, b')) = f b $ f b' seed - foldr f seed (MulF (b, b')) = f b $ f b' seed - foldr f seed (DivF (b, b')) = f b $ f b' seed - -instance Traversable (ObservationF t x o) where - sequence (ConstF x) = Prelude.pure $ ConstF x - sequence (ObserveF key) = Prelude.pure $ ObserveF key - sequence (ObserveAtF key t) = Prelude.pure $ ObserveAtF key t - sequence (NegF m) = NegF <$> m - sequence (AddF (m, m')) = curry AddF <$> m <*> m' - sequence (MulF (m, m')) = curry MulF <$> m <*> m' - sequence (DivF (m, m')) = curry DivF <$> m <*> m' - -instance (Show t, Show x, Show o) => Show (Observation t x o) where - show = cata \case - ConstF x -> "Const " <> show x - ObserveF a -> "Observe " <> show a - ObserveAtF a t -> "Observe " <> show a <> "at " <> show t - AddF ss -> pair "Add" ss - NegF s -> "Neg (" <> s <> ")" - MulF ss -> pair "Mul" ss - DivF ss -> pair "Div" ss - where pair o (s, s') = o <> " (" <> s <> ", " <> s' <> ")" diff --git a/src/main/daml/ContingentClaims/Core/V3/Util/Recursion.daml b/src/main/daml/ContingentClaims/Core/V3/Util/Recursion.daml deleted file mode 100644 index 63623e6ea..000000000 --- a/src/main/daml/ContingentClaims/Core/V3/Util/Recursion.daml +++ /dev/null @@ -1,91 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# OPTIONS -Wno-deprecations #-} -- To supress 'Monad' warnings - --- | This module collects a set of utilities used to execute recursion schemes. --- The morphisms ending in 'M' are monadic variants, allowing to interleave, e.g., `Update` or --- `Script`. `cataM` after Tim Williams' talk, https://www.youtube.com/watch?v=Zw9KeP3OzpU. -module ContingentClaims.Core.V3.Util.Recursion ( - anaM - , apoCataM - , apoM - , funzip - , futuM - , ghyloM - , hyloM - , inherit - , paraM - , synthesize -) where - -import DA.Traversable (Traversable, mapA, sequence) -import Daml.Control.Arrow (Kleisli(..), (&&&), (<<<), (>>>), (|||)) -import Daml.Control.Comonad (Comonad(..)) -import Daml.Control.Recursion (Cofree(..), Corecursive(..), Free(..), Recursive(..)) -import Prelude hiding (mapA, sequence, sum) - --- | Monadic paramorphism. -paraM : (Monad m, Traversable f, Recursive b f) => (f (b, a) -> m a) -> b -> m a -paraM f b = - (project >>> fmap (runKleisli $ Kleisli pure &&& Kleisli (paraM f)) >>> ((>>= f) . sequence)) b - --- | Monadic anamorphism. -anaM : (Monad m, Traversable f, Corecursive b f) => (a -> m (f a)) -> a -> m b -anaM f a = (fmap embed <<< (>>= mapA (anaM f)) <<< f) a - --- | Monadic apomorphism. -apoM : (Monad m, Traversable f, Corecursive b f) => (a -> m (f (Either b a))) -> a -> m b -apoM f a = (fmap embed <<< (>>= (mapA (pure ||| apoM f))) <<< f) a - --- | Monadic futumorphism. -futuM : (Monad m, Traversable f, Corecursive b f) => (a -> m (f (Free f a))) -> a -> m b -futuM f a = (fmap embed <<< (>>= (mapA (futuM' f))) <<< f) a - --- | HIDE --- mutually recursive helper function for futuM. -futuM' : (Monad m, Traversable f, Corecursive b f) => (a -> m (f (Free f a))) -> Free f a -> m b -futuM' f (Pure a) = futuM f a -futuM' f (Free as) = fmap embed . mapA (futuM' f) $ as - --- | Monadic lazy unfold (apoM) followed by a fold (cata). --- This Specialised lazy re-fold is used by `lifecycle`. -apoCataM : (Monad m, Traversable f, Corecursive b f) => - (f b -> b) -> (a -> m (f (Either b a))) -> a -> m b -apoCataM g f a = (fmap g <<< (>>= (mapA (pure ||| apoCataM g f))) <<< f) a - --- | A modified `hylo` (refold), whith an interleaved monad effect (typically `Update`). -hyloM : (Traversable f, Monad n) => (f b -> b) -> (a -> n (f a)) -> a -> n b -hyloM f g a = (fmap f <<< (>>= mapA (hyloM f g)) <<< g) a - --- | Generalised hylomorphism (with monadic unfold). -ghyloM : (Comonad w, Traversable f, Monad m, Traversable m, Monad n) - => (forall c . f (w c) -> w (f c)) - -> (forall d . m (f d) -> f (m d)) - -> (f (w b) -> b) - -> (a -> n (f (m a))) - -> a - -> n b -ghyloM w m f g a = (fmap f <<< (>>= mapA (hyloM alg coalg)) <<< g) a where - coalg = fmap g >>> sequence >>> fmap m >>> fmap (fmap join) - alg = fmap f <<< w <<< fmap duplicate - --- | Functor unzip. -funzip : Functor f => f (a, b) -> (f a, f b) -funzip = fmap fst &&& fmap snd - --- | Annotate a recursive type bottom-up. -synthesize : (Functor f, Recursive b f) => (f attr -> attr) -> b -> Cofree f attr -synthesize f = cata algebra where - -- alg : f (Cofree f a) -> Cofree f a - algebra = uncurry Cofree . ((f <<< fmap (.attribute)) &&& identity) - --- | Annotate a recursive type top-down. -inherit : (Functor f, Corecursive b f, Recursive b f) => - (b -> attr -> attr) -> attr -> b -> Cofree f attr -inherit g seed b = para algebra b seed where - -- f (b, attr -> Cofree f attr) -> attr -> Cofree f attr - algebra gbg attr = Cofree attr' f' where - (fb, ff) = funzip gbg - attr' = g (embed fb) attr - f' = fmap ($ attr') ff diff --git a/src/main/daml/ContingentClaims/Lifecycle/V3/Lifecycle.daml b/src/main/daml/ContingentClaims/Lifecycle/V3/Lifecycle.daml deleted file mode 100644 index 9c931c69c..000000000 --- a/src/main/daml/ContingentClaims/Lifecycle/V3/Lifecycle.daml +++ /dev/null @@ -1,254 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Lifecycle.V3.Lifecycle ( - Pending(..) - , Result(..) - , acquire' - , exercise - , exercise' - , expire' - , fixAcquisitionTime' - , lifecycle - , lifecycle' -) where - -import ContingentClaims.Core.V3.Claim (Inequality(..), compare) -import ContingentClaims.Core.V3.Internal.Claim (Claim(..), ClaimF(..)) -import ContingentClaims.Core.V3.Observation qualified as Observation -import ContingentClaims.Core.V3.Util.Recursion (apoCataM) -import ContingentClaims.Lifecycle.V3.Util (pruneZeros') -import DA.Traversable (sequence) -import Daml.Control.Arrow ((&&&), (|||)) -import Daml.Control.Monad.Trans.Class (lift) -import Daml.Control.Monad.Trans.Writer (WriterT, runWriterT) -import Daml.Control.Monad.Writer.Class (MonadWriter(..)) -import Daml.Control.Recursion (project) -import Prelude hiding (compare, exercise, sequence) - -type F t a o = ClaimF t Decimal a o --- CLAIMS_LIFECYCLE_BEGIN -type C t a o = Claim t Decimal a o - --- | Used to specify pending payments. -data Pending t a = Pending - with - t : t - -- ^ Payment time. - amount : Decimal - -- ^ Amount of asset to be paid. - asset : a - -- ^ Asset in which the payment is denominated. - deriving (Eq, Show) - --- | Returned from a `lifecycle` operation. -data Result t a o = Result - with - pending : [Pending t a] - -- ^ Payments requiring settlement. - remaining : C t a o - -- ^ The tree after lifecycled branches have been pruned. - deriving (Eq, Show) - --- | Collect claims falling due into a list, and return the tree with those nodes pruned. --- `m` will typically be `Update`. It is parametrised so it can be run in a `Script`. The first --- argument is used to lookup the value of any `Observables`. Returns the pruned tree + pending --- settlements up to the provided market time. -lifecycle : (Ord t, Eq a, CanAbort m) - => (o -> t -> m Decimal) - -- ^ Function to evaluate observables. - -> C t a o - -- ^ The input claim. - -> t - -- ^ The input claim's acquisition time. - -> t - -- ^ The current market time. This is the time up to which observations are known. - -> m (Result t a o) --- CLAIMS_LIFECYCLE_END -lifecycle _ claim acquisitionTime today | acquisitionTime > today = - pure Result with pending = []; remaining = claim -lifecycle spot claim acquisitionTime today - = fmap (uncurry $ flip Result) - . runWriterT - . apoCataM pruneZeros' acquireThenSettle - . (1.0, ) -- initial scaling factor - $ (acquisitionTime, claim) - where - acquireThenSettle = - (lifecycle' spot =<<) - . lift - . sequence - . fmap (sequence . (fst &&& effectfulAcquire)) - effectfulAcquire = fmap (expire' . fixAcquisitionTime') <$> acquire' spot today - --- | Helper type synonym used to write apomorphisms on a claim. --- `Left` is used if unfolding shall not continue. Otherwise, `Right` is used. The generic type --- parameter `x` is the carrier of the R-CoAlgebra (typically the sub-tree as well as some --- additional information). -type FE t a o x = F t a o (Either (C t a o) x) - --- | Acquired claim (in functor form). --- Acquired sub-trees are marked with `Right`, non-acquired sub-trees are marked with `Left`. The --- acquisition time is attached to acquired sub-trees. -type Acquired t a o = FE t a o (t, C t a o) - --- | HIDE --- Evaluate observables and skip branches for which predicates don't hold, calculate the acquisition --- time of the claim's sub-trees. This is useless on its own. Composed with other functions, it adds --- laziness. -acquire' : (Ord t, Eq a, CanAbort m) - => (o -> t -> m Decimal) - -- ^ Function to evaluate observables. - -> t - -- ^ The current market time. This is the time up to which observations are known. - -> (t, C t a o) - -- ^ Input claim in functor form and its acquisition time. - -> m (Acquired t a o) -acquire' _ t (s, _) | s > t = - abort "Acquisition time of contract is after the provided market time." -acquire' _ _ (s, When (TimeLte t) c) = - pure $ WhenF (TimeLte t) if t < s then Left c else Right (s, c) -acquire' spot t (s, When obs c) = do - predicate <- compare spot obs t - pure . WhenF obs $ if predicate then - let - -- new acquisition time - sNew = - case obs of - TimeLte _ -> s - TimeGte τ -> max s τ - Lte _ -> - -- if the predicate is non-deterministic, we assume that we are lifecycling at a time - -- `t` corresponding to the first instant in which the predicate becomes True. - t - in - Right (sNew, c) - else - Left c -acquire' spot today (s, Cond obs c c') = do - predicate <- compare spot obs s - pure if predicate then - CondF obs (Right (s, c)) (Left c') - else - CondF obs (Left c) (Right (s, c')) -acquire' spot today (_, Anytime obs e) = do - predicate <- compare spot obs today - pure . AnytimeF obs $ if predicate then - -- the acquisition time of an Anytime node is assumed to be the time at which we lifecycle - Right . (today,) <$> e - else - Left <$> e -acquire' _ _ (s, Until (TimeLte t) c) | s <= t = - -- if the contract is acquired before t, the predicate is immediately True - pure $ Left <$> UntilF (TimeLte t) c -acquire' spot today (s, Until obs c) = do - -- we assume that the predicate inside `Until` has not been met before `t` - predicate <- compare spot obs today - pure . UntilF obs $ if predicate then Left c else Right (s, c) -acquire' _ _ (s, other) = pure $ Right . (s, ) <$> project other - --- | HIDE --- Replace sub-trees that will never be acquired with `Zero`. -expire' : (Ord t, Eq a) => Acquired t a o -> Acquired t a o -expire' (WhenF (TimeLte t) (Left _)) = ZeroF -expire' (AnytimeF (TimeLte t) (_, Left _)) = ZeroF -expire' (UntilF _ (Left _)) = ZeroF -expire' (CondF pred (Right c) _) = CondF pred (Right c) (Left Zero) -expire' (CondF pred _ (Right c)) = CondF pred (Left Zero) (Right c) -expire' other = other - --- | HIDE --- Replace acquired `When pred c` nodes with `When (TimeGte t) c` when the predicate is --- non-deterministic. -fixAcquisitionTime' : (Ord t, Eq a) => Acquired t a o -> Acquired t a o -fixAcquisitionTime' (WhenF (Lte _) (Right (s, c))) = WhenF (TimeGte s) $ Right (s, c) -fixAcquisitionTime' other = other - --- | Carrier type used for `lifecycle`. It consists of a claim, its acquisition time and the --- accumulated scaling factor. -type LifecycleCarrier t a o = (Decimal, (t, C t a o)) - --- | HIDE --- Evaluate any observables in `Scale` nodes, accumulating scale factors top-down. Log the scale --- factors with their corresponding leaf values. Stop recursion at `Or` and `Anytime` branches, --- guaranteeing liveness. Replace any Ones that can be reached with Zeros. -lifecycle' : (Ord t, CanAbort m) - => (o -> t -> m Decimal) - -> (Decimal, (t, Acquired t a o)) - -- ^ the acquired input claim, its acquisition time and the accumulated scaling factor - -> WriterT [Pending t a] m (FE t a o (LifecycleCarrier t a o)) -lifecycle' _ (qty, (s, OneF asset)) = do - tell [Pending s qty asset] - pure $ ZeroF -lifecycle' _ (qty, (_, GiveF c)) = - pure . GiveF $ (-qty, ) <$> c -lifecycle' spot (qty, (s, ScaleF obs c)) = do - k <- lift $ Observation.eval spot obs s - pure . ScaleF obs $ (k * qty, ) <$> c -lifecycle' _ (_, (_, c@OrF{})) = - pure $ stop c - where stop = fmap $ Left . (identity ||| snd) -lifecycle' _ (_, (_, c@(AnytimeF {}))) = - pure $ stop c - where stop = fmap $ Left . (identity ||| snd) -lifecycle' _ (qty, (_, other)) = pure $ fmap (qty, ) <$> other - --- | Acquire `Anytime` and `Or` nodes, by making an election. --- Import this `qualified` to avoid clashes with `Prelude.exercise`. -exercise : (Ord t, Eq a, Eq o, CanAbort m) - => (o -> t -> m Decimal) - -- ^ function to evaluate observables - -> (Bool, Text) - -- ^ the election being made - -> C t a o - -- ^ the input claim - -> t - -- ^ the input claim's acquisition time - -> t - -- ^ the election date - -> m (C t a o) -exercise _ _ claim acquisitionTime today | acquisitionTime > today = pure claim -exercise spot election claim acquisitionTime today = - apoCataM pruneZeros' acquireThenExercise - . (True, ) -- initial election authorizer (`True = bearer`) - $ (acquisitionTime, claim) - where - acquireThenExercise = - fmap (exercise' election today) - . sequence - . fmap (sequence . (fst &&& acquire' spot today)) - --- | Carrier type used for `exercise`. It consists of a claim, its acquisition time and a flag --- keeping track of who is the entitled to the election (`True = bearer`). -type ExerciseCarrier t a o = (Bool, (t, C t a o)) - --- | HIDE --- Resolve `Or` nodes by removing them (keeping elected subtrees). Fix acquisition time of exercised --- `Anytime` nodes by replacing them with `When (TimeGte t)`. The election consists of a boolean --- representing the authorizer (`True = bearer`), and a tag identifying the sub-tree being chosen. -exercise' : (Eq t, Eq a, Eq o) - => (Bool, Text) - -- ^ the election being made - -> t - -- ^ the election date - -> (Bool, (t, Acquired t a o)) - -- ^ the acquired claim, its acquisition time and a flag keeping track of who is the entitled to - -- the election (`True = bearer`) - -> FE t a o (ExerciseCarrier t a o) -exercise' _ _ (isBearer, (_, GiveF c)) = GiveF $ (not isBearer, ) <$> c -exercise' (elector, election) t (isBearer, (_, ors@OrF {})) = - case snd <$> find (\x -> fst x == election) elections of - Some (Right (s, e)) | t == s && elector == isBearer - -> Left <$> project e - _ -> stop ors - where - stop = fmap $ Left . (identity ||| snd) - elections = ors.or1 :: ors.or2 :: ors.ors -exercise' (elector, election) t (isBearer, (_, f@(AnytimeF {}))) = - case snd f.electable of - Right (s, e) | fst f.electable == election && s == t && elector == isBearer - -> Left <$> WhenF (TimeGte s) e - _ -> stop f - where - stop = fmap $ Left . (identity ||| snd) -exercise' _ _ (isBearer, (_, other)) = fmap (isBearer, ) <$> other diff --git a/src/main/daml/ContingentClaims/Lifecycle/V3/Util.daml b/src/main/daml/ContingentClaims/Lifecycle/V3/Util.daml deleted file mode 100644 index 65264b765..000000000 --- a/src/main/daml/ContingentClaims/Lifecycle/V3/Util.daml +++ /dev/null @@ -1,83 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This module defines a set of utility functions to extract information from claim trees. -module ContingentClaims.Lifecycle.V3.Util ( - expiry - , fixings - , isZero - , payoffs - , pruneZeros - , pruneZeros' -) where - -import ContingentClaims.Core.V3.Internal.Claim (Claim(..), ClaimF(..), Inequality(..)) -import ContingentClaims.Core.V3.Observation (Observation) -import DA.Bifunctor (first) -import DA.Foldable (all, fold, maximum) -import Daml.Control.Recursion (Corecursive(..), Recursive(..)) -import Prelude hiding (all, mapA, sequence, sum) - --- | Return the fixing dates of a claim. This does not discriminate between optional dates which --- *may* result from a condition, and outright fixings. It also does not correctly account for --- malformed trees, where subtrees are orphaned due to impossible `When` statements, e.g., --- `When (t > 1) ((When t < 1) _)`. -fixings : Claim t x a o -> [t] -fixings = cata fixings' - --- | Algebra for `fixings`. -fixings' : ClaimF t x a o [t] -> [t] -fixings' (WhenF (TimeGte t) ts) = t :: ts -fixings' claim = fold claim - --- | Return the time after which the claim is worthless, i.e., value = 0, if such a time exists. --- Also known as 'maturity' or 'horizon' in the Eber/Jones paper. -expiry : Ord t => Claim t x a o -> Optional t -expiry c = case fixings c of - [] -> None - ts -> Some . maximum $ ts - --- | Return a list of possible scale-factor/payoff pairs. --- This does not discriminate between conditional and outright payoffs. -payoffs : (Eq t, Eq x, Eq o, Multiplicative x) => Claim t x a o -> [(Observation t x o, a)] -payoffs = fmap (first ($ munit)) . cata payoffs' - --- | Algebra for `payoffs`. This also applies 'multiplication by one' identity, -payoffs' : (Eq t, Eq x, Eq o, Multiplicative x) => - ClaimF t x a o [(Observation t x o -> Observation t x o, a)] -> - [(Observation t x o -> Observation t x o, a)] -payoffs' ZeroF = [] -payoffs' (OneF a) = [(identity, a)] -payoffs' (ScaleF k fs) = first multK <$> fs where - multK f x | x == munit = f k -- prune unit - multK f x = f (x * k) -payoffs' other = fold other - --- | Prunes sub-trees which are `Zero`. -pruneZeros : Claim t x a o -> Claim t x a o -pruneZeros = cata pruneZeros' - --- | HIDE --- Algebra for `pruneZeros`. N.b. the `Or` case : we only reduce the case when all elements are --- `Zero`. It's incorrect to remove a single `Or` (as this would remove a choice for 'inaction' from --- the bearer - think option lapse). However, we don't handle the case for `Or > 1`, as this can be --- unintuitive (although semantically correct); this may change in the future, so don't rely on this --- behaviour. -pruneZeros' : ClaimF t x a o (Claim t x a o) -> Claim t x a o -pruneZeros' (ScaleF _ Zero) = Zero -pruneZeros' (GiveF Zero) = Zero -pruneZeros' (AndF c c' cs) = case filter (not . isZero) (c :: c' :: cs) of - [] -> Zero - [c] -> c - c :: c' :: cs -> And c c' cs -pruneZeros' (WhenF _ Zero) = Zero -pruneZeros' (CondF _ Zero Zero) = Zero -pruneZeros' ors@OrF{} | isZero `all` ors = Zero -pruneZeros' (UntilF _ Zero) = Zero -pruneZeros' (AnytimeF _ (_, Zero)) = Zero -pruneZeros' other = embed other - --- | Checks if a claim is the `Zero` claim. --- This avoids requiring the equality type constraint on `a`. -isZero Zero = True -isZero _ = False diff --git a/src/main/daml/ContingentClaims/Valuation/V0/MathML.daml b/src/main/daml/ContingentClaims/Valuation/V0/MathML.daml deleted file mode 100644 index 813368a7e..000000000 --- a/src/main/daml/ContingentClaims/Valuation/V0/MathML.daml +++ /dev/null @@ -1,138 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Valuation.V0.MathML ( - ToXml, - presentation -) where - -import ContingentClaims.Valuation.V0.Stochastic (Expr, ExprF(..)) -import DA.Date (toGregorian) -import DA.Foldable (foldMap, foldr1) -import DA.Map (Map, insert, toList) -import DA.Text (intercalate, wordsBy) -import Daml.Control.Recursion (Cofree(..), Corecursive(..), Recursive(..)) -import Prelude hiding (elem, null) - -type Attrs = Map Text Text - -data Xml - = Elem { attributes : Attrs, name : Text, content: [Xml] } - | Leaf Text - deriving (Eq) - -instance Show Xml where - show Elem{attributes, name, content} = - "<" <> name <> as <> ">" <> (foldMap show content) <> " name <> ">" - where as = (<>) " " . intercalate ";" . fmap (\(k, v) -> k <> "=" <> v) . toList $ attributes - show (Leaf t) = t - -data XmlF x - = ElemF { attributes : Attrs, name : Text, content: [x] } - | LeafF Text - deriving (Show, Eq, Functor) - -instance Corecursive Xml XmlF where - embed ElemF{..} = Elem with .. - embed (LeafF a) = Leaf a - -instance Recursive Xml XmlF where - project Elem{..} = ElemF with .. - project (Leaf a) = LeafF a - --- | Renders an `Expr` into MathML presentation format. -class ToXml a where - presentation : a -> Xml - --- | Supports LaTeX-style use of underscore for subscript. -instance ToXml Text where - presentation = foldr1 msub . fmap mi . wordsBy (\case "_" -> True; _ -> False) - -instance ToXml Date where - presentation d = case toGregorian d of - (yyyy, mm, dd) -> mi $ show dd <> " " <> show mm <> " " <> show yyyy - -instance ToXml Decimal where - presentation = mn . show - -instance ToXml t => ToXml (Expr t) where - presentation = math . histo \case - ConstF a -> [mn $ show a] - ProcF name _f t -> [mi name `msub` presentation t] - SupF t τ x -> (mo "Sup" `msub` mfenced "{" "}" bound) :: mo "⁡" :: x.attribute - where bound = [presentation t, mo "≤", presentation τ] - IdentF t -> [presentation t] - SumF xs -> foldr add [] xs - where add (Cofree _ (NegF x)) xs = mo "-" :: x.attribute <> xs - add x xs = mo "+" :: x.attribute <> xs - NegF x -> mo "-" :: x.attribute - MulF (Cofree _ (PowF denom (Cofree _ (NegF (Cofree _ (ConstF 1.0)))))) num -> - [mfrac num.attribute denom.attribute] - MulF x (Cofree s (SumF _)) -> x.attribute ++ [mo "⁢" , mfenced "(" ")" s ] - MulF (Cofree s (SumF _)) x -> mfenced "(" ")" s :: mo "⁢" :: x.attribute - MulF x (Cofree s (NegF _)) -> x.attribute ++ [mo "×"] ++ s - MulF (Cofree s (ConstF _)) x -> s ++ [mo "×"] ++ x.attribute - MulF x (Cofree s (ConstF _)) -> x.attribute ++ [mo "×"] ++ s - MulF x x' -> x.attribute ++ [mo "⁢"] ++ x'.attribute - PowF x i -> [mrow x.attribute `msup` mrow i.attribute] - I_F x x' -> [mo "I" `msub` mrow (x.attribute ++ [mo "≤"] ++ x'.attribute)] - E_F x t -> [ mo "𝔼" - , mo "⁡" - , mfenced "[" "]" (x.attribute ++ [mo "|", curlyF `msub` presentation t])] - where curlyF = Elem (just "mathvariant" "script") "mo" (text "F") - -just : Text -> Text -> Attrs -just k v = insert k v mempty - --- | An element with no attributes -elem : Text -> [Xml] -> Xml -elem = Elem mempty - --- | A leaf node, text content -text : Text -> [Xml] -text t = [Leaf t] - --- | Top-level math element -math : [Xml] -> Xml -math content = Elem (just "display" "block") "math" content - --- | identifier -mi : Text -> Xml -mi = elem "mi" . text - --- | operator -mo : Text -> Xml -mo = elem "mo" . text - --- | number -mn : Text -> Xml -mn = elem "mn" . text - --- | text -mtext : Text -> Xml -mtext = elem "mtext" . text - --- | string literal -ms : Text -> Xml -ms = elem "ms" . text - --- | subscript -msub : Xml -> Xml -> Xml -msub base subscript = elem "msub" [base, subscript] - --- | subperscript -msup : Xml -> Xml -> Xml -msup base superscript = elem "msup" [base, superscript] - --- | fraction -mfrac : [Xml] -> [Xml] -> Xml -mfrac numerator denominator = elem "mfrac" [mrow numerator, mrow denominator] - -mrow : [Xml] -> Xml -mrow = elem "mrow" - --- | A helper function for rendering parentheses. -mfenced : Text -> Text -> [Xml] -> Xml -mfenced open close ctx = - mrow $ [ Elem (just "fence" "true") "mo" (text open)] ++ ctx ++ - [Elem (just "fence" "true") "mo" (text close)] diff --git a/src/main/daml/ContingentClaims/Valuation/V0/Stochastic.daml b/src/main/daml/ContingentClaims/Valuation/V0/Stochastic.daml deleted file mode 100644 index a72d97de6..000000000 --- a/src/main/daml/ContingentClaims/Valuation/V0/Stochastic.daml +++ /dev/null @@ -1,264 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- Mathematical expression, derived from `Claim`, used for pricing - -module ContingentClaims.Valuation.V0.Stochastic ( - Expr(..) - , ExprF(..) - , IsIdentifier(..) - , Process(..) - , fapf - , gbm - , riskless - , simplify - , unitIdentity -) where - -import ContingentClaims.Core.V3.Internal.Claim (Claim(..), Inequality(..)) -import ContingentClaims.Core.V3.Observation qualified as O -import ContingentClaims.Core.V3.Util.Recursion (futuM) -import DA.Foldable (Foldable(..)) -import DA.Traversable (Traversable(..)) -import Daml.Control.Arrow ((|||)) -import Daml.Control.Monad.State.Class (get, put) -import Daml.Control.Monad.Trans.State (evalState) -import Daml.Control.Recursion (Corecursive(..), Free(..), Recursive(..)) -import Prelude hiding (Time, const, mapA, sequence) - --- | A stochastic processes. Currently this represents a Geometric Browniam Motion, i.e., --- dX / X = α dt + β dW. Eventually, we wish to support other processes such as Levy. -data Process t = Process { dt : Expr t, dW: Expr t } deriving (Show, Eq) - --- | Helper function to create a riskless process `dS = r dt`. -riskless : t -> Process t -riskless r = Process { dt = Ident r, dW = Const 0.0 } - --- | Helper function to create a geometric BM `dS = μ dt + σ dW`. -gbm : t -> t -> Process t -gbm μ σ = Process { dt = Ident μ, dW = Ident σ } - --- | Base functor for `Expr`. Note that this is ADT is re-used in a couple of places, e.g., --- `Process`, where however not every choice is legal and will lead to a partial evaluator. -data ExprF t x - = ConstF Decimal - | IdentF t - | ProcF { name : Text, process: Process t, filtration : t } - | SupF { lowerBound: t, tau: t, rv : x } - | SumF [x] - | NegF x - | MulF { lhs: x, rhs: x } - | PowF { lhs: x, rhs: x } - | I_F { lhs : x, rhs: x } - | E_F { rv : x, filtration: t } - deriving (Functor) - --- | Represents an expression of t-adapted stochastic processes. -data Expr t - = Const Decimal - | Ident t - | Proc { name : Text, process : Process t, filtration : t } - | Sup { lowerBound: t, tau: t, rv : Expr t } - | Sum [Expr t] - | Neg (Expr t) - | Mul (Expr t, Expr t) - | Pow (Expr t, Expr t) - | I (Expr t , Expr t) - | E { rv : Expr t, filtration: t } - deriving (Show, Eq) - -instance Recursive (Expr t) (ExprF t) where - project (Const d) = ConstF d - project (Ident s) = IdentF s - project Proc{..} = ProcF with .. - project Sup{..} = SupF with .. - project (Sum xs) = SumF xs - project (Neg x) = NegF x - project (Mul (x, x')) = MulF x x' - project (Pow (x, x')) = PowF x x' - project (I (x, x')) = I_F x x' - project E{..} = E_F with .. - -instance Corecursive (Expr t) (ExprF t) where - embed (ConstF d) = Const d - embed (IdentF s) = Ident s - embed ProcF{..} = Proc with .. - embed SupF{..} = Sup with .. - embed (SumF xs) = Sum xs - embed (NegF x) = Neg x - embed (MulF x x') = Mul (x, x') - embed (PowF x x') = Pow (x, x') - embed (I_F x x') = I (x, x') - embed E_F{..} = E with .. - -class IsIdentifier t where - -- | Produce a local identifier of type `t`, subindexed by `i`. - localVar : Int -> t - -instance Foldable (ExprF t) where - foldMap f (ConstF _) = mempty - foldMap f (IdentF _) = mempty - foldMap f (ProcF {}) = mempty - foldMap f (SupF _ _ x) = f x - foldMap f (SumF xs) = foldMap f xs - foldMap f (NegF x) = f x - foldMap f (MulF x x') = f x <> f x' - foldMap f (PowF x x') = f x <> f x' - foldMap f (I_F x x') = f x <> f x' - foldMap f (E_F x t) = f x - -instance Traversable (ExprF t) where - sequence (ConstF d) = pure $ ConstF d - sequence (IdentF t) = pure $ IdentF t - sequence (ProcF {..}) = pure $ ProcF {..} - sequence (SupF t τ fa) = SupF t τ <$> fa - sequence (SumF [fa]) = (\a -> SumF [a]) <$> fa - sequence (SumF (fa :: fas)) = s <$> fa <*> sequence fas - where s a as = SumF (a :: as) - sequence (SumF []) = error "Traversable ExprF: sequence empty SumF" - sequence (NegF fa) = NegF <$> fa - sequence (MulF fa fa') = MulF <$> fa <*> fa' - sequence (PowF fa fa') = PowF <$> fa <*> fa' - sequence (I_F fa fa') = I_F <$> fa <*> fa' - sequence (E_F fa t) = flip E_F t <$> fa - --- | Converts a `Claim` into the Fundamental Asset Pricing Formula. The ϵ expressions are defined as --- E1-E10 in the Eber/Peyton-Jones paper. --- This is still an experimental feature. -fapf : (Eq a, Show a, Show o, IsIdentifier t) - => a - -- ^ Currency in which the value process is expressed. - -> (a -> Process t) - -- ^ Maps a currency to the corresponding discount factor process. - -> (a -> a -> Process t) - -- ^ Given an asset and a currency, it returns the value process of the asset expressed in - -- units of currency. - -> (o -> Process t) - -- ^ Given an observable, it returns its value process. - -> t - -- ^ The today date. - -> Claim t Decimal a o -> Expr t -fapf ccy disc exch val today = flip evalState 0 . futuM coalg . Left . (, today) where - -- coalg : (Either (Claim, t) (Observable, t)) -> - -- State Int (ExprF t (Free (ExprF t) (Either (Claim, t) (Observation, t)))) - coalg = ϵ ||| υ - -- ϵ : (Claim, t) -> State Int (ExprF t (Free (ExprF t) (Claim, t))) - ϵ (Zero, _) = pure $ ConstF zero - ϵ (One asset, t) = pure $ exch' asset ccy t - ϵ (Give c, t) = pure . NegF . claim $ (c, t) - ϵ (Scale k c, t) = pure $ obs (k, t) `MulF` claim (c, t) - ϵ (And c c' cs, t) = pure . SumF $ fmap (claim . (, t)) (c :: c' :: cs) - ϵ (Or (_, c) (_, c') [], t) = pure $ SumF [ - -- FIXME: handle nested ors; consider writing in nCr form. - (ind (claim (c , t)) (claim (c', t)) * claim (c , t)), - (ind (claim (c', t)) (claim (c , t)) * claim (c', t)) - ] - ϵ (Cond (TimeGte t') c c', t) = pure $ SumF [ -- FIXME: both conditions are true when t == t' - (ind (id t) (id t') * claim (c, t)), - (ind (id t') (id t) * claim (c' ,t)) - ] - ϵ (Cond (Lte (x, x')) c c', t) = pure $ SumF [ - (ind (obs (x, t)) (obs (x', t)) * claim (c, t)), - (ind (obs (x', t)) (obs (x, t)) * claim (c', t)) - ] - ϵ (When (TimeGte t') c, t) = pure $ disc' ccy t `MulF` ex (claim (c, t') / disc' ccy t') t - ϵ (Anytime (TimeGte t') (_, c), t) = do - i <- get - let τ = localVar i - put (i + 1) - return $ SupF t' τ $ disc' ccy t * ex (claim (c, τ) / disc' ccy τ) t - ϵ (Until (TimeGte t') c, t) = pure $ claim (c, t) `MulF` ind (id t) (id t') - ϵ _ = error "fapf: Stochastic 'Indicator = Lte' functions not supported yet" - -- υ : (Observable, t) -> State Int (ExprF t (Free (ExprF t) (Observation, t))) - υ (O.Const {value=k}, _) = pure $ ConstF k - υ (O.Observe {key=obs}, t) = pure $ val' obs t - υ (O.ObserveAt {key=obs, t = t'}, _) = pure $ val' obs t' - υ (O.Add (x, x'), t) = pure $ SumF [obs (x, t), obs (x', t)] - υ (O.Neg x, t) = pure . NegF $ obs (x, t) - υ (O.Mul (x, x'), t) = pure $ obs (x, t) `MulF` obs (x', t) - υ (O.Div (x, x'), t) = pure $ obs (x, t) `MulF` inv (obs (x', t)) - - -- these operators are sugar for writing the futumorphism using `Free`, above - x * y = Free $ MulF x y - x / y = Free $ MulF x (inv y) - inv x = Free $ PowF x (obs (O.Neg . O.Const $ one, today)) -- t for a `Const` is ignored - ind x y = Free $ I_F x y - sup t i x = Free $ SupF t i x - ex x t = Free $ E_F x t - id = Free . IdentF - claim = Pure . Left - obs = Pure . Right - disc' k t = Free $ ProcF (show k) (disc k) t - exch' asset ccy t = if asset == ccy then ConstF one else ProcF (show asset) (exch asset ccy) t - val' obs t = ProcF (show obs) (val obs) t - one = munit - zero = aunit - --- | This is meant to be a function that algebraically simplifies the FAPF by --- 1) using simple identities and ring laws --- 2) change of numeraire technique. --- This is still an experimental feature. -simplify : Expr t -> Expr t -simplify = - cata unitIdentity - . cata zeroIdentity - . cata factNeg - . \case [] -> Const aunit - [x] -> x - xs -> Sum xs - . cata distSum - . ana commuteLeft - . cata mulBeforeSum - -{- Functions below are helpers for simplifying the expression tree, used mainly in `simplify` -} - -zeroIdentity : ExprF t (Expr t) -> Expr t -zeroIdentity (MulF (Const 0.0) x) = Const 0.0 -zeroIdentity (MulF x (Const 0.0)) = Const 0.0 -zeroIdentity (PowF x (Const 0.0)) = Const 1.0 -zeroIdentity (SumF xs) = Sum $ filter (not . isZero) xs - where isZero (Const 0.0) = True - isZero _ = False -zeroIdentity (E_F (Const 0.0) _) = Const 0.0 -zeroIdentity other = embed other - --- | HIDE -unitIdentity : ExprF t (Expr t) -> Expr t -unitIdentity (MulF (Const 1.0) x) = x -unitIdentity (MulF x (Const 1.0)) = x -unitIdentity (PowF x (Const 1.0)) = x -unitIdentity other = embed other - -factNeg : ExprF t (Expr t) -> Expr t -factNeg (NegF (Neg x)) = x -factNeg (MulF (Neg x) (Neg y)) = Mul (x, y) -factNeg (MulF (Neg x) y) = Neg $ Mul (x, y) -factNeg (MulF y (Neg x)) = Neg $ Mul (y, x) -factNeg (E_F (Neg x) t) = Neg $ E x t -factNeg other = embed other - --- | Turn any expression into a list of terms to be summed together -distSum : ExprF t [Expr t] -> [Expr t] -distSum = \case - ConstF x -> [Const x] - IdentF x -> [Ident x] - SumF xs -> join xs - MulF xs xs' -> curry Mul <$> xs <*> xs' - NegF xs -> Neg <$> xs - E_F xs t -> flip E t <$> xs - I_F xs xs' -> [I (unroll xs, unroll xs')] - PowF xs is -> [Pow (unroll xs, unroll is)] - ProcF{..} -> [Proc{..}] - SupF t τ xs -> [Sup t τ (unroll xs)] - where unroll xs = Sum xs - --- | Change `(a + b) x c` to `c x (a + b)` -mulBeforeSum : ExprF t (Expr t) -> Expr t -mulBeforeSum (MulF y@Sum{} x) = Mul (x, y) -mulBeforeSum (MulF (Mul (x, y@Sum{})) x') = Mul (Mul (x, x'), y) -mulBeforeSum other = embed other - --- | Change e.g. `a x (b x c)` to `(a x b) x c` -commuteLeft : Expr t -> ExprF t (Expr t) -commuteLeft (Mul (x,(Mul (a, b)))) = Mul (x, a) `MulF` b -commuteLeft other = project other diff --git a/src/main/daml/Daml/Finance/Account/V4/Account.daml b/src/main/daml/Daml/Finance/Account/V4/Account.daml deleted file mode 100644 index 431e48044..000000000 --- a/src/main/daml/Daml/Finance/Account/V4/Account.daml +++ /dev/null @@ -1,138 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Account.V4.Account where - -import DA.Set qualified as Set (fromList, null, singleton) -import Daml.Finance.Holding.V4.Util (metaLookup) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Controllers(..), Credit(..), Debit(..), I, View(..), accountKey, createReference, disclosureUpdateReference) -import Daml.Finance.Interface.Account.V4.Factory qualified as AccountFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Holding.V4.Factory qualified as HoldingFactory (Create(..), I, exerciseInterfaceByKey) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingFactoryKey(..), Id(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I, RemoveObservers(..), View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (Acquire(..), I, Lock, Release(..), View(..), getLockers, mustNotBeLocked) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 -import Splice.Api.Token.MetadataV1 () - --- | Type synonym for `Account`. -type T = Account - --- | A relationship between a custodian and an asset owner. It is referenced by holdings. -template Account - with - custodian : Party - -- ^ The account provider. - owner : Party - -- ^ The account owner. - lock : Optional Lockable.Lock - -- ^ An optional lock for the account. - controllers : Account.Controllers - -- ^ Controllers of transfers. - id : Id - -- ^ Identifier of the account. - description : Text - -- ^ Description of the account. - holdingFactory : HoldingFactoryKey - -- ^ Associated holding factory. - observers : PartiesMap - -- ^ Observers. - where - signatory custodian, owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - -- Outgoing controllers must be non-empty. - ensure isValidLock lock && (not . Set.null $ controllers.outgoing) - - interface instance Account.I for Account where - view = Account.View with custodian; id; owner; description; controllers - getKey = Account.accountKey this - - credit Account.Credit{quantity} = do - Lockable.mustNotBeLocked this - HoldingFactory.exerciseInterfaceByKey @HoldingFactory.I - holdingFactory - custodian - HoldingFactory.Create with - instrument = quantity.unit - account = Account.accountKey this - amount = quantity.amount - observers = mempty - - debit Account.Debit{holdingCid} = do - Lockable.mustNotBeLocked this - holding <- fetch holdingCid - - -- Owner - assertMsg "Holding owner must match account owner" $ - (view holding).owner == owner - - -- Metadata lookup helper - let holdingView = view (toInterface @Api.HoldingV1.Holding holding) - let holdingMeta = metaLookup holdingView.meta - - -- Custodian - assertMsg "Holding custodian must match account custodian" $ - holdingMeta "custodian" == partyToText custodian - - -- Account ID - assertMsg "Holding accountId must match account accountId" $ - holdingMeta "accountId" == show id - - archive holdingCid - - interface instance Lockable.I for Account where - view = Lockable.View with lock; controllers = Set.singleton custodian - acquire lockable@Lockable.Acquire{newLockers; context; lockType} = do - newLockableCid <- toInterfaceContractId @Disclosure.I <$> - acquireImpl this.lock (\lock -> this with lock) lockable - -- adding lockers as observers to Account.R - fromInterfaceContractId @Lockable.I <$> - exercise newLockableCid Disclosure.AddObservers with - disclosers = Set.fromList $ signatory this - observersToAdd = (context, newLockers) - release lockable@Lockable.Release{context} = do - newLockableCid <- releaseImpl this.lock (\lock -> this with lock) lockable - -- removing lockers as observers to Account.R - optional newLockableCid fromInterfaceContractId <$> - exercise (toInterfaceContractId @Disclosure.I newLockableCid) - Disclosure.RemoveObservers with - disclosers = Set.fromList $ signatory this - observersToRemove = (context, Lockable.getLockers this) - - interface instance Disclosure.I for Account where - view = Disclosure.View with disclosureControllers = Set.fromList [custodian, owner]; observers - setObservers = setObserversImpl this . Some . Account.disclosureUpdateReference $ - Account.accountKey this - addObservers = addObserversImpl this . Some . Account.disclosureUpdateReference $ - Account.accountKey this - removeObservers = removeObserversImpl this . Some . Account.disclosureUpdateReference $ - Account.accountKey this - --- | Template used to create accounts. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance AccountFactory.I for Factory where - view = AccountFactory.View with provider - create' AccountFactory.Create {account; holdingFactory; controllers; observers; description} = - do - cid <- toInterfaceContractId <$> create Account with - custodian = account.custodian; owner = account.owner; lock = None; controllers - id = account.id; holdingFactory; observers; description - Account.createReference account.custodian cid - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = Set.singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None \ No newline at end of file diff --git a/src/main/daml/Daml/Finance/Claims/V3/Util.daml b/src/main/daml/Daml/Finance/Claims/V3/Util.daml deleted file mode 100644 index 961bcf1c0..000000000 --- a/src/main/daml/Daml/Finance/Claims/V3/Util.daml +++ /dev/null @@ -1,26 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Claims.V3.Util where - -import ContingentClaims.Core.V3.Claim (Claim, mapParams) -import ContingentClaims.Lifecycle.V3.Util qualified as CC (isZero) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Claims.V4.Types (TaggedClaim) - --- | Checks if all input claims are zero. -isZero : Party -> Claim.I -> Update Bool -isZero actor c = isZero' <$> Claim.getClaims c Claim.GetClaims with actor - --- | Checks if all input claims are zero. -isZero' : [TaggedClaim] -> Bool -isZero' = all $ CC.isZero . (.claim) - --- | Maps the time parameter in a `Claim` to `Time`. As `Time` is generally understood to express --- UTC time, we recommend mapping to UTC time. -toTime : (t -> Time) -> Claim t x a o -> Claim Time x a o -toTime forwardMap c = - let contraMap _ = error "Inverse mapping from `Time` is not provided" - -- currently the contramap from `Time` back to `a` is not used, because `Observation`\s do not - -- depend on time explicitly - in mapParams contraMap forwardMap identity identity identity c diff --git a/src/main/daml/Daml/Finance/Claims/V3/Util/Builders.daml b/src/main/daml/Daml/Finance/Claims/V3/Util/Builders.daml deleted file mode 100644 index 830adea55..000000000 --- a/src/main/daml/Daml/Finance/Claims/V3/Util/Builders.daml +++ /dev/null @@ -1,343 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This module includes utility functions used to build contingent claim trees that represent --- specific payoffs. A `Schedule` is usually used as an input to these utility functions. Given --- that schedules are defined in terms of dates, a claim where the time parameter is `Date` --- is returned. These are then mapped to claims where the time parameter is `Time` using a --- (user-provided) conversion function. -module Daml.Finance.Claims.V3.Util.Builders where - -import ContingentClaims.Core.V3.Builders (european) -import ContingentClaims.Core.V3.Claim (Claim, Inequality(..), and, andList, at, cond, give, one, orList, scale, until, upTo, when, zero, (<=)) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Date (addDays) -import DA.Foldable (foldMap) -import Daml.Finance.Claims.V3.Util (toTime) -import Daml.Finance.Claims.V3.Util.Date (convertImplicitDcfToActualDcf) -import Daml.Finance.Interface.Claims.V4.Types (Deliverable, Observable, TaggedClaim(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (DateRelativeToEnum(..), FloatingRate, ReferenceRateTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentQuantity) -import Daml.Finance.Interface.Types.Date.V3.Calendar (HolidayCalendarData) -import Daml.Finance.Interface.Types.Date.V3.DateOffset (DateOffset, DayTypeEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..), Schedule, SchedulePeriod) -import Daml.Finance.Util.V4.Date.Calendar (addBusinessDays, adjustDate) -import Daml.Finance.Util.V4.Date.DayCount (calcPeriodDcf) -import Prelude hiding (and, or, zero, (<=)) - -type O = Observation Date Decimal Observable -type C = Claim Date Decimal Deliverable Observable -type FixingDates = DateOffset -- FixingDates is the name used in the FpML schema - --- | Convert the claims to UTCTime and tag them. -prepareAndTagClaims : (Date -> Time) -> [C] -> - Text -> TaggedClaim -prepareAndTagClaims dateToTime cs tag = - let claim = toTime dateToTime $ andList cs - in TaggedClaim with tag; claim - --- FIXED_RATE_BOND_COUPON_CLAIMS_BEGIN -createFixRatePaymentClaimsList : Schedule -> PeriodicSchedule -> Bool -> Decimal -> Bool -> - DayCountConventionEnum -> Decimal -> Deliverable -> [C] -createFixRatePaymentClaimsList schedule periodicSchedule useAdjustedDatesForDcf couponRate - ownerReceives dayCountConvention notional cashInstrument = - let - couponDatesAdjusted = map (.adjustedEndDate) schedule - couponAmounts = map (\p -> - couponRate * - (calcPeriodDcf dayCountConvention p useAdjustedDatesForDcf - periodicSchedule.terminationDate periodicSchedule.frequency) - ) schedule - couponClaimAmounts = andList $ - zipWith - (\d a -> - when (TimeGte d) $ scale (Const a) $ scale (Const notional) $ one cashInstrument - ) couponDatesAdjusted couponAmounts - in - [if ownerReceives then couponClaimAmounts else give couponClaimAmounts] --- FIXED_RATE_BOND_COUPON_CLAIMS_END - --- | Calculate a fix rate amount for each payment date and create claims. -createFixRatePaymentClaims : (Date -> Time) -> Schedule -> PeriodicSchedule -> Bool -> Decimal -> - Bool -> DayCountConventionEnum -> Decimal -> Deliverable -> TaggedClaim -createFixRatePaymentClaims dateToTime schedule periodicSchedule useAdjustedDatesForDcf - couponRate ownerReceives dayCountConvention notional cashInstrument = - let - couponClaims = createFixRatePaymentClaimsList schedule periodicSchedule useAdjustedDatesForDcf - couponRate ownerReceives dayCountConvention notional cashInstrument - in prepareAndTagClaims dateToTime couponClaims "Fix rate payment" - --- | Calculate a floating rate amount for each payment date and create claims. --- This is a general function that supports both LIBOR and SOFR-COMPOUND reference rates. --- It also supports a fix rate spread. If no floating rate is provided, only the fix spread is used, --- i.e. fix rate claims are created. -createRatePaymentClaims : (Date -> Time) -> Schedule -> PeriodicSchedule -> Bool -> - Decimal -> Bool -> DayCountConventionEnum -> Decimal -> Deliverable -> Optional FloatingRate -> - HolidayCalendarData -> TaggedClaim -createRatePaymentClaims dateToTime schedule periodicSchedule useAdjustedDatesForDcf - floatingRateSpread ownerReceives dayCountConvention notional cashInstrument floatingRate - fixingCalendars = - let - notionalAmount = scale (Const notional) $ one cashInstrument - couponClaimAmounts = andList $ map (\p -> - when (TimeGte p.adjustedEndDate) - $ calculateRatePayment p dayCountConvention useAdjustedDatesForDcf periodicSchedule - floatingRate floatingRateSpread notionalAmount fixingCalendars None None - ) schedule - couponClaims = if ownerReceives then couponClaimAmounts else give couponClaimAmounts - in prepareAndTagClaims dateToTime [couponClaims] "Floating rate payment" - --- | HIDE Calculate the coupon claim for a current period p out of a PeriodicSchedule -calculateRatePayment : SchedulePeriod -> DayCountConventionEnum -> Bool -> PeriodicSchedule -> - Optional FloatingRate -> Decimal -> C -> HolidayCalendarData -> Optional Decimal -> - Optional Decimal -> C -calculateRatePayment p dayCountConvention useAdjustedDatesForDcf periodicSchedule - floatingRate couponRate notionalAmount fixingCalendars capRate - floorRate = - let - dcf = Const $ calcPeriodDcf dayCountConvention p useAdjustedDatesForDcf - periodicSchedule.terminationDate periodicSchedule.frequency - cpn = case floatingRate of - None -> scale ((Const couponRate) * dcf) notionalAmount - Some fr -> case fr.referenceRateType of - SingleFixing resetRelativeTo -> rateAfterCapAndFloor - where - baseDate = case (useAdjustedDatesForDcf, resetRelativeTo) of - (True, CalculationPeriodStartDate) -> p.adjustedStartDate - (True, CalculationPeriodEndDate) -> p.adjustedEndDate - (False, CalculationPeriodStartDate) -> p.unadjustedStartDate - (False, CalculationPeriodEndDate) -> p.unadjustedEndDate - resetDate = calculateFixingDate baseDate fr.fixingDates fixingCalendars dayShift - -- FLOATING_RATE_BOND_COUPON_CLAIMS_BEGIN - observedFloatingRate = ObserveAt fr.referenceRateId resetDate - -- FLOATING_RATE_BOND_COUPON_CLAIMS_END - rateAfterCapAndFloor = capAndFloorRate observedFloatingRate capRate floorRate dcf - notionalAmount couponRate - CompoundedIndex dcfConventionImpl -> rateAfterCapAndFloor - where - baseStartDate = if useAdjustedDatesForDcf then p.adjustedStartDate - else p.unadjustedStartDate - resetDateStart = calculateFixingDate baseStartDate fr.fixingDates fixingCalendars - dayShift - baseEndDate = if useAdjustedDatesForDcf then p.adjustedEndDate - else p.unadjustedEndDate - resetDateEnd = calculateFixingDate baseEndDate fr.fixingDates fixingCalendars - dayShift - compoundedFloatingRate = ObserveAt fr.referenceRateId resetDateEnd / - ObserveAt fr.referenceRateId resetDateStart - Const 1.0 - dcfConversionFactor = convertImplicitDcfToActualDcf dcf p useAdjustedDatesForDcf - periodicSchedule dcfConventionImpl - rateAfterCapAndFloor = capAndFloorRate compoundedFloatingRate capRate floorRate - dcfConversionFactor notionalAmount couponRate - where - dayShift = if fr.fixingDates.period == D then fr.fixingDates.periodMultiplier - else error "Only daily periods supported" - in cpn - --- | HIDE Calculate the fixing date by using a day shift (if applicable) and then adjusting the --- date. -calculateFixingDate : Date -> FixingDates -> HolidayCalendarData -> Int -> Date -calculateFixingDate baseDate fixingDates fixingCalendars dayShift = - let - resetDateUnadjStart = case fixingDates.dayType of - None -> baseDate - Some Business -> addBusinessDays fixingCalendars dayShift baseDate - Some Calendar -> addDays baseDate dayShift - in - adjustDate fixingCalendars fixingDates.businessDayConvention resetDateUnadjStart - --- | HIDE Apply a cap and a floor to a floating rate claim. -capAndFloorRate : O -> Optional Decimal -> Optional Decimal -> O -> C -> Decimal -> C -capAndFloorRate observedFloatingRate capRate floorRate dcf notionalAmount couponRate = - let - regularRate = observedFloatingRate + Const couponRate - regularRateClaim = scale (regularRate * dcf) notionalAmount - rateAfterCap = case capRate of - None -> regularRateClaim - Some cap -> cond capCondition capRateClaim regularRateClaim - where - capCondition = Const cap <= regularRate - capRateClaim = scale (Const cap * dcf) notionalAmount - rateAfterCapAndFloor = case floorRate of - None -> rateAfterCap - Some floor -> cond floorCondition floorRateClaim rateAfterCap - where - floorCondition = regularRate <= Const floor - floorRateClaim = scale (Const floor * dcf) notionalAmount - in rateAfterCapAndFloor - --- | Calculate a fix rate amount (if a credit event has not yet happened) for each payment date and --- create claims. -createConditionalCreditFixRatePaymentClaims : (Date -> Time) -> Schedule -> PeriodicSchedule -> - Bool -> Decimal -> Bool -> DayCountConventionEnum -> Decimal -> Deliverable -> Observable -> - TaggedClaim -createConditionalCreditFixRatePaymentClaims dateToTime schedule periodicSchedule - useAdjustedDatesForDcf couponRate ownerReceives dayCountConvention notional - cashInstrument defaultProbabilityReferenceId - = let - couponClaims = createFixRatePaymentClaimsList schedule periodicSchedule useAdjustedDatesForDcf - couponRate ownerReceives dayCountConvention notional cashInstrument - creditEvent = Lte (Const 1.0, Observe defaultProbabilityReferenceId) - couponClaimUntilCreditEvent = - when (TimeGte periodicSchedule.effectiveDate) - $ until creditEvent - $ andList couponClaims - in - prepareAndTagClaims dateToTime [couponClaimUntilCreditEvent] - "Fix rate payment (unless credit event has occurred)" - --- | Calculate a (1-recoveryRate) payment if a credit event just happened and create claims. -createCreditEventPaymentClaims : (Date -> Time) -> Bool -> Decimal -> Deliverable -> Observable -> - Observable -> PeriodicSchedule -> TaggedClaim -createCreditEventPaymentClaims dateToTime ownerReceives notional cashInstrument - defaultProbabilityReferenceId recoveryRateReferenceId periodicSchedule = - let - creditEvent = Lte (Const 1.0, Observe defaultProbabilityReferenceId) - payoffAmount = - scale ((Const 1.0 - Observe recoveryRateReferenceId) * Const notional) - $ one cashInstrument - payoff = if ownerReceives then payoffAmount else give payoffAmount - creditEventClaim = - when (TimeGte periodicSchedule.effectiveDate) - $ when creditEvent - $ when (upTo periodicSchedule.terminationDate) payoff - in prepareAndTagClaims dateToTime [creditEventClaim] "Credit event payment" - --- ASSET_PERFORMANCE_CLAIMS_BEGIN --- | Calculate the asset performance for each payment date and create claims. --- The performance is calculated using the weighted performance of the basket underlyings from the --- start date to the end date of each payment period. --- The reference asset Observables need to contain the appropriate type of fixings: --- - unadjusted fixings in case of a price return asset swap --- - adjusted fixings in case of a total return asset swap -createAssetPerformancePaymentClaims : (Date -> Time) -> Schedule -> PeriodicSchedule -> Bool -> - Bool -> DayCountConventionEnum -> Decimal -> Deliverable -> [(Text, Decimal)] - -> TaggedClaim -createAssetPerformancePaymentClaims dateToTime schedule periodicSchedule useAdjustedDatesForDcf - ownerReceives dayCountConvention notional cashInstrument underlyingRefsAndWeights = - let - assetClaimAmounts = foldMap (\p -> - let - calcBasketPerformance acc (referenceAssetId, weight) = - Const weight * (Observe referenceAssetId / - ObserveAt referenceAssetId p.adjustedStartDate - Const 1.0) + acc - basketPerformance = foldl calcBasketPerformance (Const 0.0) underlyingRefsAndWeights - in - when (TimeGte p.adjustedEndDate) - $ scale (Const notional * basketPerformance) - $ one cashInstrument - ) schedule - assetClaims = if ownerReceives then assetClaimAmounts else give assetClaimAmounts - in - prepareAndTagClaims dateToTime [assetClaims] "Asset performance payment" --- ASSET_PERFORMANCE_CLAIMS_END - --- FIXED_RATE_BOND_REDEMPTION_CLAIM_BEGIN --- | Create an FX adjusted principal claim. --- This can be used for both FX swaps (using the appropriate FX rate) and single currency bonds --- (setting the FX rate to 1.0). -createFxAdjustedPrincipalClaim : (Date -> Time) -> Bool -> Decimal -> Decimal -> Deliverable -> - Date -> TaggedClaim -createFxAdjustedPrincipalClaim dateToTime ownerReceives fxRateMultiplier notional - cashInstrument valueDate = - let - fxLegClaimAmount = when (TimeGte valueDate) - $ scale (Const fxRateMultiplier) - $ scale (Const notional) - $ one cashInstrument - fxLegClaim = if ownerReceives then fxLegClaimAmount else give fxLegClaimAmount - in - prepareAndTagClaims dateToTime [fxLegClaim] "Principal payment" --- FIXED_RATE_BOND_REDEMPTION_CLAIM_END - --- | Create the claim for a long vanilla option (cash-settled, automatically exercised). -createVanillaOptionClaim : (Date -> Time) -> Decimal -> Observable -> Deliverable -> Date -> Bool - -> Optional Decimal -> Decimal -> C -createVanillaOptionClaim dateToTime strike spot cashInstrument expiryDate isCall - referenceLevel notionalMultiplier = - let - intrinsicValueAbs = if isCall then Observe spot - Const strike - else Const strike - Observe spot - intrinsicValue = case referenceLevel of - Some ref -> intrinsicValueAbs / Const ref - None -> intrinsicValueAbs - exercised = scale (Const notionalMultiplier * intrinsicValue) $ one cashInstrument - notExercised = zero - autoExerciseCondition = if isCall then Lte (Const strike, Observe spot) - else Lte (Observe spot, Const strike) - in - when (TimeGte expiryDate) $ cond autoExerciseCondition exercised notExercised - --- | Create the claim for a cash-settled, automatically exercised option (long or short). -createEuropeanCashClaim : (Date -> Time) -> Bool -> Decimal -> Observable -> Deliverable -> Date -> - Bool -> Optional Decimal -> Decimal -> TaggedClaim -createEuropeanCashClaim dateToTime isLong strike spot cashInstrument expiryDate - isCall referenceLevel notionalMultiplier = - let - claimAmount = createVanillaOptionClaim dateToTime strike spot cashInstrument expiryDate isCall - referenceLevel notionalMultiplier - claim = if isLong then claimAmount else give claimAmount - in - prepareAndTagClaims dateToTime [claim] "European option payment" - --- | Create the claim for a barrier option (automatically exercised, cash-settled). -createBarrierEuropeanCashClaim : (Date -> Time) -> Bool -> Decimal -> Observable -> Deliverable - -> Date -> Bool -> Decimal -> Date -> Bool -> Bool -> Optional Decimal -> Decimal -> TaggedClaim -createBarrierEuropeanCashClaim dateToTime isLong strike spot cashInstrument - expiryDate isCall barrier barrierStartDate isDown isOut referenceLevel notionalMultiplier = - let - barrierEvent = if isDown then Lte (Observe spot, Const barrier) - else Lte (Const barrier, Observe spot) - vanillaOption = createVanillaOptionClaim dateToTime strike spot cashInstrument expiryDate isCall - referenceLevel notionalMultiplier - barrierClaimAmountExclStartDate = if isOut - then vanillaOption `and` when barrierEvent (when (TimeLte expiryDate) (give vanillaOption)) - else when barrierEvent $ when (TimeLte expiryDate) vanillaOption - claimAmount = when (at barrierStartDate) barrierClaimAmountExclStartDate - claim = if isLong then claimAmount else give claimAmount - in - prepareAndTagClaims dateToTime [claim] "Barrier option payment" - --- | Create the claim for a physically settled European option. -createEuropeanPhysicalClaim : (Date -> Time) -> Bool -> Decimal -> Deliverable -> Deliverable -> - Date -> Bool -> TaggedClaim -createEuropeanPhysicalClaim dateToTime isLong strike underlying ccy - expiryDate isCall = - let - exerciseClaim = - if isCall then - (one underlying) `and` scale (Const strike) (give (one ccy)) - else - give (one underlying) `and` scale (Const strike) (one ccy) - claimAmount = european expiryDate exerciseClaim - claim = if isLong then claimAmount else give claimAmount - in - prepareAndTagClaims dateToTime [claim] "Option payment" - --- | Create the claim for a physically settled Dividend option. -createDividendOptionClaim : (Date -> Time) -> Date -> InstrumentQuantity -> - Optional InstrumentQuantity -> Optional InstrumentQuantity -> TaggedClaim -createDividendOptionClaim dateToTime expiryDate cashQuantity - sharesQuantity fxQuantity = - let - cashClaim = scale (Const cashQuantity.amount) (one cashQuantity.unit) - taggedCashClaims = [("CASH", cashClaim)] - - taggedSharesClaims = case sharesQuantity of - None -> [] - Some shares -> [("SHARES", sharesClaim)] - where - sharesClaim = scale (Const shares.amount) (one shares.unit) - - taggedFxClaims = case fxQuantity of - None -> [] - Some fx -> [("CASHFX", cashFxClaim)] - where - cashFxClaim = scale (Const fx.amount) $ one fx.unit - - cashOrSharesOrFx = orList $ taggedCashClaims ++ taggedSharesClaims ++ taggedFxClaims - claim = when (at expiryDate) cashOrSharesOrFx - in - prepareAndTagClaims dateToTime [claim] "Option payment" diff --git a/src/main/daml/Daml/Finance/Claims/V3/Util/Date.daml b/src/main/daml/Daml/Finance/Claims/V3/Util/Date.daml deleted file mode 100644 index ec3fc0e4c..000000000 --- a/src/main/daml/Daml/Finance/Claims/V3/Util/Date.daml +++ /dev/null @@ -1,28 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Claims.V3.Util.Date where - -import ContingentClaims.Core.V3.Observation (Observation(..)) -import Daml.Finance.Interface.Claims.V4.Types (Observable) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..), SchedulePeriod) -import Daml.Finance.Util.V4.Date.DayCount (calcPeriodDcf) - -type O = Observation Date Decimal Observable - --- | Calculate a conversion factor if the dcf used for a floating rate compounded index does not --- match the dcf used for an instrument. -convertImplicitDcfToActualDcf : O -> SchedulePeriod -> Bool -> PeriodicSchedule -> - DayCountConventionEnum -> O -convertImplicitDcfToActualDcf dcf calculationPeriod useAdjustedDatesForDcf periodicSchedule - dcfConventionImplicit = - -- The implicit dcf used for index calculation does not necessarily match the actual - -- dcf of the current instrument -> calculate an annualized rate and apply the actual dcf: - dcf / dcfImpl - where - -- Calculate dcf using the method implicitly used for the rate Index, - -- for example Act360 in the case of SOFR Index, see page 35 here: - -- https://www.newyorkfed.org/medialibrary/Microsites/arrc/files/2021/users-guide-to-sofr2021-update.pdf - dcfImpl = Const $ calcPeriodDcf dcfConventionImplicit calculationPeriod useAdjustedDatesForDcf - periodicSchedule.terminationDate periodicSchedule.frequency diff --git a/src/main/daml/Daml/Finance/Claims/V3/Util/Lifecycle.daml b/src/main/daml/Daml/Finance/Claims/V3/Util/Lifecycle.daml deleted file mode 100644 index 36f7293d8..000000000 --- a/src/main/daml/Daml/Finance/Claims/V3/Util/Lifecycle.daml +++ /dev/null @@ -1,123 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Claims.V3.Util.Lifecycle - ( electionEvent - , lifecycle - , lifecycleClaims - , netOnTag - , splitPending - , timeEvent - ) where - -import ContingentClaims.Lifecycle.V3.Lifecycle qualified as CC (exercise, lifecycle) -import DA.Action (foldlA) -import DA.Either (partitionEithers) -import DA.List (head, sort) -import DA.Map qualified as Map (fromList, lookup) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getAcquisitionTime, getClaims) -import Daml.Finance.Interface.Claims.V4.Types (EventData(..), Observable, Pending(..), TaggedClaim(..)) -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I, observe) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentQuantity) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Util.V4.Common (sortAndGroupOn) - --- | Constructor for a time event. -timeEvent : Time -> EventData -timeEvent t = EventData with t; election = None - --- | Constructor for an election event. -electionEvent : Time -> Bool -> Text -> EventData -electionEvent t isBearer tag = EventData with t; election = Some (isBearer, tag) - --- | HIDE --- Process a single lifecycle event (time or election) for a single claim. An election is always an --- `exercise` followed by a `lifecycle`. -applyEvent : (Observable -> Time -> Update Decimal) -> Time -> EventData -> TaggedClaim -> Update - (TaggedClaim, [Pending]) -applyEvent observe acquisitionTime e (TaggedClaim with claim; tag) = do - -- Exercise - electedClaim <- case e.election of - None -> pure claim - Some election -> CC.exercise observe election claim acquisitionTime e.t - -- Lifecycle - result <- CC.lifecycle observe electedClaim acquisitionTime e.t - let - remaining = TaggedClaim with tag; claim = result.remaining - pending = map (\p -> Pending with tag; t = p.t; instrument = p.asset; amount = p.amount) - result.pending - pure (remaining, pending) - --- | HIDE --- Process events for a single claim. The events are processed in order (from the earliest to the --- latest). -applyEvents : (Observable -> Time -> Update Decimal) -> Time -> [EventData] -> TaggedClaim -> Update - (TaggedClaim, [Pending]) -applyEvents observe acquisitionTime es claim = - let - folder (claim, pending) event = - fmap (<> pending) <$> applyEvent observe acquisitionTime event claim - in foldlA folder (claim, []) $ sort es - --- | Lifecycle a set of claims at specified events. -lifecycleClaims : [ContractId NumericObservable.I] -- ^ The set of observables. - -> Time -- ^ The input claims' acquisition time. - -> [TaggedClaim] -- ^ The input claims. - -> [EventData] -- ^ Lifecycle events. - -> Update ([TaggedClaim], [Pending]) -- ^ The remaining claims and pending payments. -lifecycleClaims observableCids acquisitionTime claims events = do - observe <- collectObservables observableCids - fmap mconcat . unzip <$> mapA (applyEvents observe acquisitionTime events) claims - --- | Net pending payments on the same instrument, which also have the same tag. -netOnTag : [Pending] -> [Pending] -netOnTag pending = - let - groupedPending = sortAndGroupOn (\e -> (e.instrument, e.tag)) pending - createPendingNode p = - let - aggregatedAmount = foldl (\acc e -> acc + e.amount) 0.0 p - firstElement = head p - in - Pending with - tag = firstElement.tag - t = firstElement.t - instrument = firstElement.instrument - amount = aggregatedAmount - in - map createPendingNode groupedPending - --- | Lifecycle a claim instrument at specified events. -lifecycle : Party -- ^ The party lifecycling the claim. - -> [ContractId NumericObservable.I] -- ^ The set of observables. - -> Claim.I -- ^ The input instrument. - -> [EventData] -- ^ Lifecycle events. - -> Update ([TaggedClaim], [Pending]) -- ^ The remaining claims and pending payments. -lifecycle actor observableCids instrument events = do - let acquisitionTime = Claim.getAcquisitionTime instrument - claims <- Claim.getClaims instrument Claim.GetClaims with actor - lifecycleClaims observableCids acquisitionTime claims events - --- | HIDE --- Fetches all `Observable` contracts and stores them in a `Map` keyed by their `id`. It then --- returns a function that can be used to query them. The controller must be authorized to fetch the --- `Observable` contracts. -collectObservables : [ContractId NumericObservable.I] -> Update - (Observable -> Time -> Update Decimal) -collectObservables observableCids = do - os <- Map.fromList <$> forA observableCids \cid -> do - observation <- fetch cid - pure (show (view observation).id, observation) - pure \key t -> case Map.lookup key os of - Some o -> NumericObservable.observe o t - None -> do abort $ "Missing observable" <> show key <> " at time " <> show t - --- | Map pending settlements into corresponding instrument quantities and split them into consumed --- and produced. Pending items with an amount of `0.0` are discarded. -splitPending : [Pending] -> ([InstrumentQuantity], [InstrumentQuantity]) -splitPending = - partitionEithers . foldr f [] - where - f p acc | p.amount < 0.0 = Left (qty (- 1.0 * p.amount) p.instrument) :: acc - f p acc | p.amount > 0.0 = Right (qty p.amount p.instrument) :: acc - f _ acc = acc diff --git a/src/main/daml/Daml/Finance/Data/V4/Numeric/Observation.daml b/src/main/daml/Daml/Finance/Data/V4/Numeric/Observation.daml deleted file mode 100644 index f466d5312..000000000 --- a/src/main/daml/Daml/Finance/Data/V4/Numeric/Observation.daml +++ /dev/null @@ -1,73 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.V4.Numeric.Observation where - -import DA.Map (Map) -import DA.Map qualified as Map (lookup) -import DA.Set (singleton) -import Daml.Finance.Interface.Data.V4.Numeric.Observation qualified as Observation (I, View(..)) -import Daml.Finance.Interface.Data.V4.Numeric.Observation.Factory qualified as ObservationFactory -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Observation`. -type T = Observation - --- | An implementation of `NumericObservable` that explicitly stores time-dependent numerical --- values. For example, it can be used for equity or rate fixings. -template Observation - with - provider : Party - -- ^ The reference data provider. - id : Id - -- ^ A textual identifier. - observations : Map Time Decimal - -- ^ The time-dependent values. - observers : PartiesMap - -- ^ Observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance NumericObservable.I for Observation where - view = NumericObservable.View with provider; id - observe t = - case Map.lookup t observations of - Some obs -> pure obs - None -> fail $ "Missing observation for " <> show id <>" at t = " <> show t - - interface instance Observation.I for Observation where - view = Observation.View with provider; id; observations; observers - - interface instance Disclosure.I for Observation where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Observation @Disclosure.I this None - addObservers = addObserversImpl @Observation @Disclosure.I this None - removeObservers = removeObserversImpl @Observation @Disclosure.I this None - --- | Implementation of the corresponding Observation Factory. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance ObservationFactory.I for Factory - where - view = ObservationFactory.View with provider; observers - create' ObservationFactory.Create{id; observations; observers; provider} = - toInterfaceContractId <$> - create Observation with id; observations; observers; provider - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Data/V4/Reference/HolidayCalendar.daml b/src/main/daml/Daml/Finance/Data/V4/Reference/HolidayCalendar.daml deleted file mode 100644 index a2c253501..000000000 --- a/src/main/daml/Daml/Finance/Data/V4/Reference/HolidayCalendar.daml +++ /dev/null @@ -1,103 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.V4.Reference.HolidayCalendar where - -import DA.Set (singleton) -import Daml.Finance.Interface.Data.V4.Reference.HolidayCalendar qualified as HolidayCalendar (I, View(..)) -import Daml.Finance.Interface.Data.V4.Reference.HolidayCalendar.Factory qualified as HolidayCalendarFactory -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.Calendar (HolidayCalendarData) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..), Schedule) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Date.Schedule (createSchedule) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Key used to look up the holiday calendar of an entity, as defined by a reference data provider. -data HolidayCalendarKey = HolidayCalendarKey - with - provider : Party - -- ^ The party maintaining the `HolidayCalendar`. - id : Text - -- ^ A textual label identifying the calendar (e.g. "NYSE" for the New York Stock Exchange - -- holiday calendar). - deriving (Eq, Show) - --- | Holiday calendar of an entity (typically an exchange or a currency). --- It is maintained by a reference data provider. -template HolidayCalendar - with - calendar : HolidayCalendarData - -- ^ Holiday Calendar Data used to define holidays. - observers : PartiesMap - -- ^ Observers. - provider : Party - -- ^ The party maintaining the `HolidayCalendar`. - where - signatory provider - observer Disclosure.flattenObservers observers - - key (HolidayCalendarKey with provider; id = calendar.id) : HolidayCalendarKey - maintainer key.provider - - interface instance Disclosure.I for HolidayCalendar where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @HolidayCalendar @Disclosure.I this None - addObservers = addObserversImpl @HolidayCalendar @Disclosure.I this None - removeObservers = removeObserversImpl @HolidayCalendar @Disclosure.I this None - - interface instance HolidayCalendar.I for HolidayCalendar where - view = HolidayCalendar.View with calendar; provider - updateCalendar arg = toInterfaceContractId <$> create this with calendar = arg.newCalendar - - nonconsuming choice GetCalendar : HolidayCalendarData - -- ^ Returns the calendar's `HolidayCalendarData`. - with - viewer : Party - -- ^ The party fetching the calendar. - controller viewer - do - pure calendar - --- | Implementation of the corresponding HolidayCalendar Factory. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance HolidayCalendarFactory.I for Factory - where - view = HolidayCalendarFactory.View with provider - create' HolidayCalendarFactory.Create{calendar; observers; provider} = - toInterfaceContractId <$> create HolidayCalendar with calendar; observers; provider - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None - --- | Retrieve holiday calendar(s) from the ledger. -getHolidayCalendars : Party -> Party -> [Text] -> Update [HolidayCalendarData] -getHolidayCalendars actor provider holidayCalendarIds = - let - -- get a holiday calendar from the ledger - getCalendar id = do - exerciseByKey @HolidayCalendar holCalKey GetCalendar with viewer = actor where - holCalKey = HolidayCalendarKey with provider; id - in - -- get the holiday calendars - mapA getCalendar holidayCalendarIds - --- | Retrieve holiday calendar(s) from the ledger and roll out a schedule. --- Returns the rolled schedule and the required calendars. -rollSchedule : ([Text] -> Update [HolidayCalendarData]) -> PeriodicSchedule -> [Text] -> - Update (Schedule, [HolidayCalendarData]) -rollSchedule getHolidayCalendars periodicSchedule holidayCalendarIds = do - cals <- getHolidayCalendars holidayCalendarIds - pure (createSchedule cals periodicSchedule, cals) diff --git a/src/main/daml/Daml/Finance/Data/V4/Time/DateClock.daml b/src/main/daml/Daml/Finance/Data/V4/Time/DateClock.daml deleted file mode 100644 index 5025eeab4..000000000 --- a/src/main/daml/Daml/Finance/Data/V4/Time/DateClock.daml +++ /dev/null @@ -1,80 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.V4.Time.DateClock where - -import DA.Date (addDays) -import DA.Time (time) -import Daml.Finance.Data.V4.Time.DateClock.Types (Unit(..)) -import Daml.Finance.Data.V4.Time.DateClockUpdate (DateClockUpdateEvent(..)) -import Daml.Finance.Interface.Data.V4.Reference.Time qualified as Time (Advance(..), I, Rewind(..), View(..)) -import Daml.Finance.Interface.Lifecycle.V4.Event.Time qualified as TimeEvent (I) -import Daml.Finance.Interface.Lifecycle.V4.Observable.TimeObservable qualified as TimeObservable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) -import Daml.Finance.Interface.Types.Date.V3.Classes (HasUTCTimeConversion(..)) - --- | Type synonym for `DateClock`. -type T = DateClock - --- | A `DateClock` is a template used to keep track of the current date. --- It implements the `Time` rule interface to be able to advance and rewind business time. It also --- implements the `TimeObservable` interface. Specifically, each date `D` is mapped to --- `D 00:00:00 UTC`. If your use-case involves working across multiple time zones, you may need to --- define multiple `DateClock` templates with specific time conversions. -template DateClock - with - providers : Parties - -- ^ The clock's providers. - date : Unit - -- ^ The clock's date. - id : Id - -- ^ The clock's identifier. - description : Text - -- ^ The clock's description. - observers : Parties - -- ^ Observers. - where - signatory providers - observer observers - - interface instance TimeObservable.I for DateClock where - view = TimeObservable.View with providers; id - getTime = - let Unit currentDate = date - in pure $ time currentDate 0 0 0 - - interface instance Time.I for DateClock where - view = Time.View with providers; id - advance self Time.Advance{eventId; eventDescription} = - moveClock this self eventId eventDescription 1 - rewind self Time.Rewind{eventId; eventDescription} = - moveClock this self eventId eventDescription (-1) - --- | HIDE -moveClock : DateClock -> ContractId Time.I -> Id -> Text -> Int -> - Update (ContractId Time.I, ContractId TimeEvent.I) -moveClock this@DateClock {date; providers; observers} self eventId eventDescription offset = do - let - Unit currentDate = date - newDate = addDays currentDate offset - clock = this with date = Unit newDate - archive self - clockCid <- toInterfaceContractId <$> create clock - eventCid <- toInterfaceContractId <$> create DateClockUpdateEvent with - providers - observers - id = eventId - description = eventDescription - eventTime = toUTCTime clock - date = newDate - pure (clockCid, eventCid) - -instance HasUTCTimeConversion DateClock where - toUTCTime clock = toUTCTime clock.date - -instance Ord DateClock where - compare x y = compare x.date y.date - --- | Maps a `Date` to `Time` using the rule in the `DateClock`. -dateToDateClockTime : Date -> Time -dateToDateClockTime = toUTCTime . Unit diff --git a/src/main/daml/Daml/Finance/Data/V4/Time/DateClock/Types.daml b/src/main/daml/Daml/Finance/Data/V4/Time/DateClock/Types.daml deleted file mode 100644 index 555df9a12..000000000 --- a/src/main/daml/Daml/Finance/Data/V4/Time/DateClock/Types.daml +++ /dev/null @@ -1,20 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.V4.Time.DateClock.Types where - -import DA.Time (time) -import Daml.Finance.Interface.Types.Date.V3.Classes (HasUTCTimeConversion(..)) - --- | A `Date` which can be converted to `Time`. --- Specifically, each date `D` is mapped to `D 00:00:00 UTC`. -newtype Unit = Unit Date deriving (Eq) - -instance HasUTCTimeConversion Unit where - toUTCTime (Unit d) = time d 0 0 0 - -instance Ord Unit where - x <= y = toUTCTime x <= toUTCTime y - -instance Show Unit where - show (Unit d) = show d diff --git a/src/main/daml/Daml/Finance/Data/V4/Time/DateClockUpdate.daml b/src/main/daml/Daml/Finance/Data/V4/Time/DateClockUpdate.daml deleted file mode 100644 index c3f138978..000000000 --- a/src/main/daml/Daml/Finance/Data/V4/Time/DateClockUpdate.daml +++ /dev/null @@ -1,37 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.V4.Time.DateClockUpdate where - -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I, View(..)) -import Daml.Finance.Interface.Lifecycle.V4.Event.Time qualified as Time (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) - --- | Type synonym for `DateClockUpdateEvent`. -type T = DateClockUpdateEvent - --- | Event signalling the update of a `DateClock`. It can trigger the execution of lifecycle rules --- for some instruments. -template DateClockUpdateEvent - with - providers : Parties - -- ^ Providers of the event. - date : Date - -- ^ The updated clock data. - eventTime : Time - -- ^ The event time. - id : Id - -- ^ Event identifier. - description : Text - -- ^ Event description. - observers : Parties - -- ^ The clock's observers. - where - signatory providers - observer observers - - interface instance Event.I for DateClockUpdateEvent where - view = Event.View with providers; id; description; eventTime - - interface instance Time.I for DateClockUpdateEvent where - view = Time.View diff --git a/src/main/daml/Daml/Finance/Data/V4/Time/LedgerTime.daml b/src/main/daml/Daml/Finance/Data/V4/Time/LedgerTime.daml deleted file mode 100644 index 909fe2eda..000000000 --- a/src/main/daml/Daml/Finance/Data/V4/Time/LedgerTime.daml +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.V4.Time.LedgerTime where - -import Daml.Finance.Interface.Lifecycle.V4.Observable.TimeObservable qualified as TimeObservable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) - --- | Type synonym for `LedgerTime`. -type T = LedgerTime - --- | A `LedgerTime` is a template used to retrieve current ledger time as a `TimeObservable`. -template LedgerTime - with - providers : Parties - -- ^ The time providers. - id : Id - -- ^ The ledger time identifier. - description : Text - -- ^ The ledger time description. - observers : Parties - -- ^ Observers. - where - signatory providers - observer observers - - interface instance TimeObservable.I for LedgerTime where - view = TimeObservable.View with providers; id - getTime = Prelude.getTime diff --git a/src/main/daml/Daml/Finance/Holding/V4/Factory.daml b/src/main/daml/Daml/Finance/Holding/V4/Factory.daml deleted file mode 100644 index 89257770a..000000000 --- a/src/main/daml/Daml/Finance/Holding/V4/Factory.daml +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.Factory where - -import DA.Set (singleton) -import Daml.Finance.Holding.V4.BaseHolding (BaseHolding(..)) -import Daml.Finance.Holding.V4.Fungible (Fungible(..)) -import Daml.Finance.Holding.V4.Transferable (Transferable(..)) -import Daml.Finance.Holding.V4.TransferableFungible (TransferableFungible(..)) -import Daml.Finance.Interface.Holding.V4.Factory qualified as HoldingFactory (Create(..), I, View(..), disclosureUpdateReference, holdingFactoryKey) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Factory`. -type T = Factory - --- | Implementation of a factory template for holdings. -template Factory - with - provider : Party - -- ^ The factory's provider. - id : Id - -- ^ Identifier for the factory. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance HoldingFactory.I for Factory - where - view = HoldingFactory.View with provider; id - getKey = HoldingFactory.holdingFactoryKey this - - create' HoldingFactory.Create{instrument; account; amount; observers} = do - assertMsg "amount must be positive" $ amount > 0.0 - case instrument.holdingStandard of - HoldingStandard.TransferableFungible -> - toInterfaceContractId @Api.HoldingV1.Holding <$> - create TransferableFungible with instrument; account; amount; observers; lock = None - - HoldingStandard.Transferable -> - toInterfaceContractId @Api.HoldingV1.Holding <$> - create Transferable with instrument; account; amount; observers; lock = None - - HoldingStandard.Fungible -> - toInterfaceContractId @Api.HoldingV1.Holding <$> - create Fungible with - instrument; account; amount; observers; lock = None - - HoldingStandard.BaseHolding -> - toInterfaceContractId @Api.HoldingV1.Holding <$> - create BaseHolding with - instrument; account; amount; observers; lock = None - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl this . Some . HoldingFactory.disclosureUpdateReference $ - HoldingFactory.holdingFactoryKey this - addObservers = addObserversImpl this . Some . HoldingFactory.disclosureUpdateReference $ - HoldingFactory.holdingFactoryKey this - removeObservers = removeObserversImpl this . Some . HoldingFactory.disclosureUpdateReference $ - HoldingFactory.holdingFactoryKey this diff --git a/src/main/daml/Daml/Finance/Holding/V4/Fungible.daml b/src/main/daml/Daml/Finance/Holding/V4/Fungible.daml deleted file mode 100644 index 6876945d8..000000000 --- a/src/main/daml/Daml/Finance/Holding/V4/Fungible.daml +++ /dev/null @@ -1,65 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.Fungible where - -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl, toApiHoldingView) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Fungible`. -type T = Fungible - --- | Implementation of a fungible holding. --- The `Fungible` template implements the interface `Fungible.I` (which requires --- `Api.HoldingV1.Holding`, `Lockable.I`, and `Disclosure.I` to be implemented), but not the `Transferable.I`. -template Fungible - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && isValidLock lock && instrument.holdingStandard == HoldingStandard.Fungible - - interface instance Disclosure.I for Fungible where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for Fungible where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance Api.HoldingV1.Holding for Fungible where - view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount - - interface instance Fungible.I for Fungible where - view = Fungible.View with modifiers = singleton account.owner - split = splitImpl (toInterface @Fungible.I this) (\amount -> this with amount) - merge = mergeImpl (toInterface @Fungible.I this) (.amount) (\amount -> this with amount) diff --git a/src/main/daml/Daml/Finance/Holding/V4/Transferable.daml b/src/main/daml/Daml/Finance/Holding/V4/Transferable.daml deleted file mode 100644 index 79fa75f66..000000000 --- a/src/main/daml/Daml/Finance/Holding/V4/Transferable.daml +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.Transferable where - -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (transferImpl, toApiHoldingView) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Transferable`. -type T = Transferable - --- | Implementation of a transferable holding. --- `Transferable` implements the interface `Transferable.I` (which requires `Api.HoldingV1.Holding`, --- `Lockable.I`, and Disclosure.I` to be implemented), but not the `Fungible.I`. -template Transferable - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && isValidLock lock && instrument.holdingStandard == HoldingStandard.Transferable - - interface instance Disclosure.I for Transferable where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for Transferable where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance Api.HoldingV1.Holding for Transferable where - view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount - - interface instance Transferable.I for Transferable where - view = Transferable.View {} - transfer = transferImpl $ toInterface this diff --git a/src/main/daml/Daml/Finance/Holding/V4/TransferableFungible.daml b/src/main/daml/Daml/Finance/Holding/V4/TransferableFungible.daml deleted file mode 100644 index 793b56544..000000000 --- a/src/main/daml/Daml/Finance/Holding/V4/TransferableFungible.daml +++ /dev/null @@ -1,72 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.V4.TransferableFungible where - -import DA.Set (fromList, singleton) -import Daml.Finance.Holding.V4.Util (mergeImpl, splitImpl,toApiHoldingView, transferImpl) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, View(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `TransferableFungible`. -type T = TransferableFungible - --- | Implementation of a transferable and fungible holding. --- The `TransferableFungible` template implements the interface `Fungible.I` and `Transferable.I` --- (which requires `Api.HoldingV1.Holding`, `Lockable.I`, and `Disclosure.I` to be implemented). -template TransferableFungible - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && - isValidLock lock && - instrument.holdingStandard == HoldingStandard.TransferableFungible - - interface instance Disclosure.I for TransferableFungible where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for TransferableFungible where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance Api.HoldingV1.Holding for TransferableFungible where - view = - let - lockView : Lockable.View - lockView = view (toInterface @Lockable.I this) - in - toApiHoldingView lockView instrument account amount - - interface instance Transferable.I for TransferableFungible where - view = Transferable.View {} - transfer = transferImpl $ toInterface this - - interface instance Fungible.I for TransferableFungible where - view = Fungible.View with modifiers = singleton account.owner - split = splitImpl (toInterface @Fungible.I this) (\amount -> this with amount) - merge = mergeImpl (toInterface @Fungible.I this) (.amount) (\amount -> this with amount) diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Factory.daml deleted file mode 100644 index 7f2d193d1..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Factory.daml +++ /dev/null @@ -1,74 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.Callable.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Bond.V3.Callable.Instrument qualified as CallableBond (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Factory qualified as CallableBondFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Types (Callable(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance CallableBondFactory.I for Factory where - view = CallableBondFactory.View with provider - create' CallableBondFactory.Create{ - callable = Callable{instrument; description; floatingRate; couponRate; capRate; floorRate; - couponSchedule; callSchedule; noticeDays; holidayCalendarIds; calendarDataProvider; - dayCountConvention; useAdjustedDatesForDcf; currency; notional; lastEventTimestamp; - prevEvents}; - observers} = do - let - callableBondInstrument = CallableBond.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - floatingRate - couponRate - capRate - floorRate - couponSchedule - callSchedule - noticeDays - holidayCalendarIds - calendarDataProvider - dayCountConvention - useAdjustedDatesForDcf - currency - notional - lastEventTimestamp - prevEvents - observers - cid <- toInterfaceContractId <$> create callableBondInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I callableBondInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Instrument.daml deleted file mode 100644 index 9a3c93d56..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/Callable/Instrument.daml +++ /dev/null @@ -1,171 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.Callable.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Bond.V3.Util (createCallableBondClaims) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Instrument qualified as Callable (I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Types (Callable(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Date.Calendar (merge) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- CALLABLE_BOND_TEMPLATE_BEGIN --- | This template models a callable bond. --- It pays a fixed or a floating coupon rate at the end of every coupon period (unless the bond has --- been called). --- Callability is restricted to some (or all) of the coupon dates. This is specified by a separate --- schedule. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ The identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - floatingRate : Optional FloatingRate - -- ^ A description of the floating rate to be used (if applicable). This supports both Libor - -- and SOFR style reference rates (using a compounded index, e.g. the SOFR Index). - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "3.5% p.a coupon" this should - -- be 0.035. This can also be used as a floating coupon spread. For example, in case of - -- "3M Libor + 0.5%" this should be 0.005. - capRate : Optional Decimal - -- ^ The maximum coupon rate possible. For example, if "3M Libor + 0.5%" would result in a - -- rate of 2.5%, but capRate is 2.0%, the coupon rate used would be 2.0%. - floorRate : Optional Decimal - -- ^ The minimum coupon rate possible. For example, if "3M Libor + 0.5%" would result in a - -- rate of -0.2%, but floorRate is 0.0%, the coupon rate used would be 0.0%. - couponSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. The coupon is paid on the *last* date of - -- each schedule period. - -- In case of a floating rate, the reference rate will be fixed in relation to this schedule - -- (in case of a Libor rate: at the start/end of each period, as specified by FloatingRate). - -- This is the main schedule of the instrument, which drives both the calculation and the - -- payment of coupons. It also defines the issue date and the maturity date of the bond. - callSchedule : PeriodicSchedule - -- ^ The bond is callable on the *last* date of each schedule period. For example, if this - -- schedule is the same as the couponSchedule, it means that the bond can be called on each - -- coupon payment date. - noticeDays : Int - -- ^ The number of business days in advance of the coupon date that the issuer must give - -- notice if it wants to call the bond. The election whether to call or not to call must be - -- done by this date. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - useAdjustedDatesForDcf : Bool - -- ^ Configure whether to use adjusted dates (as specified in *businessDayAdjustment* of the - -- *couponSchedule*) for day count fractions. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous events that have been lifecycled on this instrument so far. - -- CALLABLE_BOND_TEMPLATE_END - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - ensure noticeDays >= 0 - - -- CALLABLE_BOND_CLAIMS_BEGIN - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the bond's acquisition time) - let - getCalendars = getHolidayCalendars actor calendarDataProvider - fixingBusinessCenters = case floatingRate of - None -> [] - Some fr -> fr.fixingDates.businessCenters - fixingCals <- getHolidayCalendars issuer calendarDataProvider fixingBusinessCenters - (schedule, _) <- rollSchedule getCalendars couponSchedule holidayCalendarIds - (callableSchedule, _) <- rollSchedule getCalendars callSchedule holidayCalendarIds - assertMsg "cap rate must be greater than or equal to the floor rate" - case (capRate, floorRate) of - (Some cap, Some floor) -> cap >= floor - _ -> True - let - callableClaims = createCallableBondClaims dateToDateClockTime schedule callableSchedule - couponSchedule useAdjustedDatesForDcf couponRate dayCountConvention notional currency - floatingRate capRate floorRate noticeDays $ merge fixingCals - pure [callableClaims] - -- CALLABLE_BOND_CLAIMS_END - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance Callable.I for Instrument where - view = Callable.View with - callable = Callable with - instrument = BaseInstrument.instrumentKey this - description - floatingRate - couponRate - capRate - floorRate - couponSchedule - noticeDays - callSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - useAdjustedDatesForDcf - currency - notional - lastEventTimestamp - prevEvents - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp; - prevEvents} = do - cid <- create this with version; lastEventTimestamp; prevEvents - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Factory.daml deleted file mode 100644 index 8fac72d39..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Factory.daml +++ /dev/null @@ -1,66 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.FixedRate.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Bond.V3.FixedRate.Instrument qualified as FixedRateBond (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Factory qualified as FixedRateBondFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Types (FixedRate(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance FixedRateBondFactory.I for Factory where - view = FixedRateBondFactory.View with provider - create' FixedRateBondFactory.Create{ - fixedRate = FixedRate{instrument; description; couponRate; periodicSchedule; - holidayCalendarIds; calendarDataProvider; dayCountConvention; currency; notional; - lastEventTimestamp}; - observers} = do - let - fixedRateBondInstrument = FixedRateBond.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create fixedRateBondInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I fixedRateBondInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Instrument.daml deleted file mode 100644 index d968be572..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FixedRate/Instrument.daml +++ /dev/null @@ -1,121 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.FixedRate.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createFixRatePaymentClaims, createFxAdjustedPrincipalClaim) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Instrument qualified as FixedRate (I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Types (FixedRate(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- FIXED_RATE_BOND_TEMPLATE_BEGIN --- | This template models a fixed rate bond. --- It pays a fixed coupon rate at the end of every coupon period. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ The identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "3.5% p.a coupon" this should - -- be 0.035. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. --- FIXED_RATE_BOND_TEMPLATE_END - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - -- FIXED_RATE_BOND_CLAIMS_BEGIN - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the bond's acquisition time) - let getCalendars = getHolidayCalendars actor calendarDataProvider - (schedule, _) <- rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - useAdjustedDatesForDcf = True - ownerReceives = True - fxAdjustment = 1.0 - couponClaims = createFixRatePaymentClaims dateToDateClockTime schedule periodicSchedule - useAdjustedDatesForDcf couponRate ownerReceives dayCountConvention notional currency - redemptionClaim = createFxAdjustedPrincipalClaim dateToDateClockTime ownerReceives - fxAdjustment notional currency periodicSchedule.terminationDate - pure [couponClaims, redemptionClaim] - -- FIXED_RATE_BOND_CLAIMS_END - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance FixedRate.I for Instrument where - view = FixedRate.View with - fixedRate = FixedRate with - instrument = BaseInstrument.instrumentKey this - description - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Factory.daml deleted file mode 100644 index 21ed65877..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Factory.daml +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.FloatingRate.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Bond.V3.FloatingRate.Instrument qualified as FloatingRateBond (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Factory qualified as FloatingRateBondFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Types (FloatingRate(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance FloatingRateBondFactory.I for Factory where - view = FloatingRateBondFactory.View with provider - create' FloatingRateBondFactory.Create{ - floatingRate = FloatingRate{instrument; description; floatingRate; couponSpread; - periodicSchedule; holidayCalendarIds; calendarDataProvider; dayCountConvention; currency; - notional; lastEventTimestamp}; - observers} = do - let - floatingRateBondInstrument = FloatingRateBond.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - floatingRate - couponSpread - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create floatingRateBondInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I floatingRateBondInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Instrument.daml deleted file mode 100644 index a5263263e..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/FloatingRate/Instrument.daml +++ /dev/null @@ -1,130 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.FloatingRate.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createFxAdjustedPrincipalClaim, createRatePaymentClaims) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Instrument qualified as FloatingRate (I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Types (FloatingRate(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate qualified as FloatinRateTypes (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Date.Calendar (merge) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- FLOATING_RATE_BOND_TEMPLATE_UNTIL_REFRATE_BEGIN --- | This template models a floating rate bond. --- It pays a floating coupon rate at the end of every coupon period. --- This consists of a reference rate (observed at the beginning of the coupon period) plus a coupon --- spread. For example, 3M Euribor + 0.5%. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - floatingRate : FloatinRateTypes.FloatingRate - -- ^ A description of the floating rate to be used. This supports both Libor and SOFR style - -- reference rates (using a compounded index, e.g. the SOFR Index). --- FLOATING_RATE_BOND_TEMPLATE_UNTIL_REFRATE_END - couponSpread : Decimal - -- ^ The floating rate coupon spread. For example, in case of "3M Euribor + 0.5%" this should - -- be 0.005. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the bond's acquisition time) - let getCalendars = getHolidayCalendars actor calendarDataProvider - fixingCals <- getHolidayCalendars issuer calendarDataProvider - floatingRate.fixingDates.businessCenters - (schedule, _) <- rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - useAdjustedDatesForDcf = True - ownerReceives = True - fxAdjustment = 1.0 - couponClaims = createRatePaymentClaims dateToDateClockTime schedule - periodicSchedule useAdjustedDatesForDcf couponSpread ownerReceives dayCountConvention - notional currency (Some floatingRate) $ merge fixingCals - redemptionClaim = createFxAdjustedPrincipalClaim dateToDateClockTime ownerReceives - fxAdjustment notional currency periodicSchedule.terminationDate - pure [couponClaims, redemptionClaim] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance FloatingRate.I for Instrument where - view = FloatingRate.View with - floatingRate = FloatingRate with - instrument = BaseInstrument.instrumentKey this - description - floatingRate - couponSpread - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Factory.daml deleted file mode 100644 index 2eef69154..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Factory.daml +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.InflationLinked.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Bond.V3.InflationLinked.Instrument qualified as InflationLinkedBond (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Factory qualified as InflationLinkedBondFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Types (InflationLinked(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance InflationLinkedBondFactory.I for Factory where - view = InflationLinkedBondFactory.View with provider - create' InflationLinkedBondFactory.Create{ - inflationLinked = InflationLinked{instrument; description; inflationIndexId; - inflationIndexBaseValue; couponRate; periodicSchedule; holidayCalendarIds; - calendarDataProvider; dayCountConvention; currency; notional; lastEventTimestamp}; - observers} = do - let - inflationLinkeBondInstrument = InflationLinkedBond.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - inflationIndexId - inflationIndexBaseValue - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create inflationLinkeBondInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I inflationLinkeBondInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Instrument.daml deleted file mode 100644 index 98f625a11..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/InflationLinked/Instrument.daml +++ /dev/null @@ -1,156 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.InflationLinked.Instrument where - -import ContingentClaims.Core.V3.Claim (Inequality(..), cond, one, scale, when, (<=)) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (prepareAndTagClaims) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Instrument qualified as InflationLinked (I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Types (InflationLinked(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Date.DayCount (calcPeriodDcf) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Prelude hiding ((<=)) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models an inflation linked bond. --- It pays an inflation adjusted coupon at the end of every coupon period. --- The coupon is based on a fixed rate, which is applied to a principal that is adjusted according --- to an inflation index, for example the Consumer Price Index (CPI) in the U.S. --- For example: 0.5% p.a. coupon, CPI adjusted principal: --- At maturity, the greater of the adjusted principal and the original principal is redeemed. --- For clarity, this only applies to the redemption amount. The coupons are always calculated based --- on the adjusted principal. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - inflationIndexId : Text - -- ^ The inflation index reference ID. For example, in case of "0.5% p.a. coupon, CPI adjusted - -- principal" this should be a valid reference to the "CPI" index. - inflationIndexBaseValue : Decimal - -- ^ The value of the inflation index on the first reference date of this bond (called "dated - -- date" on US TIPS). This is used as the base value for the principal adjustment. - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "0.5% p.a. coupon, CPI - -- adjusted principal" this should be 0.005. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the bond's acquisition time) - let getCalendars = getHolidayCalendars actor calendarDataProvider - (schedule, _) <- rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - -- calculate the current inflation factor (how inflation has developed from the first - -- reference date until now) - inflationFactor = Observe inflationIndexId / Const inflationIndexBaseValue - -- calculate the fixed rate coupons (based on an inflation adjusted principal) - useAdjustedDatesForDcf = True - couponClaims = - map (\p -> - when (TimeGte $ p.adjustedEndDate) $ - scale ( - (Const couponRate) * inflationFactor * - (Const (calcPeriodDcf - dayCountConvention p useAdjustedDatesForDcf periodicSchedule.terminationDate - periodicSchedule.frequency) - ) - ) $ one currency - ) schedule - -- check whether there has been deflation or inflation during the lifetime of the bond - deflation = Observe inflationIndexId <= Const inflationIndexBaseValue - -- in case of deflation: return the original principal - deflationClaim = one currency - -- in case of inflation: return the inflation adjusted principal - inflationClaim = scale inflationFactor (one currency) - -- add the redemption claim - redemptionClaim = when (TimeGte $ periodicSchedule.terminationDate) $ - cond deflation deflationClaim inflationClaim - couponClaimsTagged = prepareAndTagClaims dateToDateClockTime couponClaims "Coupon" - redemptionClaimTagged = prepareAndTagClaims dateToDateClockTime [redemptionClaim] - "Redemption" - pure [couponClaimsTagged, redemptionClaimTagged] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance InflationLinked.I for Instrument where - view = InflationLinked.View with - inflationLinked = InflationLinked with - instrument = BaseInstrument.instrumentKey this - description - inflationIndexId - inflationIndexBaseValue - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this $ Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/Util.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/Util.daml deleted file mode 100644 index e040b38ff..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/Util.daml +++ /dev/null @@ -1,79 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.Util where - -import ContingentClaims.Core.V3.Claim (Claim, and, at, give, one, or, scale, when) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.List (last) -import DA.Optional (isSome) -import Daml.Finance.Claims.V3.Util.Builders (calculateRatePayment, prepareAndTagClaims) -import Daml.Finance.Interface.Claims.V4.Types (Deliverable, Observable, TaggedClaim(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Date.V3.Calendar (HolidayCalendarData) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..), Schedule) -import Daml.Finance.Util.V4.Date.Calendar (addBusinessDays) -import Prelude hiding (and, or, (<=)) -import Prelude qualified as P (and) - -type O = Observation Date Decimal Observable -type C = Claim Date Decimal Deliverable Observable - --- | Find out which schedule periods of scheduleA exist in scheduleB. -includes : Schedule -> Schedule -> [Bool] -includes scheduleA scheduleB = - map (\a -> isSome $ find (\b -> b.adjustedEndDate == a.adjustedEndDate) scheduleB) scheduleA - --- | Calculate the claims for a callable bond with a fixed and/or floating coupon on each payment --- date and a redemption amount at the end (unless called by the issuer). -createCallableBondClaims : (Date -> Time) -> Schedule -> Schedule -> PeriodicSchedule - -> Bool -> Decimal -> DayCountConventionEnum -> Decimal -> Deliverable -> Optional FloatingRate - -> Optional Decimal -> Optional Decimal -> Int -> HolidayCalendarData - -> TaggedClaim -createCallableBondClaims dateToTime schedule callableSchedule periodicSchedule - useAdjustedDatesForDcf couponRate dayCountConvention notional cashInstrument floatingRate - capRate floorRate noticeDays fixingCalendars = - let - notionalAmount = scale (Const notional) $ one cashInstrument - - -- Coupons and principal have a give node in front, to undo the give required in the main - -- claim (in front of the or node, see explanation below). - principal = give notionalAmount - - -- Find out on which coupon dates it is possible to call the bond. - callPossibleInit = includes schedule callableSchedule - - -- Also search in the other direction, to ensure that no intended call dates are ignored. - potentialCallDatesFound = includes callableSchedule schedule - - callPossible = if P.and potentialCallDatesFound then callPossibleInit - else error "All dates in the call schedule must exist in the coupon schedule" - - combineTagClaim (p, callingIsPossible) notCalledClaim = - let - cpn = calculateRatePayment p dayCountConvention useAdjustedDatesForDcf periodicSchedule - floatingRate couponRate notionalAmount fixingCalendars capRate floorRate - coupon = give cpn - principalIncludingCoupon = when (at p.adjustedEndDate) $ and coupon principal - notCalledClaimIncludingCoupon = when (at p.adjustedEndDate) $ and coupon notCalledClaim - called = ("CALLED", principalIncludingCoupon) - notCalled = ("NOT CALLED", notCalledClaimIncludingCoupon) - callDate = addBusinessDays fixingCalendars (-noticeDays) p.adjustedEndDate - tailClaim = if callingIsPossible then when (at callDate) $ or called notCalled - else notCalledClaimIncludingCoupon - in - tailClaim - - finalCouponDate = (.adjustedEndDate) $ last schedule - notCalledFinal = when (at finalCouponDate) principal - claimAmount = foldr (\p acc -> combineTagClaim p acc) notCalledFinal $ zip schedule callPossible - - -- For a callable bond, it is the holding custodian that has the right to call. This is - -- indicated by a give node, which applies to all sub-nodes of the claims branch. However, the - -- coupons and the principal belong to the holding owner, which is why another give node is - -- required to undo the first give. - claims = give claimAmount - - in - prepareAndTagClaims dateToTime [claims] "Callable bond payment" diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Factory.daml deleted file mode 100644 index 67c64de87..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Factory.daml +++ /dev/null @@ -1,61 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.ZeroCoupon.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Bond.V3.ZeroCoupon.Instrument qualified as ZeroCouponBond (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Factory qualified as ZeroCouponBondFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Types (ZeroCoupon(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance ZeroCouponBondFactory.I for Factory where - view = ZeroCouponBondFactory.View with provider - create' ZeroCouponBondFactory.Create{ - zeroCoupon = ZeroCoupon{instrument; description; issueDate; maturityDate; currency; - notional; lastEventTimestamp}; - observers} = do - let - zeroCouponBondInstrument = ZeroCouponBond.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - issueDate - maturityDate - currency - notional - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create zeroCouponBondInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks. - Claim.getClaims (toInterface @Claim.I zeroCouponBondInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Instrument.daml deleted file mode 100644 index 460e7d97f..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Bond/V3/ZeroCoupon/Instrument.daml +++ /dev/null @@ -1,100 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.V3.ZeroCoupon.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createFxAdjustedPrincipalClaim) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Instrument qualified as ZeroCoupon (I, View(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Types (ZeroCoupon(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id, InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a zero coupon bond. --- It does not pay any coupons, only the redemption amount at maturity. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - issueDate : Date - -- ^ The date when the bond was issued. - maturityDate : Date - -- ^ The redemption date of the bond. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{} = - -- get the initial claims tree (as of the bond's acquisition time) - let - ownerReceives = True - fxAdjustment = 1.0 - redemptionClaim = createFxAdjustedPrincipalClaim dateToDateClockTime ownerReceives - fxAdjustment notional currency maturityDate - in - pure [redemptionClaim] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance ZeroCoupon.I for Instrument where - view = ZeroCoupon.View with - zeroCoupon = ZeroCoupon with - instrument = BaseInstrument.instrumentKey this - description - issueDate - maturityDate - currency - notional - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this $ Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Equity/V0/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Equity/V0/Factory.daml deleted file mode 100644 index 3a50747c1..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Equity/V0/Factory.daml +++ /dev/null @@ -1,48 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.V0.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Equity.V0.Instrument (Instrument(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as Instrument (createReference) -import Daml.Finance.Interface.Instrument.Equity.V0.Factory qualified as EquityFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance EquityFactory.I for Factory where - view = EquityFactory.View with provider - create' EquityFactory.Create{instrument; description; validAsOf; observers} = do - cid <- toInterfaceContractId <$> - create Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - validAsOf - observers - Instrument.createReference instrument.depository $ toInterfaceContractId cid - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Equity/V0/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Equity/V0/Instrument.daml deleted file mode 100644 index a783af27b..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Equity/V0/Instrument.daml +++ /dev/null @@ -1,100 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.V0.Instrument where - -import DA.Set (fromList, singleton) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Equity (DeclareDistribution(..), DeclareReplacement(..), DeclareStockSplit(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id, PartiesMap) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Lifecycle.V4.Event.Distribution qualified as Distribution (Event(..)) -import Daml.Finance.Lifecycle.V4.Event.Replacement qualified as Replacement (Event(..)) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | An Instrument representing a common stock. -template Instrument - with - issuer : Party - -- ^ Issuer. - depository : Party - -- ^ Depository. - id : Id - -- ^ A textual identifier. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - observers : PartiesMap - -- ^ Observers. - validAsOf : Time - -- ^ Timestamp as of which the instrument is valid. This usually coincides with the timestamp - -- of the event that creates the instrument. It usually does not coincide with ledger time. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - issuer; depository; id; version; holdingStandard; description; validAsOf - getKey = BaseInstrument.instrumentKey this - - interface instance Equity.I for Instrument where - view = Equity.View with instrument = BaseInstrument.instrumentKey this - declareDistribution - Equity.DeclareDistribution{id; description; effectiveTime; newInstrument; - perUnitDistribution} = - toInterfaceContractId <$> - create Distribution.Event with - providers = fromList [issuer, depository] - id - description - effectiveTime - targetInstrument = BaseInstrument.instrumentKey this - newInstrument - perUnitDistribution - observers = Disclosure.flattenObservers observers - declareStockSplit - Equity.DeclareStockSplit{id; description; adjustmentFactor; newInstrument; - effectiveTime} = do - -- An adjusmentFactor between 0 and 1 represents a classic stock split (e.g. 2-for-1 or - -- two new for one old). - -- A factor above 1 represents a reverse stock split (e.g. 1-for-2 or one new for two - -- old). - assertMsg "Factor must be greater than zero" $ adjustmentFactor > 0.0 - toInterfaceContractId <$> - -- NOTE: Doesn't handle conversion of fractional shares into cash - create Replacement.Event with - providers = fromList [issuer, depository] - id - description - effectiveTime - targetInstrument = BaseInstrument.instrumentKey this - perUnitReplacement = [qty (1.0 / adjustmentFactor) newInstrument] - observers = Disclosure.flattenObservers observers - declareReplacement - Equity.DeclareReplacement{id; description; effectiveTime; perUnitReplacement} = - toInterfaceContractId <$> - create Replacement.Event with - providers = fromList [issuer, depository] - id - description - effectiveTime - targetInstrument = BaseInstrument.instrumentKey this - perUnitReplacement - observers = Disclosure.flattenObservers observers - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Generic/V4/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Generic/V4/Factory.daml deleted file mode 100644 index fde642f29..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Generic/V4/Factory.daml +++ /dev/null @@ -1,51 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.V4.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Generic.V4.Instrument (Instrument(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as Instrument (createReference) -import Daml.Finance.Interface.Instrument.Generic.V4.Factory qualified as GenericFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for generic instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance GenericFactory.I for Factory where - view = GenericFactory.View with provider - create' GenericFactory.Create - {instrument; description; claims; acquisitionTime; lastEventTimestamp; observers} = do - cid <- toInterfaceContractId <$> - create Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - claims - acquisitionTime - lastEventTimestamp - observers - Instrument.createReference instrument.depository $ toInterfaceContractId cid - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Generic/V4/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Generic/V4/Instrument.daml deleted file mode 100644 index a4ce584df..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Generic/V4/Instrument.daml +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.V4.Instrument where - -import DA.Set (singleton) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (I, View(..)) -import Daml.Finance.Interface.Claims.V4.Types (C, TaggedClaim(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Generic.V4.Instrument qualified as GenericInstrument (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | An instrument representing a generic payoff, modelled using the Contingent Claims library. --- The responsibility for processing lifecycle events as well as elections is delegated to the --- issuer, who is hence responsible for providing the correct `Observable`\s. -template Instrument - with - depository : Party - -- ^ The instrument depository. - issuer : Party - -- ^ The instrument issuer. - id : Id - -- ^ The identifier with corresponding version. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A human readable description of the instrument. - claims : C - -- ^ The claim tree. - acquisitionTime : Time - -- ^ The claim's acquisition time. This usually corresponds to the start date of the contract. - observers : PartiesMap - -- ^ Observers. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime - getClaims _ = pure [TaggedClaim with tag = "Generic"; claim = this.claims] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance GenericInstrument.I for Instrument where - view = GenericInstrument.View with instrument = BaseInstrument.instrumentKey this; claims - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Generic/V4/Lifecycle/Rule.daml b/src/main/daml/Daml/Finance/Instrument/Generic/V4/Lifecycle/Rule.daml deleted file mode 100644 index 34c08733d..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Generic/V4/Lifecycle/Rule.daml +++ /dev/null @@ -1,154 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.V4.Lifecycle.Rule - ( Rule(..) - ) where - -import DA.Optional (fromSome) -import DA.Set (fromList) -import DA.Text (sha256) -import Daml.Finance.Claims.V3.Util (isZero') -import Daml.Finance.Claims.V3.Util.Lifecycle (electionEvent, lifecycle, splitPending, timeEvent) -import Daml.Finance.Instrument.Generic.V4.Instrument (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Claims.V4.Types (C) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (R, createReference, getKey) -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (ApplyElection(..), Exercisable(..), ExercisableView(..), getElectionTime) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), InstrumentKey, Parties, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.InterfaceKey (fetchInterfaceByKey) -import Daml.Finance.Lifecycle.V4.Effect (Effect(..)) -import Daml.Finance.Lifecycle.V4.ElectionEffect (ElectionEffect(..)) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Rule to process a lifecycle event. --- This rule supports both time update events and election events. -template Rule - with - providers : Parties - -- ^ Providers of the distribution rule. - lifecycler : Party - -- ^ Party performing the lifecycling. - observers : PartiesMap - -- ^ Observers of the distribution rule. - id : Id - -- ^ Identifier for the rule contract. - description : Text - -- ^ Textual description. - where - signatory providers - observer Disclosure.flattenObservers observers, lifecycler - - -- Process a time update event. - interface instance Lifecycle.I for Rule where - view = Lifecycle.View with lifecycler; id; description - evolve Lifecycle.Evolve{eventCid; observableCids; instrument} = do - - -- fetch event - eventView <- view <$> fetch eventCid - let eventTime = eventView.eventTime - - -- fetch claim tree - claimInstrument <- fetchInterfaceByKey @BaseInstrument.R instrument - claims <- Claim.getClaims claimInstrument $ Claim.GetClaims with actor = lifecycler - - -- lifecycle as of the time given by the event - (remaining, pending) <- - lifecycle lifecycler observableCids claimInstrument [timeEvent eventTime] - - -- create new instrument and return effect - if remaining == claims && null pending then - pure (None, []) - else do - let - instrumentT = fromSome $ fromInterface @Instrument claimInstrument - currentKey = BaseInstrument.getKey $ toInterface claimInstrument - [claim] = fmap (.claim) remaining - newKey = currentKey with version = sha256 $ show remaining - producedInstrument = if isZero' remaining then None else Some newKey - tryCreateNewInstrument lifecycler claim eventTime instrumentT newKey - let (otherConsumed, otherProduced) = splitPending pending - effectCid <- toInterfaceContractId <$> - create Effect with - providers = fromList [instrumentT.issuer, instrumentT.depository] - id = eventView.id - description = eventView.description - targetInstrument = currentKey - producedInstrument - otherConsumed - otherProduced - settlementTime = Some eventTime - observers = instrumentT.observers - - pure (Some newKey, [effectCid]) - - -- Process an election event. - interface instance Election.Exercisable for Rule where - view = Election.ExercisableView with lifecycler - applyElection Election.ApplyElection{electionCid; observableCids} = do - - -- fetch election - election <- fetch electionCid - let - v = view election - electionTime = Election.getElectionTime election - election = electionEvent electionTime v.electorIsOwner v.claim - - -- fetch claim tree - claimInstrument <- fetchInterfaceByKey @BaseInstrument.R v.instrument - claims <- Claim.getClaims (toInterface @Claim.I claimInstrument) $ Claim.GetClaims with - actor = lifecycler - - -- lifecycle as of the time given by the event, by applying the corresponding election - (remaining, pending) <- lifecycle lifecycler observableCids claimInstrument [election] - - -- create new instrument and return effect - if remaining == claims && null pending then - pure (None, []) - else do - let - instrumentT = fromSome $ fromInterface @Instrument claimInstrument - currentKey = BaseInstrument.getKey $ toInterface claimInstrument - newKey = currentKey with version = sha256 $ show remaining - [claim] = fmap (.claim) remaining - producedInstrument = if isZero' remaining then None else Some newKey - tryCreateNewInstrument lifecycler claim electionTime instrumentT newKey - let (otherConsumed, otherProduced) = splitPending pending - effectCid <- toInterfaceContractId <$> - create ElectionEffect with - providers = fromList [instrumentT.issuer, instrumentT.depository] - custodian = if v.electorIsOwner then v.counterparty else v.elector - owner = if v.electorIsOwner then v.elector else v.counterparty - id = v.id - description = v.description - targetInstrument = currentKey - producedInstrument - amount = v.amount - otherConsumed - otherProduced - settlementTime = Some electionTime - observers = v.observers - pure (Some newKey, [effectCid]) - - interface instance Disclosure.I for Rule where - view = Disclosure.View with disclosureControllers = providers; observers - setObservers = setObserversImpl @Rule @Disclosure.I this None - addObservers = addObserversImpl @Rule @Disclosure.I this None - removeObservers = removeObserversImpl @Rule @Disclosure.I this None - --- | HIDE --- Check if an instrument for the new key already exists, otherwise create it. -tryCreateNewInstrument : Party -> C -> Time -> Instrument -> InstrumentKey -> Update () -tryCreateNewInstrument actor newClaim eventTime oldInstrument newKey = do - existingRefCidOpt <- lookupByKey @BaseInstrument.R newKey - case existingRefCidOpt of - Some _ -> pure () - None -> do - instrumentCid <- create oldInstrument with - claims = newClaim - lastEventTimestamp = eventTime - version = newKey.version - BaseInstrument.createReference actor $ toInterfaceContractId instrumentCid - pure () diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml deleted file mode 100644 index 0ee9efe42..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.BarrierEuropeanCash.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Option.V0.BarrierEuropeanCash.Instrument qualified as BarrierEuropeanCashOption (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Factory qualified as BarrierEuropeanCashOptionFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Types (BarrierEuropean(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance BarrierEuropeanCashOptionFactory.I for Factory where - view = BarrierEuropeanCashOptionFactory.View with provider - create' BarrierEuropeanCashOptionFactory.Create{ - barrierEuropean = BarrierEuropean{instrument; description; referenceAssetId; ownerReceives; - optionType; strike; barrier; barrierType; barrierStartDate; expiryDate; currency; - lastEventTimestamp}; - observers} = do - let - barrierEuropeanCashOptionInstrument = BarrierEuropeanCashOption.Instrument with - depository = instrument.depository - issuer = instrument.issuer - ownerReceives - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - referenceAssetId - optionType - strike - barrier - barrierType - barrierStartDate - expiryDate - currency - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create barrierEuropeanCashOptionInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks. - Claim.getClaims (toInterface @Claim.I barrierEuropeanCashOptionInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml deleted file mode 100644 index 0157517cd..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml +++ /dev/null @@ -1,122 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.BarrierEuropeanCash.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createBarrierEuropeanCashClaim) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Instrument qualified as BarrierEuropeanOption (I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Types (BarrierEuropean(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Types (BarrierTypeEnum(..), OptionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a cash settled, automatically excercised barrier option with European --- exercise. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an option on AAPL this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - ownerReceives : Bool - -- ^ Indicate whether a holding owner of this instrument receives option payoff. - optionType : OptionTypeEnum - -- ^ Indicate whether the option is a call or a put. - strike : Decimal - -- ^ The strike price of the option. - barrier : Decimal - -- ^ The barrier level of the option. - barrierType : BarrierTypeEnum - -- ^ The type of barrier. - barrierStartDate : Date - -- ^ The start date for barrier observations. - expiryDate : Date - -- ^ The expiry date of the option. - currency : InstrumentKey - -- ^ The currency of the option. For example, if the option pays in USD this should be a USD - -- cash instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the instrument's acquisition time) - let - call = optionType == Call - (down, out) = case barrierType of - UpAndOut -> (False, True) - DownAndOut -> (True, True) - UpAndIn -> (False, False) - DownAndIn -> (True, False) - referenceLevel = None - notionalMultiplier = 1.0 - optionsClaim = createBarrierEuropeanCashClaim dateToDateClockTime ownerReceives strike - referenceAssetId currency expiryDate call barrier barrierStartDate down out - referenceLevel notionalMultiplier - pure [optionsClaim] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance BarrierEuropeanOption.I for Instrument where - view = BarrierEuropeanOption.View with - barrierEuropean = BarrierEuropean with - instrument = BaseInstrument.instrumentKey this - description - referenceAssetId - ownerReceives - optionType - strike - barrier - barrierType - barrierStartDate - expiryDate - currency - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - addObservers = addObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Election.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Election.daml deleted file mode 100644 index fe341532c..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Election.daml +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.Dividend.Election where - -import DA.Set (singleton) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Election.Factory qualified as DividendOptionElectionFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (ElectionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Lifecycle.V4.Election (Election(..)) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Factory template to create an `Election`. -template Factory - with - provider : Party - -- ^ The provider of the `Factory`. - observers : PartiesMap - -- ^ A set of observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance DividendOptionElectionFactory.I for Factory where - view = DividendOptionElectionFactory.View with provider - create' DividendOptionElectionFactory.Create{id; description; claimType; elector; - counterparty; electorIsOwner; electionTime; observers; amount; provider; instrument} = - toInterfaceContractId <$> create Election with - id; description; elector; counterparty; electorIsOwner; electionTime - observers; amount; provider; instrument - claim = case claimType of - Shares -> "SHARES" - Cash -> "CASH" - CashFx -> "CASHFX" - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Factory.daml deleted file mode 100644 index af7aa0613..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Factory.daml +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.Dividend.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Option.V0.Dividend.Instrument qualified as DividendOption (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Factory qualified as DividendOptionFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (Dividend(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance DividendOptionFactory.I for Factory where - view = DividendOptionFactory.View with provider - create' DividendOptionFactory.Create{ - dividend = Dividend{instrument; description; expiryDate; cashQuantity; sharesQuantity; - fxQuantity; lastEventTimestamp; prevEvents}; - observers} = do - let - dividendOptionInstrument = DividendOption.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - expiryDate - cashQuantity - sharesQuantity - fxQuantity - lastEventTimestamp - prevEvents - observers - cid <- toInterfaceContractId <$> create dividendOptionInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks. - Claim.getClaims (toInterface @Claim.I dividendOptionInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Instrument.daml deleted file mode 100644 index c43b37c38..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/Dividend/Instrument.daml +++ /dev/null @@ -1,101 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.Dividend.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createDividendOptionClaim) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Instrument qualified as DividendOption (I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (Dividend(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id, InstrumentQuantity, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a physically settled Dividend option. --- The holder gets to choose to receive the dividend in cash or in a different form (in shares --- and/or in a foreign currency). -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - expiryDate : Date - -- ^ The expiry date of the option. - cashQuantity : InstrumentQuantity - -- ^ Dividend paid in cash - sharesQuantity : Optional InstrumentQuantity - -- ^ Dividend paid in shares (if applicable) - fxQuantity : Optional InstrumentQuantity - -- ^ Dividend paid in a foreign currency (if applicable) - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous elections that have been lifecycled on this instrument so far. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the instrument's acquisition time) - let - optionsClaim = createDividendOptionClaim dateToDateClockTime expiryDate cashQuantity - sharesQuantity fxQuantity - pure [optionsClaim] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance DividendOption.I for Instrument where - view = DividendOption.View with - dividend = Dividend with - instrument = BaseInstrument.instrumentKey this - description - expiryDate - cashQuantity - sharesQuantity - fxQuantity - lastEventTimestamp - prevEvents - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp; - prevEvents} = do - cid <- create this with version; lastEventTimestamp; prevEvents - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - addObservers = addObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Factory.daml deleted file mode 100644 index 138848e15..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Factory.daml +++ /dev/null @@ -1,63 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.EuropeanCash.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Option.V0.EuropeanCash.Instrument qualified as EuropeanCashOption (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Factory qualified as EuropeanCashOptionFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Types (European(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance EuropeanCashOptionFactory.I for Factory where - view = EuropeanCashOptionFactory.View with provider - create' EuropeanCashOptionFactory.Create{ - european = European{instrument; description; referenceAssetId;ownerReceives; optionType; - strike; expiryDate; currency; lastEventTimestamp}; - observers} = do - let - europeanCashOptionInstrument = EuropeanCashOption.Instrument with - depository = instrument.depository - issuer = instrument.issuer - ownerReceives - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - referenceAssetId - optionType - strike - expiryDate - currency - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create europeanCashOptionInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks. - Claim.getClaims (toInterface @Claim.I europeanCashOptionInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Instrument.daml deleted file mode 100644 index 1296abeb6..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanCash/Instrument.daml +++ /dev/null @@ -1,106 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.EuropeanCash.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createEuropeanCashClaim) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Instrument qualified as EuropeanOption (I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Types (European(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Types (OptionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a cash settled, automatically excercised European option. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an option on AAPL this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - ownerReceives : Bool - -- ^ Indicate whether a holding owner of this instrument receives option payoff. - optionType : OptionTypeEnum - -- ^ Indicate whether the option is a call or a put. - strike : Decimal - -- ^ The strike price of the option. - expiryDate : Date - -- ^ The expiry date of the option. - currency : InstrumentKey - -- ^ The currency of the option. For example, if the option pays in USD this should be a USD - -- cash instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the instrument's acquisition time) - let - call = optionType == Call - referenceLevel = None - notionalMultiplier = 1.0 - optionsClaim = createEuropeanCashClaim dateToDateClockTime ownerReceives strike - referenceAssetId currency expiryDate call referenceLevel notionalMultiplier - pure [optionsClaim] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance EuropeanOption.I for Instrument where - view = EuropeanOption.View with - european = European with - instrument = BaseInstrument.instrumentKey this - description - referenceAssetId - ownerReceives - optionType - strike - expiryDate - currency - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - addObservers = addObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Factory.daml deleted file mode 100644 index 6fe9301f9..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Factory.daml +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.EuropeanPhysical.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Option.V0.EuropeanPhysical.Instrument qualified as EuropeanPhysicalOption (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Factory qualified as EuropeanPhysicalOptionFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Types (European(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance EuropeanPhysicalOptionFactory.I for Factory where - view = EuropeanPhysicalOptionFactory.View with provider - create' EuropeanPhysicalOptionFactory.Create{ - european = European{instrument; description; referenceAsset; ownerReceives; optionType; - strike; expiryDate; currency; lastEventTimestamp; prevEvents}; - observers} = do - let - europeanPhysicalOptionInstrument = EuropeanPhysicalOption.Instrument with - depository = instrument.depository - issuer = instrument.issuer - ownerReceives - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - referenceAsset - optionType - strike - expiryDate - currency - lastEventTimestamp - prevEvents - observers - cid <- toInterfaceContractId <$> create europeanPhysicalOptionInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks. - Claim.getClaims (toInterface @Claim.I europeanPhysicalOptionInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Instrument.daml deleted file mode 100644 index 026186ce2..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Option/V0/EuropeanPhysical/Instrument.daml +++ /dev/null @@ -1,110 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.V0.EuropeanPhysical.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createEuropeanPhysicalClaim) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Instrument qualified as EuropeanOption (I, View(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Types (European(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Types (OptionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a physically settled European option. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - referenceAsset : InstrumentKey - -- ^ The reference asset. For example, in case of an option on AAPL this should be an AAPL - -- instrument. - ownerReceives : Bool - -- ^ Indicate whether a holding owner of this instrument receives option payoff. - optionType : OptionTypeEnum - -- ^ Indicate whether the option is a call or a put. - strike : Decimal - -- ^ The strike price of the option. - expiryDate : Date - -- ^ The expiry date of the option. - currency : InstrumentKey - -- ^ The currency of the option. For example, if the option pays in USD this should be a USD - -- cash instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous elections that have been lifecycled on this instrument so far. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the instrument's acquisition time) - let - call = optionType == Call - optionsClaim = - createEuropeanPhysicalClaim dateToDateClockTime ownerReceives strike referenceAsset - currency expiryDate call - pure $ [optionsClaim] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance EuropeanOption.I for Instrument where - view = EuropeanOption.View with - european = European with - instrument = BaseInstrument.instrumentKey this - description - referenceAsset - ownerReceives - optionType - strike - expiryDate - currency - lastEventTimestamp - prevEvents - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp; - prevEvents} = do - cid <- create this with version; lastEventTimestamp; prevEvents - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - addObservers = addObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml b/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml deleted file mode 100644 index 123e679d1..000000000 --- a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml +++ /dev/null @@ -1,74 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.V0.AutoCallable.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.StructuredProduct.V0.AutoCallable.Instrument qualified as AutoCallable (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Factory qualified as AutoCallableFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Types (AutoCallable(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance AutoCallableFactory.I for Factory where - view = AutoCallableFactory.View with provider - create' AutoCallableFactory.Create{ - autoCallable = AutoCallable{instrument; description; referenceAssetId; putStrike; - couponBarrier; callBarrier; finalBarrier; currency; lastEventTimestamp; couponRate; - observationSchedule; periodicSchedule; holidayCalendarIds; calendarDataProvider; - dayCountConvention; notional; prevEvents}; - observers} = do - let - acInstrument = AutoCallable.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - referenceAssetId - putStrike - couponBarrier - callBarrier - finalBarrier - couponRate - observationSchedule - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - observers - prevEvents - cid <- toInterfaceContractId <$> create acInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I acInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml b/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml deleted file mode 100644 index db0375692..000000000 --- a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml +++ /dev/null @@ -1,73 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Instrument qualified as BarrierReverseConvertible (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Factory qualified as BarrierReverseConvertibleFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Types (BarrierReverseConvertible(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance BarrierReverseConvertibleFactory.I for Factory where - view = BarrierReverseConvertibleFactory.View with provider - create' BarrierReverseConvertibleFactory.Create{ - barrierReverseConvertible = BarrierReverseConvertible{instrument; description; - referenceAssetId; strike; barrier; barrierStartDate; expiryDate; currency; - lastEventTimestamp; couponRate; periodicSchedule; holidayCalendarIds; - calendarDataProvider; dayCountConvention; notional; prevEvents}; - observers} = do - let - brcInstrument = BarrierReverseConvertible.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - referenceAssetId - strike - barrier - barrierStartDate - expiryDate - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - observers - prevEvents - cid <- toInterfaceContractId <$> create brcInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I brcInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml deleted file mode 100644 index e4e7d271c..000000000 --- a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml +++ /dev/null @@ -1,162 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createBarrierEuropeanCashClaim, createFixRatePaymentClaims, createFxAdjustedPrincipalClaim) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Option.V0.Types (BarrierTypeEnum(..), OptionTypeEnum(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Instrument qualified as BarrierReverseConvertible (I, View(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Types (BarrierReverseConvertible(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a Barrier Reverse Convertible (BRC) instrument. --- It can be seen as a long fixed coupon bond and a short Down-And-In put option. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an option on AAPL this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - strike : Decimal - -- ^ The strike price of the option. - barrier : Decimal - -- ^ The barrier level of the option. - barrierStartDate : Date - -- ^ The start date for barrier observations. - expiryDate : Date - -- ^ The expiry date of the instrument. - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "3.5% p.a coupon" this should - -- be 0.035. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the product. For example, if the product pays in USD this should be a USD - -- cash instrument. - notional : Decimal - -- ^ The notional of the product. This is the face value corresponding to one unit of the - -- product. For example, if one product unit corresponds to 1000 USD, this should be 1000.0. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous events that have been lifecycled on this instrument so far. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the instrument's acquisition time) - - assertMsg "option expiry date must match last coupon date" $ - expiryDate == periodicSchedule.terminationDate - - -- Calculate option claim - let - ownerReceives = False - optionType = Put - barrierType = DownAndIn - referenceLevel = Some strike - call = optionType == Call - (down, out) = case barrierType of - UpAndOut -> (False, True) - DownAndOut -> (True, True) - UpAndIn -> (False, False) - DownAndIn -> (True, False) - optionsClaim = createBarrierEuropeanCashClaim dateToDateClockTime ownerReceives strike - referenceAssetId currency expiryDate call barrier barrierStartDate down out - referenceLevel notional - getCalendars = getHolidayCalendars actor calendarDataProvider - - -- Calculate bond claim - (schedule, _) <- rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - useAdjustedDatesForDcf = True - ownerReceives = True - fxAdjustment = 1.0 - couponClaims = createFixRatePaymentClaims dateToDateClockTime schedule periodicSchedule - useAdjustedDatesForDcf couponRate ownerReceives dayCountConvention notional currency - redemptionClaim = createFxAdjustedPrincipalClaim dateToDateClockTime ownerReceives - fxAdjustment notional currency periodicSchedule.terminationDate - - -- Return BRC claim as option + bond claim - pure [optionsClaim, couponClaims, redemptionClaim] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance BarrierReverseConvertible.I for Instrument where - view = BarrierReverseConvertible.View with - barrierReverseConvertible = BarrierReverseConvertible with - instrument = BaseInstrument.instrumentKey this - description - referenceAssetId - strike - barrier - barrierStartDate - expiryDate - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - prevEvents - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp; - prevEvents} = do - cid <- create this with version; lastEventTimestamp; prevEvents - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - addObservers = addObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/Util.daml b/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/Util.daml deleted file mode 100644 index ed1f2f80d..000000000 --- a/src/main/daml/Daml/Finance/Instrument/StructuredProduct/V0/Util.daml +++ /dev/null @@ -1,77 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.V0.Util where - -import ContingentClaims.Core.V3.Claim (Claim, Inequality(..), and, at, cond, one, scale, when, zero) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.List (head, last) -import DA.Optional (isSome) -import Daml.Finance.Claims.V3.Util.Builders (calculateRatePayment, prepareAndTagClaims) -import Daml.Finance.Interface.Claims.V4.Types (Deliverable, Observable, TaggedClaim(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Date.V3.Calendar (HolidayCalendarData) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..), Schedule) -import Prelude hiding (and, or, zero, (<=)) - -type O = Observation Date Decimal Observable -type C = Claim Date Decimal Deliverable Observable - --- | Find out which schedule periods of scheduleA exist in scheduleB. -includes : Schedule -> Schedule -> [Bool] -includes scheduleA scheduleB = - map (\a -> isSome $ find (\b -> b.adjustedEndDate == a.adjustedEndDate) scheduleB) scheduleA - --- | Calculate the claims for an auto-callable with a contingent coupon on each payment date --- and a redemption amount at maturity (unless auto-called previously). -createAutoCallableClaims : (Date -> Time) -> Schedule -> Schedule -> PeriodicSchedule - -> Bool -> Decimal -> DayCountConventionEnum -> Decimal -> Deliverable -> Optional FloatingRate - -> Optional Decimal -> Optional Decimal -> Text -> Decimal -> Decimal -> Decimal -> Decimal - -> HolidayCalendarData -> TaggedClaim -createAutoCallableClaims dateToTime paymentSchedule callableSchedule periodicSchedule - useAdjustedDatesForDcf couponRate dayCountConvention notional cashInstrument floatingRate - capRate floorRate spot couponBarrier callBarrier finalBarrier putStrike - fixingCalendars = - let - notionalAmount = scale (Const notional) $ one cashInstrument - - principal = notionalAmount - initialObservationDate = (.adjustedStartDate) $ - if null callableSchedule then error "empty callableSchedule" else head callableSchedule - - combineTagClaim (couponPeriod, callPeriod) notCalledClaim = - let - cpn = calculateRatePayment couponPeriod dayCountConvention useAdjustedDatesForDcf - periodicSchedule floatingRate couponRate notionalAmount fixingCalendars capRate floorRate - (callDate, paymentDate) = if callPeriod.adjustedEndDate > couponPeriod.adjustedEndDate - then error "each call date must be before or at the corresponding payment date" - else (callPeriod.adjustedEndDate, couponPeriod.adjustedEndDate) - spotOnObservationDate = ObserveAt spot callDate - couponBarrierLevel = Const couponBarrier * ObserveAt spot initialObservationDate - couponBarrierHit = Lte (spotOnObservationDate, couponBarrierLevel) - coupon = cond couponBarrierHit zero cpn - called = when (at paymentDate) $ and coupon principal - notCalled = when (at paymentDate) $ and coupon notCalledClaim - callBarrierLevel = Const callBarrier * ObserveAt spot initialObservationDate - autoExerciseCondition = Lte (callBarrierLevel, spotOnObservationDate) - tailClaim = when (at callDate) $ cond autoExerciseCondition called notCalled - in - tailClaim - - finalCouponDate = (.adjustedEndDate) $ last paymentSchedule - finalObservationDate = (.adjustedEndDate) $ last callableSchedule - spotOnObservationDate = ObserveAt spot finalObservationDate - finalBarrierLevel = Const finalBarrier * ObserveAt spot initialObservationDate - barrierHit = Lte (spotOnObservationDate, finalBarrierLevel) - putStrikeLevel = Const putStrike * ObserveAt spot initialObservationDate - -- This currently only works for strike = initialFixing (100%) - perf = spotOnObservationDate / putStrikeLevel - perfomanceScaledPrincipal = scale perf notionalAmount - redemptionPayment = cond barrierHit perfomanceScaledPrincipal principal - notCalledFinal = when (at finalCouponDate) redemptionPayment - claims = foldr (\p acc -> combineTagClaim p acc) notCalledFinal $ - zip paymentSchedule callableSchedule - - in - prepareAndTagClaims dateToTime [claims] "AutoCallable payment" diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/DistributionRule.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/DistributionRule.daml deleted file mode 100644 index 0d38d7483..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/DistributionRule.daml +++ /dev/null @@ -1,89 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Asset.DistributionRule where - -import DA.List (dedup) -import DA.Map(fromList) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (exerciseInterfaceByKey) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Factory qualified as AssetSwapFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Instrument qualified as Asset (GetView(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), Parties) -import Daml.Finance.Interface.Util.V3.Common (scale) -import Daml.Finance.Lifecycle.V4.Effect (Effect(..)) -import Daml.Finance.Lifecycle.V4.Event.Distribution qualified as Distribution (Event(..)) - --- | Rule contract used to process a Distribution event (e.g. share or cash dividends) targeting an --- underlying of an asset swap. -template DistributionRule - with - providers : Parties - -- ^ Providers of the distribution rule. - lifecycler : Party - -- ^ Party performing the lifecycling. - observers : Parties - -- ^ Observers of the distribution rule. - id : Id - -- ^ Identifier for the rule contract. - description : Text - -- ^ Textual description. - assetSwapFactoryCid : ContractId AssetSwapFactory.I - -- ^ Factory used to create an updated version of the asset swap. - newInstrumentObservers : [(Text, Parties)] - -- ^ Observers used for the updated version of the asset swap. - where - signatory providers - observer observers, lifecycler - - interface instance Lifecycle.I for DistributionRule where - view = Lifecycle.View with lifecycler; id; description - evolve Lifecycle.Evolve{eventCid; instrument} = do - distribution <- fetch $ fromInterfaceContractId @Distribution.Event eventCid - - -- Get the instrument view - v <- BaseInstrument.exerciseInterfaceByKey @Asset.I - instrument - lifecycler - Asset.GetView with viewer = lifecycler - - assertMsg "duplicate underlyings are not supported" $ - length v.asset.underlyings == length (dedup (map (.referenceAsset) v.asset.underlyings)) - - -- Create a new asset swap instrument with an updated instrument key for the underlying that - -- paid a dividend. - let divUnderlyingFound = find (\u -> u.referenceAsset == distribution.targetInstrument) - v.asset.underlyings - case divUnderlyingFound of - None -> pure (None, []) - Some divUnderlying -> do - let - swapInstrumentAfterDiv = instrument with - version = v.asset.instrument.version <> "-exDiv" - newUnderlying = divUnderlying with referenceAsset = distribution.newInstrument - newUnderlyings = map (\u -> if u == divUnderlying then newUnderlying else u) - v.asset.underlyings - - exercise assetSwapFactoryCid AssetSwapFactory.Create with - asset = v.asset with - instrument = swapInstrumentAfterDiv - underlyings = newUnderlyings - observers = fromList newInstrumentObservers - - -- Calculate dividend amount (divide by initial fixing) - let dividends = map (\d -> scale (divUnderlying.weight / divUnderlying.initialPrice) d) - distribution.perUnitDistribution - - -- Create lifecycle effect - effectCid <- toInterfaceContractId <$> - create Effect with - providers - id = distribution.id - description = distribution.description - targetInstrument = instrument - producedInstrument = Some swapInstrumentAfterDiv - otherConsumed = [] - otherProduced = dividends - settlementTime = Some distribution.effectiveTime - observers = fromList [("RuleObservers", observers)] - pure (Some swapInstrumentAfterDiv, [effectCid]) diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Factory.daml deleted file mode 100644 index 89603c1fe..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Factory.daml +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Asset.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Swap.V0.Asset.Instrument qualified as AssetSwap (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Factory qualified as AssetSwapFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Types (Asset(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance AssetSwapFactory.I for Factory where - view = AssetSwapFactory.View with provider - create' AssetSwapFactory.Create{ - asset = Asset{instrument; description; underlyings; ownerReceivesRate; fixRate; - floatingRate; periodicSchedule; holidayCalendarIds; calendarDataProvider; - dayCountConvention; currency; lastEventTimestamp}; - observers} = do - let - assetSwapInstrument = AssetSwap.Instrument with - depository = instrument.depository - issuer = instrument.issuer - ownerReceivesRate - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - underlyings - floatingRate - fixRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create assetSwapInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I assetSwapInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Instrument.daml deleted file mode 100644 index 8c3efca23..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Asset/Instrument.daml +++ /dev/null @@ -1,144 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Asset.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createAssetPerformancePaymentClaims, createRatePaymentClaims) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Instrument qualified as Asset (I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Types (Asset(..), Underlying) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Date.Calendar (merge) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models an asset swap. --- It pays an asset performance vs a fix interest rate at the end of every payment period. --- It can be used to model equity swaps, some types of commodity swaps (of the form performance vs --- rate) and swaps with the same payoff on other asset types. --- The asset leg is described by an observable containing either unadjusted or adjusted fixings (for --- a price return or a total return swap, respectively). --- The template calculates the performance for each payment period using this observable. --- For example: AAPL total return vs 2.5% fix. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - underlyings : [Underlying] - -- ^ The list of underlyings (the basket of reference assets for the asset swap). - ownerReceivesRate : Bool - -- ^ Indicate whether a holding owner of this instrument receives the rate or the asset leg of - -- the swap. - floatingRate : Optional FloatingRate - -- ^ A description of the floating rate to be used (if applicable). This supports both Libor - -- and SOFR style reference rates (using a compounded index, e.g. the SOFR Index). - fixRate : Decimal - -- ^ The interest rate of the fix leg. For example, in case of "AAPL total return vs 2.5% fix" - -- this should be 0.025. This can also be used as a floating rate spread. For example, in - -- case of "3M Libor + 0.5%" this should be 0.005. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the swap. For example, if the swap pays in USD this should be a USD cash - -- instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the swap's acquisition time) - assertMsg "the sum of weights must be 1" $ - foldl (\acc u -> u.weight + acc) 0.0 underlyings == 1.0 - - let - getCalendars = getHolidayCalendars actor calendarDataProvider - businessCenters = case floatingRate of - Some fr -> fr.fixingDates.businessCenters - None -> [] - fixingCals <- getHolidayCalendars issuer calendarDataProvider businessCenters - schedule <- fst <$> rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - useAdjustedDatesForDcf = True - notional = 1.0 - ownerReceivesAssetLeg = not ownerReceivesRate - underlyingRefsAndWeights = map (\u -> (u.referenceAssetId, u.weight)) underlyings - rateClaims = createRatePaymentClaims dateToDateClockTime schedule periodicSchedule - useAdjustedDatesForDcf fixRate ownerReceivesRate dayCountConvention notional currency - floatingRate $ merge fixingCals - assetClaims = createAssetPerformancePaymentClaims dateToDateClockTime schedule - periodicSchedule useAdjustedDatesForDcf ownerReceivesAssetLeg dayCountConvention - notional currency underlyingRefsAndWeights - pure [rateClaims, assetClaims] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance Asset.I for Instrument where - view = Asset.View with - asset = Asset with - instrument = BaseInstrument.instrumentKey this - description - underlyings - ownerReceivesRate - floatingRate - fixRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - addObservers = addObserversImpl @Instrument this $ - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . - Some . BaseInstrument.disclosureUpdateReference $ BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Factory.daml deleted file mode 100644 index 136ff0aa9..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Factory.daml +++ /dev/null @@ -1,65 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.CreditDefault.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Swap.V0.CreditDefault.Instrument qualified as CreditDefaultSwap (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Factory qualified as CreditDefaultSwapFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Types (CreditDefault(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance CreditDefaultSwapFactory.I for Factory where - view = CreditDefaultSwapFactory.View with provider - create' CreditDefaultSwapFactory.Create{ - creditDefault = CreditDefault{instrument; description; defaultProbabilityReferenceId; - recoveryRateReferenceId; ownerReceivesFix; fixRate; periodicSchedule; holidayCalendarIds; - calendarDataProvider; dayCountConvention; currency; lastEventTimestamp}; - observers} = do - let - creditDefaultSwapInstrument = CreditDefaultSwap.Instrument with - depository = instrument.depository - issuer = instrument.issuer - ownerReceivesFix - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - defaultProbabilityReferenceId - recoveryRateReferenceId - fixRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create creditDefaultSwapInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I creditDefaultSwapInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Instrument.daml deleted file mode 100644 index dc1939f07..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/CreditDefault/Instrument.daml +++ /dev/null @@ -1,131 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.CreditDefault.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createConditionalCreditFixRatePaymentClaims, createCreditEventPaymentClaims) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Instrument qualified as CreditDefaultSwap (I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Types (CreditDefault(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a cash-settled credit default swap. --- In case of a credit default event it pays (1-recoveryRate), in exchange for a fix rate at the end --- of every payment period. For example: 2.5% fix vs (1-recoveryRate) if TSLA defaults on a bond --- payment -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - defaultProbabilityReferenceId : Text - -- ^ The reference ID of the default probability observable. For example, in case of - -- protection against a "TSLA bond payment default" this should be a valid reference to the - -- "TSLA default probability". - recoveryRateReferenceId : Text - -- ^ The reference ID of the recovery rate observable. For example, in case of a "TSLA bond - -- payment default with a 60% recovery rate" this should be a valid reference to the "TSLA - -- bond recovery rate". - ownerReceivesFix : Bool - -- ^ Indicate whether a holding owner of this instrument receives the fix or the default - -- protection leg of the swap. - fixRate : Decimal - -- ^ The interest rate of the fix leg. For example, in case of "2.5% fix" this should be - -- 0.025. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the swap. For example, if the swap pays in USD this should be a USD cash - -- instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the swap's acquisition time) - let getCalendars = getHolidayCalendars actor calendarDataProvider - schedule <- fst <$> rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - useAdjustedDatesForDcf = True - notional = 1.0 - ownerReceivesCreditLeg = not ownerReceivesFix - fixClaims = createConditionalCreditFixRatePaymentClaims dateToDateClockTime schedule - periodicSchedule useAdjustedDatesForDcf fixRate ownerReceivesFix dayCountConvention - notional currency defaultProbabilityReferenceId - creditDefaultClaims = createCreditEventPaymentClaims dateToDateClockTime - ownerReceivesCreditLeg notional currency defaultProbabilityReferenceId - recoveryRateReferenceId periodicSchedule - pure [fixClaims, creditDefaultClaims] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance CreditDefaultSwap.I for Instrument where - view = CreditDefaultSwap.View with - creditDefault = CreditDefault with - instrument = BaseInstrument.instrumentKey this - description - defaultProbabilityReferenceId - recoveryRateReferenceId - ownerReceivesFix - fixRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Factory.daml deleted file mode 100644 index bc2217c38..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Factory.daml +++ /dev/null @@ -1,69 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Currency.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Swap.V0.Currency.Instrument qualified as CurrencySwap (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Factory qualified as CurrencySwapFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Types (CurrencySwap(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance CurrencySwapFactory.I for Factory where - view = CurrencySwapFactory.View with provider - create' CurrencySwapFactory.Create{ - currencySwap = CurrencySwap{instrument; description; ownerReceivesBase; baseRate; - foreignRate; periodicSchedule; holidayCalendarIds; calendarDataProvider; - dayCountConvention; baseCurrency; foreignCurrency; fxRate; lastEventTimestamp}; - observers} = do - let - currencySwapInstrument = CurrencySwap.Instrument with - depository = instrument.depository - issuer = instrument.issuer - ownerReceivesBase - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - baseRate - foreignRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - baseCurrency - foreignCurrency - lastEventTimestamp - fxRate - observers - cid <- toInterfaceContractId <$> create currencySwapInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I currencySwapInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Instrument.daml deleted file mode 100644 index 6e4ac81e0..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Currency/Instrument.daml +++ /dev/null @@ -1,137 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Currency.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createFixRatePaymentClaims) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Instrument qualified as CurrencySwap (I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Types (CurrencySwap(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a currency swap. --- It pays a fix vs fix rate (in different currencies) at the end of every payment period. --- The principal in the foreign currency is calculated using an fx rate and the principal amount in --- the base currency. The principal is not exchanged. --- For example: USD 1000k principal, fx rate 1.10 -> EUR 1100k principal --- 3% fix rate on USD 1000k vs --- 2% fix rate on EUR 1100k -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - ownerReceivesBase : Bool - -- ^ Indicate whether a holding owner of this instrument receives the base currency leg or the - -- foreign currency leg of the swap. - baseRate : Decimal - -- ^ The interest rate of the base currency. For example, in case of "3% in USD" this should - -- be 0.03. - foreignRate : Decimal - -- ^ The interest rate of the foreign currency. For example, in case of "2% in EUR" this - -- should be 0.02. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - baseCurrency : InstrumentKey - -- ^ The base currency of the swap. For example, in the case of USD this should be a USD cash - -- instrument. - foreignCurrency : InstrumentKey - -- ^ The foreign currency of the swap. For example, in case of EUR this should be a EUR cash - -- instrument. - fxRate : Decimal - -- ^ The fx rate used to convert from the base currency principal amount to the foreign - -- currency principal amount. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the swap's acquisition time) - let getCalendars = getHolidayCalendars actor calendarDataProvider - schedule <- fst <$> rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - useAdjustedDatesForDcf = True - notional = 1.0 - issuerPaysForeignLeg = not ownerReceivesBase - foreignRateInclFxPrincipalAdjustmentFactor = foreignRate * fxRate - baseLegClaims = createFixRatePaymentClaims dateToDateClockTime schedule periodicSchedule - useAdjustedDatesForDcf baseRate ownerReceivesBase dayCountConvention notional - baseCurrency - foreignLegClaims = createFixRatePaymentClaims dateToDateClockTime schedule - periodicSchedule useAdjustedDatesForDcf foreignRateInclFxPrincipalAdjustmentFactor - issuerPaysForeignLeg dayCountConvention notional foreignCurrency - pure [baseLegClaims, foreignLegClaims] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance CurrencySwap.I for Instrument where - view = CurrencySwap.View with - currencySwap = CurrencySwap with - instrument = BaseInstrument.instrumentKey this - description - ownerReceivesBase - baseRate - foreignRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - baseCurrency - foreignCurrency - fxRate - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Factory.daml deleted file mode 100644 index a5e51d0e8..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Factory.daml +++ /dev/null @@ -1,65 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.ForeignExchange.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Swap.V0.ForeignExchange.Instrument qualified as ForeignExchangeSwap (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Factory qualified as ForeignExchangeSwapFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Types (ForeignExchange(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance ForeignExchangeSwapFactory.I for Factory where - view = ForeignExchangeSwapFactory.View with provider - create' ForeignExchangeSwapFactory.Create{ - foreignExchange = ForeignExchange{instrument; description; firstFxRate; finalFxRate; - issueDate; firstPaymentDate; maturityDate; baseCurrency; foreignCurrency; - lastEventTimestamp}; - observers} = do - let - foreignExchangeSwapInstrument = ForeignExchangeSwap.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - firstFxRate - finalFxRate - issueDate - firstPaymentDate - maturityDate - baseCurrency - foreignCurrency - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create foreignExchangeSwapInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks. - Claim.getClaims (toInterface @Claim.I foreignExchangeSwapInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Instrument.daml deleted file mode 100644 index 6ce2f8c8b..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/ForeignExchange/Instrument.daml +++ /dev/null @@ -1,113 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.ForeignExchange.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createFxAdjustedPrincipalClaim) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Instrument qualified as ForeignExchange (I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Types (ForeignExchange(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a foreign exchange swap (FX Swap). --- It has two legs: an initial FX transaction and a final FX transaction. --- The instrument has a base currency and a foreign currency. --- The convention is that a holding owner receives the foreign currency in the initial transaction --- (and pays it in the final transaction). --- Both FX rates and transaction dates are predetermined between the counterparties. --- For example: USD 1000k vs EUR 1100k (fx rate: 1.10) today --- USD 1000k vs EUR 1200k (fx rate: 1.20) in 6 months -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - firstFxRate : Decimal - -- ^ The fx rate used for the first swap payment. - finalFxRate : Decimal - -- ^ The fx rate used for the final swap payment. - issueDate : Date - -- ^ The date when the swap was issued. - firstPaymentDate : Date - -- ^ The first payment date of the swap. - maturityDate : Date - -- ^ The final payment date of the swap. - baseCurrency : InstrumentKey - -- ^ The base currency of the swap, which will be exchanged to another (foreign) currency on - -- the first payment date. For example, in case of USD this should be a USD cash instrument. - foreignCurrency : InstrumentKey - -- ^ The foreign currency of the swap. For example, in case of EUR this should be a EUR cash - -- instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims _ = do - -- get the initial claims tree (as of the swap's acquisition time) - let - notional = 1.0 - baseCurrencyFirstPayment = createFxAdjustedPrincipalClaim dateToDateClockTime False 1.0 - notional baseCurrency firstPaymentDate - foreignCurrencyFirstPayment = createFxAdjustedPrincipalClaim dateToDateClockTime True - firstFxRate notional foreignCurrency firstPaymentDate - baseCurrencyFinalPayment = createFxAdjustedPrincipalClaim dateToDateClockTime True 1.0 - notional baseCurrency maturityDate - foreignCurrencyFinalPayment = createFxAdjustedPrincipalClaim dateToDateClockTime False - finalFxRate notional foreignCurrency maturityDate - pure [baseCurrencyFirstPayment, foreignCurrencyFirstPayment, baseCurrencyFinalPayment, - foreignCurrencyFinalPayment] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance ForeignExchange.I for Instrument where - view = ForeignExchange.View with - foreignExchange = ForeignExchange with - instrument = BaseInstrument.instrumentKey this - description; firstFxRate; finalFxRate; issueDate - firstPaymentDate; maturityDate; baseCurrency; foreignCurrency; lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Factory.daml deleted file mode 100644 index a8074c5fb..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Factory.daml +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Fpml.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Swap.V0.Fpml.Instrument qualified as FpmlSwap (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Factory qualified as FpmlSwapFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Types (Fpml(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance FpmlSwapFactory.I for Factory where - view = FpmlSwapFactory.View with provider - create' FpmlSwapFactory.Create{ - fpml = Fpml{instrument; description; issuerPartyRef; swapStreams; calendarDataProvider; - currencies; lastEventTimestamp}; - observers} = do - let - fpmlSwapInstrument = FpmlSwap.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - issuerPartyRef - swapStreams - calendarDataProvider - currencies - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create fpmlSwapInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I fpmlSwapInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Instrument.daml deleted file mode 100644 index a94f05124..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Instrument.daml +++ /dev/null @@ -1,144 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Fpml.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Swap.V0.Fpml.Util (applyPaymentDaysOffset, calculateClaimsFromSwapStream, createCalculationPeriodicSchedule, createPaymentPeriodicSchedule) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.FpmlTypes (DateRelativeToEnum(..), NotionalScheduleValue(..), SwapStream(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Instrument qualified as Fpml (I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Types (Fpml(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models a swap specified by FpML swapStream modules. --- It can contain one or several legs of different types: fix or floating rates -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - swapStreams : [SwapStream] - -- ^ Each element describes a stream of swap payments, for example a regular fixed or floating - -- rate. - issuerPartyRef : Text - -- ^ Used to the identify which counterparty is the issuer in the swapStream. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - currencies : [InstrumentKey] - -- ^ The currencies of the different swap legs, one for each swapStream. For example, if one - -- leg pays in USD this should be a USD cash instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the swap's acquisition time) - let - calculateSwapStreamClaims (s, ccy) = do - let - calculationPeriodicSchedule = - createCalculationPeriodicSchedule s.calculationPeriodDates - paymentPeriodicSchedule = createPaymentPeriodicSchedule s - useAdjustedDatesForDcf = True - issuerPaysLeg = if s.payerPartyReference == s.receiverPartyReference - then error "payer and receiver must be different counterparties" - else (s.payerPartyReference == issuerPartyRef) - -- Verify the payment schedule - assertMsg ("The payment schedule must refer to the calculationPeriodDates of the " <> - "current swapStream") $ - s.paymentDates.calculationPeriodDatesReference == s.calculationPeriodDates.id - assertMsg "Only payment schedules relative to CalculationPeriodEndDate supported" $ - s.paymentDates.payRelativeTo == CalculationPeriodEndDate - let getCalendars = getHolidayCalendars issuer calendarDataProvider - calculationSchedule <- fst <$> rollSchedule getCalendars calculationPeriodicSchedule - s.calculationPeriodDates.calculationPeriodDatesAdjustments.businessCenters - (paymentScheduleBase, paymentCalendars) <- rollSchedule getCalendars - paymentPeriodicSchedule s.paymentDates.paymentDatesAdjustments.businessCenters - let - paymentSchedule = applyPaymentDaysOffset paymentScheduleBase s.paymentDates - paymentCalendars - -- If there is an fxLinkedNotionalSchedule, look up which swap leg contains the base - -- notional - let - swapStreamNotionalRef = - case s.calculationPeriodAmount.calculation.notionalScheduleValue of - NotionalSchedule_FxLinked fxl -> - find (\e -> case e.calculationPeriodAmount.calculation.notionalScheduleValue of - NotionalSchedule_FxLinked fxl -> False - NotionalSchedule_Regular notionalSchedule -> - notionalSchedule.id == fxl.constantNotionalScheduleReference) swapStreams - NotionalSchedule_Regular n -> None - -- Calculate the claims from the current leg (either fix or float) - calculateClaimsFromSwapStream - s - calculationPeriodicSchedule - calculationSchedule - paymentSchedule - swapStreamNotionalRef - useAdjustedDatesForDcf - issuerPaysLeg - ccy - issuer - calendarDataProvider - allClaims <- mapA calculateSwapStreamClaims $ zip swapStreams currencies - pure $ concat allClaims - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance Fpml.I for Instrument where - view = Fpml.View with - fpml = Fpml with - instrument = BaseInstrument.instrumentKey this - description - swapStreams - issuerPartyRef - calendarDataProvider - currencies - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Util.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Util.daml deleted file mode 100644 index d98de61c0..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/Fpml/Util.daml +++ /dev/null @@ -1,744 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.Fpml.Util where - -import ContingentClaims.Core.V3.Claim (Claim, Inequality(..), andList, give, one, scale, when) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Date (addDays, subDate) -import DA.Foldable (foldMap) -import DA.List (dedup, head, init, last, sortOn, tail) -import DA.Math ((**)) -import DA.Optional (fromOptional, fromSome, fromSomeNote, isNone, isSome, whenSome) -import Daml.Finance.Claims.V3.Util.Builders (prepareAndTagClaims) -import Daml.Finance.Claims.V3.Util.Date (convertImplicitDcfToActualDcf) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Types (Deliverable, Observable, TaggedClaim(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.FpmlTypes -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayAdjustment(..), BusinessDayConventionEnum(..), HolidayCalendarData) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period(..), PeriodEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.Schedule (Frequency(..), PeriodicSchedule(..), ScheduleFrequency(..), SchedulePeriod(..), StubPeriodTypeEnum(..)) -import Daml.Finance.Util.V4.Date.Calendar (addBusinessDays, adjustDate, merge) -import Daml.Finance.Util.V4.Date.DayCount (calcPeriodDcf) -import Daml.Finance.Util.V4.Date.RollConvention (addPeriod) -import Prelude hiding (Down) -import Prelude qualified as P (Down(..)) - -type O = Observation Date Decimal Observable -type C = Claim Date Decimal Deliverable Observable - --- | HIDE Static data for a single period in the calculation schedule of a floating rate leg. -data CalculationPeriodStaticData = CalculationPeriodStaticData - with - calculationPeriod : SchedulePeriod - -- ^ Calculation period that this static data refers to. - notional : Decimal - -- ^ Notional used for this calculation period. - fxAdjRequired : Bool - -- ^ Indicates whether the notional should be FX adjusted. - rateFixingDate : Date - -- ^ The fixing date used for the floating rate. - deriving (Eq, Show) - --- | HIDE Data for a single period in the calculation schedule of a floating rate leg. -data CalculationPeriodData = CalculationPeriodData - with - calculationPeriod : SchedulePeriod - -- ^ Calculation period that this static data refers to. - rateFixingDate : Date - -- ^ The fixing date used for the floating rate. - dcf : O - -- ^ The daycount fraction used for the floating rate in this calculation period. - notional : O - -- ^ (Possibly fx adjusted) notional used for this calculation period. - deriving (Eq, Show) - --- | Create a schedule for calculation periods. -createCalculationPeriodicSchedule : CalculationPeriodDates -> PeriodicSchedule -createCalculationPeriodicSchedule c = - PeriodicSchedule with - businessDayAdjustment = BusinessDayAdjustment with - calendarIds = c.calculationPeriodDatesAdjustments.businessCenters - convention = c.calculationPeriodDatesAdjustments.businessDayConvention - effectiveDateBusinessDayAdjustment = None - terminationDateBusinessDayAdjustment = None - frequency = case c.calculationPeriodFrequency.period of - Regular pe -> Periodic Frequency with - rollConvention = c.calculationPeriodFrequency.rollConvention - period = Period with - period = pe - periodMultiplier = c.calculationPeriodFrequency.periodMultiplier - T -> SinglePeriod - effectiveDate = case c.firstPeriodStartDate of - Some fp -> fp.unadjustedDate - None -> c.effectiveDate.unadjustedDate - firstRegularPeriodStartDate = c.firstRegularPeriodStartDate - lastRegularPeriodEndDate = c.lastRegularPeriodEndDate - stubPeriodType = None - terminationDate = c.terminationDate.unadjustedDate - --- | Create a schedule for payment periods. -createPaymentPeriodicSchedule : SwapStream -> PeriodicSchedule -createPaymentPeriodicSchedule s = - PeriodicSchedule with - businessDayAdjustment = BusinessDayAdjustment with - calendarIds = s.paymentDates.paymentDatesAdjustments.businessCenters - convention = s.paymentDates.paymentDatesAdjustments.businessDayConvention - effectiveDateBusinessDayAdjustment = None - terminationDateBusinessDayAdjustment = None - frequency = case s.paymentDates.paymentFrequency.period of - Regular pe -> Periodic Frequency with - rollConvention = s.calculationPeriodDates.calculationPeriodFrequency.rollConvention - period = Period with - period = pe - periodMultiplier = s.paymentDates.paymentFrequency.periodMultiplier - T -> SinglePeriod - effectiveDate = s.calculationPeriodDates.effectiveDate.unadjustedDate - firstRegularPeriodStartDate = s.paymentDates.firstPaymentDate - lastRegularPeriodEndDate = s.paymentDates.lastRegularPaymentDate - stubPeriodType = None - terminationDate = s.calculationPeriodDates.terminationDate.unadjustedDate - --- | Retrieve holiday calendars and adjust a date as specified in a BusinessDayAdjustments FpML --- element -getCalendarsAndAdjust : Date -> BusinessDayAdjustments -> Party -> Party -> Update Date -getCalendarsAndAdjust unadjustedDate businessDayAdjustments issuer calendarDataAgency = do - cals <- getHolidayCalendars issuer calendarDataAgency businessDayAdjustments.businessCenters - pure $ adjustDate (merge cals) businessDayAdjustments.businessDayConvention unadjustedDate - --- | Adjust a date as specified in a BusinessDayAdjustments FpML element --- (or not at all if NoAdjustment) -adjustDateAccordingToBusinessDayAdjustments : Date -> BusinessDayAdjustments -> Party - -> Party -> Update Date -adjustDateAccordingToBusinessDayAdjustments unadjustedDate businessDayAdjustments issuer - calendarDataAgency = - case businessDayAdjustments.businessDayConvention of - NoAdjustment -> pure unadjustedDate - _ -> getCalendarsAndAdjust unadjustedDate businessDayAdjustments issuer calendarDataAgency - --- | Adjust payment schedule according to paymentDaysOffset (if available). -applyPaymentDaysOffset : [SchedulePeriod] -> PaymentDates -> [HolidayCalendarData] -> - [SchedulePeriod] -applyPaymentDaysOffset paymentSchedule paymentDates paymentCalendars = - case paymentDates.paymentDaysOffset of - Some dateOffset -> case dateOffset.dayType of - Some Business -> map (\p -> p with - adjustedEndDate = addBusinessDays cals nDays p.adjustedEndDate - ) paymentSchedule - Some Calendar -> map (\p -> p with - adjustedEndDate = adjustDate cals - paymentDates.paymentDatesAdjustments.businessDayConvention - (addDays p.adjustedEndDate nDays) - ) paymentSchedule - _ -> error "Only Business or Calendar day type supported" - where - nDays = if dateOffset.period == D then dateOffset.periodMultiplier - else error "Only daily offset supported" - cals = merge paymentCalendars - None -> paymentSchedule - --- | Define observable part of claim when one specific floating rate is provided for a stub period. -getSingleStubRate : StubFloatingRate -> Date -> Optional O -getSingleStubRate floatingRate rateFixingDate = - Some (ObserveAt floatingRate.floatingRateIndex rateFixingDate) - --- | Linearly interpolates two rates within a period, as specified in --- https://www.isda.org/a/aWkgE/Linear-interpolation-04022022.pdf -getInterpolatedStubRate : StubFloatingRate -> StubFloatingRate -> SchedulePeriod -> - HolidayCalendarData -> BusinessDayConventionEnum -> Date -> Optional O -getInterpolatedStubRate fr1 fr2 p cal convention rateFixingDate = - let - tenor1 = fromSome fr1.indexTenor - tenor2 = fromSome fr2.indexTenor - s = p.adjustedStartDate - p1 = adjustDate cal convention (addPeriod s tenor1) - p2 = adjustDate cal convention (addPeriod s tenor2) - tn = subDate p.adjustedEndDate s - t1 = subDate p1 s - t2 = subDate p2 s - d1 = tn - t1 - d2 = t2 - tn - w1 = intToDecimal d2 / intToDecimal (d1 + d2) - w2 = 1.0 - w1 - -- In the ISDA paper, the following expression is used for linear interpolation: - -- Some ( - -- Observe (fr1.floatingRateIndex) + - -- (Observe (fr2.floatingRateIndex) - Observe (fr1.floatingRateIndex)) * - -- Const (intToDecimal (tn - t1) / intToDecimal (t2 - t1)) - -- ) - -- This expression can be simplified to: - in - Some $ Const w1 * ObserveAt fr1.floatingRateIndex rateFixingDate + - Const w2 * ObserveAt fr2.floatingRateIndex rateFixingDate - --- | Get the floating stub rate to be used for a stub period. -getStubRateFloating : [StubFloatingRate] -> SchedulePeriod -> HolidayCalendarData -> - BusinessDayConventionEnum -> Date -> Optional O -getStubRateFloating floatingRates p cal convention rateFixingDate = - case floatingRates of - [rate] -> getSingleStubRate rate rateFixingDate - [rate1, rate2] -> getInterpolatedStubRate rate1 rate2 p cal convention rateFixingDate - other -> error "only one or two floating stub rates supported" - --- | Get the stub rate to be used for a stub period. --- Currently, three main options from the FpML schema are supported: --- 1. A fix stubRate. --- 2. One or two floating rates for the stub. --- 3. No specific stub rate defined -> use the same rate as is used for regular periods. -getStubRate : StubCalculationPeriodAmount -> Bool -> SchedulePeriod -> HolidayCalendarData -> - BusinessDayConventionEnum -> Bool -> Date -> Optional O -getStubRate sc initialStub p cal convention fixLeg rateFixingDate = - let - stubValue = if initialStub then fromSome sc.initialStub else fromSome sc.finalStub - in - case stubValue of - StubValue_StubRate stubRate -> Const <$> Some stubRate - StubValue_FloatingRate stubFloatingRates -> - if fixLeg - then error "floating stub not supported for fix leg" - else getStubRateFloating stubFloatingRates p cal convention rateFixingDate - --- | Align the payment schedule with the calculation schedule. -alignPaymentSchedule : [SchedulePeriod] -> [SchedulePeriod] -> Update [SchedulePeriod] -alignPaymentSchedule calculationSchedule paymentSchedule = do - assertMsg "The payment schedule has fewer periods than the calculation schedule" $ - length paymentSchedule <= length calculationSchedule - let - calculationScheduleWithoutStubs = filter (isNone . (.stubType)) calculationSchedule - paymentScheduleWithoutStubs = filter (isNone . (.stubType)) paymentSchedule - assertMsg - "The payment schedule periods must be an even multiple of the calculation schedule periods" $ - null paymentScheduleWithoutStubs || - length calculationScheduleWithoutStubs % length paymentScheduleWithoutStubs == 0 - let - firstPeriod = head paymentSchedule - lastPeriod = last paymentSchedule - initialStubIfItExists = case firstPeriod.stubType of - Some ShortInitial -> [firstPeriod] - Some LongInitial -> [firstPeriod] - _ -> [] - finalStubIfItExists = case lastPeriod.stubType of - Some ShortFinal -> [lastPeriod] - Some LongFinal -> [lastPeriod] - _ -> [] - paymentScheduleAlignedWithoutStubs = case length paymentScheduleWithoutStubs of - 0 -> [] - _ -> foldMap (replicate nCalculationPeriodsPerPaymentPeriod) paymentScheduleWithoutStubs - where - nCalculationPeriodsPerPaymentPeriod = - length calculationScheduleWithoutStubs / length paymentScheduleWithoutStubs - paymentScheduleAligned = - initialStubIfItExists ++ paymentScheduleAlignedWithoutStubs ++ finalStubIfItExists - assertMsg "The payment schedule must match the calculation schedule" $ - length paymentScheduleAligned == length calculationSchedule - pure paymentScheduleAligned - -verifyFxScheduleAndGetId : [SchedulePeriod] -> SwapStream -> Party -> Party -> - FxLinkedNotionalSchedule -> Update (Optional Text, Optional Decimal, Optional [Date]) -verifyFxScheduleAndGetId calculationSchedule s issuer calendarDataAgency fx = do - fxFixingCalendars <- - getHolidayCalendars issuer calendarDataAgency fx.varyingNotionalFixingDates.businessCenters - let - fxFixingDates = map (\p -> - addBusinessDays - (merge fxFixingCalendars) - fx.varyingNotionalFixingDates.periodMultiplier - p.adjustedStartDate - ) calculationSchedule - - pure (Some fx.fxSpotRateSource.primaryRateSource.rateSourcePage, fx.initialValue, - Some fxFixingDates) - -getFxRateId : [SchedulePeriod] -> SwapStream -> Party -> Party -> - Update (Optional Text, Optional Decimal, Optional [Date]) -getFxRateId calculationSchedule s issuer calendarDataAgency = - case s.calculationPeriodAmount.calculation.notionalScheduleValue of - NotionalSchedule_FxLinked fx -> - verifyFxScheduleAndGetId calculationSchedule s issuer calendarDataAgency fx - _ -> pure (None, None, None) - -getRateFixingsAndCalendars : SwapStream -> ResetDates -> [SchedulePeriod] -> Party -> Party -> - Update ([Date], HolidayCalendarData) -getRateFixingsAndCalendars s r calculationSchedule issuer calendarDataAgency = do - assertMsg "resetDate must refer to the calculationPeriodDates of the current swapStream" $ - r.calculationPeriodDatesReference == s.calculationPeriodDates.id - assertMsg "resetDate period must match calculation period" $ - r.resetFrequency.period == s.calculationPeriodDates.calculationPeriodFrequency.period - assertMsg "resetDate periodMultiplier must match calculation periodMultiplier" $ - r.resetFrequency.periodMultiplier == - s.calculationPeriodDates.calculationPeriodFrequency.periodMultiplier - assertMsg "resetDate businessDayConvention must match calculation businessDayConvention" $ - r.resetDatesAdjustments.businessDayConvention == - s.calculationPeriodDates.calculationPeriodDatesAdjustments.businessDayConvention - assertMsg "resetDate businessCenters must match calculation businessCenters" $ - r.resetDatesAdjustments.businessCenters == - s.calculationPeriodDates.calculationPeriodDatesAdjustments.businessCenters - assertMsg "Only daily fixing date period supported" $ r.fixingDates.period == D - whenSome r.fixingDates.dayType $ \dayType -> - assertMsg "Only Business day type supported" $ dayType == Business - rateFixingCalendars <- getHolidayCalendars issuer calendarDataAgency r.fixingDates.businessCenters - let - rateFixingCalendar = merge rateFixingCalendars - rateFixingDatesAfterAddDays = map (\p -> - addBusinessDays rateFixingCalendar r.fixingDates.periodMultiplier $ - if r.resetRelativeTo == CalculationPeriodStartDate then p.adjustedStartDate - else p.adjustedEndDate - ) calculationSchedule - rateFixingDates = map (adjustDate rateFixingCalendar r.fixingDates.businessDayConvention) - rateFixingDatesAfterAddDays - pure (rateFixingDates, rateFixingCalendar) - --- | Create claims from swapStream that describes a fixed coupon stream. -calculateFixPaymentClaimsFromSwapStream : FixedRateSchedule -> SwapStream -> PeriodicSchedule -> - [SchedulePeriod] -> [SchedulePeriod] -> Bool -> Bool -> Deliverable -> Party -> Party -> - Optional Text -> Optional [Date] -> [(Decimal, Bool)] -> Update [TaggedClaim] -calculateFixPaymentClaimsFromSwapStream fixedRateSchedule s periodicSchedule calculationSchedule - paymentScheduleAligned useAdjustedDatesForDcf issuerPaysLeg currency issuer calendarDataAgency - fxRateId fxFixingDates notionals = do - assertMsg "Non-standard stub rates not supported for the fixed rate leg" $ - isNone s.stubCalculationPeriodAmount - assertMsg "Compounding not supported for the fixed rate leg" $ - isNone s.calculationPeriodAmount.calculation.compoundingMethodEnum - let - initialStep = Step with - stepDate = (.unadjustedStartDate) $ head calculationSchedule - stepValue = fixedRateSchedule.initialValue - rateStepScheduleInclInitial = sortOn (\x -> P.Down x.stepDate) $ - initialStep :: fixedRateSchedule.step - - -- Find the fixed rate for the current date in the step list - findRate rateSteps calculationPeriod = - lastMatching.stepValue - where - lastMatching = fromSome $ find (\r -> r.stepDate <= calculationPeriod.unadjustedStartDate) - rateSteps - - -- calculate fix rate claims - createClaim (c, (n, fxAdjRequired)) p = - when (TimeGte p.adjustedEndDate) - $ scale notional - $ scale (rate * Const - (calcPeriodDcf s.calculationPeriodAmount.calculation.dayCountFraction c - useAdjustedDatesForDcf periodicSchedule.terminationDate periodicSchedule.frequency - )) - $ one currency - where - notionalConst = Const n - notional = case fxRateId of - None -> notionalConst - Some fxRateId -> if fxAdjRequired - then error "fx adjusted notional not yet supported for fix rate leg" - else notionalConst - fixRate = findRate rateStepScheduleInclInitial c - regularRate = Const fixRate - rate = regularRate - claimAmounts = - andList $ zipWith createClaim (zip calculationSchedule notionals) paymentScheduleAligned - claims = if issuerPaysLeg then claimAmounts else give claimAmounts - claimsTagged = prepareAndTagClaims dateToDateClockTime [claims] "Fix rate payment" - allTaggedClaims = case s.principalExchanges of - None -> [claimsTagged] - Some principalExchanges -> [claimsTagged, principalClaimsTagged] - where - rateFixingDates = map (.adjustedStartDate) paymentScheduleAligned - principalClaimsTagged = calculatePrincipalExchangePaymentClaims paymentScheduleAligned - issuerPaysLeg currency fxRateId notionals rateFixingDates principalExchanges - pure allTaggedClaims - --- | Create principal exchange claims. -calculatePrincipalExchangePaymentClaims : [SchedulePeriod] -> Bool -> Deliverable -> - Optional Text -> [(Decimal, Bool)] -> [Date] -> PrincipalExchanges -> TaggedClaim -calculatePrincipalExchangePaymentClaims paymentScheduleAligned issuerPaysLeg currency - fxRateId notionals rateFixingDates pe = - let - createPrincipalClaim fixingDate p (n, fxAdjRequired) startOrEndDate = - when (TimeGte paymentDate) $ scale notional $ one currency - where - paymentDate = startOrEndDate p - notionalConst = Const n - notional = case fxRateId of - None -> notionalConst - Some fxRateId -> if fxAdjRequired then notionalConst * fxRateObs else notionalConst - where fxRateObs = ObserveAt fxRateId fixingDate - createInitialClaim f p (n, fxAdjRequired) = - if issuerPaysLeg then give principalInitialClaim else principalInitialClaim - where - principalInitialClaim = createPrincipalClaim f p (n, fxAdjRequired) (.adjustedStartDate) - createIntermediateClaim f p (n, fxAdjRequired) = - createPrincipalClaim f p (n, fxAdjRequired) (.adjustedEndDate) - createClaim f p (n, fxAdjRequired) = - if issuerPaysLeg then give principalClaim else principalClaim - where principalClaim = createIntermediateClaim f p (n, fxAdjRequired) - undoClaim f p (n, fxAdjRequired) = give $ createClaim f p (n, fxAdjRequired) - initialClaims = if pe.initialExchange - then [createInitialClaim (head rateFixingDates) - (head paymentScheduleAligned) (head notionals)] - else [] - intermediateUndoClaims = - if pe.intermediateExchange - then - if length rateFixingDates == length paymentScheduleAligned && - length rateFixingDates == length notionals then - zipWith3 undoClaim (init rateFixingDates) (init paymentScheduleAligned) (init notionals) - else error "rateFixings, paymentSchedule and notionals must be of equal length" - else - case fxRateId of - Some fx -> error "intermediate exchange disabled, unclear which FX rate to use" - _ -> [] - intermediateNewClaims = - if pe.intermediateExchange - then zipWith3 createClaim (tail rateFixingDates) (init paymentScheduleAligned) - (tail notionals) - else [] - principalFinalClaims = - if pe.finalExchange - then [undoClaim (last rateFixingDates) (last paymentScheduleAligned) (last notionals)] - else [] - principalClaims = initialClaims ++ intermediateUndoClaims ++ intermediateNewClaims ++ - principalFinalClaims - in - prepareAndTagClaims dateToDateClockTime principalClaims "Principal exchange payment" - --- | Apply rounding convention to the rate used in a calculation period. --- Takes a Rounding FpML object as an input: --- https://www.fpml.org/spec/fpml-5-11-3-lcwd-1/html/confirmation/schemaDocumentation/schemas/fpml-shared-5-11_xsd/complexTypes/FloatingRateCalculation/finalRateRounding.html -roundRate : Decimal -> Rounding -> Decimal -roundRate rate rounding = - let - scaleFactor = 10.0 ** (- (intToDecimal rounding.precision)) - roundNumber : (Decimal -> Int) -> Decimal - roundNumber r = intToDecimal $ r (rate * 10.0 ** (intToDecimal (rounding.precision))) - in case rounding.roundingDirection of - Up -> roundNumber ceiling * scaleFactor - Down -> roundNumber floor * scaleFactor - Nearest -> roundNumber round * scaleFactor - --- | HIDE --- Get the floating rate to be used for a period, taking stub periods into account. -getFloatingRate : SwapStream -> SchedulePeriod -> SchedulePeriod -> - O -> HolidayCalendarData -> Bool -> Date -> O -getFloatingRate s calculationPeriod paymentPeriod - regularRate rateFixingCalendar fixLeg rateFixingDate = - case (calculationPeriod.stubType, s.stubCalculationPeriodAmount) of - (Some stubType, Some scpa) -> fromOptional regularRate $ - getStubRate - scpa - (stubType == LongInitial || stubType == ShortInitial) - paymentPeriod - rateFixingCalendar - s.calculationPeriodDates.calculationPeriodDatesAdjustments.businessDayConvention - fixLeg - rateFixingDate - _ -> regularRate - --- | HIDE --- Recursive function to calculate flat compounding. --- It follows the ISDA calculation example for flat compounding, example 4.2: --- https://www.isda.org/a/2KiDE/isda-compounding-memo.pdf -calcFlatCompounding : O -> Deliverable -> SchedulePeriod -> SwapStream - -> Text -> Decimal -> HolidayCalendarData -> Bool -> - [CalculationPeriodData] -> [CalculationPeriodData] -> [C] -calcFlatCompounding notional currency p s - floatingRateIndex floatingRateSpread rateFixingCalendar fixLeg - (x::xs) calculationPeriodDataSelected = - calcFlatCompounding notional currency p s - floatingRateIndex floatingRateSpread rateFixingCalendar fixLeg - xs calculationPeriodDataSelected ++ - calcFlatCompounding notional currency p s - floatingRateIndex floatingRateSpread rateFixingCalendar fixLeg - xs (calculationPeriodDataSelected ++ [x]) -calcFlatCompounding notional currency p s - floatingRateIndex floatingRateSpread rateFixingCalendar fixLeg - [] calculationPeriodDataSelected = - if null calculationPeriodDataSelected then [] else [scale notional $ compoundedRates] - where - foldRates acc (pp, includeSpread) = - scale (rate * pp.dcf) acc - where - regularRateExclSpread = ObserveAt floatingRateIndex pp.rateFixingDate - regularRateInclSpread = regularRateExclSpread + Const floatingRateSpread - regularRate = if includeSpread then regularRateInclSpread else regularRateExclSpread - rate = getFloatingRate s pp.calculationPeriod p regularRate rateFixingCalendar fixLeg - pp.rateFixingDate - - includeSpread = True :: replicate (length calculationPeriodDataSelected - 1) False - - compoundedRates = when (TimeGte p.adjustedEndDate) $ foldl - foldRates - (one currency) - (reverse $ zip calculationPeriodDataSelected includeSpread) - --- | HIDE --- Calculate notional and fixing data for a payment period. -calculateNotionalAndFixings : SchedulePeriod -> SwapStream -> - [CalculationPeriodStaticData] -> Optional Text -> Bool -> PeriodicSchedule -> - (Optional O, [CalculationPeriodData]) -calculateNotionalAndFixings p s - paymentPeriodStaticData fxRateId useAdjustedDatesForDcf periodicSchedule = - (constantNotional, paymentPeriodData) - where - paymentPeriodStaticDataFiltered = filter (\c -> - c.calculationPeriod.unadjustedEndDate <= p.unadjustedEndDate && - c.calculationPeriod.unadjustedEndDate > p.unadjustedStartDate) - paymentPeriodStaticData - - -- Ensure that all notionals and fxAdjRequireds are the same for each paymentPeriod - notionals = map (.notional) paymentPeriodStaticDataFiltered - n = if length (dedup notionals) <= 1 then head notionals - else error "notional must be constant within a payment period" - fxAdjRequireds = map (.fxAdjRequired) paymentPeriodStaticDataFiltered - fxAdjRequired = if length (dedup fxAdjRequireds) <= 1 then head fxAdjRequireds - else error "fxAdjRequired must be constant within a payment period" - - notionalConst = Const n - constantNotional = case fxRateId of - None -> Some notionalConst - Some fxRateId -> None - paymentPeriodData = map - (\c -> CalculationPeriodData with - calculationPeriod = c.calculationPeriod - rateFixingDate = c.rateFixingDate - dcf = Const (calcPeriodDcf s.calculationPeriodAmount.calculation.dayCountFraction - c.calculationPeriod useAdjustedDatesForDcf periodicSchedule.terminationDate - periodicSchedule.frequency) - notional = case fxRateId of - None -> notionalConst - Some fxRateId -> if fxAdjRequired then notionalConst * fxRateObs else notionalConst - where fxRateObs = ObserveAt fxRateId c.rateFixingDate - ) - paymentPeriodStaticDataFiltered - --- | Check whether a FloatingRateCalculation uses a reference rate that needs to be compounded. --- Seems there is no FpML element that specificies this, but that it is implicit in the rate name, --- for example "USD-SOFR-COMPOUND" --- If it is a compounded reference rate, also return the daycount convention that was used for the --- corresponding reference index, e.g. Act360 in the case of the SOFR Index. -checkRefRateCompounding : FloatingRateCalculation -> (Bool, Optional DayCountConventionEnum) -checkRefRateCompounding floatingRateCalculation = - case floatingRateCalculation.floatingRateIndex of - "USD-SOFR-COMPOUND" -> (True, Some Act360) - "EUR-EONIA-OIS-COMPOUND" -> (True, Some Act360) - _ -> (False, None) - --- | Create claims from swapStream that describes a floating coupon stream. -calculateFloatingPaymentClaimsFromSwapStream : FloatingRateCalculation -> SwapStream -> - PeriodicSchedule -> [SchedulePeriod] -> [SchedulePeriod] -> Bool -> Bool -> Deliverable -> - Party -> Party -> Optional Text -> Optional [Date] -> [(Decimal, Bool)] -> Update [TaggedClaim] -calculateFloatingPaymentClaimsFromSwapStream floatingRateCalculation s - periodicSchedule calculationSchedule paymentSchedule useAdjustedDatesForDcf issuerPaysLeg currency - issuer calendarDataAgency fxRateId fxFixingDates notionals = do - assertMsg "rate rounding not yet supported" $ isNone floatingRateCalculation.finalRateRounding - let resetDates = fromSome s.resetDates - (rateFixingDates, rateFixingCalendar) <- getRateFixingsAndCalendars s resetDates - calculationSchedule issuer calendarDataAgency - whenSome fxFixingDates $ \fxDates -> - assertMsg "fxFixingDates must match rateFixingDates" $ fxDates == rateFixingDates - - let - fixLeg = False - calculationScheduleStaticData = zipWith3 (\c (n, fx) f -> CalculationPeriodStaticData with - calculationPeriod = c - notional = n - fxAdjRequired = fx - rateFixingDate = f - ) calculationSchedule notionals rateFixingDates - floatingRateSpread = case floatingRateCalculation.spreadSchedule of - [] -> 0.0 - [se] -> se.initialValue - _ -> error "Multiple SpreadSchedules not yet supported" - (compoundedRefRate, dcfConventionImplicit) = checkRefRateCompounding floatingRateCalculation - - -- calculate compounded floating rate claim for a payment period - -- this supports both straight and spread-exclusive compounding - createClaim includeSpread p = - scale notional compoundedRatePayment - where - (constNotional, paymentPeriodData) = calculateNotionalAndFixings p s - calculationScheduleStaticData fxRateId useAdjustedDatesForDcf periodicSchedule - notional = fromSomeNote "createClaim requires a constant notional during a payment period" - constNotional - - compoundRates acc pp = - (Const 1.0 + rate * pp.dcf) * acc - where - regularRateExclSpread = ObserveAt floatingRateCalculation.floatingRateIndex - pp.rateFixingDate - regularRateInclSpread = regularRateExclSpread + Const floatingRateSpread - regularRate = if includeSpread then regularRateInclSpread else regularRateExclSpread - rate = getFloatingRate s pp.calculationPeriod p regularRate rateFixingCalendar fixLeg - pp.rateFixingDate - - compoundedRates = foldl compoundRates (Const 1.0) paymentPeriodData - compoundedRatePayment = when (TimeGte p.adjustedEndDate) $ - scale (compoundedRates - Const 1.0) $ one currency - - -- calculate all calculation period claims (using flat compounding) for a payment period - createCalcPeriodClaim p = - andList $ calcFlatCompounding notional currency p s - floatingRateCalculation.floatingRateIndex floatingRateSpread rateFixingCalendar fixLeg - paymentPeriodData [] - where - (constNotional, paymentPeriodData) = calculateNotionalAndFixings p s - calculationScheduleStaticData fxRateId useAdjustedDatesForDcf periodicSchedule - notional = fromSomeNote - "createCalcPeriodClaim requires a constant notional during a payment period" - constNotional - - -- calculate simple interest rate claim (no calc period compounding) for a payment period - -- using a non-compounded reference rate - createSimpleClaim p = - andList $ map createSimpleRate paymentPeriodData - where - (_, paymentPeriodData) = calculateNotionalAndFixings p s - calculationScheduleStaticData fxRateId useAdjustedDatesForDcf periodicSchedule - createSimpleRate pp = - when (TimeGte p.adjustedEndDate) $ scale (pp.notional * periodRate) $ one currency - where - regularRateExclSpread = ObserveAt floatingRateCalculation.floatingRateIndex - pp.rateFixingDate - regularRate = regularRateExclSpread + Const floatingRateSpread - rate = getFloatingRate s pp.calculationPeriod p regularRate rateFixingCalendar fixLeg - pp.rateFixingDate - periodRate = rate * pp.dcf - - -- calculate simple interest rate claim (no calc period compounding) for a payment period - -- using a compounded reference rate - createSimpleClaimCompoundedRefRate p = - andList $ map createSimpleRateCompoundingRefRate paymentPeriodData - where - (_, paymentPeriodData) = calculateNotionalAndFixings p s - calculationScheduleStaticData fxRateId useAdjustedDatesForDcf periodicSchedule - createSimpleRateCompoundingRefRate pp = claim - where - dcfConversionFactor = convertImplicitDcfToActualDcf pp.dcf pp.calculationPeriod - useAdjustedDatesForDcf periodicSchedule $ fromSome dcfConventionImplicit - endClaim = scale (pp.notional * dcfConversionFactor) $ one currency - fixingStartDate = addBusinessDays rateFixingCalendar - resetDates.fixingDates.periodMultiplier pp.calculationPeriod.adjustedStartDate - rateStart = ObserveAt floatingRateCalculation.floatingRateIndex fixingStartDate - fixingEndDate = addBusinessDays rateFixingCalendar - resetDates.fixingDates.periodMultiplier pp.calculationPeriod.adjustedEndDate - rateEnd = ObserveAt floatingRateCalculation.floatingRateIndex fixingEndDate - claim = - -- calculate a daily compounded reference rate using the corresponding index, - -- see page 36 here: - -- https://www.newyorkfed.org/medialibrary/Microsites/arrc/files/2021/users-guide-to-sofr2021-update.pdf - when (TimeGte p.adjustedEndDate) $ scale (rateEnd / rateStart - Const 1.0) endClaim - - -- calculate floating rate spread claim for a payment period - createSpreadClaim p = - andList $ simpleInterestSpreadClaims - where - (constNotional, paymentPeriodData) = calculateNotionalAndFixings p s - calculationScheduleStaticData fxRateId useAdjustedDatesForDcf periodicSchedule - notional = fromSomeNote - "createSpreadClaim requires a constant notional during a payment period" - constNotional - spread = Const floatingRateSpread - simpleInterestSpreadClaims = map - (\pp -> scale (notional * spread * pp.dcf) $ - when (TimeGte p.adjustedEndDate) $ one currency) - (reverse paymentPeriodData) - - -- calculate floating rate when there is no payment period compounding - -- (but a compounded reference rate can still be used) - calcRateNoCompounding compoundedRefRate = - if compoundedRefRate then - let - claimAmounts = andList $ - map createSimpleClaimCompoundedRefRate paymentSchedule - spreadClaimAmounts = andList $ map createSpreadClaim paymentSchedule - in [claimAmounts, spreadClaimAmounts] - else map createSimpleClaim paymentSchedule - - claimAmounts = case s.calculationPeriodAmount.calculation.compoundingMethodEnum of - Some Straight -> if compoundedRefRate then error "compounded ref rate not supported" - else [claimAmounts] - where - claimAmounts = andList $ map (createClaim True) paymentSchedule - Some SpreadExclusive -> if compoundedRefRate then error "compounded ref rate not supported" - else [claimAmounts, spreadClaimAmounts] - where - claimAmounts = andList $ map (createClaim False) paymentSchedule - spreadClaimAmounts = andList $ map createSpreadClaim paymentSchedule - Some Flat -> if compoundedRefRate then error "compounded ref rate not supported" - else map createCalcPeriodClaim paymentSchedule - Some NoCompounding -> calcRateNoCompounding compoundedRefRate - None -> calcRateNoCompounding compoundedRefRate - - claims = if issuerPaysLeg then claimAmounts else fmap give claimAmounts - claimsTagged = prepareAndTagClaims dateToDateClockTime claims "Floating rate payment" - allTaggedClaims = case s.principalExchanges of - None -> [claimsTagged] - Some principalExchanges -> [claimsTagged, principalClaimsTagged] - where - principalClaimsTagged = calculatePrincipalExchangePaymentClaims paymentSchedule - issuerPaysLeg currency fxRateId notionals rateFixingDates principalExchanges - - pure allTaggedClaims - --- | Create claims from swapStream that describes a fixed or floating coupon stream. -calculateClaimsFromSwapStream : SwapStream -> PeriodicSchedule -> [SchedulePeriod] -> - [SchedulePeriod] -> Optional SwapStream -> Bool -> Bool -> Deliverable -> Party -> Party -> - Update [TaggedClaim] -calculateClaimsFromSwapStream s periodicSchedule calculationSchedule paymentSchedule - swapStreamNotionalRef useAdjustedDatesForDcf issuerPaysLeg currency issuer calendarDataAgency = do - case s.calculationPeriodAmount.calculation.notionalScheduleValue of - NotionalSchedule_FxLinked fxl -> assertMsg - "swapStream currency does not match swap currency" $ - currency.id == Id fxl.varyingNotionalCurrency - NotionalSchedule_Regular n -> assertMsg - "swapStream currency does not match swap currency" $ - currency.id == Id n.notionalStepSchedule.currency - assertMsg - "stub must refer to the calculationPeriodDates of the current swapStream" $ - isNone s.stubCalculationPeriodAmount || - getField @"calculationPeriodDatesReference" (fromSome s.stubCalculationPeriodAmount) == - s.calculationPeriodDates.id - -- calculate the notional to be used for each calculation period (either fix, amortizing or fx - -- linked) - (fxRateId, fxLinkedNotionalInitialValue, fxFixingDates) <- - getFxRateId calculationSchedule s issuer calendarDataAgency - let - fxAdjustmentRequired = isSome fxRateId - n = case swapStreamNotionalRef of - Some s2 -> case s2.calculationPeriodAmount.calculation.notionalScheduleValue of - NotionalSchedule_FxLinked fxl -> - error "notional reference swapStream must be of regular type, not fx-linked" - NotionalSchedule_Regular nr -> nr - _ -> case s.calculationPeriodAmount.calculation.notionalScheduleValue of - NotionalSchedule_Regular nr -> nr - _ -> error "Regular notional schedule required if no swapStream notional ref provided." - - -- Find the notional of a calculation period in the notional step list - findNotional notionalSteps fxAdjustmentRequired calculationPeriod = - (lastMatching.stepValue, fxAdjustmentRequired) - where - lastMatching = fromSome $ find (\n -> n.stepDate <= calculationPeriod.unadjustedStartDate) - notionalSteps - - initialStep = Step with - stepDate = (.unadjustedStartDate) $ head calculationSchedule - stepValue = n.notionalStepSchedule.initialValue - notionalStepScheduleInclInitial = sortOn (\x -> P.Down x.stepDate) $ - initialStep :: n.notionalStepSchedule.step - notionalBase = map (findNotional notionalStepScheduleInclInitial fxAdjustmentRequired) - calculationSchedule - notionals = case fxLinkedNotionalInitialValue of - None -> notionalBase - Some iv -> (iv, False) :: (drop 1 notionalBase) - assertMsg "notionals list must be of same length as calculationSchedule" $ - length notionals == length calculationSchedule - paymentScheduleAligned <- alignPaymentSchedule calculationSchedule paymentSchedule - case s.calculationPeriodAmount.calculation.rateTypeValue of - RateType_Fixed fixedRateSchedule -> - calculateFixPaymentClaimsFromSwapStream fixedRateSchedule s periodicSchedule - calculationSchedule paymentScheduleAligned useAdjustedDatesForDcf issuerPaysLeg currency - issuer calendarDataAgency fxRateId fxFixingDates notionals - RateType_Floating floatingRateCalculation -> - calculateFloatingPaymentClaimsFromSwapStream floatingRateCalculation s periodicSchedule - calculationSchedule paymentSchedule useAdjustedDatesForDcf issuerPaysLeg currency - issuer calendarDataAgency fxRateId fxFixingDates notionals \ No newline at end of file diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Factory.daml deleted file mode 100644 index 963463852..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Factory.daml +++ /dev/null @@ -1,65 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.InterestRate.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Swap.V0.InterestRate.Instrument qualified as InterestRateSwap (Instrument(..)) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, getClaims) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Factory qualified as InterestRateSwapFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Types (InterestRate(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance InterestRateSwapFactory.I for Factory where - view = InterestRateSwapFactory.View with provider - create' InterestRateSwapFactory.Create{interestRate = InterestRate{instrument; description; - floatingRate; ownerReceivesFix; fixRate; periodicSchedule; holidayCalendarIds; - calendarDataProvider; dayCountConvention; currency; lastEventTimestamp}; observers} = do - let - interestRateSwapInstrument = InterestRateSwap.Instrument with - depository = instrument.depository - issuer = instrument.issuer - ownerReceivesFix - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - floatingRate - fixRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - lastEventTimestamp - observers - cid <- toInterfaceContractId <$> create interestRateSwapInstrument - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - -- Get the claims in order to run the associated checks (e.g. verify that the schedules - -- are valid). - Claim.getClaims (toInterface @Claim.I interestRateSwapInstrument) $ - Claim.GetClaims with actor = instrument.issuer - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Instrument.daml deleted file mode 100644 index 68263f2a1..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Swap/V0/InterestRate/Instrument.daml +++ /dev/null @@ -1,128 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.V0.InterestRate.Instrument where - -import DA.Date (daysSinceEpochToDate) -import DA.Set (singleton) -import Daml.Finance.Claims.V3.Util.Builders (createFixRatePaymentClaims, createRatePaymentClaims) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (getHolidayCalendars, rollSchedule) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (GetClaims(..), I, View(..)) -import Daml.Finance.Interface.Claims.V4.Dynamic.Instrument qualified as DynamicInstrument (CreateNewVersion(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), createReference, disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Instrument qualified as InterestRate (I, View(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Types (InterestRate(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Date.Calendar (merge) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | This template models an interest rate swap. --- It pays a fix vs floating rate at the end of every payment period. --- The floating leg depends on a reference rate (observed at the beginning of the swap payment --- period). For example: 3M Euribor vs 2.5% fix. -template Instrument - with - depository : Party - -- ^ The depository of the instrument. - issuer : Party - -- ^ The issuer of the instrument. - id : Id - -- ^ An identifier of the instrument. - version : Text - -- ^ The instrument's version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - floatingRate : FloatingRate - -- ^ A description of the floating rate to be used. This supports both Libor and SOFR style - -- reference rates (using a compounded index, e.g. the SOFR Index). - ownerReceivesFix : Bool - -- ^ Indicate whether a holding owner of this instrument receives the fix or the floating leg - -- of the swap. - fixRate : Decimal - -- ^ The interest rate of the fix leg. For example, in case of "3M Euribor vs 2.5% fix" this - -- should be 0.025. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the swap. For example, if the swap pays in USD this should be a USD cash - -- instrument. - observers : PartiesMap - -- ^ The observers of the instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance Claim.I for Instrument where - view = Claim.View with acquisitionTime = dateToDateClockTime $ daysSinceEpochToDate 0 - getClaims Claim.GetClaims{actor} = do - -- get the initial claims tree (as of the swap's acquisition time) - let getCalendars = getHolidayCalendars actor calendarDataProvider - fixingCals <- getHolidayCalendars issuer calendarDataProvider - floatingRate.fixingDates.businessCenters - schedule <- fst <$> rollSchedule getCalendars periodicSchedule holidayCalendarIds - let - useAdjustedDatesForDcf = True - notional = 1.0 - ownerReceivesFloatingLeg = not ownerReceivesFix - fixClaims = createFixRatePaymentClaims dateToDateClockTime schedule periodicSchedule - useAdjustedDatesForDcf fixRate ownerReceivesFix dayCountConvention notional currency - floatingClaims = createRatePaymentClaims dateToDateClockTime schedule - periodicSchedule useAdjustedDatesForDcf 0.0 ownerReceivesFloatingLeg dayCountConvention - notional currency (Some floatingRate) $ merge fixingCals - pure [fixClaims, floatingClaims] - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; issuer; id; version; holdingStandard; description - validAsOf = lastEventTimestamp - getKey = BaseInstrument.instrumentKey this - - interface instance InterestRate.I for Instrument where - view = InterestRate.View with - interestRate = InterestRate with - instrument = BaseInstrument.instrumentKey this - description - floatingRate - ownerReceivesFix - fixRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - lastEventTimestamp - - interface instance DynamicInstrument.I for Instrument where - view = DynamicInstrument.View with lifecycler = issuer; lastEventTimestamp; prevEvents = [] - createNewVersion DynamicInstrument.CreateNewVersion{version; lastEventTimestamp} = do - cid <- create this with version; lastEventTimestamp - BaseInstrument.createReference issuer $ toInterfaceContractId cid - pure $ toInterfaceContractId cid - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this $ Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Instrument/Token/V4/Factory.daml b/src/main/daml/Daml/Finance/Instrument/Token/V4/Factory.daml deleted file mode 100644 index a593058ac..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Token/V4/Factory.daml +++ /dev/null @@ -1,49 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Token.V4.Factory where - -import DA.Set (singleton) -import Daml.Finance.Instrument.Token.V4.Instrument qualified as Token (Instrument(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (createReference) -import Daml.Finance.Interface.Instrument.Token.V4.Factory qualified as TokenFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Instrument.Token.V4.Types (Token(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Factory template for instrument creation. -template Factory - with - provider : Party - -- ^ The factory's provider. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance TokenFactory.I for Factory where - view = TokenFactory.View with provider - create' TokenFactory.Create{token = Token{instrument; validAsOf; description}; observers} = do - cid <- toInterfaceContractId <$> - create Token.Instrument with - depository = instrument.depository - issuer = instrument.issuer - id = instrument.id - version = instrument.version - holdingStandard = instrument.holdingStandard - description - validAsOf - observers - BaseInstrument.createReference instrument.depository $ toInterfaceContractId cid - pure cid - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Instrument/Token/V4/Instrument.daml b/src/main/daml/Daml/Finance/Instrument/Token/V4/Instrument.daml deleted file mode 100644 index 4e587194e..000000000 --- a/src/main/daml/Daml/Finance/Instrument/Token/V4/Instrument.daml +++ /dev/null @@ -1,58 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Token.V4.Instrument where - -import DA.Set (singleton) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, View(..), disclosureUpdateReference, instrumentKey) -import Daml.Finance.Interface.Instrument.Token.V4.Instrument qualified as Token (I, View(..)) -import Daml.Finance.Interface.Instrument.Token.V4.Types (Token(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Instrument`. -type T = Instrument - --- | Implementation of a Token Instrument, which is a simple instrument whose economic terms --- on the ledger are represented by an `id` and a textual `description`. -template Instrument - with - depository : Party - -- ^ The instrument's depository. - issuer : Party - -- ^ The instrument's issuer. - id : Id - -- ^ The intrument's identifier. - version : Text - -- ^ A textual instrument version. - holdingStandard : HoldingStandard - -- ^ The holding standard for holdings referencing this instrument. - description : Text - -- ^ A description of the instrument. - validAsOf : Time - -- ^ Timestamp as of which the instrument is valid. This usually coincides with the timestamp - -- of the event that creates the instrument. It usually does not coincide with ledger time. - observers : PartiesMap - -- ^ Observers. - where - signatory depository, issuer - observer Disclosure.flattenObservers observers - - interface instance BaseInstrument.I for Instrument where - view = BaseInstrument.View with - depository; id; issuer; version; holdingStandard; description; validAsOf - getKey = BaseInstrument.instrumentKey this - - interface instance Token.I for Instrument where - view = Token.View with - token = Token with instrument = BaseInstrument.instrumentKey this; description; validAsOf - - interface instance Disclosure.I for Instrument where - view = Disclosure.View with disclosureControllers = singleton issuer; observers - setObservers = setObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - addObservers = addObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this - removeObservers = removeObserversImpl this . Some . BaseInstrument.disclosureUpdateReference $ - BaseInstrument.instrumentKey this diff --git a/src/main/daml/Daml/Finance/Interface/Account/V4/Account.daml b/src/main/daml/Daml/Finance/Interface/Account/V4/Account.daml deleted file mode 100644 index 2741b5b04..000000000 --- a/src/main/daml/Daml/Finance/Interface/Account/V4/Account.daml +++ /dev/null @@ -1,204 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - --- | We recommend to import this module qualified. -module Daml.Finance.Interface.Account.V4.Account where - -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), Id, InstrumentKey(..), Parties, PartiesMap, Quantity) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I, RemoveObservers(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.InterfaceKey (createReferenceHelper, disclosureUpdateReferenceHelper, exerciseInterfaceByKeyHelper) -import Daml.Finance.Interface.Util.V3.InterfaceKey qualified as InterfaceKey (HasInterfaceKey(..)) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Account`. -type I = Account - --- | Type synonym for `Reference`. This type is currently used as a work-around given the lack of --- interface keys. -type R = Reference - --- | Type synonym for `View`. -type V = View - --- | Controllers of the account (related to transfers). -data Controllers = Controllers - with - outgoing : Parties - -- ^ Parties instructing a transfer (outgoing). - incoming : Parties - -- ^ Parties approving a transfer (incoming). - deriving (Eq, Show) - --- | View for `Account`. -data View = View - with - custodian : Party - -- ^ Party providing accounting services. - owner : Party - -- ^ Party owning this account. - id : Id - -- ^ Identifier for the account. - description : Text - -- ^ Human readable description of the account. - controllers : Controllers - -- ^ Parties controlling transfers. - deriving (Eq, Show) - --- | Convert the account's 'View' to its key. -toKey : View -> AccountKey -toKey v = AccountKey with custodian = v.custodian; owner = v.owner; id = v.id - --- | Retrieves the key of an `Account`. -accountKey : (HasToInterface i Account) => i -> AccountKey -accountKey = toKey . view . toInterface @Account - --- | An interface which represents an established relationship between a provider and an owner. -interface Account requires Disclosure.I where - viewtype V - - getKey : AccountKey - -- ^ Get the unique key of the `Account`. - credit : Credit -> Update (ContractId Api.HoldingV1.Holding) - -- ^ Implementation of the `Credit` choice. - debit : Debit -> Update () - -- ^ Implementation of the `Debit` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party fetching the view. - controller viewer - do - pure $ view this - - nonconsuming choice Credit : ContractId Api.HoldingV1.Holding - -- ^ Creates a new `Holding` in the corresponding `Account`. - with - quantity : Quantity InstrumentKey Decimal - -- ^ The target `Instrument` and corresponding amount. - controller (view this).custodian, (view this).controllers.incoming - do - credit this arg - - nonconsuming choice Debit : () - -- ^ Removes an existing `Holding`. - with - holdingCid : ContractId Api.HoldingV1.Holding - -- ^ The `Holding`'s contract id. - controller (view this).custodian, (view this).controllers.outgoing - do - debit this arg - - choice Remove : () - -- ^ Archive the account. - controller signatory this - do - (refCid, _) <- fetchByKey @Reference $ getKey this - archive refCid - --- | HIDE --- This template is used to key an Account contract. It allows for looking up this contract by key --- then acquiring the Account contract by fetching its contract id on this contract. As updates are --- made to an Account, this Reference contract is required to be kept in sync. -template Reference - with - accountView : View - -- ^ The default view for accounts. - cid : ContractId Account - -- ^ The contract id of the account. - observers : PartiesMap - where - signatory accountView.custodian, accountView.owner - observer Disclosure.flattenObservers observers - - key toKey accountView : AccountKey - maintainer key.custodian - - nonconsuming choice GetCid : ContractId Account - -- ^ Get the `Account`'s contract id. - with - viewer : Party - -- ^ The party retrieving the account. - controller viewer - do - pure cid - - choice SetCid : ContractId Reference - -- ^ Set the account cid. This choice should be called only from `Account` implementations. - with - newCid : ContractId Account - -- ^ The account cid. - controller signatory this - do - create this with cid = newCid - - choice SetObservers : ContractId Reference - -- ^ Set observers. This choice should be called only from `Account` implementations. - with - newObservers : PartiesMap - -- ^ The new observers. - controller signatory this - do - create this with observers = newObservers - --- | Disclose account. -disclose : (Text, Parties) -> Party -> Parties -> AccountKey -> Update (ContractId Account) -disclose observersToAdd actor disclosers account = - fromInterfaceContractId <$> - exerciseInterfaceByKey @Disclosure.I - account - actor - Disclosure.AddObservers with disclosers; observersToAdd - --- | Undisclose account. -undisclose : (Text, Parties) -> Party -> Parties -> AccountKey -> - Update (Optional (ContractId Account)) -undisclose observersToRemove actor disclosers account = - fmap fromInterfaceContractId <$> - exerciseInterfaceByKey @Disclosure.I - account - actor - Disclosure.RemoveObservers with disclosers; observersToRemove - --- | Exercise interface by key. --- This method can be used to exercise a choice on an `Account` given its `AccountKey`. --- Requires as input the `AccountKey`, --- For example: --- ``` --- exerciseInterfaceByKey @Account.I accountKey actor Account.Debit with holdingCid --- ``` -exerciseInterfaceByKey : forall i c r. - ( HasInterfaceTypeRep i - , HasExercise i c r - ) - => AccountKey -- ^ The account key. - -> Party -- ^ The actor exercising. - -> c -- ^ The choice arguments. - -> Update r -exerciseInterfaceByKey k actor arg = - exerciseInterfaceByKeyHelper @Reference @GetCid @SetCid @SetObservers @GetView @i k actor arg - --- | HIDE --- Create instance of HasInterfaceKey. -instance InterfaceKey.HasInterfaceKey Account View AccountKey Reference GetCid SetCid SetObservers - GetView where - createReference = Reference - getCid = GetCid - setCid = SetCid - setObservers = SetObservers - getView = GetView - --- | HIDE --- Create Reference for the account. -createReference : Party -> ContractId Account -> Update (ContractId Reference) -createReference = createReferenceHelper @Reference @GetCid @SetCid @SetObservers @GetView - --- | HIDE --- Helper function to update the account reference once observers are added to the account. -disclosureUpdateReference : AccountKey -> PartiesMap -> ContractId Account -> - Update (ContractId Disclosure.I) -disclosureUpdateReference = - disclosureUpdateReferenceHelper @Reference @GetCid @SetCid @SetObservers @GetView diff --git a/src/main/daml/Daml/Finance/Interface/Account/V4/Factory.daml b/src/main/daml/Daml/Finance/Interface/Account/V4/Factory.daml deleted file mode 100644 index 163a95fc2..000000000 --- a/src/main/daml/Daml/Finance/Interface/Account/V4/Factory.daml +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Account.V4.Factory where - -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Controllers(..), I) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), HoldingFactoryKey, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Interface that allows implementing templates to create accounts. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Account.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Account.I - -- ^ Create a new account. - with - account : AccountKey - -- ^ The account's key. - holdingFactory : HoldingFactoryKey - -- ^ Associated holding factory for the account. - controllers : Account.Controllers - -- ^ Controllers of the account. - description : Text - -- ^ Human readable description of the account. - observers : PartiesMap - -- ^ The account's observers. - controller account.custodian, account.owner - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Account/V4/Util.daml b/src/main/daml/Daml/Finance/Interface/Account/V4/Util.daml deleted file mode 100644 index 87d4fa1c5..000000000 --- a/src/main/daml/Daml/Finance/Interface/Account/V4/Util.daml +++ /dev/null @@ -1,47 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Account.V4.Util where - -import DA.Optional(fromSome) -import DA.TextMap qualified as TextMap -import Daml.Finance.Interface.Account.V4.Account qualified as Account (I, R) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), Id(..)) -import Daml.Finance.Interface.Util.V3.InterfaceKey (fetchInterfaceByKey) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 -import Splice.Api.Token.MetadataV1 () - --- | Fetch the account of a holding. -fetchAccount : (HasToInterface t Api.HoldingV1.Holding) => t -> Update Account.I -fetchAccount holding = - let accountKey = getAccount holding - in fetchInterfaceByKey @Account.R @Account.I accountKey - --- | Get the account key of a holding. -getAccount : (HasToInterface t Api.HoldingV1.Holding) => t -> AccountKey -getAccount holding = - let - vHolding = view (toInterface @Api.HoldingV1.Holding holding) - metaVals = vHolding.meta.values - - custodianTxt = fromSome (TextMap.lookup "custodian" metaVals) - accountIdTxt = fromSome (TextMap.lookup "accountId" metaVals) - - in - AccountKey with - custodian = fromSome (partyFromText custodianTxt) - owner = vHolding.owner - id = Id accountIdTxt - --- | Get the custodian of a holding. -getCustodian : (HasToInterface t Api.HoldingV1.Holding) => t -> Party -getCustodian holding = - let - metaVals = (view $ toInterface @Api.HoldingV1.Holding holding).meta.values - custodianTxt = fromSome (TextMap.lookup "custodian" metaVals) - in - fromSome (partyFromText custodianTxt) - --- | Get the owner of a holding. -getOwner : (HasToInterface t Api.HoldingV1.Holding) => t -> Party -getOwner = (.owner) . view . toInterface @Api.HoldingV1.Holding diff --git a/src/main/daml/Daml/Finance/Interface/Claims/V4/Claim.daml b/src/main/daml/Daml/Finance/Interface/Claims/V4/Claim.daml deleted file mode 100644 index c4787acc2..000000000 --- a/src/main/daml/Daml/Finance/Interface/Claims/V4/Claim.daml +++ /dev/null @@ -1,60 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Claims.V4.Claim where - -import Daml.Finance.Interface.Claims.V4.Types (C, TaggedClaim) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Claim`. -type I = Claim - --- | Type synonym for `View`. -type V = View - --- | View for `Claim`. -data View = View - with - acquisitionTime : Time - -- ^ The claim's acquisition time. - deriving (Eq, Show) - --- | Interface implemented by templates that can be represented as Contingent Claims. -interface Claim requires BaseInstrument.I, Disclosure.I where - viewtype V - - getClaims : GetClaims -> Update [TaggedClaim] - -- ^ The list of claims representing the instrument. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice GetClaims : [TaggedClaim] - -- ^ Retrieves the list of claims representing the instrument. This might involve fetching - -- reference data, such as calendars, on which the actor must have visibility. - with - actor : Party - -- ^ The party retrieving the claims. - controller actor - do - getClaims this arg - --- | Retrieves the single claim representing the template. An error is thrown if there are zero or --- more than one claims. -getClaim : Party -> Claim -> Update C -getClaim actor instrument = do - x <- getClaims instrument GetClaims with actor - case x of - [tc] -> pure tc.claim - other -> abort "Expecting exactly one claim" - --- | Retrieves the claim's acquisition time. -getAcquisitionTime : Claim -> Time -getAcquisitionTime = (.acquisitionTime) . view diff --git a/src/main/daml/Daml/Finance/Interface/Claims/V4/Dynamic/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Claims/V4/Dynamic/Instrument.daml deleted file mode 100644 index 9a9c4da6c..000000000 --- a/src/main/daml/Daml/Finance/Interface/Claims/V4/Dynamic/Instrument.daml +++ /dev/null @@ -1,56 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Claims.V4.Dynamic.Instrument where - -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View for `Instrument`. -data View = View - with - lifecycler : Party - -- ^ Party performing the lifecycling. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous elections that have been lifecycled on this instrument so far. - deriving (Eq, Show) - --- | Interface implemented by instruments that create Contingent Claims trees on-the-fly (i.e., the --- tree is not stored on disk as part of a contract, but created and processed in-memory). -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - createNewVersion : CreateNewVersion -> Update (ContractId Instrument) - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice CreateNewVersion : ContractId Instrument - -- ^ Create a new version of an instrument, using a new lastEventTimestamp and a list of - -- previous elections (if applicable). - with - version : Text - -- ^ The new version of the instrument. - lastEventTimestamp : Time - -- ^ The new lastEventTimestamp of the instrument. - prevEvents : [EventData] - -- ^ A list of previous elections that have been lifecycled on this instrument so far. - controller (view this).lifecycler - do - createNewVersion this arg diff --git a/src/main/daml/Daml/Finance/Interface/Claims/V4/Types.daml b/src/main/daml/Daml/Finance/Interface/Claims/V4/Types.daml deleted file mode 100644 index fc22dd12b..000000000 --- a/src/main/daml/Daml/Finance/Interface/Claims/V4/Types.daml +++ /dev/null @@ -1,46 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Claims.V4.Types where - -import ContingentClaims.Core.V3.Claim (Claim) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) - --- | Type used to reference assets in the claim tree. -type Deliverable = InstrumentKey - --- | Type used to reference observables in the claim tree. -type Observable = Text - --- | The specialized claim type. -type C = Claim Time Decimal Deliverable Observable - --- | A claim and a textual tag. -data TaggedClaim = TaggedClaim - with - claim : C - tag : Text - deriving (Eq, Show) - --- | Type used to record pending payments. -data Pending = Pending - with - t : Time - tag : Text - instrument : Deliverable - amount : Decimal - deriving (Eq, Show) - --- | HIDE --- A lifecycle event in the context of a claim. This is either a time-based event or an election. -data EventData = EventData - with - t : Time - -- ^ Time of the event. - election : Optional (Bool, Text) - -- ^ When this is an election, a flag indicating which party makes the election (`True` if - -- bearer, `False` if counterparty) and the tag corresponding to the elected sub-tree. - deriving (Eq, Show) - -instance Ord EventData where - x <= y = x.t <= y.t diff --git a/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation.daml b/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation.daml deleted file mode 100644 index 8797f6530..000000000 --- a/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation.daml +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Data.V4.Numeric.Observation where - -import DA.Map (Map) -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Observation`. -type I = Observation - --- | Type synonym for `View`. -type V = View - --- | View for `Observation`. -data View = View - with - provider : Party - -- ^ The reference data provider. - id : Id - -- ^ A textual identifier. - observations : Map Time Decimal - -- ^ The time-dependent values. - observers : PartiesMap - -- ^ Observers. - --- | Interface for a time-dependent numeric `Observation`, where the values are explicitly stored --- on-ledger. -interface Observation requires NumericObservable.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party fetching the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation/Factory.daml b/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation/Factory.daml deleted file mode 100644 index bdd3e3488..000000000 --- a/src/main/daml/Daml/Finance/Interface/Data/V4/Numeric/Observation/Factory.daml +++ /dev/null @@ -1,47 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Data.V4.Numeric.Observation.Factory where - -import DA.Map (Map) -import Daml.Finance.Interface.Data.V4.Numeric.Observation qualified as Observation (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonyms for `Factory`. -type I = Factory -type F = Factory -- to be deprecated - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - observers : PartiesMap - -- ^ The observers of the `Factory`. - deriving (Eq, Show) - --- | Factory contract used to create, remove and view a `Numeric.Observation`. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Observation.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Observation.I - -- ^ Create an `Observation`. - with - provider : Party - -- ^ The reference data provider. - id : Id - -- ^ A textual identifier. - observations : Map Time Decimal - -- ^ The time-dependent values. - observers : PartiesMap - -- ^ Observers. - controller provider - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar.daml b/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar.daml deleted file mode 100644 index 3c3344411..000000000 --- a/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar.daml +++ /dev/null @@ -1,46 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Data.V4.Reference.HolidayCalendar where - -import Daml.Finance.Interface.Types.Date.V3.Calendar -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `HolidayCalendar`. -type I = HolidayCalendar - --- | Type synonym for `View`. -type V = View - --- | View for `HolidayCalendar`. -data View = View - with - provider : Party - -- ^ The parties providing the `HolidayCalendar`. - calendar : HolidayCalendarData - -- ^ Holiday Calendar Data used to define holidays. - --- | Interface for contracts storing holiday calendar data on the ledger. -interface HolidayCalendar requires Disclosure.I where - viewtype V - - updateCalendar : UpdateCalendar -> Update (ContractId HolidayCalendar) - -- ^ Updates the holiday calendar. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party fetching the view. - controller viewer - do - pure $ view this - - choice UpdateCalendar : ContractId HolidayCalendar - -- ^ Updates the holiday calendar. - with - newCalendar : HolidayCalendarData - -- ^ The new `HolidayCalendarData`. - controller (view this).provider - do - updateCalendar this arg diff --git a/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar/Factory.daml b/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar/Factory.daml deleted file mode 100644 index 824d9dd1f..000000000 --- a/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/HolidayCalendar/Factory.daml +++ /dev/null @@ -1,43 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Data.V4.Reference.HolidayCalendar.Factory where - -import Daml.Finance.Interface.Data.V4.Reference.HolidayCalendar qualified as HolidayCalendar (I) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Types.Date.V3.Calendar (HolidayCalendarData) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonyms for `Factory`. -type I = Factory -type F = Factory -- to be deprecated - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Interface that allows implementing templates to create holiday calendars. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId HolidayCalendar.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId HolidayCalendar.I - -- ^ Create a new Holiday Calendar. - with - calendar : HolidayCalendarData - -- ^ Holiday Calendar Data used to define holidays. - observers : PartiesMap - -- ^ Observers. - provider : Party - -- ^ The calendar's provider. - controller provider - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/Time.daml b/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/Time.daml deleted file mode 100644 index e0e595188..000000000 --- a/src/main/daml/Daml/Finance/Interface/Data/V4/Reference/Time.daml +++ /dev/null @@ -1,70 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This module defines an interface for `BusinessTime` rules, which are contracts to control and --- keep track of business time. -module Daml.Finance.Interface.Data.V4.Reference.Time where - -import Daml.Finance.Interface.Lifecycle.V4.Event.Time qualified as Time (Event) -import Daml.Finance.Interface.Lifecycle.V4.Observable.TimeObservable qualified as TimeObservable (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) -import Prelude hiding (Time) - --- | Type synonym for `Time`. -type I = Time - --- | Type synonym for `View`. -type V = View - --- | View for `Time`. -data View = View - with - providers : Parties - -- ^ Parties controlling time. - id : Id - -- ^ Textual identifier for the time rule. - deriving (Eq, Show) - --- | An interface to manage and control business time. Controlled time rules (i.e. clocks) are --- managed by entities that have control certain business time events. These can be trading-open / --- -close on an exchange, start-of-day / end-of-day events of a trading desk, or just a daily --- clock tick to signal the passing of aticking. Intervals in which --- the clock "ticks" don't have to be regular, and can e.g. consider business days only. -interface Time requires TimeObservable.I where - viewtype V - - advance : ContractId Time -> Advance -> Update (ContractId Time, ContractId Time.Event) - -- ^ Implementation of the `Advance` choice. - rewind : ContractId Time -> Rewind -> Update (ContractId Time, ContractId Time.Event) - -- ^ Implementation of the `Rewind` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Advance : (ContractId Time, ContractId Time.Event) - -- ^ Advance time to its next state. - with - eventId : Id - -- ^ Event identifier. - eventDescription : Text - -- ^ Event description. - controller (view this).providers - do - advance this self arg - - nonconsuming choice Rewind : (ContractId Time, ContractId Time.Event) - -- ^ Rewind time to its previous state. - with - eventId : Id - -- ^ Event identifier. - eventDescription : Text - -- ^ Event description. - controller (view this).providers - do - rewind this self arg diff --git a/src/main/daml/Daml/Finance/Interface/Holding/V4/Factory.daml b/src/main/daml/Daml/Finance/Interface/Holding/V4/Factory.daml deleted file mode 100644 index b2d30bce9..000000000 --- a/src/main/daml/Daml/Finance/Interface/Holding/V4/Factory.daml +++ /dev/null @@ -1,191 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Interface.Holding.V4.Factory where - -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), HoldingFactoryKey(..), Id, InstrumentKey(..), Parties, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I, RemoveObservers(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.InterfaceKey (createReferenceHelper, disclosureUpdateReferenceHelper, exerciseInterfaceByKeyHelper) -import Daml.Finance.Interface.Util.V3.InterfaceKey qualified as InterfaceKey (HasInterfaceKey(..)) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `Reference`. This type is currently used as a work-around given the lack of --- interface keys. -type R = Reference - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - id : Id - -- ^ Identifier for the holding factory. - deriving (Eq, Show) - --- | Convert the account's 'View' to its key. -toKey : View -> HoldingFactoryKey -toKey v = HoldingFactoryKey with provider = v.provider; id = v.id - --- | Retrieves the key of a `Factory`. -holdingFactoryKey : (HasToInterface i Factory) => i -> HoldingFactoryKey -holdingFactoryKey = toKey . view . toInterface @Factory - --- | Holding factory contract used to create (credit) holdings. -interface Factory requires Disclosure.I where - viewtype V - - getKey : HoldingFactoryKey - -- ^ Get the unique key of the `HoldingFactory`. - create' : Create -> Update (ContractId Api.HoldingV1.Holding) - -- ^ Implementation of `Create` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party fetching the view. - controller viewer - do - pure $ view this - - nonconsuming choice Create : ContractId Api.HoldingV1.Holding - -- ^ Create a holding on the instrument in the corresponding account. - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - observers : PartiesMap - -- ^ Observers of the holding to be credited. - controller account.custodian, account.owner - do - create' this arg - - choice Remove : () - -- ^ Archive the factory. - controller signatory this - do - (refCid, _) <- fetchByKey @Reference $ getKey this - archive refCid - --- | HIDE --- This template is used to key a Holding Factory contract. It allows for looking up this contract --- by key then acquiring the Factory contract by fetching its contract id on this contract. As --- updates are made to a Factory, this Reference contract is required to be kept in sync. -template Reference - with - factoryView : View - -- ^ The default view for factories. - cid : ContractId Factory - -- ^ The contract id of the factory. - observers : PartiesMap - where - signatory factoryView.provider - observer Disclosure.flattenObservers observers - - key toKey factoryView : HoldingFactoryKey - maintainer key.provider - - nonconsuming choice GetCid : ContractId Factory - -- ^ Get the `Factory`'s contract id. - with - viewer : Party - -- ^ The party retrieving the reference. - controller viewer - do - pure cid - - choice SetCid : ContractId Reference - -- ^ Set the factory cid. This choice should be called only from `Factory` implementations. - with - newCid : ContractId Factory - -- ^ The factory cid. - controller signatory this - do - create this with cid = newCid - - choice SetObservers : ContractId Reference - -- ^ Set observers. This choice should be called only from `Factory` implementations. - with - newObservers : PartiesMap - -- ^ The new observers. - controller signatory this - do - create this with observers = newObservers - --- | Create factory including reference. -createFactory : (HasCreate f, HasToInterface f Factory) => f -> Update (ContractId Factory) -createFactory factory = do - cid <- toInterfaceContractId @Factory <$> create factory - createReference (view $ toInterface @Factory factory).provider cid - pure cid - --- | Disclose factory. -disclose : (Text, Parties) -> Party -> Parties -> HoldingFactoryKey -> Update (ContractId Factory) -disclose observersToAdd actor disclosers factory = - fromInterfaceContractId <$> - exerciseInterfaceByKey @Disclosure.I - factory - actor - Disclosure.AddObservers with disclosers; observersToAdd - --- | Undisclose factory. -undisclose : (Text, Parties) -> Party -> Parties -> HoldingFactoryKey -> - Update (Optional (ContractId Factory)) -undisclose observersToRemove actor disclosers factory = - fmap fromInterfaceContractId <$> - exerciseInterfaceByKey @Disclosure.I - factory - actor - Disclosure.RemoveObservers with disclosers; observersToRemove - --- | Exercise interface by key. --- This method can be used to exercise a choice on a `Factory` given its `HoldingFactoryKey`. --- Requires as input the `HoldingFactoryKey`, the actor exercising the choice, and the choice --- arguments. For example: --- ``` --- exerciseInterfaceByKey @HoldingFactory.I holdingFactoryKey actor --- HoldingFactory.Create with instrument; account; amount; observers --- ``` -exerciseInterfaceByKey : forall i c r. - ( HasInterfaceTypeRep i - , HasExercise i c r - ) - => HoldingFactoryKey -- ^ The factory key. - -> Party -- ^ The actor exercising. - -> c -- ^ The choice arguments. - -> Update r -exerciseInterfaceByKey k actor arg = - exerciseInterfaceByKeyHelper @Reference @GetCid @SetCid @SetObservers @GetView @i k actor arg - --- | HIDE --- Create instance of HasInterfaceKey. -instance InterfaceKey.HasInterfaceKey Factory View HoldingFactoryKey Reference GetCid SetCid - SetObservers GetView where - createReference = Reference - getCid = GetCid - setCid = SetCid - setObservers = SetObservers - getView = GetView - --- | HIDE --- Create Reference for the factory. -createReference : Party -> ContractId Factory -> Update (ContractId Reference) -createReference = createReferenceHelper @Reference @GetCid @SetCid @SetObservers @GetView - --- | HIDE --- Update the factory reference once observers are added to the factory. -disclosureUpdateReference : HoldingFactoryKey -> PartiesMap -> ContractId Factory -> - Update (ContractId Disclosure.I) -disclosureUpdateReference = - disclosureUpdateReferenceHelper @Reference @GetCid @SetCid @SetObservers @GetView diff --git a/src/main/daml/Daml/Finance/Interface/Holding/V4/Fungible.daml b/src/main/daml/Daml/Finance/Interface/Holding/V4/Fungible.daml deleted file mode 100644 index 8d9da1239..000000000 --- a/src/main/daml/Daml/Finance/Interface/Holding/V4/Fungible.daml +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Holding.V4.Fungible where - -import Daml.Finance.Interface.Types.Common.V3.Types (Parties) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 --- | Type synonym for `Fungible`. -type I = Fungible - --- | Type synonym for `View`. -type V = View - --- | View for `Fungible`. -data View = View - with - modifiers : Parties - -- ^ Parties which have the authorization to modify a fungible asset. - deriving (Eq, Show) - --- | Result of a call to `Split`. -data SplitResult = SplitResult - with - splitCids : [ContractId Fungible] - -- ^ The contract ids for the split holdings. - rest : Optional (ContractId Fungible) - -- ^ Contract id for the holding on the remaining amount. It is `None` when the split is - -- exact. - deriving (Eq, Show) - --- | Interface for a fungible holding. -interface Fungible requires Api.HoldingV1.Holding, Lockable.I, Disclosure.I where - viewtype V - - split : Split -> Update SplitResult - -- ^ Implementation of the `Split` choice. - merge : Merge -> Update (ContractId Fungible) - -- ^ Implementation of the `Merge` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party fetching the view. - controller viewer - do - pure $ view this - - choice Split : SplitResult - -- ^ Split a fungible contract into multiple contracts by amount. - with - amounts : [Decimal] - -- ^ The quantities to split the fungible asset by, creating a new contract per amount. - controller (view this).modifiers - do - split this arg - - choice Merge : ContractId Fungible - -- ^ Merge multiple fungible contracts into a single fungible contract. - with - fungibleCids : [ContractId Fungible] - -- ^ The fungible contracts to merge which will get consumed. - controller (view this).modifiers - do - merge this arg diff --git a/src/main/daml/Daml/Finance/Interface/Holding/V4/Transferable.daml b/src/main/daml/Daml/Finance/Interface/Holding/V4/Transferable.daml deleted file mode 100644 index 6f8a46a1a..000000000 --- a/src/main/daml/Daml/Finance/Interface/Holding/V4/Transferable.daml +++ /dev/null @@ -1,46 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Holding.V4.Transferable where - -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey, Parties) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Transferable`. -type I = Transferable - --- | Type synonym for `View`. -type V = View - --- | View for `Transferable`. -data View = View {} deriving (Eq, Show) - --- | An interface respresenting a contract where ownership can be transferred to other parties. -interface Transferable requires Api.HoldingV1.Holding, Disclosure.I, Lockable.I where - viewtype View - - transfer : ContractId I -> Transfer -> Update (ContractId Transferable) - -- ^ Implementation of the `Transfer` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Transfer : ContractId Transferable - -- ^ Transfer a contract to a new owner. - with - actors : Parties - -- ^ Parties authorizing the transfer. - newOwnerAccount : AccountKey - -- ^ The new owner's account. - observer newOwnerAccount.owner - controller actors - do - transfer this self arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Factory.daml deleted file mode 100644 index c3045a7c3..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.Callable.Factory where - -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Types (Callable) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate callable bond instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - callable : Callable - -- ^ Attributes to create a callable rate bond. - observers : PartiesMap - -- ^ The instrument's observers. - controller callable.instrument.depository, callable.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Instrument.daml deleted file mode 100644 index a0ab56fdd..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.Callable.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Types (Callable) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - callable : Callable - -- ^ Attributes of a callable bond. - deriving (Eq, Show) - --- | Instrument interface representing a callable bond. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Types.daml deleted file mode 100644 index d22a386c1..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/Callable/Types.daml +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.Callable.Types where - -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule) - --- | Describes the attributes of a Callable Bond. -data Callable = Callable - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the bond. - floatingRate : Optional FloatingRate - -- ^ A description of the floating rate to be used (if applicable). This supports both Libor - -- and SOFR style reference rates (using a compounded index, e.g. the SOFR Index). - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "3.5% p.a coupon" this should - -- be 0.035. This can also be used as a floating coupon spread. For example, in case of - -- "3M Libor + 0.5%" this should be 0.005. - capRate : Optional Decimal - -- ^ The maximum coupon rate possible. For example, if "3M Libor + 0.5%" would result in a - -- rate of 2.5%, but capRate is 2.0%, the coupon rate used would be 2.0%. - floorRate : Optional Decimal - -- ^ The minimum coupon rate possible. For example, if "3M Libor + 0.5%" would result in a - -- rate of -0.2%, but floorRate is 0.0%, the coupon rate used would be 0.0%. - couponSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. The coupon is paid on the last date of - -- each schedule period. - -- In case of a floating rate, the reference rate will be fixed in relation to this schedule - -- (at the start/end of each period, as specified by FloatingRate). - -- This is the main schedule of the instrument, which drives both the calculation and the - -- payment of coupons. It also defines the issue date and the maturity date of the bond. - callSchedule : PeriodicSchedule - -- ^ The bond is callable on the last date of each schedule period. For example, if this - -- schedule is the same as the periodicSchedule, it means that the bond can be called on - -- each coupon payment date. - noticeDays : Int - -- ^ The number of business days in advance of the coupon date that the issuer must give - -- notice if it wants to call the bond. The election whether to call or not to call must be - -- done by this date. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - useAdjustedDatesForDcf : Bool - -- ^ Configure whether to use adjusted dates (as specified in *businessDayAdjustment* of the - -- *couponSchedule*) for day count fractions. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous events that have been lifecycled on this instrument so far. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Factory.daml deleted file mode 100644 index eed1d28d0..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Factory where - -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Types (FixedRate) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate fixed-rate bond instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - fixedRate : FixedRate - -- ^ Attributes to create a fixed rate bond. - observers : PartiesMap - -- ^ The instrument's observers. - controller fixedRate.instrument.depository, fixedRate.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Instrument.daml deleted file mode 100644 index 0e2e8257d..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Types (FixedRate) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - fixedRate : FixedRate - -- ^ Attributes of a fixed rate bond. - deriving (Eq, Show) - --- | Instrument interface representing a fixed rate bond. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Types.daml deleted file mode 100644 index d9f9902f5..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FixedRate/Types.daml +++ /dev/null @@ -1,37 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule) - --- | Describes the attributes of a Fixed Rate Bond. -data FixedRate = FixedRate - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the bond. - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "3.5% p.a. coupon" this - -- should be 0.035. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Factory.daml deleted file mode 100644 index cc49966ab..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Factory where - -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Types (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate floating-rate bond instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - floatingRate : FloatingRate - -- ^ Attributes to create a floating rate bond. - observers : PartiesMap - -- ^ The instrument's observers. - controller floatingRate.instrument.depository, floatingRate.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Instrument.daml deleted file mode 100644 index de72fcde3..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Types (FloatingRate) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - floatingRate : FloatingRate - -- ^ Attributes of a floating rate bond. - deriving (Eq, Show) - --- | Instrument interface representing a floating rate bond. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Types.daml deleted file mode 100644 index 822300984..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/FloatingRate/Types.daml +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Types where - -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate qualified as FloatinRateTypes (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) - --- | Describes the attributes representing a floating rate bond. -data FloatingRate = FloatingRate - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the bond. - floatingRate : FloatinRateTypes.FloatingRate - -- ^ A description of the floating rate to be used. This supports both Libor and SOFR style - -- reference rates (using a compounded index, e.g. the SOFR Index). - couponSpread : Decimal - -- ^ The floating rate coupon spread. For example, in case of "3M Euribor + 0.5%" this should - -- be 0.005. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Factory.daml deleted file mode 100644 index 922341287..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Factory where - -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Types (InflationLinked) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate inflation-linked bond instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - inflationLinked : InflationLinked - -- ^ Attributes to create an inflation linked bond. - observers : PartiesMap - -- ^ The instrument's observers. - controller inflationLinked.instrument.depository, inflationLinked.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Instrument.daml deleted file mode 100644 index d45a711ee..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Types (InflationLinked) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - inflationLinked : InflationLinked - -- ^ Attributes of an inflation linked bond. - deriving (Eq, Show) - --- | Instrument interface representing an inflation linked bond. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Types.daml deleted file mode 100644 index 30d6fc1c1..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/InflationLinked/Types.daml +++ /dev/null @@ -1,43 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule) - --- | Describes the attributes of an Inflation Linked Bond. -data InflationLinked = InflationLinked - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the bond. - inflationIndexId : Text - -- ^ The inflation index reference ID. For example, in case of "0.5% p.a. coupon, CPI adjusted - -- principal" this should be a valid reference to the "CPI" index. - inflationIndexBaseValue : Decimal - -- ^ The value of the inflation index on the first reference date of this bond (called "dated - -- date" on US TIPS). This is used as the base value for the principal adjustment. - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "0.5% p.a. coupon, CPI - -- adjusted principal" this should be 0.005. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Factory.daml deleted file mode 100644 index d12e82dce..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Factory where - -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Types (ZeroCoupon) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate zero-coupon bond instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - zeroCoupon : ZeroCoupon - -- ^ Attributes to create a zero coupon bond. - observers : PartiesMap - -- ^ The instrument's observers. - controller zeroCoupon.instrument.depository, zeroCoupon.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Instrument.daml deleted file mode 100644 index f1b67a2f1..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Types (ZeroCoupon) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - zeroCoupon : ZeroCoupon - -- ^ Attributes of a zero coupon bond. - deriving (Eq, Show) - --- | Instrument interface representing a zero coupon bond. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Types.daml deleted file mode 100644 index c7aeff47d..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Bond/V3/ZeroCoupon/Types.daml +++ /dev/null @@ -1,28 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) - --- | Describes the attributes of a Zero Coupon bond. -data ZeroCoupon = ZeroCoupon - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the bond. - issueDate : Date - -- ^ The date when the bond was issued. - maturityDate : Date - -- ^ The redemption date of the bond. - currency : InstrumentKey - -- ^ The currency of the bond. For example, if the bond pays in USD this should be a USD cash - -- instrument. - notional : Decimal - -- ^ The notional of the bond. This is the face value corresponding to one unit of the bond - -- instrument. For example, if one bond unit corresponds to 1000 USD, this should be 1000.0. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Factory.daml deleted file mode 100644 index 5c1ba1010..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Factory.daml +++ /dev/null @@ -1,44 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Equity.V0.Factory where - -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate equities. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ A description of the instrument. - validAsOf : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - observers : PartiesMap - -- ^ The instrument's observers. - controller instrument.depository, instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Instrument.daml deleted file mode 100644 index d22201ec2..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Equity/V0/Instrument.daml +++ /dev/null @@ -1,92 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Equity.V0.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey, InstrumentQuantity) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View for `Instrument`. -data View = View - with - instrument : InstrumentKey - -- ^ The instrument's key. - deriving (Eq, Show) - --- | An interface for a generic equity instrument. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - declareDistribution : DeclareDistribution -> Update (ContractId Event.I) - -- ^ Implementation for the `DeclareDistribution` choice. - declareStockSplit : DeclareStockSplit -> Update (ContractId Event.I) - -- ^ Implementation for the `DeclareStockSplit` choice. - declareReplacement : DeclareReplacement -> Update (ContractId Event.I) - -- ^ Implementation for the `DeclareReplacement` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice DeclareDistribution : ContractId Event.I - -- ^ Declare a distribution (e.g. a dividend or a rights issue) to shareholders. - with - id : Id - -- ^ Event identifier of the dividend distribution. - description : Text - -- ^ Description of the dividend event. - effectiveTime : Time - -- ^ Time at which the dividend is distributed. - newInstrument : InstrumentKey - -- ^ Instrument held after the dividend distribution (i.e. "ex-dividend" stock). - perUnitDistribution : [InstrumentQuantity] - -- ^ Distributed quantities per unit held. - controller (view $ toInterface @BaseInstrument.I this).issuer - do - declareDistribution this arg - - nonconsuming choice DeclareStockSplit : ContractId Event.I - -- ^ Declare a stock split. - with - id : Id - -- ^ Event identifier of the stock split. - description : Text - -- ^ Description of the stock split event. - effectiveTime : Time - -- ^ Time at which the stock split is effective. - newInstrument : InstrumentKey - -- ^ Instrument to be held after the stock split is executed. - adjustmentFactor : Decimal - -- ^ Adjustment factor for the stock split. - controller (view $ toInterface @BaseInstrument.I this).issuer - do - declareStockSplit this arg - - nonconsuming choice DeclareReplacement : ContractId Event.I - -- ^ Declare a replacement event, where units of the instrument are replaced by a basket of - -- other instruments. - with - id : Id - -- ^ Distribution Id. - description : Text - -- ^ Description of the replacement event. - effectiveTime : Time - -- ^ Time the replacement is to be executed. - perUnitReplacement : [InstrumentQuantity] - -- ^ Payout offered to shareholders per held share. - controller (view $ toInterface @BaseInstrument.I this).issuer - do - declareReplacement this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Factory.daml deleted file mode 100644 index 05b6eebe7..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Factory.daml +++ /dev/null @@ -1,50 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Generic.V4.Factory where - -import Daml.Finance.Interface.Claims.V4.Types (C) -import Daml.Finance.Interface.Instrument.Generic.V4.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..), PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate generic instruments using Contingent Claims. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new generic instrument. - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ A description of the instrument. - claims : C - -- ^ The claim tree. - acquisitionTime : Time - -- ^ The claim's acquisition time. This usually corresponds to the start date of the - -- contract. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - observers : PartiesMap - -- ^ The instrument's observers. - controller instrument.depository, instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Instrument.daml deleted file mode 100644 index 04a57f90a..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Generic/V4/Instrument.daml +++ /dev/null @@ -1,38 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Generic.V4.Instrument where - -import Daml.Finance.Interface.Claims.V4.Claim qualified as Claim (I) -import Daml.Finance.Interface.Claims.V4.Types (C) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- View of `Instrument`. -data View = View - with - instrument : InstrumentKey - -- ^ The instrument's key. - claims : C - -- ^ The claim tree. - deriving (Eq, Show) - --- | Interface for generic instruments utilizing Contingent Claims. -interface Instrument requires BaseInstrument.I, Claim.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml deleted file mode 100644 index fddd1db0c..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Factory where - -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Types (BarrierEuropean) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate barrier options. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - barrierEuropean : BarrierEuropean - -- ^ Attributes to create a barrier option. - observers : PartiesMap - -- ^ The instrument's observers. - controller barrierEuropean.instrument.depository, barrierEuropean.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml deleted file mode 100644 index 287a9a29e..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Types (BarrierEuropean) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - barrierEuropean : BarrierEuropean - -- ^ Attributes of a barrier option. - deriving (Eq, Show) - --- | Instrument interface representing a barrier option. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Types.daml deleted file mode 100644 index a56a7da0c..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/BarrierEuropeanCash/Types.daml +++ /dev/null @@ -1,39 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Types where - -import Daml.Finance.Interface.Instrument.Option.V0.Types (BarrierTypeEnum, OptionTypeEnum) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) - --- | Describes the attributes of a cash-settled barrier option with European exercise. -data BarrierEuropean = BarrierEuropean - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the option. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an option on AAPL this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - ownerReceives : Bool - -- ^ Indicate whether a holding owner of this instrument receives the option payoff. - optionType : OptionTypeEnum - -- ^ Indicate whether the option is a call or a put. - strike : Decimal - -- ^ The strike price of the option. - barrier : Decimal - -- ^ The barrier level of the option. - barrierType : BarrierTypeEnum - -- ^ The type of barrier. - barrierStartDate : Date - -- ^ The start date for barrier observations. - expiryDate : Date - -- ^ The expiry date of the option. - currency : InstrumentKey - -- ^ The currency of the option. For example, if the option pays in USD this should be a USD - -- cash instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Election/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Election/Factory.daml deleted file mode 100644 index 2e5018c07..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Election/Factory.daml +++ /dev/null @@ -1,60 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.Dividend.Election.Factory where - -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (ElectionTypeEnum) -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey(..), Parties, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate elections on generic instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Election.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Election.I - -- ^ Create a new Election. - with - actors : Parties - -- ^ Parties calling the `Create` choice. - elector : Party - -- ^ Parties on behalf of which the election is made. - counterparty : Party - -- ^ Faces the `elector` in the `Holding`. - provider : Party - -- ^ Party that signs the election (together with the elector). - id : Id - -- ^ The identifier for an election. - description : Text - -- ^ A description of the instrument. - claimType : ElectionTypeEnum - -- ^ The election type corresponding to the elected sub-tree. - electorIsOwner : Bool - -- ^ `True` if election is on behalf of the owner of the holding, `False` otherwise. - electionTime : Time - -- ^ Time at which the election is put forward. - observers : PartiesMap - -- ^ Observers of the election. - amount : Decimal - -- ^ Number of instrument units to which the election applies. - instrument : InstrumentKey - -- ^ The instrument to which the election applies. - controller actors - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Factory.daml deleted file mode 100644 index d9545a927..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.Dividend.Factory where - -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (Dividend) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate Dividend options. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - dividend : Dividend - -- ^ Attributes to create a Dividend option. - observers : PartiesMap - -- ^ The instrument's observers. - controller dividend.instrument.depository, dividend.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Instrument.daml deleted file mode 100644 index beb9ff08f..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.Dividend.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (Dividend) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - dividend : Dividend - -- ^ Attributes of a Dividend option. - deriving (Eq, Show) - --- | Instrument interface representing a physically settled Dividend option. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Types.daml deleted file mode 100644 index 96a922b0e..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Dividend/Types.daml +++ /dev/null @@ -1,39 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types where - -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..), InstrumentQuantity) - --- | Describes the attributes of a physically settled Dividend option. -data Dividend = Dividend - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the option. - expiryDate : Date - -- ^ The expiry date of the option. - cashQuantity : InstrumentQuantity - -- ^ Dividend paid in cash - sharesQuantity : Optional InstrumentQuantity - -- ^ Dividend paid in shares (if applicable) - fxQuantity : Optional InstrumentQuantity - -- ^ Dividend paid in a foreign currency (if applicable) - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous elections that have been lifecycled on this instrument so far. - deriving (Eq, Show) - --- | An election type classification. -data ElectionTypeEnum - = Shares - -- ^ Shares dividend. - | Cash - -- ^ Cash dividend. - | CashFx - -- ^ Foreign currency cash dividend. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Factory.daml deleted file mode 100644 index 0500b7c4b..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Factory where - -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Types (European) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate European options. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - european : European - -- ^ Attributes to create a European option. - observers : PartiesMap - -- ^ The instrument's observers. - controller european.instrument.depository, european.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Instrument.daml deleted file mode 100644 index 80aa4ee66..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Types (European) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - european : European - -- ^ Attributes of a European option. - deriving (Eq, Show) - --- | Instrument interface representing a European option. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Types.daml deleted file mode 100644 index cb46855be..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanCash/Types.daml +++ /dev/null @@ -1,33 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Types where - -import Daml.Finance.Interface.Instrument.Option.V0.Types (OptionTypeEnum) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) - --- | Describes the attributes of a cash-settled European option. -data European = European - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the option. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an option on AAPL this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - ownerReceives : Bool - -- ^ Indicate whether a holding owner of this instrument receives the option payoff. - optionType : OptionTypeEnum - -- ^ Indicate whether the option is a call or a put. - strike : Decimal - -- ^ The strike price of the option. - expiryDate : Date - -- ^ The expiry date of the option. - currency : InstrumentKey - -- ^ The currency of the option. For example, if the option pays in USD this should be a USD - -- cash instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Factory.daml deleted file mode 100644 index 63bc7cee3..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Factory where - -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Types (European) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate European options. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - european : European - -- ^ Attributes to create a European option. - observers : PartiesMap - -- ^ The instrument's observers. - controller european.instrument.depository, european.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Instrument.daml deleted file mode 100644 index b81037484..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Types (European) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - european : European - -- ^ Attributes of a European option. - deriving (Eq, Show) - --- | Instrument interface representing a physically settled European option. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Types.daml deleted file mode 100644 index a8613f671..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/EuropeanPhysical/Types.daml +++ /dev/null @@ -1,36 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Types where - -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Instrument.Option.V0.Types (OptionTypeEnum) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) - --- | Describes the attributes of a physically settled European option. -data European = European - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the option. - referenceAsset : InstrumentKey - -- ^ The reference asset. For example, in case of an option on AAPL this should be an AAPL - -- instrument. - ownerReceives : Bool - -- ^ Indicate whether a holding owner of this instrument receives the option payoff. - optionType : OptionTypeEnum - -- ^ Indicate whether the option is a call or a put. - strike : Decimal - -- ^ The strike price of the option. - expiryDate : Date - -- ^ The expiry date of the option. - currency : InstrumentKey - -- ^ The currency of the option. For example, if the option pays in USD this should be a USD - -- cash instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous elections that have been lifecycled on this instrument so far. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Types.daml deleted file mode 100644 index 6bc4f0f6f..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Option/V0/Types.daml +++ /dev/null @@ -1,24 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Option.V0.Types where - --- | An option type classification. -data OptionTypeEnum - = Call - -- ^ Call option. - | Put - -- ^ Put option. - deriving (Eq, Show) - --- | A barrier type classification. -data BarrierTypeEnum - = UpAndOut - -- ^ The option is knocked out if the underlying trades at or above the barrier. - | DownAndOut - -- ^ The option is knocked out if the underlying trades at or below the barrier. - | UpAndIn - -- ^ The option is activated if the underlying trades at or above the barrier. - | DownAndIn - -- ^ The option is activated if the underlying trades at or below the barrier. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml deleted file mode 100644 index e4ad8d3b8..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Factory.daml +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Factory where - -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Types (AutoCallable) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate AutoCallable instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - autoCallable : AutoCallable - -- ^ Attributes to create an AutoCallable. - observers : PartiesMap - -- ^ The instrument's observers. - controller - autoCallable.instrument.depository, autoCallable.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml deleted file mode 100644 index 9dba0bf17..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Types (AutoCallable) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - autoCallable : AutoCallable - -- ^ Attributes of an AutoCallable. - deriving (Eq, Show) - --- | Instrument interface representing an AutoCallable. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Types.daml deleted file mode 100644 index 1582324d2..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/AutoCallable/Types.daml +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Types where - -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) - --- | Describes the attributes of an AutoCallable instrument that pays a conditional coupon. -data AutoCallable = AutoCallable - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the option. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an AAPL underlying this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - putStrike : Decimal - -- ^ The strike of the put (as a percentage of the underlying closing price on the first - -- observation date). - couponBarrier : Decimal - -- ^ The coupon barrier (as a percentage of the underlying closing price on the first - -- observation date). - callBarrier : Decimal - -- ^ The barrier used to automatically call the instrument (as a percentage of the underlying - -- closing price on the first observation date). - finalBarrier : Decimal - -- ^ The barrier used to determine the final redemption amount (as a percentage of the - -- underlying closing price on the first observation date). - couponRate : Decimal - -- ^ The fixed coupon rate, either per annum or per coupon period (depending on the - -- dayCountConvention below). - observationSchedule : PeriodicSchedule - -- ^ The schedule for the observation dates. These are used to observe the barrier, determine - -- whether the instrument is automatically called and to determine the final redemption - -- amount. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the product. For example, if the product pays in USD this should be a USD - -- cash instrument. - notional : Decimal - -- ^ The notional of the product. This is the face value corresponding to one unit of the - -- product. For example, if one product unit corresponds to 1000 USD, this should be 1000.0. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous events that have been lifecycled on this instrument so far. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml deleted file mode 100644 index 09172da3c..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Factory.daml +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Factory where - -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Types (BarrierReverseConvertible) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate BRCs. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - barrierReverseConvertible : BarrierReverseConvertible - -- ^ Attributes to create a BRC. - observers : PartiesMap - -- ^ The instrument's observers. - controller - barrierReverseConvertible.instrument.depository, barrierReverseConvertible.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml deleted file mode 100644 index 99fde9d10..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Types (BarrierReverseConvertible) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - barrierReverseConvertible : BarrierReverseConvertible - -- ^ Attributes of a BRC. - deriving (Eq, Show) - --- | Instrument interface representing a BRC. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Types.daml deleted file mode 100644 index 85e1da609..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/BarrierReverseConvertible/Types.daml +++ /dev/null @@ -1,52 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Types where - -import Daml.Finance.Interface.Claims.V4.Types (EventData) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) - --- | Describes the attributes of a Barrier Reverse Convertible (BRC) instrument. --- It can be seen as a long fixed coupon bond and a short Down-And-In put option. -data BarrierReverseConvertible = BarrierReverseConvertible - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the option. - referenceAssetId : Text - -- ^ The reference asset ID. For example, in case of an option on AAPL this should be a valid - -- reference to the AAPL fixings to be used for the payoff calculation. - strike : Decimal - -- ^ The strike price of the option. - barrier : Decimal - -- ^ The barrier level of the option. - barrierStartDate : Date - -- ^ The start date for barrier observations. - expiryDate : Date - -- ^ The expiry date of the instrument. - couponRate : Decimal - -- ^ The fixed coupon rate, per annum. For example, in case of a "3.5% p.a coupon" this should - -- be 0.035. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic coupon payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the coupon schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the product. For example, if the product pays in USD this should be a USD - -- cash instrument. - notional : Decimal - -- ^ The notional of the product. This is the face value corresponding to one unit of the - -- product. For example, if one product unit corresponds to 1000 USD, this should be 1000.0. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - prevEvents : [EventData] - -- ^ A list of previous events that have been lifecycled on this instrument so far. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/Types.daml deleted file mode 100644 index 68243cb6b..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/StructuredProduct/V0/Types.daml +++ /dev/null @@ -1,12 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.StructuredProduct.V0.Types where - --- | An option type classification. -data OptionTypeEnum - = Call - -- ^ Call option. - | Put - -- ^ Put option. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Factory.daml deleted file mode 100644 index 2d1e7033b..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Asset.Factory where - -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Types (Asset) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate asset swaps. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - asset : Asset - -- ^ Attributes to create an asset swap. - observers : PartiesMap - -- ^ The instrument's observers. - controller asset.instrument.depository, asset.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Instrument.daml deleted file mode 100644 index 6a19ecb2a..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Asset.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Types (Asset) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - asset : Asset - -- ^ Attributes of an asset swap. - deriving (Eq, Show) - --- | Instrument interface representing an asset swap. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Types.daml deleted file mode 100644 index a2f5281ee..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Asset/Types.daml +++ /dev/null @@ -1,57 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Asset.Types where - -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) - --- | Describes the attributes of an Asset swap. -data Asset = Asset - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the swap. - underlyings : [Underlying] - -- ^ The list of underlyings (the basket of reference assets for the asset swap). - ownerReceivesRate : Bool - -- ^ Indicate whether a holding owner of this instrument receives the rate or the asset leg of - -- the swap. - floatingRate : Optional FloatingRate - -- ^ A description of the floating rate to be used (if applicable). This supports both Libor - -- and SOFR style reference rates (using a compounded index, e.g. the SOFR Index). - fixRate : Decimal - -- ^ The interest rate of the fix leg. For example, in case of "AAPL total return vs 2.5% fix" - -- this should be 0.025. This can also be used as a floating rate spread. For example, in - -- case of "3M Libor + 0.5%" this should be 0.005. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the swap. For example, if the swap pays in USD this should be a USD cash - -- instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) - --- | Describes an underlying of a product. -data Underlying = Underlying - with - referenceAsset : InstrumentKey - -- ^ The underlying's key. - referenceAssetId : Text - -- ^ The reference asset ID. This is used to retrieve observations for this underlying. - weight : Decimal - -- ^ The basket weight of the underlying. - initialPrice : Decimal - -- ^ The initial price of the underlying. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Factory.daml deleted file mode 100644 index a1a9d072b..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Factory where - -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Types (CreditDefault) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate credit default swaps. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - creditDefault : CreditDefault - -- ^ Attributes to create a credit default swap. - observers : PartiesMap - -- ^ The instrument's observers. - controller creditDefault.instrument.depository, creditDefault.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Instrument.daml deleted file mode 100644 index 6a9cf5499..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Types (CreditDefault) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - creditDefault : CreditDefault - -- ^ Attributes of a credit default swap. - deriving (Eq, Show) - --- | Instrument interface representing a credit default swap. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Types.daml deleted file mode 100644 index 1e059b896..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/CreditDefault/Types.daml +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) - --- | Describes the attributes of a Credit Default swap. -data CreditDefault = CreditDefault - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the swap. - defaultProbabilityReferenceId : Text - -- ^ The reference ID of the default probability observable. For example, in case of - -- protection against a "TSLA bond payment default" this should be a valid reference to the - -- "TSLA default probability". - recoveryRateReferenceId : Text - -- ^ The reference ID of the recovery rate observable. For example, in case of a "TSLA bond - -- payment default with a 60% recovery rate" this should be a valid reference to the "TSLA - -- bond recovery rate". - ownerReceivesFix : Bool - -- ^ Indicate whether a holding owner of this instrument receives the fix or the default - -- protection leg of the swap. - fixRate : Decimal - -- ^ The interest rate of the fix leg. For example, in case of "2.5% fix" this should be - -- 0.025. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the swap. For example, if the swap pays in USD this should be a USD cash - -- instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Factory.daml deleted file mode 100644 index b06cb0c1e..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Currency.Factory where - -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Types (CurrencySwap) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate currency swaps. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - currencySwap : CurrencySwap - -- ^ Attributes to create a currency swap. - observers : PartiesMap - -- ^ The instrument's observers. - controller currencySwap.instrument.depository, currencySwap.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Instrument.daml deleted file mode 100644 index b3d517bf3..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Currency.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Types (CurrencySwap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - currencySwap : CurrencySwap - -- ^ Attributes of a currency swap. - deriving (Eq, Show) - --- | Instrument interface representing a currency swap. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Types.daml deleted file mode 100644 index 99482f6b4..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Currency/Types.daml +++ /dev/null @@ -1,46 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Currency.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) - --- | Describes the attributes of a Currency swap. -data CurrencySwap = CurrencySwap - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the swap. - ownerReceivesBase : Bool - -- ^ Indicate whether a holding owner of this instrument receives the base currency leg or the - -- foreign currency leg of the swap. - baseRate : Decimal - -- ^ The interest rate of the base currency. For example, in case of "3% in USD" this should - -- be 0.03. - foreignRate : Decimal - -- ^ The interest rate of the foreign currency. For example, in case of "2% in EUR" this - -- should be 0.02. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - baseCurrency : InstrumentKey - -- ^ The base currency of the swap. For example, in the case of USD this should be a USD cash - -- instrument. - foreignCurrency : InstrumentKey - -- ^ The foreign currency of the swap. For example, in case of EUR this should be a EUR cash - -- instrument. - fxRate : Decimal - -- ^ The fx rate used to convert from the base currency principal amount to the foreign - -- currency principal amount. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Factory.daml deleted file mode 100644 index 76bb1c89a..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Factory where - -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Types (ForeignExchange) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate foreign exchange swaps. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - foreignExchange : ForeignExchange - -- ^ Attributes to create an FX swap. - observers : PartiesMap - -- ^ The instrument's observers. - controller foreignExchange.instrument.depository, foreignExchange.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Instrument.daml deleted file mode 100644 index 9b0b4b02a..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Types (ForeignExchange) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - foreignExchange : ForeignExchange - -- ^ Attributes of an FX swap. - deriving (Eq, Show) - --- | Instrument interface representing an FX swap. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Types.daml deleted file mode 100644 index 0dba935d2..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/ForeignExchange/Types.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) - --- | Describes the attributes of a Foreign Exchange swap. -data ForeignExchange = ForeignExchange - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the swap. - firstFxRate : Decimal - -- ^ The fx rate used for the first swap payment. - finalFxRate : Decimal - -- ^ The fx rate used for the final swap payment. - issueDate : Date - -- ^ The date when the swap was issued. - firstPaymentDate : Date - -- ^ The first payment date of the swap. - maturityDate : Date - -- ^ The final payment date of the swap. - baseCurrency : InstrumentKey - -- ^ The base currency of the swap, which will be exchanged to another (foreign) currency on - -- the first payment date. For example, in case of USD this should be a USD cash instrument. - foreignCurrency : InstrumentKey - -- ^ The foreign currency of the swap. For example, in case of EUR this should be a EUR cash - -- instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Factory.daml deleted file mode 100644 index 675168271..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Factory where - -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Types (Fpml) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate FpML swaps. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - fpml : Fpml - -- ^ Attributes to create a swap specified as FpML swapStreams. - observers : PartiesMap - -- ^ The instrument's observers. - controller fpml.instrument.depository, fpml.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/FpmlTypes.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/FpmlTypes.daml deleted file mode 100644 index 0425a1b19..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/FpmlTypes.daml +++ /dev/null @@ -1,532 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Fpml.FpmlTypes where - -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period, PeriodEnum, RollConventionEnum) - --- | The swap streams, describing each leg of the swap. -data SwapStream = SwapStream - with - payerPartyReference : Text - receiverPartyReference : Text - calculationPeriodDates : CalculationPeriodDates - paymentDates : PaymentDates - resetDates : Optional ResetDates - calculationPeriodAmount : CalculationPeriodAmount - stubCalculationPeriodAmount : Optional StubCalculationPeriodAmount - principalExchanges : Optional PrincipalExchanges - deriving (Eq, Show) - --- | A type defining which principal exchanges occur for --- the stream. -data PrincipalExchanges = PrincipalExchanges - with - -- id_ : Optional Text - initialExchange : Bool - -- ^ A true/false flag to indicate whether there is an initial exchange of principal on the - -- effective date. - finalExchange : Bool - -- ^ A true/false flag to indicate whether there is a final exchange of principal on the - -- termination date. - intermediateExchange : Bool - -- ^ A true/false flag to indicate whether there are intermediate or interim exchanges of - -- principal during the term of the swap. - deriving (Eq, Show) - --- | The calculation periods dates schedule. -data CalculationPeriodDates = CalculationPeriodDates - with - id : Text - effectiveDate : AdjustableDate - terminationDate : AdjustableDate - calculationPeriodDatesAdjustments : CalculationPeriodDatesAdjustments - firstPeriodStartDate : Optional AdjustableDate - firstRegularPeriodStartDate : Optional Date - lastRegularPeriodEndDate : Optional Date - calculationPeriodFrequency : CalculationPeriodFrequency - deriving (Eq, Show) - --- | The payment dates schedule. -data PaymentDates = PaymentDates - with - -- id : Optional Text - calculationPeriodDatesReference : Text - paymentFrequency : PaymentFrequency - firstPaymentDate : Optional Date - lastRegularPaymentDate : Optional Date - payRelativeTo : DateRelativeToEnum - paymentDaysOffset : Optional DateOffset - paymentDatesAdjustments : BusinessDayAdjustments - deriving (Eq, Show) - --- | A type defining an offset used in calculating a date when this date is defined in reference to --- another date through a date offset. The type includes the convention for adjusting the date and --- an optional sequence element to indicate the order in a sequence of multiple date offsets. -data DateOffset = DateOffset - with - -- id : Optional Text - periodMultiplier : Int - -- ^ A time period multiplier, e.g. 1, 2 or 3 etc. A negative value can be used when - -- specifying an offset relative to another date, e.g. -2 days. - period : PeriodEnum - -- ^ A time period, e.g. a day, week, month or year of the stream. If the periodMultiplier - -- value is 0 (zero) then period must contain the value D (day). - dayType : Optional DayTypeEnum - -- ^ In the case of an offset specified as a number of days, this element defines whether - -- consideration is given as to whether a day is a good business day or not. If a day type of - -- business days is specified then non-business days are ignored when calculating the offset. - -- The financial business centers to use for determination of business days are implied by the - -- context in which this element is used. This element must only be included when the offset - -- is specified as a number of days. If the offset is zero days then the dayType element - -- should not be included. - deriving (Eq, Show) - --- | A type for defining a date that shall be subject to adjustment if it would otherwise fall on a --- day that is not a business day in the specified business centers, together with the convention --- for adjusting the date. -data AdjustableDate = AdjustableDate - with - -- id_ : Optional Text - unadjustedDate : Date - -- ^ A date subject to adjustment. - dateAdjustments : BusinessDayAdjustments - -- ^ The business day convention and financial business centers used for adjusting the date - -- if it would otherwise fall on a day that is not a business date in the specified - -- business centers. - -- adjustedDate : Optional IdentifiedDate - -- ^ The date once the adjustment has been performed. (Note that this date may change if the - -- business center holidays change). - deriving (Eq, Show) - --- | A type defining the business day convention and financial business centers used for adjusting --- any relevant date if it would otherwise fall on a day that is not a business day in the --- specified business centers. -data BusinessDayAdjustments = BusinessDayAdjustments - with - -- id_ : Optional Text - businessDayConvention : BusinessDayConventionEnum - -- ^ The convention for adjusting a date if it would otherwise fall on a day that is not a - -- business day. - businessCenters : [Text] - deriving (Eq, Show) - --- | The reset dates schedule. This only applies for a floating rate stream. -data ResetDates = ResetDates - with - calculationPeriodDatesReference : Text - resetRelativeTo : DateRelativeToEnum - fixingDates : FixingDates - resetFrequency : ResetFrequency - resetDatesAdjustments : ResetDatesAdjustments - deriving (Eq, Show) - --- | The specification of whether payments/resets occur relative to the first or last day of a --- calculation period. -data DateRelativeToEnum - = CalculationPeriodStartDate - -- ^ Payments/Resets will occur relative to the first day of each calculation period. - | CalculationPeriodEndDate - -- ^ Payments/Resets will occur relative to the last day of each calculation period. - deriving (Eq, Show) - --- | Specifies the fixing date relative to the reset date in terms of a business days offset and an --- associated set of financial business centers. -data FixingDates = FixingDates - with - periodMultiplier : Int - period : PeriodEnum - dayType : Optional DayTypeEnum - businessDayConvention : BusinessDayConventionEnum - businessCenters : [Text] - deriving (Eq, Show) - --- | A day type classification used in counting the number of days between two dates. -data DayTypeEnum - = Business - -- ^ When calculating the number of days between two dates the count includes only business - -- days. - | Calendar - -- ^ When calculating the number of days between two dates the count includes all calendar days. - | CommodityBusiness - -- ^ When calculating the number of days between two dates the count includes only commodity - -- business days. - | CurrencyBusiness - -- ^ When calculating the number of days between two dates the count includes only currency - -- business days. - | ExchangeBusiness - -- ^ When calculating the number of days between two dates the count includes only stock - -- exchange business days. - | ScheduledTradingDay - -- ^ When calculating the number of days between two dates the count includes only scheduled - -- trading days. - deriving (Eq, Show) - --- | The period of a schedule, for example the calculation schedule. -data PeriodExtendedEnum - = Regular PeriodEnum - -- A regular time period, e.g. a day, week, month, year. - | T - -- The term of the stream. This results in a single period covering the whole term. - deriving (Eq, Show) - --- | The frequency at which reset dates occur. -data ResetFrequency = ResetFrequency - with - periodMultiplier : Int - period : PeriodExtendedEnum - deriving (Eq, Show) - --- | The frequency at which regular payment dates occur. If the payment frequency is equal to the --- frequency defined in the calculation period dates component then one calculation period --- contributes to each payment amount. If the payment frequency is less frequent than the --- frequency defined in the calculation period dates component then more than one calculation --- period will contribute to the payment amount. A payment frequency more frequent than the --- calculation period frequency or one that is not a multiple of the calculation period frequency --- is invalid. If the payment frequency is of value T (term), the period is defined by the --- swap\swapStream\calculationPerioDates\effectiveDate and the --- swap\swapStream\calculationPerioDates\terminationDate. -data PaymentFrequency = PaymentFrequency - with - periodMultiplier : Int - period : PeriodExtendedEnum - deriving (Eq, Show) - --- | The business day convention to apply to each calculation period end date if it would otherwise --- fall on a day that is not a business day in the specified financial business centers. -data CalculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments - with - businessDayConvention : BusinessDayConventionEnum - businessCenters : [Text] - deriving (Eq, Show) - --- | The business day convention to apply to each reset date if it would otherwise fall on a day --- that is not a business day in the specified financial business centers. -data ResetDatesAdjustments = ResetDatesAdjustments - with - businessDayConvention : BusinessDayConventionEnum - businessCenters : [Text] - deriving (Eq, Show) - --- | A type defining the frequency at which calculation period end dates occur within the regular --- part of the calculation period schedule and thier roll date convention. In case the calculation --- frequency is of value T (term), the period is defined by the --- swap\swapStream\calculationPerioDates\effectiveDate and the --- swap\swapStream\calculationPerioDates\terminationDate. -data CalculationPeriodFrequency = CalculationPeriodFrequency - with - -- id_ : Optional Text - periodMultiplier : Int - -- ^ A time period multiplier, e.g., 1, 2 or 3 etc. If the period value is T (Term) then - -- periodMultiplier must contain the value 1. - period : PeriodExtendedEnum - -- ^ A time period, e.g., a day, week, month, year or term of the stream. - rollConvention : RollConventionEnum - -- ^ Used in conjunction with a frequency and the regular period start date of a calculation - -- period, determines each calculation period end date within the regular part of a c - -- alculation period schedule. - deriving (Eq, Show) - --- | The calculation period amount parameters. -data CalculationPeriodAmount = CalculationPeriodAmount - with - calculation : Calculation - deriving (Eq, Show) - --- | The parameters used in the calculation of fixed or floating rate period amounts. -data Calculation = Calculation - with - notionalScheduleValue : NotionalScheduleValue - rateTypeValue : RateTypeValue - dayCountFraction : DayCountConventionEnum - compoundingMethodEnum : Optional CompoundingMethodEnum - deriving (Eq, Show) - --- | The compounding calculation method -data CompoundingMethodEnum - = Flat - -- ^ Flat compounding. Compounding excludes the spread. Note that the first compounding period - -- has it's interest calculated including any spread then subsequent periods compound this at a - -- rate excluding the spread. - | NoCompounding - -- ^ No compounding is to be applied. - | Straight - -- ^ Straight compounding. Compounding includes the spread. - | SpreadExclusive - -- ^ Spread Exclusive compounding. - deriving (Eq, Show) - --- | Specifies whether the swapStream has a fixed or a floating rate. -data RateTypeValue - = RateType_Fixed FixedRateSchedule - -- ^ Fixed rate. - | RateType_Floating FloatingRateCalculation - -- ^ Floating rate. - deriving (Eq, Show) - --- | Specifies how the notional schedule is defined: either regular or fx linked. -data NotionalScheduleValue - = NotionalSchedule_Regular NotionalSchedule - -- ^ Regular notional schedule. - | NotionalSchedule_FxLinked FxLinkedNotionalSchedule - -- ^ FX linked notional schedule. - deriving (Eq, Show) - --- | The notional amount or notional amount schedule. -data NotionalSchedule = NotionalSchedule - with - id : Text - notionalStepSchedule : NotionalStepSchedule - deriving (Eq, Show) - --- | The notional amount or notional amount schedule (FX linked). -data FxLinkedNotionalSchedule = FxLinkedNotionalSchedule - with - constantNotionalScheduleReference : Text - initialValue : Optional Decimal - varyingNotionalCurrency : Text - varyingNotionalFixingDates : FixingDates - fxSpotRateSource : FxSpotRateSource - -- varyingNotionalInterimExchangePaymentDates : VaryingNotionalInterimExchangePaymentDates - deriving (Eq, Show) - --- | A type defining the rate source and fixing time for --- an fx rate. -data FxSpotRateSource = FxSpotRateSource - with - primaryRateSource : InformationSource - -- ^ The primary source for where the rate observation will occur. Will typically be either a - -- page or a reference bank published rate. - -- secondaryRateSource : Optional InformationSource - -- ^ An alternative, or secondary, source for where the rate observation will occur. Will - -- typically be either a page or a reference bank published rate. - fixingTime : Optional BusinessCenterTime - -- ^ The time at which the spot currency exchange rate will be observed. It is specified as a - -- time in a business day calendar location, e.g., 11:00am London time. - deriving (Eq, Show) - --- | A type for defining a time with respect to a business day calendar location. For example, --- 11:00am London time. -data BusinessCenterTime = BusinessCenterTime - with - hourMinuteTime : HourMinuteTime - -- ^ A time specified in hh:mm:ss format where the second component must be '00', e.g., 11am - -- would be represented as 11:00:00. - businessCenter : Text - deriving (Eq, Show) - --- | A type defining a time specified in hh:mm:ss format where the second component must be '00', --- e.g., 11am would be represented as 11:00:00. -type HourMinuteTime = Text - --- | A type defining the source for a piece of information (e.g. a rate refix or an fx fixing). -data InformationSource = InformationSource - with - -- rateSource : InformationProvider - rateSource : Text - -- ^ An information source for obtaining a market rate. For example, Bloomberg, Reuters, - -- Telerate etc. - -- rateSourcePage : Optional RateSourcePage - rateSourcePage : Text - -- ^ A specific page for the rate source for obtaining a market rate. - -- rateSourcePageHeading : Optional String - -- ^ The heading for the rate source on a given rate source page. - deriving (Eq, Show) - --- | The notional amount or notional amount schedule expressed as explicit outstanding notional --- amounts and dates. -data NotionalStepSchedule = NotionalStepSchedule - with - initialValue : Decimal - step : [Step] - currency : Text - deriving (Eq, Show) - --- | The schedule of step date and non-negative value pairs. On each step date the associated step --- value becomes effective. A list of steps may be ordered in the document by ascending step date. --- An FpML document containing an unordered list of steps is still regarded as a conformant --- document. -data Step = Step - with - stepDate : Date - stepValue : Decimal - deriving (Eq, Show) - --- | A type defining the floating rate and definitions --- relating to the calculation of floating rate amounts. -data FloatingRateCalculation = FloatingRateCalculation - with - -- id_ : Optional Text - -- floatingRateIndex : FloatingRateIndex - floatingRateIndex : Text - indexTenor : Optional Period - -- ^ The ISDA Designated Maturity, i.e., the tenor of the floating rate. - -- floatingRateMultiplierSchedule : Optional Schedule - -- ^ A rate multiplier or multiplier schedule to apply to the floating rate. A multiplier - -- schedule is expressed as explicit multipliers and dates. In the case of a schedule, the - -- step dates may be subject to adjustment in accordance with any adjustments specified in - -- the - -- calculationPeriodDatesAdjustments. The multiplier can be a positive or negative decimal. - -- This element should only be included if the multiplier is not equal to 1 (one) for the - -- term of the stream. - spreadSchedule : [SpreadSchedule] - -- ^ The ISDA Spread or a Spread schedule expressed as explicit spreads and dates. In the case - -- of a schedule, the step dates may be subject to adjustment in accordance with any - -- adjustments specified in calculationPeriodDatesAdjustments. The spread is a per annum - -- rate, expressed as a decimal. For purposes of determining a calculation period amount, if - -- positive the spread will be added to the floating rate and if negative the spread will be - -- subtracted from the floating rate. A positive 10 basis point (0.1%) spread would be - -- represented as 0.001. - -- rateTreatment : Optional RateTreatmentEnum - -- ^ The specification of any rate conversion which needs to be applied to the observed rate - -- before being used in any calculations. The two common conversions are for securities - -- quoted on a bank discount basis which will need to be converted to either a Money Market - -- Yield or Bond Equivalent Yield. See the Annex to the 2000 ISDA Definitions, Section 7.3. - -- Certain General Definitions Relating to Floating Rate Options, paragraphs (g) and (h) for - -- definitions of these terms. - -- capRateSchedule : [StrikeSchedule] - -- ^ The cap rate or cap rate schedule, if any, which applies to the floating rate. The cap - -- rate (strike) is only required where the floating rate on a swap stream is capped at a - -- certain level. A cap rate schedule is expressed as explicit cap rates and dates and the - -- step dates may be subject to adjustment in accordance with any adjustments specified in - -- calculationPeriodDatesAdjustments. The cap rate is assumed to be exclusive of any spread - -- and is a per annum rate, expressed as a decimal. A cap rate of 5% would be represented as - -- 0.05. - -- floorRateSchedule : [StrikeSchedule] - -- ^ The floor rate or floor rate schedule, if any, which applies to the floating rate. The - -- floor rate (strike) is only required where the floating rate on a swap stream is floored - -- at a certain strike level. A floor rate schedule is expressed as explicit floor rates and - -- dates and the step dates may be subject to adjustment in accordance with any adjustments - -- specified in calculationPeriodDatesAdjustments. The floor rate is assumed to be exclusive - -- of any spread and is a per annum rate, expressed as a decimal. A floor rate of 5% would - -- be represented as 0.05. - -- initialRate : Optional Decimal - -- ^ The initial floating rate reset agreed between the principal parties involved in the - -- trade. This is assumed to be the first required reset rate for the first regular - -- calculation period. It should only be included when the rate is not equal to the rate - -- published on the source implied by the floating rate index. An initial rate of 5% would - -- be represented as 0.05. - finalRateRounding : Optional Rounding - -- ^ The rounding convention to apply to the final rate used in determination of a calculation - -- period amount. - -- averagingMethod : Optional AveragingMethodEnum - -- ^ If averaging is applicable, this component specifies whether a weighted or unweighted - -- average method of calculation is to be used. The component must only be included when - -- averaging applies. - -- negativeInterestRateTreatment : Optional NegativeInterestRateTreatmentEnum - -- ^ The specification of any provisions for calculating payment obligations when a floating - -- rate is negative (either due to a quoted negative floating rate or by operation of a - -- spread that is subtracted from the floating rate). - deriving (Eq, Show) - --- | A type defining a rounding direction and precision to be used in the rounding of a rate. -data Rounding = Rounding - with - roundingDirection : RoundingDirectionEnum - -- ^ Specifies the rounding direction. - precision : Int - -- ^ Specifies the rounding precision in terms of a number of decimal places. Note how a - -- percentage rate rounding of 5 decimal places is expressed as a rounding precision of 7 in - -- the FpML document since the percentage is expressed as a decimal, e.g. 9.876543% (or - -- 0.09876543) being rounded to the nearest 5 decimal places is 9.87654% (or 0.0987654). - deriving (Eq, Show) - --- | The method of rounding a fractional number. -data RoundingDirectionEnum - = Up - -- ^ A fractional number will be rounded up to the specified number of decimal places (the - -- precision). For example, 5.21 and 5.25 rounded up to 1 decimal place are 5.3 and 5.3 - -- respectively. - | Down - -- ^ A fractional number will be rounded down to the specified number of decimal places (the - -- precision). For example, 5.29 and 5.25 rounded down to 1 decimal place are 5.2 and 5.2 - -- respectively. - | Nearest - -- ^ A fractional number will be rounded either up or down to the specified number of decimal - -- places (the precision) depending on its value. For example, 5.24 would be rounded down to 5.2 - -- and 5.25 would be rounded up to 5.3 if a precision of 1 decimal place were specified. - deriving (Eq, Show) - --- | Adds an optional spread type element to the Schedule to identify a long or short spread value. -data SpreadSchedule = SpreadSchedule - with - -- id_ : Optional Text - initialValue : Decimal - -- ^ The initial rate or amount, as the case may be. An initial rate of 5% would be - -- represented as 0.05. - -- step : [Step] - -- ^ The schedule of step date and value pairs. On each step date the associated step value - -- becomes effective. A list of steps may be ordered in the document by ascending step date. - -- An FpML document containing an unordered list of steps is still regarded as a conformant - -- document. - -- type_ : Optional SpreadScheduleType - deriving (Eq, Show) - --- | Specify the fixed rate -data FixedRateSchedule = FixedRateSchedule - with - -- id_ : Optional Text - initialValue : Decimal - -- ^ The initial rate or amount, as the case may be. An initial rate of 5% would be - -- represented as 0.05. - step : [Step] - -- ^ The schedule of step date and value pairs. On each step date the associated step value - -- becomes effective. A list of steps may be ordered in the document by ascending step date. - -- An FpML document containing an unordered list of steps is still regarded as a conformant - -- document. - -- type_ : Optional SpreadScheduleType - deriving (Eq, Show) - --- | The stub calculation period amount parameters. This element must only be included if there is --- an initial or final stub calculation period. Even then, it must only be included if either the --- stub references a different floating rate tenor to the regular calculation periods, or if the --- stub is calculated as a linear interpolation of two different floating rate tenors, or if a --- specific stub rate or stub amount has been negotiated. -data StubCalculationPeriodAmount = StubCalculationPeriodAmount - with - calculationPeriodDatesReference : Text - initialStub : Optional StubValue - finalStub : Optional StubValue - deriving (Eq, Show) - --- | Specifies how the stub amount is calculated. A single floating rate tenor different to that --- used for the regular part of the calculation periods schedule may be specified, or two floating --- tenors may be specified. If two floating rate tenors are specified then Linear Interpolation --- (in accordance with the 2000 ISDA Definitions, Section 8.3. Interpolation) is assumed to apply. --- Alternatively, an actual known stub rate or stub amount may be specified. -data StubValue - = StubValue_FloatingRate [StubFloatingRate] - -- ^ The rates to be applied to the initial or final stub may be the linear interpolation of two - -- different rates. While the majority of the time, the rate indices will be the same as that - -- specified in the stream and only the tenor itself will be different, it is possible to - -- specift two different rates. For example, a 2 month stub period may use the linear - -- interpolation of a 1 month and 3 month rate. The different rates would be specified in this - -- component. Note that a maximum of two rates can be specified. If a stub period uses the - -- same floating rate index, including tenor, as the regular calculation periods then this - -- should not be specified again within this component, i.e., the stub calculation period - -- amount component may not need to be specified even if there is an initial or final stub - -- period. If a stub period uses a different floating rate index compared to the regular - -- calculation periods then this should be specified within this component. If specified here, - -- they are likely to have id attributes, allowing them to be referenced from within the - -- cashflows component. - | StubValue_StubRate Decimal - -- ^ An actual rate to apply for the initial or final stub period may have been agreed between - -- the principal parties (in a similar way to how an initial rate may have been agreed for the - -- first regular period). If an actual stub rate has been agreed then it would be included in - -- this component. It will be a per annum rate, expressed as a decimal. A stub rate of 5% - -- would be represented as 0.05. - -- | StubValue_StubAmount Money - -- ^ An actual amount to apply for the initial or final stub period may have been agreed between - -- the two parties. If an actual stub amount has been agreed then it would be included in this - -- component. - deriving (Eq, Show) - --- | The rates to be applied to the initial or final stub may be the linear interpolation of two --- different rates. -data StubFloatingRate = StubFloatingRate - with - floatingRateIndex : Text - indexTenor : Optional Period - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Instrument.daml deleted file mode 100644 index ca62fcd8b..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Types (Fpml) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - fpml : Fpml - -- ^ Attributes of a swap specified as FpML swapStreams. - deriving (Eq, Show) - --- | Instrument interface representing a swap specified as FpML swapStreams. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Types.daml deleted file mode 100644 index 272cbffe8..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/Fpml/Types.daml +++ /dev/null @@ -1,28 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Types where - -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.FpmlTypes (SwapStream(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) - -data Fpml = Fpml - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the swap. - swapStreams : [SwapStream] - -- ^ Each element describes a stream of swap payments, for example a regular fixed or floating - -- rate. - issuerPartyRef : Text - -- ^ Used to the identify which counterparty is the issuer in the swapStream. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - currencies : [InstrumentKey] - -- ^ The currencies of the different swap legs, one for each swapStream. For example, if one - -- leg pays in USD this should be a USD cash instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Factory.daml deleted file mode 100644 index fbc72725f..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Factory where - -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Types (InterestRate) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate interest rate swaps. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new instrument. - with - interestRate : InterestRate - -- ^ Attributes to create an interest rate swap. - observers : PartiesMap - -- ^ The instrument's observers. - controller interestRate.instrument.depository, interestRate.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Instrument.daml deleted file mode 100644 index 3587d09f8..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Instrument.daml +++ /dev/null @@ -1,34 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Types (InterestRate) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - interestRate : InterestRate - -- ^ Attributes of an interest rate swap. - deriving (Eq, Show) - --- | Instrument interface representing an interest rate swap. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Types.daml deleted file mode 100644 index 74b047ec0..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Swap/V0/InterestRate/Types.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Types where - -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) - -data InterestRate = InterestRate - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ The description of the swap. - floatingRate : FloatingRate - -- ^ A description of the floating rate to be used. This supports both Libor and SOFR style - -- reference rates (using a compounded index, e.g. the SOFR Index). - ownerReceivesFix : Bool - -- ^ Indicate whether a holding owner of this instrument receives the fix or the floating leg - -- of the swap. - fixRate : Decimal - -- ^ The interest rate of the fix leg. For example, in case of "3M Euribor vs 2.5% fix" this - -- should be 0.025. - periodicSchedule : PeriodicSchedule - -- ^ The schedule for the periodic swap payments. - holidayCalendarIds : [Text] - -- ^ The identifiers of the holiday calendars to be used for the swap payment schedule. - calendarDataProvider : Party - -- ^ The reference data provider to use for the holiday calendar. - dayCountConvention : DayCountConventionEnum - -- ^ The day count convention used to calculate day count fractions. For example: Act360. - currency : InstrumentKey - -- ^ The currency of the swap. For example, if the swap pays in USD this should be a USD cash - -- instrument. - lastEventTimestamp : Time - -- ^ (Market) time of the last recorded lifecycle event. If no event has occurred yet, the - -- time of creation should be used. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Factory.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Factory.daml deleted file mode 100644 index 59082d4a9..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Factory.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Token.V4.Factory where - -import Daml.Finance.Interface.Instrument.Token.V4.Instrument qualified as Instrument (I) -import Daml.Finance.Interface.Instrument.Token.V4.Types (Token) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate simple tokens. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Instrument.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Instrument.I - -- ^ Create a new token. - with - token : Token - -- ^ Attributes to create a token. - observers : PartiesMap - -- ^ The instrument's observers. - controller token.instrument.depository, token.instrument.issuer - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Instrument.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Instrument.daml deleted file mode 100644 index a8cc0c0a7..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Instrument.daml +++ /dev/null @@ -1,35 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Token.V4.Instrument where - -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I) -import Daml.Finance.Interface.Instrument.Token.V4.Types (Token) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Instrument`. -type I = Instrument - --- | Type synonym for `View`. -type V = View - --- | View of `Instrument`. -data View = View - with - token : Token - -- ^ Attributes of a Token Instrument. - deriving (Eq, Show) - --- | Interface for a Token, an instrument whose economic terms on the ledger are represented --- by an `id` and a textual `description`. -interface Instrument requires BaseInstrument.I, Disclosure.I where - viewtype V - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Types.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Types.daml deleted file mode 100644 index 5bd0e926b..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Token/V4/Types.daml +++ /dev/null @@ -1,17 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Token.V4.Types where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey) - --- | Describes the attributes of a Token Instrument. -data Token = Token - with - instrument : InstrumentKey - -- ^ The instrument's key. - description : Text - -- ^ A description of the instrument. - validAsOf : Time - -- ^ Timestamp as of which the instrument is valid. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Instrument/Types/V2/FloatingRate.daml b/src/main/daml/Daml/Finance/Interface/Instrument/Types/V2/FloatingRate.daml deleted file mode 100644 index 3f5cd3c00..000000000 --- a/src/main/daml/Daml/Finance/Interface/Instrument/Types/V2/FloatingRate.daml +++ /dev/null @@ -1,47 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Instrument.Types.V2.FloatingRate where - -import Daml.Finance.Interface.Types.Date.V3.DateOffset (DateOffset) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) - -type FixingDates = DateOffset -- FixingDates is the name used in the FpML schema - --- | The specification of whether payments/resets occur relative to the first or last day of a --- calculation period. -data DateRelativeToEnum - = CalculationPeriodStartDate - -- ^ Payments/Resets will occur relative to the first day of each calculation period. - | CalculationPeriodEndDate - -- ^ Payments/Resets will occur relative to the last day of each calculation period. - deriving (Eq, Show) - --- | The type of reference rate, which defines how the reference rate is calculated. -data ReferenceRateTypeEnum - = SingleFixing DateRelativeToEnum - -- ^ The reference rate is fixed on one observation date. This is usually the case for Libor - -- and similar reference rates. A DateRelativeToEnum is required to indicate whether the - -- reference rate will reset relative to the first or the last day of the calculation period. - | CompoundedIndex DayCountConventionEnum - -- ^ The reference rate is a regularly (e.g. daily) compounded reference rate, e.g. compounded - -- SOFR, calculated via an index that is continuously compounded since a specified start date. - -- This enables efficient calculation using only the index values at the start and at the end of - -- the calculation period: SOFR_INDEX_END / SOFR_INDEX_START - 1, as described here: - -- https://www.newyorkfed.org/markets/reference-rates/additional-information-about-reference-rates#tgcr_bgcr_sofr_calculation_methodology - -- The day count convention used for the index calculation (by the index provider) is also - -- required. For example, in the case of SOFR this is Act360, which is implied by the 360/dc - -- factor in the formula in the "Calculation Methodology for the SOFR Averages and Index" - -- section in the link above. - deriving (Eq, Show) - --- | Specifies the data required for a floating rate coupon. -data FloatingRate = FloatingRate - with - referenceRateId : Text - -- ^ The identifier of the reference rate to be used for the coupon, e.g. Libor-3M. - referenceRateType : ReferenceRateTypeEnum - -- ^ The type of reference rate, which defines how the reference rate is calcuated. - fixingDates : FixingDates - -- ^ Specifies the fixing dates as an offset of the calculation date, e.g. -2 business days. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Effect.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Effect.daml deleted file mode 100644 index 8a39e8be1..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Effect.daml +++ /dev/null @@ -1,89 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Effect where - -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey, InstrumentQuantity, Parties) --- | Type synonym for `Effect`. -type I = Effect - --- | Type synonym for `View`. -type V = View - --- | View for `Effect`. -data View = View - with - providers : Parties - -- ^ The parties providing the claim processing. - targetInstrument : InstrumentKey - -- ^ The target instrument. A holding on this instrument is required to claim the effect. - -- For example, in the case of a swap instrument, this would be the original instrument - -- version before lifecycling, that contains the current swap payment. - producedInstrument : Optional InstrumentKey - -- ^ The produced instrument, if it exists. - -- For example, in the case of a swap instrument, this would be the new instrument - -- version after lifecycling, that does not contain the current swap payment. - -- If there are no more claims remaining after the current lifecycling, this would be None. - id : Id - -- ^ A textual identifier. - description : Text - -- ^ A human readable description of the Effect. - settlementTime : Optional Time - -- ^ The effect's settlement time (if any). - otherConsumed : [InstrumentQuantity] - -- ^ Consumed quantities (in addition to the target instrument). - -- For example, in the case of a fix vs floating rate swap, this could be a 2.5% fix - -- payment. - otherProduced : [InstrumentQuantity] - -- ^ Produced quantities (in additon to the produced instrument). - -- For example, in the case of a fix vs floating rate swap, this could be a 3M Euribor - -- floating payment. - deriving (Eq, Show) - --- | Interface for contracts exposing effects of lifecycling processes. -interface Effect where - viewtype V - - setProviders : SetProviders -> Update (ContractId Effect) - -- ^ Implementation of the `SetProviders` choice. - calculate : Calculate -> ContractId Effect -> Update CalculationResult - -- ^ Implementation of the `Calculate` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Calculate : CalculationResult - -- ^ Given an instrument quantity of the target instrument, it calculates the instrument - -- quantities to settle. - with - actor : Party - -- ^ The flexible controller of the choice. - quantity : InstrumentQuantity - -- ^ The quantity being targeted. - controller actor - do - calculate this arg self - - choice SetProviders : ContractId Effect - -- ^ Set the provider of the effect. - with - newProviders : Parties - -- ^ The new provider. - controller (view this).providers, newProviders - do - setProviders this arg - --- | Data type encapsulating the effect's calculation result. -data CalculationResult = CalculationResult - with - consumed : [InstrumentQuantity] - -- ^ Consumed quantities. - produced : [InstrumentQuantity] - -- ^ Produced quantities. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election.daml deleted file mode 100644 index 037a4d806..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election.daml +++ /dev/null @@ -1,108 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Election where - -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (I) -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I, getEventTime) -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey, PartiesMap) - --- | Type synonym for `Election`. -type I = Election - --- | Type synonym for `View`. -type V = View - --- | View for `Election`. -data View = View - with - id : Id - -- ^ The identifier for an election. - description : Text - -- ^ A description of the instrument. - claim : Text - -- ^ The tag corresponding to the elected sub-tree. - elector : Party - -- ^ Parties on behalf of which the election is made. - counterparty : Party - -- ^ Faces the `elector` in the `Holding`. - electorIsOwner : Bool - -- ^ `True` if election is on behalf of the owner of the holding, `False` otherwise. - observers : PartiesMap - -- ^ Observers of the election. - amount : Decimal - -- ^ Number of instrument units to which the election applies. - provider : Party - -- ^ Party that is authorized to process the election and generate the new instrument version - -- and effects. - instrument : InstrumentKey - -- ^ The instrument to which the election applies. - deriving (Eq, Show) - --- | Interface implemented by templates that represents a claim-based election. This interface --- requires the `Event` interface implementation. -interface Election requires Event.I where - viewtype V - - apply : ContractId Election -> Apply -> Update (Optional InstrumentKey, [ContractId Effect.I]) - -- ^ Implementation of the `Apply` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Apply : (Optional InstrumentKey, [ContractId Effect.I]) - -- ^ Applies the election to the instrument, returning the new instrument as well as the - -- corresponding effects. The election is archived as part of this choice. - with - observableCids : [ContractId NumericObservable.I] - -- ^ Set of observables. - exercisableCid : ContractId Exercisable - -- ^ The contract that is used to apply an election to the instrument. - controller (view this).provider - do - apply this self arg - --- | Retrieves the election's time. -getElectionTime : Election -> Time -getElectionTime = Event.getEventTime . toInterface @Event.I - --- | View for `Exercisable`. -data ExercisableView = ExercisableView - with - lifecycler : Party - -- ^ Party processing the election. - deriving (Eq, Show) - --- | Interface implemented by instruments that admit (claim-based) elections. -interface Exercisable where - viewtype ExercisableView - - applyElection : ApplyElection -> Update (Optional InstrumentKey, [ContractId Effect.I]) - -- ^ Implementation of the `ApplyElection` choice. - - nonconsuming choice Exercisable_GetView : ExercisableView - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice ApplyElection : (Optional InstrumentKey, [ContractId Effect.I]) - -- ^ Applies an election to the instrument. - with - electionCid : ContractId Election - -- ^ The election. - observableCids : [ContractId NumericObservable.I] - -- ^ Set of observables. - controller (view this).lifecycler - do - applyElection this arg diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election/Factory.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election/Factory.daml deleted file mode 100644 index 516cdb208..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Election/Factory.daml +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Election.Factory where - -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey(..), Parties, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- View of `Factory`. -data View = View - with - provider : Party - -- ^ The provider of the `Factory`. - deriving (Eq, Show) - --- | Factory interface to instantiate elections on generic instruments. -interface Factory requires Disclosure.I where - viewtype V - - create' : Create -> Update (ContractId Election.I) - -- ^ Implementation of `Create` choice. - - nonconsuming choice Create : ContractId Election.I - -- ^ Create a new Election. - with - actors : Parties - -- ^ Parties calling the `Create` choice. - elector : Party - -- ^ Parties on behalf of which the election is made. - counterparty : Party - -- ^ Faces the `elector` in the `Holding`. - provider : Party - -- ^ Party that signs the election (together with the elector). - id : Id - -- ^ The identifier for an election. - description : Text - -- ^ A description of the instrument. - claim : Text - -- ^ The tag corresponding to the elected sub-tree. - electorIsOwner : Bool - -- ^ `True` if election is on behalf of the owner of the holding, `False` otherwise. - electionTime : Time - -- ^ Time at which the election is put forward. - observers : PartiesMap - -- ^ Observers of the election. - amount : Decimal - -- ^ Number of instrument units to which the election applies. - instrument : InstrumentKey - -- ^ The instrument to which the election applies. - controller actors - do - create' this arg diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event.daml deleted file mode 100644 index 560839ba1..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event.daml +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Event where - -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) - --- | Type synonym for `Event`. -type I = Event - --- | Type synonym for `View`. -type V = View - --- | View for `Event`. -data View = View - with - providers : Parties - -- ^ Providers of the event. - id : Id - -- ^ Identifier for the event. - description : Text - -- ^ A human readable description of the event. - eventTime : Time - -- ^ The time of the event. This allows ordering of events. - deriving (Eq, Show) - --- | A lifecycle event. These events are ordered based on the corresponding event time. -interface Event where - viewtype V - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - -instance Ord Event where - x <= y = getEventTime x <= getEventTime y - --- | Given an event, retrieves the event time. -getEventTime : Event -> Time -getEventTime e = (view e).eventTime diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Distribution.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Distribution.daml deleted file mode 100644 index 1c7dd5f9c..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Distribution.daml +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Event.Distribution where - -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Base (I) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey, InstrumentQuantity) - --- | Type synonym for `Event`. -type I = Event - --- | Type synonym for `View`. -type V = View - --- | View for `Event`. -data View = View - with - effectiveTime : Time - -- ^ Time on which the distribution is effectuated. - targetInstrument : InstrumentKey - -- ^ Instrument the distribution event applies to. - newInstrument : InstrumentKey - -- ^ Instrument after the distribution has been claimed. - perUnitDistribution : [InstrumentQuantity] - -- ^ Distributed quantities per unit held. - deriving (Eq, Show) - --- | Event interface for the distribution of units of an instrument for each unit of a target --- instrument (e.g. share or cash dividends). -interface Event requires Base.I where - viewtype V - - nonconsuming choice GetView : View - -- ^ Retrieves the event view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Replacement.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Replacement.daml deleted file mode 100644 index 5554d2082..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Replacement.daml +++ /dev/null @@ -1,38 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Event.Replacement where - -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Base (I) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey, InstrumentQuantity) - --- | Type synonym for `Event`. -type I = Event - --- | Type synonym for `View`. -type V = View - --- | View for `Event`. -data View = View - with - effectiveTime : Time - -- ^ Time on which the replacement is effectuated. - targetInstrument : InstrumentKey - -- ^ Instrument the replacement event applies to. - perUnitReplacement : [InstrumentQuantity] - -- ^ Instrument quantities the target instrument is replaced with. - deriving (Eq, Show) - --- | Event interface for the replacement of units of an instrument with a basket of other --- instruments (e.g. stock merger). -interface Event requires Base.I where - viewtype V - - nonconsuming choice GetView : View - -- ^ Retrieves the event view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Time.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Time.daml deleted file mode 100644 index ebb5ffe56..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Event/Time.daml +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Event.Time where - -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Base (I) - --- | Type synonym for `Event`. -type I = Event - --- | Type synonym for `View`. -type V = View - --- | View for `Event`. -data View = View {} deriving (Eq, Show) - --- | Event interface for events that signal the passing of (business) time. -interface Event requires Base.I where - viewtype V - - nonconsuming choice GetView : View - -- ^ Retrieves the event view. The event's time can be retrieved from the generic `Event` - -- interface. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/NumericObservable.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/NumericObservable.daml deleted file mode 100644 index cb6ff300a..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/NumericObservable.daml +++ /dev/null @@ -1,51 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This module defines an interface for a `NumericObservable`, which is used to inspect --- time-dependent numerical values. -module Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable where - -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) - --- | Type synonym for `Observable`. -type I = NumericObservable - --- | Type synonym for `View`. -type V = View - --- | View for `Observable`. -data View = View - with - provider : Party - -- ^ Party providing the observations. - id : Id - -- ^ Textual reference to the observable. - deriving (Eq, Show) - --- | An interface to inspect some (time-dependent) numerical values (e.g. a stock price or an --- interest rate fixing) required when processing a lifecycle rule. -interface NumericObservable where - viewtype V - - observe : Time -> Update Decimal - -- ^ Implementation of the `Observe` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Observe : Decimal - -- ^ Observe the `Observable`. - with - actors : Parties - -- ^ Parties calling this 'Observe' choice. - t : Time - -- ^ Time at which the value is observed. - controller actors - do - observe this t diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/TimeObservable.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/TimeObservable.daml deleted file mode 100644 index 97475dc7e..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Observable/TimeObservable.daml +++ /dev/null @@ -1,49 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This module defines an interface for a `TimeObservable`, which is implemented by templates --- exposing time information. -module Daml.Finance.Interface.Lifecycle.V4.Observable.TimeObservable where - -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) -import Prelude hiding (getTime) - --- | Type synonym for `TimeObservable`. -type I = TimeObservable - --- | Type synonym for `View`. -type V = View - --- | View for `TimeObservable`. -data View = View - with - providers : Parties - -- ^ Parties providing the observation. - id : Id - -- ^ Textual reference to the observable. - deriving (Eq, Show) - --- | An interface to inspect a time value. -interface TimeObservable where - viewtype V - - getTime : Update Time - -- ^ Implementation of the `GetTime` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice GetTime : Time - -- ^ Retrieves the current time. - with - actors : Parties - -- ^ The party retrieving the current time. - controller actors - do - getTime this diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Claim.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Claim.daml deleted file mode 100644 index c3f75a389..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Claim.daml +++ /dev/null @@ -1,75 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Rule.Claim where - -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (I) -import Daml.Finance.Interface.Settlement.V4.Factory qualified as SettlementFactory (I) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (I) -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Claim`. -type I = Claim - --- | Type synonym for `View`. -type V = View - --- | View for `Settlement`. -data View = View - with - providers : Parties - -- ^ Providers of the claim rule. Together with the actors of the `ClaimEffect` choice the - -- authorization requirements to upgrade the holdings being claimed have to be met. - claimers : Parties - -- ^ Any of the parties can claim an effect. - settlers : Parties - -- ^ Any of the parties can trigger settlement of the resulting batch. - routeProviderCid : ContractId RouteProvider.I - -- ^ RouteProvider contract used to discover settlement routes. - settlementFactoryCid : ContractId SettlementFactory.I - -- ^ Settlement factory contract used to create a `Batch` of `Instruction`\s. - deriving (Eq, Show) - --- | Data type wrapping the results of `Claim`ing an `Effect`. -data ClaimResult = ClaimResult - with - batchCid : ContractId Batch.I - -- ^ Batch used to batch-settle settlement instructions. - instructionCids : [ContractId Instruction.I] - -- ^ Settlement instructions to settle all effect consequences. - deriving (Eq, Show) - --- | Interface for contracts that allow holders to claim an `Effect` and generate --- `SettlementInstruction`\s. -interface Claim where - viewtype V - - claimEffect : ClaimEffect -> Update ClaimResult - -- ^ Implementation of the `ClaimEffect` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice ClaimEffect : ClaimResult - -- ^ Claim an effect and generate corresponding settlement instructions. - with - claimer : Party - -- ^ The party claiming the effect. - holdingCids : [ContractId Api.HoldingV1.Holding] - -- ^ The holdings to process. - effectCid : ContractId Effect.I - -- ^ The effect to process. - batchId : Id - -- ^ Identifier used for the generated settlement batch. - controller claimer - do - claimEffect this arg diff --git a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Lifecycle.daml b/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Lifecycle.daml deleted file mode 100644 index 5855e6871..000000000 --- a/src/main/daml/Daml/Finance/Interface/Lifecycle/V4/Rule/Lifecycle.daml +++ /dev/null @@ -1,57 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle where - -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (I) -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I) -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), InstrumentKey) - --- | Type synonym for `Lifecycle`. -type I = Lifecycle - --- | Type synonym for `View`. -type V = View - --- | View for `Lifecycle`. -data View = View - with - id : Id - -- ^ Identifier for the rule contract. - description : Text - -- ^ Textual description. - lifecycler : Party - -- ^ Party performing the lifecycling. - deriving (Eq, Show) - --- | Interface implemented by instruments that can be lifecycled (either by the instrument itself --- or by a separate rule contract). -interface Lifecycle where - viewtype V - - evolve : Evolve -> Update (Optional InstrumentKey, [ContractId Effect.I]) - -- ^ Implementation of the `Evolve` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Evolve : (Optional InstrumentKey, [ContractId Effect.I]) - -- ^ Process an event. It returns a tuple of the lifecycled instrument (or the original - -- instrument when the former does not exist) and the effects. - with - eventCid : ContractId Event.I - -- ^ The event. - instrument : InstrumentKey - -- ^ The target instrument. - observableCids : [ContractId NumericObservable.I] - -- ^ Set of numerical time-dependent observables. - controller (view this).lifecycler - do - evolve this arg diff --git a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Batch.daml b/src/main/daml/Daml/Finance/Interface/Settlement/V4/Batch.daml deleted file mode 100644 index 8067c745a..000000000 --- a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Batch.daml +++ /dev/null @@ -1,72 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Settlement.V4.Batch where - -import Daml.Finance.Interface.Settlement.V4.Types (RoutedStep) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Batch`. -type I = Batch - --- | Type synonym for `View`. -type V = View - --- | View for `Batch`. -data View = View - with - instructor : Party - -- ^ Party instructing settlement (and the creation of the `Batch`). - consenters : Parties - -- ^ Parties consenting with the creation of the `Batch`. - settlers : Parties - -- ^ Parties that can trigger the final settlement. - id : Id - -- ^ Batch identifier. - description : Text - -- ^ Batch description. - contextId : Optional Id - -- ^ Identifier to link a batch to a context (e.g. the `Effect` it originated from). - routedSteps : [RoutedStep] - -- ^ Routed settlement steps. - settlementTime : Optional Time - -- ^ Settlement time (if any). - deriving (Eq, Show) - --- | An interface for atomically settling a batch of `Instruction`\s. --- The corresponding Instructions are referenced by key. -interface Batch where - viewtype V - - settle : Settle -> Update [ContractId Api.HoldingV1.Holding] - -- ^ Implementation of the `Settle` choice. - cancel : Cancel -> Update [ContractId Api.HoldingV1.Holding] - -- ^ Implementation of the `Cancel` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - choice Settle : [ContractId Api.HoldingV1.Holding] - -- ^ Settles the batch. - with - actors : Parties - -- ^ The parties settling the batch. - controller actors - do - settle this arg - - choice Cancel : [ContractId Api.HoldingV1.Holding] - -- ^ Cancels the batch. - with - actors : Parties - -- ^ The parties canceling the batch. - controller actors - do - cancel this arg diff --git a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Factory.daml b/src/main/daml/Daml/Finance/Interface/Settlement/V4/Factory.daml deleted file mode 100644 index c7f5f1ad0..000000000 --- a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Factory.daml +++ /dev/null @@ -1,63 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Settlement.V4.Factory where - -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (I) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (I) -import Daml.Finance.Interface.Settlement.V4.Types (RoutedStep) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) - --- | Type synonym for `Factory`. -type I = Factory - --- | Type synonym for `View`. -type V = View - --- | View for `Factory`. -data View = View - with - provider : Party - -- ^ Party providing the facility. - observers : Parties - -- ^ Observers. - deriving (Eq, Show) - --- | An interface used to generate settlement instructions. -interface Factory where - viewtype V - - instruct : Instruct -> Update (ContractId Batch.I, [ContractId Instruction.I]) - -- ^ Implementation of the `Instruct` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Instruct : (ContractId Batch.I, [ContractId Instruction.I]) - -- ^ Generate settlement instructions, and a batch for settling them. - with - instructor : Party - -- ^ Party instructing settlement (and the creation of the `Batch` and `Instruction`\s). - consenters : Parties - -- ^ Parties consenting with the `Batch` and `Instruction`\s being created. - settlers : Parties - -- ^ Any of the parties can trigger the final settlement. - id : Id - -- ^ Batch identifier. - description : Text - -- ^ Batch description. - contextId : Optional Id - -- ^ Identifier to link a batch to a context (e.g. the `Effect` it originated from). - routedSteps : [RoutedStep] - -- ^ Routed settlement steps to instruct. - settlementTime : Optional Time - -- ^ Settlement time (if any). - controller instructor, consenters - do - instruct this arg diff --git a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Instruction.daml b/src/main/daml/Daml/Finance/Interface/Settlement/V4/Instruction.daml deleted file mode 100644 index 9cc596c90..000000000 --- a/src/main/daml/Daml/Finance/Interface/Settlement/V4/Instruction.daml +++ /dev/null @@ -1,104 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Settlement.V4.Instruction where - -import Daml.Finance.Interface.Settlement.V4.Types (Allocation, Approval, RoutedStep) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Instruction`. -type I = Instruction - --- | Type synonym for `View`. -type V = View - --- | View for `Instruction`. -data View = View - with - instructor : Party - -- ^ Party that instructs settlement (and the creation of the `Instruction`). - consenters : Parties - -- ^ Parties consenting with the creation of the `Instruction`. - settlers : Parties - -- ^ Parties that can execute the Instruction. - batchId : Id - -- ^ Batch identifier. - id : Id - -- ^ Instruction identifier. - routedStep : RoutedStep - -- ^ Instruction details to execute. - settlementTime : Optional Time - -- ^ Settlement time (if any). - allocation : Allocation - -- ^ Allocation from the sender. - approval : Approval - -- ^ Approval from the receiver. - signedSenders : Parties - -- ^ Additional signatories, used to collect authorization (on sending side). - signedReceivers : Parties - -- ^ Additional signatories, used to collect authorization (on receiving side). - deriving (Eq, Show) - --- | An interface for providing a single instruction to transfer an asset. -interface Instruction requires Disclosure.I where - viewtype V - - allocate : Allocate -> Update (ContractId Instruction, Optional (ContractId Api.HoldingV1.Holding)) - -- ^ Implementation of the `Allocate` choice. - approve : Approve -> Update (ContractId Instruction) - -- ^ Implementation of the `Approve` choice. - execute : Execute -> Update (Optional (ContractId Api.HoldingV1.Holding)) - -- ^ Implementation of the `Execute` choice. - cancel : Cancel -> Update (Optional (ContractId Api.HoldingV1.Holding)) - -- ^ Implementation of the `Cancel` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - choice Allocate : (ContractId Instruction, Optional (ContractId Api.HoldingV1.Holding)) - -- ^ Allocates this instruction and optionally returns a previously allocated (mutated) asset. - with - actors : Parties - -- ^ The parties allocating the instruction. - allocation : Allocation - -- ^ Allocation of an instruction. - controller actors - do - allocate this arg - - choice Approve : ContractId Instruction - -- ^ Approves this instruction. - with - actors : Parties - -- ^ The parties approving the instruction. - approval : Approval - -- ^ Approval of an instruction. - controller actors - do - approve this arg - - choice Execute : Optional (ContractId Api.HoldingV1.Holding) - -- ^ Executes this instruction. - with - actors : Parties - -- ^ The parties executing the instruction. - controller actors - do - execute this arg - - choice Cancel : Optional (ContractId Api.HoldingV1.Holding) - -- ^ Cancels this instruction. - with - actors : Parties - -- ^ The parties canceling the instruction. - controller actors - do - cancel this arg diff --git a/src/main/daml/Daml/Finance/Interface/Settlement/V4/RouteProvider.daml b/src/main/daml/Daml/Finance/Interface/Settlement/V4/RouteProvider.daml deleted file mode 100644 index ff3987ff6..000000000 --- a/src/main/daml/Daml/Finance/Interface/Settlement/V4/RouteProvider.daml +++ /dev/null @@ -1,51 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Settlement.V4.RouteProvider where - -import Daml.Finance.Interface.Settlement.V4.Types (RoutedStep, Step) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, Parties) - --- | Type synonym for `RouteProvider`. -type I = RouteProvider - --- | Type synonym for `View`. -type V = View - --- | View for `RouteProvider`. -data View = View - with - provider : Party - -- ^ Party providing the `RouteProvider` facility. - observers : Parties - -- ^ Observers. - deriving (Eq, Show) - --- | An interface used to discover the settlement route for each `Step`, i.e., `[RoutedStep]`. -interface RouteProvider where - viewtype V - - discover : Discover -> Update [RoutedStep] - -- ^ Implementation of the `Discover` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - nonconsuming choice Discover : [RoutedStep] - -- ^ Discover the settlement route for each `Step`. - with - discoverors : Parties - -- ^ Parties requesting to discover. - contextId : Optional Id - -- ^ Context for the discovery. - steps : [Step] - -- ^ Settlement steps to route. - controller discoverors - do - discover this arg diff --git a/src/main/daml/Daml/Finance/Interface/Types/Common/V3/Types.daml b/src/main/daml/Daml/Finance/Interface/Types/Common/V3/Types.daml deleted file mode 100644 index bf265f7e6..000000000 --- a/src/main/daml/Daml/Finance/Interface/Types/Common/V3/Types.daml +++ /dev/null @@ -1,95 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Types.Common.V3.Types where - -import DA.Map (Map) -import DA.Set (Set) - --- | A set of parties. -type Parties = Set Party - --- | Parties mapped by a specific key (or context). --- The textual key is the "context" which describes the value set of parties. --- This allows processes to add/remove parties for their specific purpose, without affecting others. -type PartiesMap = Map Text Parties - --- A textual identifier. -newtype Id = Id Text - deriving (Eq, Ord) - -instance Show Id where - show (Id t) = t - --- | The `HoldingStandard` data type categorizes holdings into four distinct classes, each defined --- by the combination of holding interfaces they implement: `Transferable.I`, `Fungible.I`, and --- `Holding.I`. Notably, `Transferable.I` and `Fungible.I` both require the implementation of the --- `Holding.I` interface. Please also note that, in this context, "Transferable.I" refers to the --- capability of a holding to be transferred between parties (e.g., from Alice to Bob) through a --- single custodian. Additionally, it is important to highlight that all classes of holdings can be --- credited and debited, and thereby effectively settled. -data HoldingStandard - = TransferableFungible - -- ^ Represents the class of holdings which implement `Fungible.I` and `Transferable.I`, and by - -- extension `Holding.I`. Holdings in this class are both interchangeable (fungible) and - -- can be transferred between parties (such as Alice to Bob) via a custodian. - | Transferable - -- ^ Represents the class of holdings which implement `Transferable.I` and, by extension, - -- `Holding.I`, but not `Fungible.I`. This class pertains to assets that can be transferred - -- between parties through a custodian, but are not interchangeable. - | Fungible - -- ^ Represents the class of holdings which implement `Fungible.I` and, by extension, - -- `Holding.I`, but not `Transferable.I`. These holdings are interchangeable, suitable for - -- scenarios where asset fungibility is crucial, but do not have the transfer capability - -- between parties via a custodian. - | BaseHolding - -- ^ Represents the class of holdings which implement only `Holding.I` and neither - -- `Transferable.I` nor `Fungible.I`. This class encompasses basic holdings without the - -- functionalities of custodian-based transferability or fungibility. - deriving (Eq, Ord, Show) - --- | A unique key for a holding factory. -data HoldingFactoryKey = HoldingFactoryKey - with - provider : Party - -- ^ Holding factory provider. - id : Id - -- ^ Unique identifier for a holding factory. - deriving (Eq, Ord, Show) - --- | A unique key for Accounts. -data AccountKey = AccountKey - with - custodian : Party - -- ^ Account provider. - owner : Party - -- ^ Account owner. - id : Id - -- ^ Unique identifier for an account. - deriving (Eq, Ord, Show) - --- | A unique key for Instruments. -data InstrumentKey = InstrumentKey - with - depository : Party - -- ^ Party providing depository services. - issuer : Party - -- ^ Issuer of instrument. - id : Id - -- ^ A unique identifier for an instrument. - version : Text - -- ^ A textual instrument version. - holdingStandard: HoldingStandard - -- ^ The used holding standard for the instrument. - deriving (Eq, Ord, Show) - --- | A dimensioned quantity. -data Quantity u a = Quantity - with - unit : u - -- ^ The quantity's unit. - amount : a - -- ^ A numerical amount. - deriving (Eq, Ord, Show) - -type InstrumentQuantity = Quantity InstrumentKey Decimal diff --git a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Calendar.daml b/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Calendar.daml deleted file mode 100644 index e83e9f343..000000000 --- a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Calendar.daml +++ /dev/null @@ -1,44 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Types.Date.V3.Calendar where - -import DA.Date (DayOfWeek(..)) - --- | Holiday Calendar Data used to define holidays (non-business days). -data HolidayCalendarData = HolidayCalendarData - with - id : Text - -- ^ The id of the holiday calendar. - weekend : [DayOfWeek] - -- ^ A list of week days defining the weekend. - holidays : [Date] - -- ^ A list of dates defining holidays. - deriving (Eq, Show) - --- | An enum type to specify how a non-business day is adjusted. -data BusinessDayConventionEnum - = Following - -- ^ Adjust a non-business day to the next business day. - | ModifiedFollowing - -- ^ Adjust a non-business day to the next business day - -- unless it is not in the same month. In this case use - -- the previous business day. - | ModifiedPreceding - -- ^ Adjust a non-business day to the previous business day - -- unless it is not in the same month. In this case use - -- the next business day. - | NoAdjustment - -- ^ Non-business days are not adjusted. - | Preceding - -- ^ Adjust a non-business day to the previous business day. - deriving (Eq, Show) - --- | A data type to define how non-business days are adjusted. -data BusinessDayAdjustment = BusinessDayAdjustment - with - calendarIds : [Text] - -- ^ A list of calendar ids to define holidays. - convention : BusinessDayConventionEnum - -- ^ The business day convention used for the adjustment. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Classes.daml b/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Classes.daml deleted file mode 100644 index ff9dcb7e1..000000000 --- a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Classes.daml +++ /dev/null @@ -1,8 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Types.Date.V3.Classes where - --- | Types that can be converted to UTC time. -class HasUTCTimeConversion a where - toUTCTime : a -> Time diff --git a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DateOffset.daml b/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DateOffset.daml deleted file mode 100644 index 554f6b943..000000000 --- a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DateOffset.daml +++ /dev/null @@ -1,32 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Types.Date.V3.DateOffset where - -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum) - --- | A day type classification used in counting the number of days between two dates. -data DayTypeEnum - = Business - -- ^ When calculating the number of days between two dates the count includes only business - -- days. - | Calendar - -- ^ When calculating the number of days between two dates the count includes all calendar days. - deriving (Eq, Show) - --- | A date offset type that can be used e.g. to specify a rate fixing date relative to the reset --- date in terms of a business days offset and an associated set of financial business centers. -data DateOffset = DateOffset - with - period : PeriodEnum - -- ^ The unit of the date offset, e.g. D means that the date offset is specified in days. - periodMultiplier : Int - -- ^ The number of days (if period is D) before or after the base date the fixing is observed. - dayType : Optional DayTypeEnum - -- ^ Indicate whether the date offset is given in Business days or Calendar days. - businessDayConvention : BusinessDayConventionEnum - -- ^ Business day convention that describes how a non-business day is adjusted. - businessCenters : [Text] - -- ^ The identifiers of the holiday calendars to be used for date adjustment (if any). - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DayCount.daml b/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DayCount.daml deleted file mode 100644 index 38007830e..000000000 --- a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/DayCount.daml +++ /dev/null @@ -1,61 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Types.Date.V3.DayCount where - --- | An enum type to specify a day count convention used to calculate day count fractions. --- For a detailed definition of each convention, we refer to the "Method of Interest Computation --- Indicator" definitions in the context of the ISO-20022 standard. Where useful, we provide --- disambiguation comments. -data DayCountConventionEnum - = Act360 - -- ^ Actual 360. - -- In CDM it is called *DayCountFractionEnum_ACT_360*. In ISO20022 it is called *A004*. - | Act365Fixed - -- ^ Actual 365 fixed. - -- In CDM it is called *DayCountFractionEnum_ACT_365_FIXED*. In ISO20022 it is called *A005*. - | Act365NL - -- ^ Actual 365NL (No Leap). - -- It excludes any leap days from the day count in each period (exclusive-inclusive). - -- In ISO20022 it is called *A014*. - | Act365L - -- ^ Actual 365L. - -- In CDM it is called *DayCountFractionEnum_ACT_365L*. In ISO20022 it is called *A009*. - | ActActAFB - -- ^ Actual Actual AFB. - -- In CDM it is called *DayCountFractionEnum_ACT_ACT_AFB*. In ISO20022 it is called *A010*. - | ActActISDA - -- ^ Actual Actual ISDA. - -- In CDM it is called *DayCountFractionEnum_ACT_ACT_ISDA*. In ISO20022 it is called *A008*. - | ActActICMA - -- ^ Actual Actual ICMA. - -- In CDM it is called *DayCountFractionEnum_ACT_ACT_ICMA* and - -- *DayCountFractionEnum_ACT_ACT_ISMA* (they are identical: - -- https://www.isda.org/2011/01/07/act-act-icma/). - -- In ISO20022 it is called *A006*. Also called ISMA in the 1998 ISDA paper. - | Basis1 - -- ^ 1/1. - -- In CDM it is called *DayCountFractionEnum__1_1*. Currently not included in ISO20022. - | Basis30360 - -- ^ 30/360. - -- In CDM it is called *DayCountFractionEnum__30_360*. In ISO20022 it is called *A001*. - -- Also called 30/360 ISDA or American Basic rule. - | Basis30365 - -- ^ 30/365. - -- In ISO20022 it is called *A002*. - | Basis30360ICMA - -- ^ 30/360 ICMA. - -- In CDM it is called *DayCountFractionEnum__30E_360*. In ISO20022 it is called *A011*. - -- Also called Basic Rule. This corresponds to "30E/360" of the 2006 ISDA definitions. - | Basis30E360 - -- ^ 30E/360. - -- In CDM it is called *DayCountFractionEnum__30E_360_ISDA*. In ISO20022 it is called *A007*. - -- Also called Eurobond basis. This corresponds to "30E360 (ISDA)" of the 2006 ISDA definitions. - | Basis30E2360 - -- ^ 30E2/360. - -- In ISO20022 it is called *A012*. Also called Eurobond basis model 2. - | Basis30E3360 - -- ^ 30E3/360. - -- Currently not included in CDM. In ISO20022 it is called *A013*. Also called Eurobond basis - -- model 3. - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/RollConvention.daml b/src/main/daml/Daml/Finance/Interface/Types/Date/V3/RollConvention.daml deleted file mode 100644 index 993810d19..000000000 --- a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/RollConvention.daml +++ /dev/null @@ -1,36 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Types.Date.V3.RollConvention where - --- | A data type to define periods. -data Period = Period - with - period : PeriodEnum - -- ^ A period, e.g., a day, week, month or year. - periodMultiplier : Int - -- ^ A period multiplier, e.g., 1, 2 or 3 etc. - deriving (Eq, Show) - --- | An enum type to specify a period, e.g., day or week. -data PeriodEnum - = D - -- ^ Day - | M - -- ^ Month - | W - -- ^ Week - | Y - -- ^ Year - deriving (Eq, Show) - --- | An enum type to specify how to roll dates. -data RollConventionEnum - = EOM - -- ^ Rolls on month end. - | DOM Int - -- ^ Rolls on the corresponding day of the month. - | NoRollConvention - -- ^ No roll convention is specified. This is for e.g. when date roll is not required (`D` or `W` - -- tenors, single-period schedules). - deriving (Eq, Show) diff --git a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Schedule.daml b/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Schedule.daml deleted file mode 100644 index 087ff82b8..000000000 --- a/src/main/daml/Daml/Finance/Interface/Types/Date/V3/Schedule.daml +++ /dev/null @@ -1,80 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Types.Date.V3.Schedule where - -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayAdjustment(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period, RollConventionEnum) - --- | An enum type to specify a stub. -data StubPeriodTypeEnum - = LongFinal - -- ^ A long (more than one period) final stub. - | LongInitial - -- ^ A long (more than one period) initial stub. - | ShortFinal - -- ^ A short (less than one period) final stub. - | ShortInitial - -- ^ A short (less than one period) initial stub. - deriving (Eq, Show) - --- | Frequency of a periodic schedule. -data Frequency = Frequency - with - period : Period - -- ^ The period (e.g., 1D, 3M, 1Y). - rollConvention : RollConventionEnum - -- ^ The roll convention. - deriving (Eq, Show) - --- | Frequency of a schedule. It can be specified as a regular frequency or --- as `SinglePeriod`. -data ScheduleFrequency - = Periodic Frequency - -- ^ Periodic frequency (e.g. 1D, 3M, 1Y). - | SinglePeriod - -- ^ Used for schedules that have exactly one regular period covering their full term - -- (from `effectiveDate` to `terminationDate`). - deriving (Eq, Show) - --- | A periodic schedule. -data PeriodicSchedule = PeriodicSchedule - with - effectiveDate : Date - -- ^ Effective date, i.e., the (unadjusted) start date of the first period. - terminationDate : Date - -- ^ Termination date, i.e., the (unadjusted) end date of the last period. - firstRegularPeriodStartDate : Optional Date - -- ^ The (unadjusted) start date of the first regular period (optional). - lastRegularPeriodEndDate : Optional Date - -- ^ The (unadjusted) end date of the last regular period (optional). - frequency : ScheduleFrequency - -- ^ The frequency of the periodic schedule. - businessDayAdjustment : BusinessDayAdjustment - -- ^ The business day adjustment to determine adjusted dates. - effectiveDateBusinessDayAdjustment : Optional BusinessDayAdjustment - -- ^ The (optional) business day adjustment of the effective date - terminationDateBusinessDayAdjustment : Optional BusinessDayAdjustment - -- ^ The (optional) business day adjustment of the termination date - stubPeriodType : Optional StubPeriodTypeEnum - -- ^ An optional stub to define a stub implicitly and not via `firstRegularPeriodStartDate` or - -- `lastRegularPeriodEndDate`. - deriving (Eq, Show) - --- | A single period in a schedule. -data SchedulePeriod = SchedulePeriod - with - adjustedEndDate : Date - -- ^ Adjusted end date. - adjustedStartDate : Date - -- ^ Adjusted start date. - unadjustedEndDate : Date - -- ^ Unadjusted end date. - unadjustedStartDate : Date - -- ^ Unadjusted start date. - stubType : Optional StubPeriodTypeEnum - -- ^ Indicates whether this period is a stub (and if so, what type of stub it is) - deriving (Eq, Show) - --- | A schedule defined by a list of periods. -type Schedule = [SchedulePeriod] diff --git a/src/main/daml/Daml/Finance/Interface/Util/V3/Common.daml b/src/main/daml/Daml/Finance/Interface/Util/V3/Common.daml deleted file mode 100644 index 89f6ace4c..000000000 --- a/src/main/daml/Daml/Finance/Interface/Util/V3/Common.daml +++ /dev/null @@ -1,20 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Interface.Util.V3.Common where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey, InstrumentQuantity, Quantity(..)) - --- | Verify is assertMsg with its arguments flipped. -verify : CanAssert m => Bool -> Text -> m () -verify = flip assertMsg - --- | Wraps an amount and an instrument key into an instrument quantity. -qty : Decimal -> InstrumentKey -> InstrumentQuantity -qty amount instrument = Quantity with unit = instrument; amount - --- | Scale `quantity` by the provided factor. -scale : Decimal -> InstrumentQuantity -> InstrumentQuantity -scale factor quantity = quantity with amount = quantity.amount * factor diff --git a/src/main/daml/Daml/Finance/Interface/Util/V3/Disclosure.daml b/src/main/daml/Daml/Finance/Interface/Util/V3/Disclosure.daml deleted file mode 100644 index 320a27121..000000000 --- a/src/main/daml/Daml/Finance/Interface/Util/V3/Disclosure.daml +++ /dev/null @@ -1,118 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Util.V3.Disclosure where - -import DA.Map (values) -import Daml.Finance.Interface.Types.Common.V3.Types (Parties, PartiesMap) - --- | Type synonym for `Disclosure`. -type I = Disclosure - --- | Type synonym for `View`. -type V = View - --- | View for `Disclosure`. -data View = View - with - disclosureControllers : Parties - -- ^ Disjunction choice controllers. - observers : PartiesMap - -- ^ Observers with context. - -- The parties are mapped by a specific key. - -- The textual key is the "observation context" of the disclosure. - -- This allows processes to add/remove parties for their specific purpose, without affecting - -- others. - deriving (Eq, Show) - --- | An interface for managing the visibility of contracts for non-authorizing parties. -interface Disclosure where - viewtype V - - setObservers : SetObservers -> Update (ContractId Disclosure) - -- ^ Implementation of the `SetObservers` choice. - addObservers : AddObservers -> Update (ContractId Disclosure) - -- ^ Implementation of the `AddObservers` choice. - removeObservers : ContractId Disclosure -> RemoveObservers -> Update (Optional ( - ContractId Disclosure)) - -- ^ Implementation of the `RemoveObservers` choice. - - nonconsuming choice GetView : View - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - choice SetObservers : ContractId Disclosure - -- ^ Set the observers for a contract. - with - disclosers : Parties - -- ^ Party calling this choice. - newObservers : PartiesMap - -- ^ Observers to set for this contract. This overrides the existing observers. - -- The parties are mapped by a specific key. - -- The textual key is the "observation context" of the disclosure. - -- This allows processes to add/remove parties for their specific purpose, without affecting - -- others. - controller disclosers - do - setObservers this arg - - choice AddObservers : ContractId Disclosure - -- ^ Add a single new observer context to the existing observers. - with - disclosers : Parties - -- ^ Party calling this choice. - observersToAdd : (Text, Parties) - -- ^ Parties to add as observers to the contract and the corresponding observer context. - -- If the observer context already exists, the new set of parties is added to the old one. - controller disclosers - do - addObservers this arg - - nonconsuming choice RemoveObservers : Optional (ContractId Disclosure) - -- ^ Remove observers from a context. - -- None is returned if no update is needed. Parties for a context can be removed if any - -- of the disclosers are part of the observers to be removed or the disclosureControllers. - with - disclosers : Parties - -- ^ Parties calling this choice. - observersToRemove : (Text, Parties) - -- ^ Parties to be removed from the contract observers and the corresponding observer - -- context. - controller disclosers - do - removeObservers this self arg - --- | Flattens observers which use the `PartiesMap` into a `Set Party` for usage in template --- definitions. For example: --- ``` --- observer $ flattenObservers observers --- ``` -flattenObservers : PartiesMap -> Parties -flattenObservers = mconcat . values - --- | Disclosure helpers (reuse existing logic). -disclose : - ( HasInterfaceTypeRep i - , HasToInterface i I - , HasFromInterface i I - ) - => (Text, Parties) -> Parties -> ContractId i -> Update (ContractId i) -disclose observersToAdd disclosers cid = fromInterfaceContractId <$> - exercise (toInterfaceContractId @I cid) AddObservers with - disclosers; observersToAdd - -undisclose : - ( HasInterfaceTypeRep i - , HasToInterface i I - , HasFromInterface i I - ) - => (Text, Parties) -> Parties -> ContractId i -> Update (Optional (ContractId i)) -undisclose observersToRemove disclosers cid = fmap fromInterfaceContractId <$> - exercise (toInterfaceContractId @I cid) RemoveObservers with - disclosers; observersToRemove - diff --git a/src/main/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml b/src/main/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml deleted file mode 100644 index 7937d9bd1..000000000 --- a/src/main/daml/Daml/Finance/Interface/Util/V3/HoldingSplice.daml +++ /dev/null @@ -1,46 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Util.V3.HoldingSplice where - -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 -import DA.TextMap qualified as TextMap -import DA.Optional (fromOptional) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..), Id(..), HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure () - --- | Convert a text back to a Party. Inverse of partyToText. -textToParty : Text -> Party -textToParty t = case partyFromText t of - Some p -> p - None -> error ("Invalid Party text: " <> t) - --- | Parse HoldingStandard from its textual form. -parseHoldingStandard : Text -> HoldingStandard -parseHoldingStandard t = - case t of - "TransferableFungible" -> TransferableFungible - "Transferable" -> Transferable - "Fungible" -> Fungible - "BaseHolding" -> BaseHolding - s -> error ("Unknown HoldingStandard: " <> s) - - --- | Extract the `InstrumentKey` from a Holding, provided the appropriate metadata are populated. -getInstrument : Api.HoldingV1.Holding -> InstrumentKey -getInstrument holding = - let - holdingView = view holding - instrId = holdingView.instrumentId - metaVals = holdingView.meta.values - lookup k = fromOptional ("Missing metadata: " <> k) (TextMap.lookup k metaVals) - in InstrumentKey with - issuer = instrId.admin - depository = textToParty (lookup "depository") - id = Id instrId.id - version = lookup "version" - holdingStandard = parseHoldingStandard (lookup "holdingStandard") - --- | Extract the current token amount. -getAmount : Api.HoldingV1.Holding -> Decimal -getAmount = (.amount) . view diff --git a/src/main/daml/Daml/Finance/Interface/Util/V3/InterfaceKey.daml b/src/main/daml/Daml/Finance/Interface/Util/V3/InterfaceKey.daml deleted file mode 100644 index 8c5c22168..000000000 --- a/src/main/daml/Daml/Finance/Interface/Util/V3/InterfaceKey.daml +++ /dev/null @@ -1,97 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Interface.Util.V3.InterfaceKey where - -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (GetView(..), I) - --- | Fetch an interface by key. -fetchInterfaceByKey : forall ref i2 k i1. - ( HasInterfaceTypeRep i1 - , HasInterfaceTypeRep i2 - , HasFetchByKey ref k - , HasField "cid" ref (ContractId i1) - , HasFetch i2 - ) - => k -> Update i2 -fetchInterfaceByKey k = do - d <- snd <$> fetchByKey @ref k - fetch $ coerceInterfaceContractId @i2 d.cid - --- | HIDE --- Type class used for interface keys. -class - ( HasInterfaceTypeRep i - , HasCreate ref - , HasExerciseByKey ref k c1 (ContractId i) - , HasExerciseByKey ref k c2 (ContractId ref) - , HasExerciseByKey ref k c3 (ContractId ref) - , HasExercise i c4 v - , HasInterfaceView i v - , HasKey ref k - ) - => - HasInterfaceKey - i -- Type of the keyed interface. - v -- View associated with the interface i. - k -- Key type used for the interface i. - ref -- Template that holds reference information. - c1 -- Choice on the reference template to retrieve the interface instance. - c2 -- Choice on the reference template to set the interface instance. - c3 -- Choice on the reference template to set observers. - c4 -- Choice on the interface to get a view. - where - createReference : v -> ContractId i -> PartiesMap -> ref - getCid : Party -> c1 - setCid : ContractId i -> c2 - setObservers : PartiesMap -> c3 - getView : Party -> c4 - --- | HIDE --- Helper function for exercising an interface by key. -exerciseInterfaceByKeyHelper : forall ref c1 c2 c3 c4 it ct rt i v k. - ( HasInterfaceKey i v k ref c1 c2 c3 c4 - , HasInterfaceTypeRep it - , HasExercise it ct rt - ) - => k -- ^ The key. - -> Party -- ^ The actor exercising the choice by key. - -> ct -- ^ The choice arguments. - -> Update rt -exerciseInterfaceByKeyHelper k actor arg = do - cid <- exerciseByKey @ref k $ getCid @i @v @k @ref @c1 @c2 @c3 @c4 actor - exercise (coerceInterfaceContractId @it cid) arg - --- | HIDE --- Helper function for creating a reference for an interface. -createReferenceHelper : forall ref c1 c2 c3 c4 i v k. - ( HasInterfaceKey i v k ref c1 c2 c3 c4 - , HasToInterface i Disclosure.I - ) - => Party - -> ContractId i - -> Update (ContractId ref) -createReferenceHelper actor cid = do - view <- exercise cid $ getView @i @v @k @ref @c1 @c2 @c3 @c4 actor - disclosureView <- exercise - (toInterfaceContractId @Disclosure.I cid) - Disclosure.GetView with viewer = actor - create $ createReference @i @v @k @ref @c1 @c2 @c3 @c4 view cid disclosureView.observers - --- | HIDE --- Helper function for updating the reference once observers are added to the referred to instance. -disclosureUpdateReferenceHelper : forall ref c1 c2 c3 c4 i v k. - ( HasInterfaceKey i v k ref c1 c2 c3 c4 - , HasToInterface i Disclosure.I - ) - => k - -> PartiesMap - -> ContractId i - -> Update (ContractId Disclosure.I) -disclosureUpdateReferenceHelper k newObservers iCid = do - exerciseByKey @ref k $ setCid @i @v @k @ref @c1 @c2 @c3 @c4 iCid - exerciseByKey @ref k $ setObservers @i @v @k @ref @c1 @c2 @c3 @c4 newObservers - pure $ toInterfaceContractId iCid diff --git a/src/main/daml/Daml/Finance/Interface/Util/V3/Lockable.daml b/src/main/daml/Daml/Finance/Interface/Util/V3/Lockable.daml deleted file mode 100644 index 074f162bf..000000000 --- a/src/main/daml/Daml/Finance/Interface/Util/V3/Lockable.daml +++ /dev/null @@ -1,94 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Interface.Util.V3.Lockable where - -import DA.Optional (isNone) -import DA.Set (Set) -import Daml.Finance.Interface.Types.Common.V3.Types (Parties) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure -import Splice.Api.Token.HoldingV1 () - --- | Type synonym for `Lockable`. -type I = Lockable - --- | Type synonym for `View`. -type V = View - --- | Type of lock held. -data LockType - = Semaphore - -- ^ A one time only lock. - | Reentrant - -- ^ A mutual exclusion lock where the same lockers may lock a contract multiple times. - deriving (Eq, Show) - --- | Locking details. -data Lock = Lock - with - lockers : Parties - -- ^ Parties which are locking the contract. - context : Set Text - -- ^ Context of the lock, explaining why this lock is held by the locking parties. If the lock - -- is reentrant, there may be more than one locking context for the set of lockers. - lockType : LockType - -- ^ The type of lock applied. - deriving (Eq, Show) - --- | View for `Lockable`. -data View = View - with - lock : Optional Lock - -- ^ An optional lock, indicating if it is locked or not. - controllers : Parties - -- ^ All parties whose authorization is required to acquire a lock. - deriving (Eq, Show) - --- | Lockable interface, layered on top of Splice Holding. --- This allows tests that used to lock Daml.Finance holdings --- to still work against Splice holdings. -interface Lockable requires Disclosure.I where - viewtype V - - acquire : Acquire -> Update (ContractId Lockable) - -- ^ Implementation of the `Acquire` choice. - release : Release -> Update (ContractId Lockable) - -- ^ Implementation of the `Release` choice. - - nonconsuming choice GetView : V - -- ^ Retrieves the interface view. - with - viewer : Party - -- ^ The party retrieving the view. - controller viewer - do - pure $ view this - - choice Acquire : ContractId Lockable - -- ^ Lock a contract. - with - newLockers : Parties - -- ^ Parties which restrain the contract's ability to perform specified actions. - context : Text - -- ^ Reason for acquiring a lock. - lockType : LockType - -- ^ Type of lock to acquire. - controller (view this).controllers, newLockers - do - acquire this arg - - choice Release : ContractId Lockable - -- ^ Unlock a locked contract. - with - context : Text - controller getLockers this - do - release this arg - --- | Retrieves the lockers of a `Lockable`. -getLockers : HasToInterface t Lockable => t -> Parties -getLockers lockable = optional mempty (.lockers) (view $ toInterface @Lockable lockable).lock - --- | Asserts that a lockable is not locked. -mustNotBeLocked : (HasToInterface i Lockable) => i -> Update () -mustNotBeLocked = assertMsg "Must not be locked" . isNone . (.lock) . view . toInterface @Lockable diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Effect.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Effect.daml deleted file mode 100644 index 3488ca217..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Effect.daml +++ /dev/null @@ -1,72 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Effect where - -import DA.Assert ((===)) -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (Calculate(..), CalculationResult(..), I, SetProviders(..), View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey, InstrumentQuantity(..), Parties, PartiesMap) -import Daml.Finance.Interface.Util.V3.Common (qty, scale) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Effect`. -type T = Effect - --- | A contract encoding the consequences of a lifecycle event for one unit of the target --- instrument. -template Effect - with - providers : Parties - -- ^ The effect provider. - id : Id - -- ^ The effect's identifier. - description : Text - -- ^ The effect's description. - targetInstrument : InstrumentKey - -- ^ The target instrument. A holding on this instrument is required to claim the effect. - -- For example, in the case of a swap instrument, this would be the original instrument - -- version before lifecycling, that contains the current swap payment. - producedInstrument : Optional InstrumentKey - -- ^ The produced instrument, if it exists. - -- For example, in the case of a swap instrument, this would be the new instrument - -- version after lifecycling, that does not contain the current swap payment. - -- If there are no more claims remaining after the current lifecycling, this would be None. - otherConsumed : [InstrumentQuantity] - -- ^ Consumed quantities (in addition to the target instrument). - -- For example, in the case of a fix vs floating rate swap, this could be a 2.5% fix - -- payment. - otherProduced : [InstrumentQuantity] - -- ^ Produced quantities (in additon to the produced instrument). - -- For example, in the case of a fix vs floating rate swap, this could be a 3M Euribor - -- floating payment. - settlementTime : Optional Time - -- ^ The effect's settlement time (if any). - observers : PartiesMap - -- ^ Observers. - where - signatory providers - observer Disclosure.flattenObservers observers - - interface instance Effect.I for Effect where - view = Effect.View with - providers; id; description; targetInstrument; producedInstrument; otherConsumed - otherProduced; settlementTime - - calculate Effect.Calculate{quantity} _ = do - quantity.unit === targetInstrument - let scaleAll = fmap . scale $ quantity.amount - pure Effect.CalculationResult with - consumed = scaleAll $ qty 1.0 targetInstrument :: otherConsumed - produced = scaleAll $ case producedInstrument of - Some pi -> qty 1.0 pi :: otherProduced - None -> otherProduced - - setProviders Effect.SetProviders{newProviders} = - toInterfaceContractId <$> create this with providers = newProviders - - interface instance Disclosure.I for Effect where - view = Disclosure.View with disclosureControllers = providers; observers - setObservers = setObserversImpl @Effect @Disclosure.I this None - addObservers = addObserversImpl @Effect @Disclosure.I this None - removeObservers = removeObserversImpl @Effect @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Election.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Election.daml deleted file mode 100644 index 99e86b89c..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Election.daml +++ /dev/null @@ -1,95 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Election where - -import DA.Set (singleton) -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (Apply(..), ApplyElection(..), I, View(..)) -import Daml.Finance.Interface.Lifecycle.V4.Election.Factory qualified as ElectionFactory (Create(..), I, View(..)) -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), InstrumentKey, PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Election`. -type T = Election - --- | An election, such as the exercise of an option. -template Election - with - elector : Party - -- ^ Entity making the election. - counterparty : Party - -- ^ Faces the `elector` in the `Holding`. - provider : Party - -- ^ The provider of the election is an entity that has the authority to process the election - -- and create a new instrument version. - id : Id - -- ^ Election identifier. - description : Text - -- ^ A human readable description of the election. - instrument : InstrumentKey - -- ^ The instrument to which the election applies. - amount : Decimal - -- ^ Number of units of instrument to which the election applies. - claim : Text - -- ^ The tag corresponding to the elected sub-tree. - electorIsOwner : Bool - -- ^ `True` if the elector is the owner of a claim, `False` otherwise. - electionTime : Time - -- ^ Time at which the election is put forward. - observers : PartiesMap - -- ^ A set of observers. - where - signatory elector, provider - observer Disclosure.flattenObservers observers - - interface instance Election.I for Election where - view = Election.View with - id; description; amount; elector; counterparty; electorIsOwner; observers; provider - instrument; claim - apply self Election.Apply{observableCids; exercisableCid} = do - let v = view $ toInterface @Election.I this - (newInstrument, effects) <- exercise exercisableCid Election.ApplyElection with - observableCids - electionCid = toInterfaceContractId self - archive self -- this is needed as we can't write postconsuming choices on interfaces - pure (newInstrument, effects) - - interface instance Disclosure.I for Election where - view = Disclosure.View with disclosureControllers = singleton elector; observers - setObservers = setObserversImpl @Election @Disclosure.I this None - addObservers = addObserversImpl @Election @Disclosure.I this None - removeObservers = removeObserversImpl @Election @Disclosure.I this None - - interface instance Event.I for Election where - view = Event.View with - providers = singleton provider - id - description - eventTime = electionTime - --- | Factory template to create an `Election`. -template Factory - with - provider : Party - -- ^ The provider of the `Factory`. - observers : PartiesMap - -- ^ A set of observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance ElectionFactory.I for Factory where - view = ElectionFactory.View with provider - create' ElectionFactory.Create{id; description; claim; elector; counterparty; electorIsOwner; - electionTime; observers; amount; provider; instrument} = - toInterfaceContractId <$> create Election with - id; description; claim; elector; counterparty; electorIsOwner; electionTime - observers; amount; provider; instrument - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/ElectionEffect.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/ElectionEffect.daml deleted file mode 100644 index 798158b21..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/ElectionEffect.daml +++ /dev/null @@ -1,79 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.ElectionEffect where - -import DA.Assert ((===)) -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (Calculate(..), CalculationResult(..), I, SetProviders(..), View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey, InstrumentQuantity, Parties, PartiesMap) -import Daml.Finance.Interface.Util.V3.Common (qty, scale) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `ElectionEffect`. -type T = ElectionEffect - --- | A contract encoding the consequences of an election for one unit of the target instrument. --- It needs to be claimed with the right amount and is consumed after claiming. -template ElectionEffect - with - providers : Parties - -- ^ The effect provider. - custodian : Party - -- ^ The custodian of the holding put forward for election. - owner : Party - -- ^ The owner of the holding put forward for election. - id : Id - -- ^ The effect's identifier. - description : Text - -- ^ The effect's description. - targetInstrument : InstrumentKey - -- ^ The target instrument. - producedInstrument : Optional InstrumentKey - -- ^ The produced instrument, when it exists. - amount : Decimal - -- ^ The elected amount. - otherConsumed : [InstrumentQuantity] - -- ^ Consumed quantities (not including the target instrument). - otherProduced : [InstrumentQuantity] - -- ^ Produced quantities (not including the produced instrument). - settlementTime : Optional Time - -- ^ The effect's settlement time (if any). - observers : PartiesMap - -- ^ Observers. - where - signatory providers - observer Disclosure.flattenObservers observers - - interface instance Effect.I for ElectionEffect where - view = Effect.View with - providers - id - description - targetInstrument - producedInstrument - otherConsumed - otherProduced - settlementTime - - calculate Effect.Calculate{actor; quantity} self = do - quantity.unit === targetInstrument - assertMsg "Amount must match the elected amounts" $ amount == quantity.amount - assertMsg "Election effects can only be calculated by the elector or their counterparty" $ - actor == owner || actor == custodian - archive self - let scaleAll = fmap $ scale amount - pure Effect.CalculationResult with - consumed = scaleAll $ qty 1.0 targetInstrument :: otherConsumed - produced = scaleAll $ case producedInstrument of - Some pi -> qty 1.0 pi :: otherProduced - None -> otherProduced - - setProviders Effect.SetProviders{newProviders} = - toInterfaceContractId <$> create this with providers = newProviders - - interface instance Disclosure.I for ElectionEffect where - view = Disclosure.View with disclosureControllers = providers; observers - setObservers = setObserversImpl @ElectionEffect @Disclosure.I this None - addObservers = addObserversImpl @ElectionEffect @Disclosure.I this None - removeObservers = removeObserversImpl @ElectionEffect @Disclosure.I this None diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Distribution.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Distribution.daml deleted file mode 100644 index c4ceed051..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Distribution.daml +++ /dev/null @@ -1,46 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Event.Distribution where - -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I, View(..)) -import Daml.Finance.Interface.Lifecycle.V4.Event.Distribution qualified as Distribution (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey, InstrumentQuantity, Parties) - --- | Type synonym for `Event`. -type T = Event - --- | Event contract for the distribution of units of an instrument for each unit of a target --- instrument (e.g. share or cash dividends). -template Event - with - providers : Parties - -- ^ Providers of the distribution event. - id : Id - -- ^ Event Identifier. - description : Text - -- ^ Event description. - effectiveTime : Time - -- ^ Time on which the distribution is effectuated. - targetInstrument : InstrumentKey - -- ^ Instrument the distribution event applies to. - newInstrument : InstrumentKey - -- ^ Instrument after the distribution has been claimed. - perUnitDistribution : [InstrumentQuantity] - -- ^ Distributed quantities per unit held. - observers : Parties - -- ^ Observers. - where - signatory providers - observer observers - - ensure targetInstrument.depository == newInstrument.depository - && targetInstrument.issuer == newInstrument.issuer - && targetInstrument.id == newInstrument.id - - interface instance Event.I for Event where - view = Event.View with providers; id; description; eventTime = effectiveTime - - interface instance Distribution.I for Event where - view = Distribution.View with - effectiveTime; targetInstrument; newInstrument; perUnitDistribution diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Replacement.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Replacement.daml deleted file mode 100644 index c1da6ab9e..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Event/Replacement.daml +++ /dev/null @@ -1,39 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Event.Replacement where - -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I, View(..)) -import Daml.Finance.Interface.Lifecycle.V4.Event.Replacement qualified as Replacement (I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, InstrumentKey, InstrumentQuantity, Parties) - --- | Type synonym for `Event`. -type T = Event - --- | Event contract for the replacement of units of an instrument with a basket of other --- instruments, e.g., a stock merger. -template Event - with - providers : Parties - -- ^ Providers of the distribution event. - id : Id - -- ^ Event identifier. - description : Text - -- ^ Event description. - effectiveTime : Time - -- ^ Time on which the replacement is effectuated. - targetInstrument : InstrumentKey - -- ^ Instrument the replacement event applies to. - perUnitReplacement : [InstrumentQuantity] - -- ^ Instrument quantities the target instrument is replaced with. - observers : Parties - -- ^ Observers. - where - signatory providers - observer observers - - interface instance Event.I for Event where - view = Event.View with providers; id; description; eventTime = effectiveTime - - interface instance Replacement.I for Event where - view = Replacement.View with effectiveTime; targetInstrument; perUnitReplacement \ No newline at end of file diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Claim.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Claim.daml deleted file mode 100644 index 5f5b3a54a..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Claim.daml +++ /dev/null @@ -1,106 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Rule.Claim where - -import DA.Set (member, singleton) -import Daml.Finance.Interface.Account.V4.Util (getCustodian, getOwner) -import Daml.Finance.Interface.Util.V3.HoldingSplice (getAmount, getInstrument) -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (Calculate(..), CalculationResult(..), GetView(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), ClaimResult(..), I, View(..)) -import Daml.Finance.Interface.Settlement.V4.Factory qualified as SettlementFactory (I, Instruct(..)) -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (Discover(..), I) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Quantity(..), Step(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Parties, Quantity(..)) -import Daml.Finance.Lifecycle.V4.Rule.Util -import Daml.Finance.Settlement.V4.Conversion (fromInstrumentKey) - - --- | Type synonym for `Rule`. -type T = Rule - --- | Rule contract that allows an actor to claim effects, returning settlement instructions. -template Rule - with - provider : Party - -- ^ Provider of the claim rule. Together with the actors of the `ClaimEffect` choice the - -- authorization requirements to upgrade the holdings being claimed have to be met. - claimers : Parties - -- ^ Any of the parties can claim an effect. - settlers : Parties - -- ^ Any of the parties can trigger settlement of the resulting batch. - routeProviderCid : ContractId RouteProvider.I - -- ^ RouteProvider used to discover settlement routes. - settlementFactoryCid : ContractId SettlementFactory.I - -- ^ Settlement factory contract used to create a `Batch` of `Instruction`\s. - netInstructions : Bool - -- ^ Configure whether netting should be enabled for quantities having the same (instrument, - -- sender, receiver). - where - signatory provider - observer claimers - - interface instance Claim.I for Rule where - view = Claim.View with - providers = singleton provider; claimers; settlers; routeProviderCid; settlementFactoryCid - claimEffect Claim.ClaimEffect{claimer; holdingCids; effectCid; batchId} = do - assertMsg "Effect can only be claimed by authorized parties." $ - claimer `member` this.claimers - effectView <- exercise effectCid Effect.GetView with viewer = claimer - holdings <- mapA fetch holdingCids - - -- Calculate settlement steps - let - createSteps consume quantities holding = - let - owner = getOwner holding - custodian = getCustodian holding - sender = if consume then owner else custodian - receiver = if consume then custodian else owner - in map (\quantity -> SettlementTypes.Step with sender; receiver; quantity) quantities - - calculateSteps holding = do - Effect.CalculationResult{consumed; produced} <- - exercise effectCid Effect.Calculate with - actor = claimer - quantity = Quantity with - unit = getInstrument holding - amount = getAmount holding - let - (consumedNetted, producedNetted) = - if netInstructions - then splitPending . net $ mergeConsumedAndProduced consumed produced - else (consumed, produced) - - -- Convert each legacy InstrumentQuantity (InstrumentKey) to new Quantity (InstrumentId) - toNewQuantity (Quantity with unit; amount) = - SettlementTypes.Quantity with - unit = fromInstrumentKey unit - amount - - consumedNew = map toNewQuantity consumedNetted - producedNew = map toNewQuantity producedNetted - - consumedSteps = createSteps True consumedNew holding - producedSteps = createSteps False producedNew holding - pure $ consumedSteps <> producedSteps - - -- Settlement steps - steps <- mconcat <$> mapA calculateSteps holdings - - -- Discover settlement routes - routedSteps <- exercise routeProviderCid RouteProvider.Discover with - discoverors = singleton provider; contextId = None; steps - - -- Generate settlement instructions for other instruments - (batchCid, instructionCids) <- exercise settlementFactoryCid SettlementFactory.Instruct with - instructor = provider - consenters = mempty - settlers - id = batchId - description = effectView.description - contextId = Some effectView.id - routedSteps - settlementTime = effectView.settlementTime - - pure Claim.ClaimResult with batchCid; instructionCids diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Distribution.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Distribution.daml deleted file mode 100644 index 241369d32..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Distribution.daml +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Rule.Distribution where - -import DA.Map (fromList) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (GetView(..), I, exerciseInterfaceByKey) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), Parties) -import Daml.Finance.Lifecycle.V4.Effect (Effect(..)) -import Daml.Finance.Lifecycle.V4.Event.Distribution qualified as Distribution (Event) - --- | Type synonym for `Rule`. -type T = Rule - --- | Rule contract that defines the distribution of units of an instrument for each unit of a target --- instrument (e.g. share or cash dividends). -template Rule - with - providers : Parties - -- ^ Providers of the distribution rule. - lifecycler : Party - -- ^ Party performing the lifecycling. - observers : Parties - -- ^ Observers of the distribution rule. - id : Id - -- ^ Identifier for the rule contract. - description : Text - -- ^ Textual description. - where - signatory providers - observer observers, lifecycler - - interface instance Lifecycle.I for Rule where - view = Lifecycle.View with lifecycler; id; description - evolve Lifecycle.Evolve{eventCid; instrument} = do - distribution <- fetch $ fromInterfaceContractId @Distribution.Event eventCid - assertMsg "The input instrument must match the distribution's target instrument" $ - instrument == distribution.targetInstrument - - -- Check that the targetInstrument as well as the producedInstrument are both active - let - checkActive instrument = BaseInstrument.exerciseInterfaceByKey @BaseInstrument.I - instrument lifecycler BaseInstrument.GetView with viewer = lifecycler - checkActive distribution.targetInstrument - checkActive distribution.newInstrument - - effectCid <- toInterfaceContractId <$> - create Effect with - providers - id = distribution.id - description = distribution.description - targetInstrument = distribution.targetInstrument - producedInstrument = Some distribution.newInstrument - otherConsumed = [] - otherProduced = distribution.perUnitDistribution - settlementTime = Some distribution.effectiveTime - observers = fromList [("RuleObservers", observers)] - pure (Some distribution.newInstrument, [effectCid]) diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Replacement.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Replacement.daml deleted file mode 100644 index faacdc337..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Replacement.daml +++ /dev/null @@ -1,56 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Rule.Replacement where - -import DA.Map (fromList) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (GetView(..), I, exerciseInterfaceByKey) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), Parties) -import Daml.Finance.Lifecycle.V4.Effect (Effect(..)) -import Daml.Finance.Lifecycle.V4.Event.Replacement qualified as Replacement (Event) - --- | Type synonym for `Rule`. -type T = Rule - --- | Rule contract that defines the replacement of units of an instrument with a basket of other --- instruments (e.g. stock merger). -template Rule - with - providers : Parties - -- ^ Providers of the replacement rule. - lifecycler : Party - -- ^ Party performing the lifecycling. - observers : Parties - -- ^ Observers. - id : Id - -- ^ Identifier for the rule contract. - description : Text - -- ^ Textual description. - where - signatory providers - observer observers, lifecycler - - interface instance Lifecycle.I for Rule where - view = Lifecycle.View with lifecycler; id; description - evolve Lifecycle.Evolve{eventCid; instrument} = do - replacement <- fetch $ fromInterfaceContractId @Replacement.Event eventCid - assertMsg "The input instrument must match the replacement's target instrument" - $ instrument == replacement.targetInstrument - - -- Check that the targetInstrument is active - BaseInstrument.exerciseInterfaceByKey @BaseInstrument.I replacement.targetInstrument - lifecycler BaseInstrument.GetView with viewer = lifecycler - - effectCid <- toInterfaceContractId <$> - create Effect with - providers = replacement.providers - id = replacement.id - description = replacement.description - targetInstrument = replacement.targetInstrument - producedInstrument = None - otherConsumed = [] - otherProduced = replacement.perUnitReplacement - settlementTime = Some replacement.effectiveTime - observers = fromList [("RuleObservers", observers)] - pure (None, [effectCid]) diff --git a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Util.daml b/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Util.daml deleted file mode 100644 index f76e1d587..000000000 --- a/src/main/daml/Daml/Finance/Lifecycle/V4/Rule/Util.daml +++ /dev/null @@ -1,47 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Lifecycle.V4.Rule.Util where - -import DA.Either (partitionEithers) -import DA.List (head) -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey, InstrumentQuantity) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Util.V4.Common (sortAndGroupOn) - --- | Type used to record pending payments. -data Pending = Pending - with - instrument : InstrumentKey - amount : Decimal - deriving (Eq, Show) - --- | Merge consumed and produced instruments into a list of pending settlements. --- This will only reproduce instrument and quantity, not tag or time. -mergeConsumedAndProduced : [InstrumentQuantity] -> [InstrumentQuantity] -> [Pending] -mergeConsumedAndProduced consumed produced = pendingConsumed ++ pendingProduced where - pendingConsumed = map (\q -> Pending with instrument = q.unit, amount = -1.0 * q.amount) consumed - pendingProduced = map (\q -> Pending with instrument = q.unit, amount = q.amount) produced - --- | Map pending settlements into corresponding instrument quantities and split them into consumed --- and produced. Pending items with an amount of `0.0` are discarded. -splitPending : [Pending] -> ([InstrumentQuantity], [InstrumentQuantity]) -splitPending = partitionEithers . foldr f [] where - f p acc | p.amount < 0.0 = Left (qty (- 1.0 * p.amount) p.instrument) :: acc - f p acc | p.amount > 0.0 = Right (qty p.amount p.instrument) :: acc - f _ acc = acc - --- | Net pending payments on the same instrument (regardless of tags). -net : [Pending] -> [Pending] -net pending = - let - groupedPending = sortAndGroupOn (.instrument) pending - createPendingNode p = - let - aggregatedAmount = foldl (\acc e -> acc + e.amount) 0.0 p - in - Pending with - instrument = (.instrument) $ head p - amount = aggregatedAmount - in - map createPendingNode groupedPending diff --git a/src/main/daml/Daml/Finance/Settlement/V4/Batch.daml b/src/main/daml/Daml/Finance/Settlement/V4/Batch.daml deleted file mode 100644 index 54d012b8b..000000000 --- a/src/main/daml/Daml/Finance/Settlement/V4/Batch.daml +++ /dev/null @@ -1,140 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.V4.Batch where - -import DA.Action (foldlA) -import DA.Map qualified as Map (fromList, lookup) -import DA.Optional (catOptionals, fromSomeNote) -import DA.Set (Set) -import DA.Set qualified as Set (insert, intersection, member, null, singleton) -import Daml.Finance.Interface.Util.V3.HoldingSplice () -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Cancel(..), I, Settle(..), View(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Cancel(..), Execute(..), I) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..), InstructionKey(..), RoutedStep(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), Parties) -import Daml.Finance.Settlement.V4.Instruction (Instruction(..), mustAuthorizeHelper) - --- | Type synonym for `Batch`. -type T = Batch - --- | Allows you to atomically settle a set of settlement `Step`. -template Batch - with - instructor : Party - -- ^ Party instructing settlement (and the creation of the `Batch`). - consenters : Parties - -- ^ Parties consenting with the creation of the `Batch`. - settlers : Parties - -- ^ Any of the parties can trigger the settlement. - id : Id - -- ^ Batch identifier. - description : Text - -- ^ Batch description. - contextId : Optional Id - -- ^ Identifier to link a batch to a context (e.g. the `Effect` it originated from). - routedStepsWithInstructionId : [(RoutedStep, Id)] - -- ^ The settlement `RoutedStep`\s and the identifiers of the corresponding `Instruction`\s. - settlementTime : Optional Time - -- ^ Settlement time (if any). - where - signatory instructor, consenters - observer settlers - -- Enforce uniqueness of (instructor, id) - key (instructor, id) : (Party, Id) - maintainer key._1 - - interface instance Batch.I for Batch where - view = Batch.View with - instructor; consenters; settlers; id; description; contextId - routedSteps = routedSteps this.routedStepsWithInstructionId; settlementTime - settle Batch.Settle{actors} = do - assertMsg "Actors must intersect with settlers." $ - not $ Set.null $ actors `Set.intersection` settlers - -- order instructions (such that they can be executed with passthroughs) - orderedInstructions <- - orderPassThroughChains . fmap (fmap (buildKey this)) $ routedStepsWithInstructionId - assertMsg "Ordering must be complete." $ - length orderedInstructions == length routedStepsWithInstructionId - -- settle - let - settleInstruction instructionKey = do - let context = show instructionKey - -- execute instruction and get used holding standards for the instrument - (instructionCid, instruction) <- fetchByKey @Instruction instructionKey - settledCid <- exercise (toInterfaceContractId @Instruction.I instructionCid) - Instruction.Execute with actors = actors <> Set.singleton instructor <> consenters - --join <$> T.mapA (undisclose (context, settlers) actors) settledCid - pure settledCid - -- execute instructions - orderedSettledCids <- mapA settleInstruction orderedInstructions - -- order returned settledCids according to the initial order of the instructions - let - orderedInstructionIdsAndSettleCids = - zip ((.id) <$> orderedInstructions) orderedSettledCids - settledCids = fromSomeNote "All keys must exist in the map." . - (`Map.lookup` (Map.fromList orderedInstructionIdsAndSettleCids)) <$> - instructionIds this.routedStepsWithInstructionId - pure $ catOptionals settledCids - cancel Batch.Cancel{actors} = do - let - allMustAuthorize = mustAuthorizeHelper True actors - cancelInstruction instruction = do - instructionCid <- fst <$> fetchByKey @Instruction instruction - exercise (toInterfaceContractId @Instruction.I instructionCid) - Instruction.Cancel with actors - allMustAuthorize $ Set.singleton instructor <> consenters - -- cancel instructions - catOptionals <$> mapA (cancelInstruction . buildKey this . snd) routedStepsWithInstructionId - --- | HIDE -routedSteps : [(RoutedStep, Id)] -> [RoutedStep] -routedSteps = fmap fst - --- | HIDE -instructionIds : [(RoutedStep, Id)] -> [Id] -instructionIds = fmap snd - --- | HIDE -buildKey : Batch -> Id -> InstructionKey -buildKey Batch {instructor; id} instructionId = - InstructionKey with instructor; batchId = id; id = instructionId - --- | HIDE --- Partially order instructions, so that pass-through chains can be executed in order. -orderPassThroughChains : [(RoutedStep, InstructionKey)] -> Update [InstructionKey] -orderPassThroughChains routedStepsWithInstructions = - reverse . fst <$> foldlA - (\(ordered, used) (routedStep, current) -> - if Set.member current used - then - -- instruction has already been visited, do not re-insert in list - pure (ordered, used) - else do - currentInstruction <- snd <$> fetchByKey @Instruction current - assertMsg "Routed step must match." $ routedStep == currentInstruction.routedStep - let - ordered' = current :: ordered - used' = Set.insert current used - case currentInstruction.allocation of - -- a Pledge might be the start of a pass-through chain, try to follow the chain - Pledge _ -> collectPassThroughChain ordered' used' currentInstruction - -- A PassThroughFrom will be visited as part of a chain, do not insert in list - PassThroughFrom _ -> pure (ordered, used) - _ -> pure (ordered', used') - ) ([], mempty) routedStepsWithInstructions - --- | HIDE --- Follows the pass-through chain and collects the corresponding instructions in an ordered list. -collectPassThroughChain : [InstructionKey] -> Set InstructionKey -> Instruction -> - Update ([InstructionKey], Set InstructionKey) -collectPassThroughChain - ordered -- i.e., previously-ordered instructions - used -- i.e., instructions that have already been visited - currentInstruction = -- i.e., first instruction of the chain - case currentInstruction.approval of - PassThroughTo (_, next) -> do - nextInstruction <- snd <$> fetchByKey @Instruction next - assertMsg "Next instruction must not have been used before." . not $ Set.member next used - collectPassThroughChain (next :: ordered) (Set.insert next used) nextInstruction - _ -> pure (ordered, used) diff --git a/src/main/daml/Daml/Finance/Settlement/V4/Conversion.daml b/src/main/daml/Daml/Finance/Settlement/V4/Conversion.daml deleted file mode 100644 index d882f7993..000000000 --- a/src/main/daml/Daml/Finance/Settlement/V4/Conversion.daml +++ /dev/null @@ -1,26 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 -module Daml.Finance.Settlement.V4.Conversion where - -import Daml.Finance.Interface.Types.Common.V3.Types (InstrumentKey(..), Id(..), HoldingStandard(..)) -import Splice.Api.Token.HoldingV1 (InstrumentId(..)) - --- | Convert a Splice InstrumentId to a legacy InstrumentKey . -toInstrumentKey : Party -> InstrumentId -> InstrumentKey -toInstrumentKey admin (InstrumentId with admin = instrumentAdmin; id) = - InstrumentKey - with - issuer = instrumentAdmin - depository = instrumentAdmin - id = Id id - -- The version field is temporarily fixed to "0" as a neutral placeholder. - -- This ensures backward compatibility during the transition to InstrumentId. - version = "0" -- HARDCODED --> May cause issues later! - holdingStandard = TransferableFungible -- HARDCODED --> May cause issues later! - --- | Convert a legacy InstrumentKey to a Splice InstrumentId. -fromInstrumentKey : InstrumentKey -> InstrumentId -fromInstrumentKey (InstrumentKey with issuer; id; ..) = - InstrumentId with - admin = issuer - id = show id \ No newline at end of file diff --git a/src/main/daml/Daml/Finance/Settlement/V4/Factory.daml b/src/main/daml/Daml/Finance/Settlement/V4/Factory.daml deleted file mode 100644 index f58dccf24..000000000 --- a/src/main/daml/Daml/Finance/Settlement/V4/Factory.daml +++ /dev/null @@ -1,76 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.V4.Factory where - -import DA.List (mapAccumL) -import DA.Map (fromList) -import qualified DA.TextMap as TextMap -import DA.Fail (failWithStatus, FailureStatus(..), invalidArgument) -import Daml.Finance.Interface.Settlement.V4.Factory qualified as SettlementFactory (I, Instruct(..), View(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), Parties) -import Daml.Finance.Settlement.V4.Batch (Batch(..)) -import Daml.Finance.Settlement.V4.Instruction (Instruction(..)) - --- | Factory template that implements the `Factory` interface. --- It is used to create a set of settlement `Instruction`\s, and a `Batch` to atomically settle --- them. -template Factory - with - provider : Party - -- ^ Party providing the facility. - observers : Parties - -- ^ Observers. - where - signatory provider - observer observers - - interface instance SettlementFactory.I for Factory where - view = SettlementFactory.View with provider; observers - instruct SettlementFactory.Instruct {instructor; consenters; settlers; id; description; - contextId; routedSteps; settlementTime} = do - let - createInstruction index routedStep = - ( index + 1, - Instruction with - instructor - consenters - settlers - batchId = id - id = Id (show index) - routedStep - settlementTime - allocation = Unallocated - approval = Unapproved - signedSenders = mempty - signedReceivers = mempty - observers = fromList [(show id, settlers)] - ) - instructions = snd $ mapAccumL createInstruction 0 routedSteps - instructionIds = map (.id) instructions - instructionCids <- mapA (fmap toInterfaceContractId . create) instructions - - -- Enforce uniqueness: prevent duplicate batch IDs (query fallback) - existingBatch <- lookupByKey @Batch (instructor, id) - case existingBatch of - Some _ -> do - failWithStatus - FailureStatus - { errorId = "daml.finance/duplicate-batch-id" - , category = invalidArgument - , message = "Batch id already exists" - , meta = TextMap.empty - } - None -> do - batchCid <- toInterfaceContractId <$> - create Batch with - instructor - consenters - settlers - id - description - contextId - routedStepsWithInstructionId = zip routedSteps instructionIds - settlementTime - pure (batchCid, instructionCids) diff --git a/src/main/daml/Daml/Finance/Settlement/V4/Hierarchy.daml b/src/main/daml/Daml/Finance/Settlement/V4/Hierarchy.daml deleted file mode 100644 index c436fb641..000000000 --- a/src/main/daml/Daml/Finance/Settlement/V4/Hierarchy.daml +++ /dev/null @@ -1,71 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.V4.Hierarchy where - -import DA.List (dedup, isSuffixOf, stripInfix, stripSuffix, tails) -import DA.Optional (isSome) -import Daml.Finance.Interface.Settlement.V4.Types (RoutedStep(..), Step(..)) - --- | Data type that describes a hierarchical account structure among multiple parties for holdings --- on an instrument. -data Hierarchy = Hierarchy - with - rootCustodian : Party - -- ^ Root custodian of the instrument. - pathsToRootCustodian : [[Party]] - -- ^ Paths from "leaf" owners to the root custodian of the instrument. - deriving (Eq, Show) - --- Given a hierarchy, unfold a step from sender to receiver onto the corresponding route. --- Returns `None` if no route can be found. -unfoldStep : Hierarchy -> Step -> Optional [RoutedStep] -unfoldStep hierarchy step = do - senderPath <- locateParty step.sender hierarchy - receiverPath <- locateParty step.receiver hierarchy - map (\(sender, receiver, custodian) -> - RoutedStep with sender; receiver; custodian; quantity = step.quantity; version = None ) <$> - getRoute senderPath receiverPath - --- | HIDE --- Given a sender path to root custodian and a receiver path to root custodian, calculate the --- route to transfer a holding from sender to receiver. We assume that transfers can only be done --- between accounts at the same custodian. Returns `None` if no such route can be found. --- Otherwise, a list of (sender, receiver, custodian) triplets is returned. -getRoute : (Eq a) => [a] -> [a] -> Optional [(a, a, a)] -getRoute senderPath receiverPath | senderPath `isSuffixOf` receiverPath = do - -- sending down the chain : cut the receiver path at the sender and flip the chain - fullRoute <- reverse <$> stripSuffix (drop 1 senderPath) receiverPath - pure $ zip3 fullRoute (drop 1 fullRoute) fullRoute -getRoute senderPath receiverPath | receiverPath `isSuffixOf` senderPath = do - -- sending up the chain : cut the sender path at the receiver - fullRoute <- stripSuffix (drop 1 receiverPath) senderPath - let receivers = drop 1 fullRoute - pure $ zip3 fullRoute receivers receivers -getRoute senderPath receiverPath = - -- sending up and then down the chain - case filter (`isSuffixOf` receiverPath) $ tails senderPath of - [] -> None - h :: _ -> do - fromRoute <- stripSuffix h senderPath - toRoute <- stripSuffix h receiverPath - let - -- custodians on the path up the chain - fromCustodians = fmap snd $ zip fromRoute $ drop 1 senderPath - -- custodians on the path down the chain - toCustodians = reverse . fmap snd $ zip toRoute $ drop 1 receiverPath - fullRoute = fromRoute <> reverse toRoute - receivers = drop 1 fullRoute - custodians = fromCustodians <> drop 1 toCustodians - Some $ zip3 fullRoute receivers custodians - --- | HIDE --- Locate a party within a hierarchy, returning the path to the root custodian. --- Returns `None` if no path could be found. Returns an error if multiple paths could be found. -locateParty : Party -> Hierarchy -> Optional [Party] -locateParty p h | p == h.rootCustodian = Some [p, p] -locateParty p h = - case dedup . filter isSome $ map (fmap snd . stripInfix [p]) h.pathsToRootCustodian of - [Some path] -> Some $ [p] <> path <> [h.rootCustodian] - [] -> None - _ -> error $ "Multiple paths to root custodian found for party " <> show p diff --git a/src/main/daml/Daml/Finance/Settlement/V4/Instruction.daml b/src/main/daml/Daml/Finance/Settlement/V4/Instruction.daml deleted file mode 100644 index e98d1ed85..000000000 --- a/src/main/daml/Daml/Finance/Settlement/V4/Instruction.daml +++ /dev/null @@ -1,420 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.V4.Instruction where - -import DA.List qualified as L (head) -import DA.Set (Set) -import DA.Set qualified as Set (fromList, insert, intersection, isSubsetOf, null, singleton, toList, union) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Credit(..), Debit(..), I, R, disclose, exerciseInterfaceByKey, undisclose) -import Daml.Finance.Interface.Account.V4.Util (getAccount) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Util.V3.HoldingSplice qualified as Holding (getAmount) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..), Cancel(..), Execute(..), I, View(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..), InstructionKey(..), RoutedStep) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey, Id(..), Parties, PartiesMap, InstrumentQuantity) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers, AddObservers(..), RemoveObservers(..)) -import Daml.Finance.Interface.Util.V3.InterfaceKey (fetchInterfaceByKey) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (Acquire(..), I, LockType(..), Release(..)) -import Daml.Finance.Interface.Util.V3.Common qualified as Common (qty) -import Daml.Finance.Settlement.V4.Conversion (toInstrumentKey) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Type synonym for `Instruction`. -type T = Instruction - --- | Instruction is used to settle a single settlement `Step`. In order to settle the instruction, --- - the sender must allocate a suitable holding --- - the receiver must define the receiving account -template Instruction - with - instructor : Party - -- ^ Party instructing settlement (and the creation of the `Instruction`). - consenters : Parties - -- ^ Parties consenting with the creation of the `Instruction`. - settlers : Parties - -- ^ Any of the parties can trigger the settlement. - batchId : Id - -- ^ Trade identifier. - id : Id - -- ^ Instruction identifier. - routedStep : RoutedStep - -- ^ Routed settlement step. - settlementTime : Optional Time - -- ^ Settlement time (if any). - allocation : Allocation - -- ^ Allocation from the sender. - approval : Approval - -- ^ Approval from the receiver. - signedSenders : Parties - -- ^ Additional signatories, used to collect authorization. - signedReceivers : Parties - -- ^ Additional signatories, used to collect authorization. - observers : PartiesMap - -- ^ Observers. - where - signatory instructor, consenters, signedSenders, signedReceivers - observer routedStep.sender, routedStep.receiver, settlers, Disclosure.flattenObservers observers - - key InstructionKey with instructor; batchId; id : InstructionKey - maintainer key.instructor - - interface instance Disclosure.I for Instruction where - view = Disclosure.View with - disclosureControllers = Set.fromList [routedStep.sender, routedStep.receiver]; observers - setObservers = setObserversImpl @Instruction @Disclosure.I this None - addObservers = addObserversImpl @Instruction @Disclosure.I this None - removeObservers = removeObserversImpl @Instruction @Disclosure.I this None - - interface instance Instruction.I for Instruction where - view = Instruction.View with - instructor; consenters; settlers; batchId; id; routedStep; settlementTime - allocation; approval; signedSenders; signedReceivers - - allocate Instruction.Allocate{actors; allocation} = do - let - allMustAuthorize = mustAuthorizeHelper True actors - atLeastOneMustAuthorize = mustAuthorizeHelper False actors - - atLeastOneMustAuthorize $ Set.fromList [routedStep.custodian, routedStep.sender] - assertMsg ("Allocation must be new. " <> context this) $ allocation /= this.allocation - releasedCid <- releasePreviousAllocation this actors - - -- allocate - newAllocation <- case allocation of - - Pledge oldHoldingCid -> do - - newHoldingCid <- disclosePledge this oldHoldingCid actors - - holding <- fetch newHoldingCid - let holdingI = toInterface @Api.HoldingV1.Holding holding - - -- Sender account (linked to the investor, not custodian) - let senderAccountKey = getAccount holdingI - - senderAccount <- view <$> - fetchInterfaceByKey @Account.R @Account.I senderAccountKey - discloseAccount this senderAccountKey actors - allMustAuthorize senderAccount.controllers.outgoing - mustBe this Custodian senderAccount.custodian - mustBe this Sender senderAccount.owner - - assertMsg ("Pledged amount must match. " <> context this) $ - Holding.getAmount holdingI == routedStep.quantity.amount - - let holdingView = view holdingI - let expectedInstr = routedStep.quantity.unit - - assertMsg ("Pledged instrument ID mismatch. " <> context this) $ - holdingView.instrumentId.id == expectedInstr.id - - assertMsg ("Pledged instrument issuer mismatch. " <> context this) $ - holdingView.instrumentId.admin == expectedInstr.admin - - newLockedCid <- coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I <$> - exercise (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding newHoldingCid) - Lockable.Acquire with - newLockers = Set.singleton instructor <> senderAccount.controllers.outgoing - context = context this - lockType = Lockable.Semaphore - - pure $ Pledge newLockedCid - - PassThroughFrom (passThroughAccountKey, fromInstructionKey) -> do - discloseAccount this passThroughAccountKey actors - passThroughAccount <- view <$> - fetchInterfaceByKey @Account.R @Account.I passThroughAccountKey - allMustAuthorize passThroughAccount.controllers.incoming - allMustAuthorize passThroughAccount.controllers.outgoing - mustBe this Custodian passThroughAccount.custodian - mustBe this Sender passThroughAccount.owner - fromInstruction <- snd <$> fetchByKey @Instruction fromInstructionKey - assertMsg ("Pass-through-from instruction must be part of the batch. " <> context this) - $ fromInstruction.batchId == batchId && fromInstruction.instructor == instructor - mustBe this Custodian fromInstruction.routedStep.custodian - mustBe this Sender fromInstruction.routedStep.receiver - pure allocation - - CreditReceiver -> do - allMustAuthorize $ Set.singleton routedStep.custodian - pure allocation - - SettleOffledger -> do - allMustAuthorize $ Set.fromList [routedStep.custodian, routedStep.sender] - pure allocation - - Unallocated -> do - pure allocation - - newInstructionCid <- toInterfaceContractId <$> create this with - allocation = newAllocation - signedSenders = if newAllocation == Unallocated then mempty else actors - - pure (newInstructionCid, releasedCid) - approve Instruction.Approve{actors; approval} = do - let - allMustAuthorize = mustAuthorizeHelper True actors - atLeastOneMustAuthorize = mustAuthorizeHelper False actors - atLeastOneMustAuthorize $ Set.fromList [routedStep.custodian, routedStep.receiver] - assertMsg ("Approval must be new. " <> context this) $ approval /= this.approval - releasePreviousApproval this actors - - - -- approve - case approval of - TakeDelivery receiverAccountKey -> do - discloseAccount this receiverAccountKey actors - receiverAccount <- view <$> - fetchInterfaceByKey @Account.R @Account.I receiverAccountKey - allMustAuthorize receiverAccount.controllers.incoming - mustBe this Custodian receiverAccount.custodian - mustBe this Receiver receiverAccount.owner - PassThroughTo (passThroughAccountKey, toInstructionKey) -> do - discloseAccount this passThroughAccountKey actors - passThroughAccount <- view <$> - fetchInterfaceByKey @Account.R @Account.I passThroughAccountKey - allMustAuthorize passThroughAccount.controllers.incoming - allMustAuthorize passThroughAccount.controllers.outgoing - mustBe this Custodian passThroughAccount.custodian - mustBe this Receiver passThroughAccount.owner - toInstruction <- snd <$> fetchByKey @Instruction toInstructionKey - assertMsg ("Pass-through-to instruction must be part of the batch. " <> context this) $ - toInstruction.batchId == batchId && toInstruction.instructor == instructor - mustBe this Custodian toInstruction.routedStep.custodian - mustBe this Receiver toInstruction.routedStep.sender - DebitSender -> do - allMustAuthorize $ Set.singleton routedStep.custodian - mustBe this Custodian routedStep.receiver - SettleOffledgerAcknowledge -> - allMustAuthorize $ Set.fromList [routedStep.custodian, routedStep.receiver] - Unapproved -> pure () - toInterfaceContractId <$> create this with - approval - signedReceivers = if approval == Unapproved then mempty else actors - execute Instruction.Execute{actors} = do - let allMustAuthorize = mustAuthorizeHelper True actors - allMustAuthorize $ Set.insert instructor consenters - assertMsg ("Actors must intersect with settlers. " <> context this) $ - not $ Set.null $ actors `Set.intersection` settlers - let - abortUnapproved = abort $ "Instruction must be approved. " <> context this - abortOnOffledgerMix = - abort $ "Mix of on- and off-ledger settlement is not supported. " <> context this - -- execute - case (allocation, approval) of - (Unallocated, Unapproved) -> - abort $ "Instruction must be allocated and approved. " <> context this - - (Unallocated, _) -> abort $ "Instruction must be allocated. " <> context this - - (_, Unapproved) -> abortUnapproved - - (PassThroughFrom _, _) -> do - -- Pass-throughs are consumed by the routedStep (*) below - abort $ "Holding has not been passed through. " <> context this - - (Pledge holdingCid, a) -> do - holdingCid <- coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I <$> - exercise (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) Lockable.Release with - context = context this - - holding <- fetch holdingCid - let holdingI = toInterface @Api.HoldingV1.Holding holding - let senderAccountKey = getAccount holdingI - - case a of - TakeDelivery receiverAccountKey -> do - let transferableCid = fromInterfaceContractId @Transferable.I holdingCid - newHoldingCid <- toInterfaceContractId <$> - exercise transferableCid Transferable.Transfer with - actors = signedSenders <> signedReceivers; newOwnerAccount = receiverAccountKey - -- undisclose accounts - undiscloseAccount this senderAccountKey actors - undiscloseAccount this receiverAccountKey actors - -- disclose to settlers (such that they can get the TemplateTypeRep in the Batch) - Some <$> disclosePledge this newHoldingCid actors - DebitSender -> do - Account.exerciseInterfaceByKey @Account.I - senderAccountKey - routedStep.custodian - Account.Debit with holdingCid - undiscloseAccount this senderAccountKey actors - pure None - PassThroughTo (passThroughAccountKey, toInstructionKey) -> do - let transferableCid = fromInterfaceContractId @Transferable.I holdingCid - holdingCid <- toInterfaceContractId <$> - exercise transferableCid Transferable.Transfer with - actors = signedSenders <> signedReceivers - newOwnerAccount = passThroughAccountKey - (toInstructionCid, toInstruction) <- fetchByKey @Instruction toInstructionKey - assertMsg ("The pass-through process must be compatible between the origin and " <> - "destination endpoints. " <> context this) $ - toInstruction.allocation == PassThroughFrom (passThroughAccountKey, key this) - -- (*) in case of a pass-through, the newly created holding is immediately allocated - -- to the next routedStep - exercise (toInterfaceContractId @Instruction.I toInstructionCid) - Instruction.Allocate with - actors = signedSenders <> signedReceivers; allocation = Pledge holdingCid - undiscloseAccount this senderAccountKey actors - undiscloseAccount this passThroughAccountKey actors - pure None - SettleOffledgerAcknowledge -> abortOnOffledgerMix - Unapproved -> abortUnapproved - (CreditReceiver, a) -> - case a of - TakeDelivery receiverAccountKey -> do - mustBe this Custodian routedStep.sender - let legacyQty : InstrumentQuantity = Common.qty routedStep.quantity.amount (toInstrumentKey instructor routedStep.quantity.unit) - holdingCid <- Account.exerciseInterfaceByKey @Account.I - receiverAccountKey - routedStep.custodian - Account.Credit with quantity = legacyQty - undiscloseAccount this receiverAccountKey actors - -- disclose to actors (such that they can get the TemplateTypeRep in the Batch) - Some <$> disclosePledge this holdingCid actors - DebitSender -> do - assertMsg ("Sender must be the same party as receiver. " <> context this) $ - routedStep.sender == routedStep.receiver - pure None - PassThroughTo _ -> abort $ - "Credit-receiver and pass-through-to combination is not supported. " <> context this - SettleOffledgerAcknowledge -> abortOnOffledgerMix - Unapproved -> abortUnapproved - (SettleOffledger, a) -> - case a of - SettleOffledgerAcknowledge -> pure None - _ -> abortOnOffledgerMix - cancel Instruction.Cancel{actors} = do - let allMustAuthorize = mustAuthorizeHelper True actors - allMustAuthorize $ Set.insert instructor consenters - releasePreviousApproval this actors - releasePreviousAllocation this actors - --- | HIDE -context : Instruction -> Text -context = show . key - --- | HIDE -mustBe : Instruction -> Role -> Party -> Update () -mustBe Instruction{routedStep} role party = do - let - roleParty = case role of - Custodian -> routedStep.custodian - Sender -> routedStep.sender - Receiver -> routedStep.receiver - assertMsg @Update - (show party <> " must match " <> show roleParty <> "(" <> show role <> ")") $ - party == roleParty - --- | HIDE -addSignatories : HasSignatory t => t -> Set Party -> Set Party -addSignatories this parties = parties `Set.union` Set.fromList (signatory this) - --- | HIDE -discloseAccount : Instruction -> AccountKey -> Set Party -> Update (ContractId Account.I) -discloseAccount this@Instruction {settlers} accountKey actors = discloseAccountHelper - Account.disclose (context this, settlers) accountKey $ addSignatories this actors - --- | HIDE -undiscloseAccount : Instruction -> AccountKey -> Set Party -> - Update (Optional (ContractId Account.I)) -undiscloseAccount this@Instruction {settlers} accountKey actors = - discloseAccountHelper Account.undisclose (context this, settlers) accountKey $ - addSignatories this actors - --- | HIDE: Add observers for the pledge -disclosePledge : Instruction -> ContractId Api.HoldingV1.Holding -> Set Party -> Update (ContractId Api.HoldingV1.Holding) -disclosePledge this@Instruction {settlers} holdingCid actors = do - let discCid = coerceInterfaceContractId @Disclosure.I @Api.HoldingV1.Holding holdingCid - newDisclosureCid <- exercise discCid Disclosure.AddObservers with - disclosers = addSignatories this actors - observersToAdd = (context this, settlers) - pure (coerceInterfaceContractId @Api.HoldingV1.Holding @Disclosure.I newDisclosureCid) - --- | HIDE: Remove observers for the pledge -undisclosePledge : Instruction -> ContractId Api.HoldingV1.Holding -> Set Party -> - Update (Optional (ContractId Api.HoldingV1.Holding)) -undisclosePledge this@Instruction {settlers} holdingCid actors = do - let discCid = coerceInterfaceContractId @Disclosure.I @Api.HoldingV1.Holding holdingCid - mDisc' <- exercise discCid Disclosure.RemoveObservers with - disclosers = addSignatories this actors - observersToRemove = (context this, settlers) - pure (fmap (coerceInterfaceContractId @Api.HoldingV1.Holding @Disclosure.I) mDisc') - --- | HIDE -releasePreviousAllocation : Instruction -> Parties -> Update (Optional (ContractId Api.HoldingV1.Holding)) -releasePreviousAllocation this@Instruction {allocation; signedSenders} actors = do - let allMustAuthorize = mustAuthorizeHelper True actors - -- signed senders must agree to release previous allocation - allMustAuthorize signedSenders - - case allocation of - Pledge holdingCid -> do - -- Convert Holding → Lockable - let lockableCid : ContractId Lockable.I = coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid - - -- Release the lock (returns Lockable CID) - releasedLockableCid <- - exercise lockableCid Lockable.Release with - context = context this - - -- Convert Lockable → Holding - let releasedHoldingCid : ContractId Api.HoldingV1.Holding = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I releasedLockableCid - - -- Fetch holding to get account - holding <- fetch releasedHoldingCid - - let holdingI = toInterface @Api.HoldingV1.Holding holding - let senderAccountKey = getAccount holdingI - undiscloseAccount this senderAccountKey actors - mUndisclosed <- undisclosePledge this releasedHoldingCid actors - - let - finalCid = - case mUndisclosed of - Some cid' -> cid' - None -> releasedHoldingCid - - pure (Some finalCid) - - PassThroughFrom (passThroughAccountKey, _) -> do - undiscloseAccount this passThroughAccountKey actors - pure None - _ -> pure None - --- | HIDE -releasePreviousApproval : Instruction -> Parties -> Update (Optional (ContractId Account.I)) -releasePreviousApproval this@Instruction {approval; signedReceivers} actors = do - let allMustAuthorize = mustAuthorizeHelper True actors - -- signed receivers must authorize to release previous approval - allMustAuthorize signedReceivers - case approval of - TakeDelivery receiverAccountKey -> undiscloseAccount this receiverAccountKey actors - PassThroughTo (passThroughAccountKey, _) -> undiscloseAccount this passThroughAccountKey actors - _ -> pure None - --- | HIDE -data Role - = Custodian - | Sender - | Receiver - deriving (Eq, Show) - --- | HIDE -mustAuthorizeHelper : Bool -> Parties -> Parties -> Update () -mustAuthorizeHelper requireAllToAuthorize authorizers parties = - if requireAllToAuthorize then - assertMsg ("All parties in " <> show parties <> " must be in the authorizing set " <> - show authorizers <> ")") $ parties `Set.isSubsetOf` authorizers - else - assertMsg ("At least one party from " <> show parties <> " must be in the authorizing set " - <> show authorizers <> ".") . not . Set.null $ parties `Set.intersection` authorizers - --- | HIDE -discloseAccountHelper : ((Text, Parties) -> Party -> Parties -> AccountKey -> Update a) -> - (Text, Parties) -> AccountKey -> Parties -> Update a -discloseAccountHelper discloseAction (context, settlers) accountKey actors = do - account <- fetchInterfaceByKey @Account.R @Account.I accountKey - discloseAction (context, settlers) (L.head . Set.toList $ actors) actors accountKey diff --git a/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/IntermediatedStatic.daml b/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/IntermediatedStatic.daml deleted file mode 100644 index f71b9dd8a..000000000 --- a/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/IntermediatedStatic.daml +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.V4.RouteProvider.IntermediatedStatic where - -import DA.List (head) -import DA.Map (Map) -import DA.Map as Map (lookup) -import DA.Optional (fromSomeNote) -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (Discover(..), I, View(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Parties) -import Daml.Finance.Settlement.V4.Hierarchy (Hierarchy(..), unfoldStep) -import Daml.Finance.Util.V4.Common (sortAndGroupOn) - - --- | Template which implements the `RouteProvider` interface. --- It is used to discover the settlement route for each settlement `Step`, i.e., `RoutedSteps`\s. --- For each instrument to settle as part of the batch, a hierarchy of intermediaries is specified --- in `paths`. This hierarchy is used to generate the `RoutedStep`\s. -template IntermediatedStatic - with - provider : Party - -- ^ Party providing the facility. - observers : Parties - -- ^ Observers. - paths : Map Text Hierarchy - -- ^ Hierarchical paths used to settle holding transfers. A path is specified for each - -- instrument label. - where - signatory provider - observer observers - - interface instance RouteProvider.I for IntermediatedStatic where - view = RouteProvider.View with provider; observers - discover RouteProvider.Discover{discoverors; contextId; steps} = - let - -- Group steps by instrument. For each group, lookup corresponding paths and expand steps - -- according to the corresponding settlement route. - routedSteps = mconcat $ fromSomeNote "Could not find path or route." $ mapA (\steps -> do - let k = (head steps).quantity.unit.id - route <- Map.lookup k paths - mconcat <$> mapA (unfoldStep route) steps - ) $ sortAndGroupOn (.quantity.unit) steps - in - pure routedSteps diff --git a/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/SingleCustodian.daml b/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/SingleCustodian.daml deleted file mode 100644 index 19407e40e..000000000 --- a/src/main/daml/Daml/Finance/Settlement/V4/RouteProvider/SingleCustodian.daml +++ /dev/null @@ -1,36 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian where - -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (Discover(..), I, View(..)) -import Daml.Finance.Interface.Settlement.V4.Types (RoutedStep(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Parties) - --- | Template which implements the `RouteProvider` interface. --- It is used to transform each settlement `Step` into a `RoutedStep` using a single custodian. -template SingleCustodian - with - provider : Party - -- ^ Party providing the facility. - observers : Parties - -- ^ Observers. - custodian : Party - -- ^ The custodian to be used to route each `Step`. - where - signatory provider - observer observers - - interface instance RouteProvider.I for SingleCustodian where - view = RouteProvider.View with provider; observers - discover RouteProvider.Discover{discoverors; contextId; steps} = - let - routeStep step = RoutedStep with - sender = step.sender - receiver = step.receiver - quantity = step.quantity - custodian - version = None - routedSteps = map routeStep steps - in - pure routedSteps diff --git a/src/main/daml/Daml/Finance/Util/V4/Common.daml b/src/main/daml/Daml/Finance/Util/V4/Common.daml deleted file mode 100644 index 52edfcb72..000000000 --- a/src/main/daml/Daml/Finance/Util/V4/Common.daml +++ /dev/null @@ -1,16 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Util.V4.Common where - -import DA.List qualified as L (groupOn, null, sortOn) - --- | Checks if the input list is not empty. -notNull : [a] -> Bool -notNull = not . L.null - --- | Like `List.groupOn`, but sorts the list first. -sortAndGroupOn : Ord k => (a -> k) -> [a] -> [[a]] -sortAndGroupOn f = L.groupOn f . L.sortOn f diff --git a/src/main/daml/Daml/Finance/Util/V4/Date/Calendar.daml b/src/main/daml/Daml/Finance/Util/V4/Date/Calendar.daml deleted file mode 100644 index e00ba2043..000000000 --- a/src/main/daml/Daml/Finance/Util/V4/Date/Calendar.daml +++ /dev/null @@ -1,82 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.V4.Date.Calendar where - -import DA.Date (addDays, dayOfWeek, toGregorian) -import DA.List (dedup, foldl1) -import Daml.Finance.Interface.Types.Date.V3.Calendar(BusinessDayConventionEnum(..), HolidayCalendarData(..)) - --- | Merge multiple holiday calendars into a single one. `id`\s are concatenated by `,`. -merge : [HolidayCalendarData] -> HolidayCalendarData -merge [] = HolidayCalendarData with id = "Empty"; holidays = []; weekend = [] -merge cals = foldl1 (\cal1 cal2 -> - HolidayCalendarData with - id = cal1.id <> "," <> cal2.id - weekend = dedup $ cal1.weekend ++ cal2.weekend - holidays = dedup $ cal1.holidays ++ cal2.holidays) cals - --- | Check if Date is a holiday. -isHoliday : HolidayCalendarData -> Date -> Bool -isHoliday cal date = date `elem` cal.holidays || (dayOfWeek date) `elem` cal.weekend - --- | Check if Date is a business day. -isBusinessDay : HolidayCalendarData -> Date -> Bool -isBusinessDay cal date = not $ isHoliday cal date - --- | Get next business day. -nextBusinessDay : HolidayCalendarData -> Date -> Date -nextBusinessDay cal date = - let next = addDays date 1 - in if isHoliday cal next then nextBusinessDay cal next else next - --- | Get previous business day. -previousBusinessDay : HolidayCalendarData -> Date -> Date -previousBusinessDay cal date = - let previous = addDays date (-1) - in if isHoliday cal previous then previousBusinessDay cal previous else previous - --- | Get next or same business day. -nextOrSameBusinessDay : HolidayCalendarData -> Date -> Date -nextOrSameBusinessDay cal date = if isHoliday cal date then nextBusinessDay cal date else date - --- | Get previous or same business day. -previousOrSameBusinessDay : HolidayCalendarData -> Date -> Date -previousOrSameBusinessDay cal date = - if isHoliday cal date then previousBusinessDay cal date else date - --- | Get next or same business day if before end of month. Otherwise get last business day in month. -nextSameOrLastInMonthBusinessDay : HolidayCalendarData -> Date -> Date -nextSameOrLastInMonthBusinessDay cal date = - let - nextOrSame = nextOrSameBusinessDay cal date - month date = let (_, m, _) = toGregorian date in m - in - if month nextOrSame /= month date then previousBusinessDay cal date else nextOrSame - --- | Get previous or same business day if before end of month. Otherwise get first business day in --- month. -previousSameOrFirstInMonthBusinessDay : HolidayCalendarData -> Date -> Date -previousSameOrFirstInMonthBusinessDay cal date = - let - previousOrSame = previousOrSameBusinessDay cal date - month date = let (_, m, _) = toGregorian date in m - in - if month previousOrSame /= month date then nextBusinessDay cal date else previousOrSame - --- | Add business days to a Date. -addBusinessDays : HolidayCalendarData -> Int -> Date -> Date -addBusinessDays cal n date - | n == 0 = date - | n < 0 = addBusinessDays cal (n + 1) $ previousBusinessDay cal date - | otherwise = addBusinessDays cal (n - 1) $ nextBusinessDay cal date - --- | Adjust date according to the given business day convention. -adjustDate : HolidayCalendarData -> BusinessDayConventionEnum -> Date -> Date -adjustDate cal convention date = - case convention of - Following -> nextOrSameBusinessDay cal date - ModifiedFollowing -> nextSameOrLastInMonthBusinessDay cal date - Preceding -> previousOrSameBusinessDay cal date - ModifiedPreceding -> previousSameOrFirstInMonthBusinessDay cal date - NoAdjustment -> date diff --git a/src/main/daml/Daml/Finance/Util/V4/Date/DayCount.daml b/src/main/daml/Daml/Finance/Util/V4/Date/DayCount.daml deleted file mode 100644 index 0017bc32d..000000000 --- a/src/main/daml/Daml/Finance/Util/V4/Date/DayCount.daml +++ /dev/null @@ -1,275 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.V4.Date.DayCount - ( calcDcf - , calcDcf30360 - , calcDcf30360Icma - , calcDcf30E360 - , calcDcfAct360 - , calcDcfAct365Fixed - , calcDcfAct365L - , calcDcfActActAfb - , calcPeriodDcf - , calcPeriodDcfActActIsda - , calcPeriodDcfActActIsma - ) where - -import DA.Date (Month(..), fromGregorian, fromMonth, isLeapYear, monthDayCount, subDate, toGregorian) -import DA.Optional (isNone) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.Schedule (ScheduleFrequency(..), SchedulePeriod, StubPeriodTypeEnum(..)) -import Daml.Finance.Util.V4.Date.RollConvention (next, previous) - --- | Calculates the day count fraction given the correponding convention. --- Currently 30E360 is not supported as we do not want to expose the maturity date of the product --- as an additional parameter. -calcDcf : DayCountConventionEnum -> Date -> Date -> Decimal -calcDcf _ f t | f > t = error "fromDate is greater than toDate" -calcDcf Act360 f t = calcDcfAct360 f t -calcDcf Act365Fixed f t = calcDcfAct365Fixed f t -calcDcf Act365NL f t = calcDcfAct365NL f t -calcDcf Act365L f t = calcDcfAct365L f t -calcDcf ActActAFB f t = calcDcfActActAfb f t -calcDcf ActActISDA f t = - error "This call requires the knowledge of the stub period. Please, call `calcPeriodDcf` instead." -calcDcf ActActICMA f t = - error "This call requires the knowledge of the stub period. Please, call `calcPeriodDcf` instead." -calcDcf Basis30360 f t = calcDcf30360 f t -calcDcf Basis30365 f t = calcDcf30Fix 365 f t -calcDcf Basis1 f t = 1.0 -calcDcf Basis30360ICMA f t = calcDcf30360Icma f t -calcDcf Basis30E2360 f t = - error "This call requires the knowledge of the stub period. Please, call `calcPeriodDcf` instead." -calcDcf Basis30E3360 f t = calcDcf30E360 False f t -- i.e., 30E/360 with no maturity date adjustment -calcDcf Basis30E360 f t = error $ - "This call requires the knowledge of the maturity date of the product. " <> - "Please, use `calcDcf30E360` instead." - --- | Calculate day count fraction for a schedule period. --- It takes the following parameters: --- - DayCountConventionEnum: to specify which day count convention should be used --- - SchedulePeriod: the schedule period for which the day count fraction should be calculated --- - Bool: Whether day count fraction should be calculated on adjusted dates --- (if False: unadjusted dates) --- - Date: The maturity date of the instrument --- - Frequency: the frequency of the schedule period -calcPeriodDcf : DayCountConventionEnum -> SchedulePeriod -> Bool -> Date -> ScheduleFrequency -> - Decimal -calcPeriodDcf ActActISDA p useAdjustedDates maturityDate frequency = - calcPeriodDcfActActIsda p useAdjustedDates maturityDate -calcPeriodDcf ActActICMA p useAdjustedDates maturityDate frequency = - calcPeriodDcfActActIsma p useAdjustedDates maturityDate frequency -calcPeriodDcf Basis30E360 p useAdjustedDates maturityDate frequency = - calcDcf30E360 - (maturityDate == if useAdjustedDates then p.adjustedEndDate else p.unadjustedEndDate) - (if useAdjustedDates then p.adjustedStartDate else p.unadjustedStartDate) - (if useAdjustedDates then p.adjustedEndDate else p.unadjustedEndDate) -calcPeriodDcf Basis30E2360 p useAdjustedDates maturityDate frequency = - calcDcf30E2360 - (isNone p.stubType) - (if useAdjustedDates then p.adjustedStartDate else p.unadjustedStartDate) - (if useAdjustedDates then p.adjustedEndDate else p.unadjustedEndDate) -calcPeriodDcf basis p useAdjustedDates _ _ = - calcDcf - basis - (if useAdjustedDates then p.adjustedStartDate else p.unadjustedStartDate) - (if useAdjustedDates then p.adjustedEndDate else p.unadjustedEndDate) - --- | Calculate Actual Actual day count fraction according to the ISDA method. -calcPeriodDcfActActIsda : SchedulePeriod -> Bool -> Date -> Decimal -calcPeriodDcfActActIsda p useAdjustedDates maturityDate = - let - startDate = if useAdjustedDates then p.adjustedStartDate else p.unadjustedStartDate - endDate = if useAdjustedDates then p.adjustedEndDate else p.unadjustedEndDate - (y1, m1, d1) = toGregorian startDate - (y2, m2, d2) = toGregorian endDate - nYears = y2 - y1 + 1 - in - -- DCF calculation depends on whether coupon period spans over year-end (more than one calendar - -- year involved?) - case nYears of - 1 -> intToDecimal nDaysY1 / intToDecimal nTotDaysY1 - where - nDaysY1 = subDate endDate startDate - nTotDaysY1 = if isLeapYear y1 then 366 else 365 - x | x > 1 -> intToDecimal nDaysY1 / intToDecimal nTotDaysY1 + (intToDecimal nYears - 2.0) + - intToDecimal nDaysY2 / intToDecimal nTotDaysY2 - where - dateYearEnd = fromGregorian (y1, Dec, 31) - nDaysY1 = subDate dateYearEnd startDate + 1 - nDaysY2 = subDate endDate dateYearEnd - 1 - nTotDaysY1 = if isLeapYear y1 then 366 else 365 - nTotDaysY2 = if isLeapYear y2 then 366 else 365 - _ -> error "The coupon end date must be in the same or in a following calendar year" - --- | Calculate Actual Actual day count fraction according to the ISMA method. -calcPeriodDcfActActIsma : SchedulePeriod -> Bool -> Date -> ScheduleFrequency -> Decimal -calcPeriodDcfActActIsma _ _ _ SinglePeriod = - error "ActActISMA is not supported for schedules without a regular frequency. " -calcPeriodDcfActActIsma p useAdjustedDates maturityDate (Periodic frequency) = - let - startDate = if useAdjustedDates then p.adjustedStartDate else p.unadjustedStartDate - endDate = if useAdjustedDates then p.adjustedEndDate else p.unadjustedEndDate - nDays = subDate endDate startDate - nPeriodsPerYear = if frequency.period.period == M - then 12.0 / intToDecimal frequency.period.periodMultiplier - else error "only monthly period currently supported" - in - -- DCF calculation depends on the type of period (regular or stub) - case p.stubType of - None -> (intToDecimal nDays) / (intToDecimal nDays * nPeriodsPerYear) - Some ShortInitial -> - (intToDecimal nDays) / (intToDecimal (subDate endDate notionalStartDate) * nPeriodsPerYear) - where - notionalStartDate = previous endDate frequency.period frequency.rollConvention - Some LongInitial -> (intToDecimal nDaysP1) / (intToDecimal nDaysP1 * nPeriodsPerYear) + - (intToDecimal nDaysP2) / - (intToDecimal (subDate notionalPaymentDate notionalStartDate) * nPeriodsPerYear) - where - notionalPaymentDate = previous endDate frequency.period frequency.rollConvention - notionalStartDate = previous notionalPaymentDate frequency.period frequency.rollConvention - nDaysP1 = subDate endDate notionalPaymentDate - nDaysP2 = subDate notionalPaymentDate startDate - Some ShortFinal -> (intToDecimal nDays) / - (intToDecimal (subDate notionalMaturityDate startDate) * nPeriodsPerYear) - where - notionalMaturityDate = next startDate frequency.period frequency.rollConvention - Some LongFinal -> (intToDecimal nDaysP1) / (intToDecimal nDaysP1 * nPeriodsPerYear) + - (intToDecimal nDaysP2) / - (intToDecimal (subDate notionalMaturityDate notionalPaymentDate) * nPeriodsPerYear) - where - notionalPaymentDate = next startDate frequency.period frequency.rollConvention - notionalMaturityDate = next notionalPaymentDate frequency.period frequency.rollConvention - nDaysP1 = subDate notionalPaymentDate startDate - nDaysP2 = subDate endDate notionalPaymentDate - --- Calculate Actual Actual AFB day count fraction. -calcDcfActActAfb : Date -> Date -> Decimal -calcDcfActActAfb fromDate toDate = - let - (y1, m1, d1) = toGregorian fromDate - (y2, m2, d2) = toGregorian toDate - feb29IncludedInY1 = - isLeapYear y1 && fromDate <= getDateEndOfFebruary y1 && getDateEndOfFebruary y1 <= toDate - feb29IncludedInY2 = - isLeapYear y2 && fromDate <= getDateEndOfFebruary y2 && getDateEndOfFebruary y2 <= toDate - nTotDays = if feb29IncludedInY1 || feb29IncludedInY2 then 366 else 365 - nDays = subDate toDate fromDate - in - if nDays <= nTotDays - then intToDecimal nDays / intToDecimal nTotDays - else error "coupon period more than one year not supported" - --- Calculate Actual 360 day count fraction. -calcDcfAct360 : Date -> Date -> Decimal -calcDcfAct360 fromDate toDate = - (/ 360.0) . intToDecimal $ subDate toDate fromDate - --- Calculate Actual 365 (Fixed) day count fraction. -calcDcfAct365Fixed : Date -> Date -> Decimal -calcDcfAct365Fixed fromDate toDate = - (/ 365.0) . intToDecimal $ subDate toDate fromDate - --- Calculate Actual 365NL day count fraction. -calcDcfAct365NL : Date -> Date -> Decimal -calcDcfAct365NL fromDate toDate = - (/ 365.0) . intToDecimal $ subDate toDate fromDate - countLeapDays fromDate toDate - --- Calculate Actual 365L (Leap-year) day count fraction. -calcDcfAct365L : Date -> Date -> Decimal -calcDcfAct365L fromDate toDate = - let - (y2, m2, d2) = toGregorian toDate - nTotDaysY2 = if isLeapYear y2 then 366 else 365 - in - (/ intToDecimal nTotDaysY2) . intToDecimal $ subDate toDate fromDate - --- Calculate 30/360 day count fraction. This is also known as the '30/360 (ISDA)' or 'Bond Basis' --- day count convention. -calcDcf30360 : Date -> Date -> Decimal -calcDcf30360 = calcDcf30Fix 360 - --- Calculate 30/360 or 30/365 day count fraction. -calcDcf30Fix : Int -> Date -> Date -> Decimal -calcDcf30Fix daysPerYear fromDate toDate = - let - d1Adj = if d1 == 31 then 30 else d1 - d2Adj = if d2 == 31 && d1 > 29 then 30 else d2 - in - calc30FixFormula daysPerYear (y1, m1, d1Adj) (y2, m2, d2Adj) - where - (y1, m1, d1) = toGregorian fromDate - (y2, m2, d2) = toGregorian toDate - --- Calculate 30/360 ICMA day count fraction. -calcDcf30360Icma : Date -> Date -> Decimal -calcDcf30360Icma fromDate toDate = - let - adjust d = if d == 31 then 30 else d - in - calc30FixFormula 360 (y1, m1, adjust d1) (y2, m2, adjust d2) - where - (y1, m1, d1) = toGregorian fromDate - (y2, m2, d2) = toGregorian toDate - --- | Calculate 30E/360 day count fraction. -calcDcf30E360 : Bool -> Date -> Date -> Decimal -calcDcf30E360 _ fromDate toDate | fromDate > toDate = - error "fromDate is greater than toDate" -calcDcf30E360 toDateIsMaturityDate fromDate toDate = - let - d1Adj = if d1 == monthDayCount y1 m1 then 30 else d1 - d2Adj = if d2 == 31 || not toDateIsMaturityDate && isEndOfFebruary (y2, m2, d2) then 30 else d2 - in - calc30FixFormula 360 (y1, m1, d1Adj) (y2, m2, d2Adj) - where - (y1, m1, d1) = toGregorian fromDate - (y2, m2, d2) = toGregorian toDate - --- | Calculate 30E2/360 day count fraction. -calcDcf30E2360 : Bool -> Date -> Date -> Decimal -calcDcf30E2360 _ fromDate toDate | fromDate > toDate = - error "fromDate is greater than toDate" -calcDcf30E2360 isRegularPeriod fromDate toDate = - let - d1Adj = if d1 == monthDayCount y1 m1 then 30 else d1 - d2Adj - | isEndOfFebruary (y2, m2, d2) && d1Adj > d2 && isRegularPeriod = d1Adj - | otherwise = if d2 == 31 then 30 else d2 - in - calc30FixFormula 360 (y1, m1, d1Adj) (y2, m2, d2Adj) - where - (y1, m1, d1) = toGregorian fromDate - (y2, m2, d2) = toGregorian toDate - --- | HIDE -calc30FixFormula : Int -> (Int, Month, Int) -> (Int, Month, Int) -> Decimal -calc30FixFormula daysPerYear (y1, m1, d1) (y2, m2, d2) = - (/ intToDecimal daysPerYear) . - intToDecimal $ daysPerYear * (y2-y1) + 30 * (fromMonth m2 - fromMonth m1) + (d2-d1) - --- | HIDE -isEndOfFebruary : (Int, Month, Int) -> Bool -isEndOfFebruary (y, m, d) = - m == Feb && d == monthDayCount y m - --- | HIDE -getDateEndOfFebruary : Int -> Date -getDateEndOfFebruary y = - fromGregorian (y, Feb, monthDayCount y Feb) - --- | HIDE -leapDayInDateRange : Int -> Date -> Date -> Bool -leapDayInDateRange y fromDate toDate = - isLeapYear y && endOfFebDate > fromDate && endOfFebDate <= toDate - where endOfFebDate = getDateEndOfFebruary y - --- | HIDE -countLeapDays : Date -> Date -> Int -countLeapDays fromDate toDate = - foldl (\acc y -> acc + if leapDayInDateRange y fromDate toDate then 1 else 0) 0 [y1..y2] - where - (y1, m1, d1) = toGregorian fromDate - (y2, m2, d2) = toGregorian toDate diff --git a/src/main/daml/Daml/Finance/Util/V4/Date/RollConvention.daml b/src/main/daml/Daml/Finance/Util/V4/Date/RollConvention.daml deleted file mode 100644 index f51c3291a..000000000 --- a/src/main/daml/Daml/Finance/Util/V4/Date/RollConvention.daml +++ /dev/null @@ -1,75 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.V4.Date.RollConvention - ( addPeriod - , next - , previous - ) where - -import DA.Date as D -import Daml.Finance.Interface.Types.Date.V3.RollConvention(Period(..), PeriodEnum(..), RollConventionEnum(..)) - --- | Get next periodic (daily `D` and weekly `W` not supported) date according --- to a given roll convention. -next : Date -> Period -> RollConventionEnum -> Date -next _ period _ | period.period == D = error "daily periodic dates not supported." -next _ period _ | period.period == W = error "weekly periodic dates not supported." -next _ _ NoRollConvention = - error "A roll convention is required for schedules with a monthly or yearly frequency." -next date period EOM - | d /= monthDayCount y m = error $ "day " <> show d <> " does not match roll convention EOM." - | otherwise = - let (yEnd, mEnd, dEnd) = toGregorian $ addPeriod date period - in D.date yEnd mEnd (monthDayCount yEnd mEnd) - where - (y, m, d) = toGregorian date -next date period (DOM rollDay) - | d /= rollDay && (d /= monthDayCount y m || d > rollDay) = - error $ "day " <> show d <> " does not match roll convention DOM " <> show rollDay - | otherwise = - let - (yEnd, mEnd, dEnd) = toGregorian $ addPeriod date period - eomEnd = monthDayCount yEnd mEnd - in - D.date yEnd mEnd $ min rollDay eomEnd - where - (y, m, d) = toGregorian date - --- | Get previous periodic (daily `D` and weekly `W` not supported) date according --- to a given roll convention. -previous : Date -> Period -> RollConventionEnum -> Date -previous date Period{period; periodMultiplier} rc = - let periodRev = Period with periodMultiplier = -periodMultiplier; period - in next date periodRev rc - --- | Add period to given date. -addPeriod : Date -> Period -> Date -addPeriod date Period{periodMultiplier; period = D} = addDays date periodMultiplier -addPeriod date Period{periodMultiplier; period = M} = addMonths date periodMultiplier -addPeriod date Period{periodMultiplier; period = W} = addDays date (7 * periodMultiplier) -addPeriod date Period{periodMultiplier; period = Y} = addYears date periodMultiplier - --- | HIDE --- Add number of months to Date (clip days if invalid). -addMonths : Date -> Int -> Date -addMonths date n = D.date y' m' d' - where - (y, m, d) = toGregorian date - (y', m') = rolloverMonths (y, fromEnum m + 1 + n) - d' = clip 1 (monthDayCount y' m') d - - rolloverMonths : (Int, Int) -> (Int, Month) - rolloverMonths (y, m) = (y + div (m - 1) 12, toEnum $ mod (m - 1) 12) - where - div x y = floor $ (intToDecimal x) / (intToDecimal y) - mod x y = x - (div x y) * y - - clip : Int -> Int -> Int -> Int - clip a _ x | x < a = a - clip _ b x | x > b = b - clip _ _ x = x - --- | HIDE -addYears : Date -> Int -> Date -addYears date n = addMonths date (n * 12) diff --git a/src/main/daml/Daml/Finance/Util/V4/Date/Schedule.daml b/src/main/daml/Daml/Finance/Util/V4/Date/Schedule.daml deleted file mode 100644 index d83cd5867..000000000 --- a/src/main/daml/Daml/Finance/Util/V4/Date/Schedule.daml +++ /dev/null @@ -1,225 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.V4.Date.Schedule - ( createSchedule - ) where - -import DA.List (head, init, tail) -import DA.Optional (fromOptional, fromSomeNote, isSome) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayAdjustment, HolidayCalendarData) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period, RollConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule(Frequency(..), PeriodicSchedule(..), Schedule(..), ScheduleFrequency(..), SchedulePeriod(..), StubPeriodTypeEnum(..)) -import Daml.Finance.Util.V4.Date.Calendar (adjustDate, merge) -import Daml.Finance.Util.V4.Date.RollConvention (addPeriod, next, previous) - --- | Generate schedule from a periodic schedule. -createSchedule : [HolidayCalendarData] -> PeriodicSchedule -> Schedule -createSchedule _ ps | Some errorMsg <- validDates ps = error errorMsg -createSchedule cals ps@PeriodicSchedule {businessDayAdjustment; effectiveDateBusinessDayAdjustment; - terminationDateBusinessDayAdjustment, frequency, effectiveDate, terminationDate} = - let - (unadj, stubTypeInitial, stubTypeFinal) = case frequency of - SinglePeriod -> ([effectiveDate, terminationDate], None, None) - Periodic f -> generateUnadjustedDatesAndStubInfo ps f - adj = adjust - cals - businessDayAdjustment - effectiveDateBusinessDayAdjustment - terminationDateBusinessDayAdjustment - unadj - in - toSchedule unadj adj stubTypeInitial stubTypeFinal - --- | HIDE -validDates : PeriodicSchedule -> Optional Text -validDates PeriodicSchedule{effectiveDate; terminationDate; firstRegularPeriodStartDate; - lastRegularPeriodEndDate} = - let - firstRegStartDate = fromOptional effectiveDate firstRegularPeriodStartDate - lastRegEndDate = fromOptional terminationDate lastRegularPeriodEndDate - in - if effectiveDate >= terminationDate then - Some "terminationDate must be after effectiveDate" - else if effectiveDate > firstRegStartDate then - Some "firstRegularPeriodStartDate must be on or after effectiveDate" - else if firstRegStartDate > lastRegEndDate then - Some "lastRegularPeriodEndDate must be on or after firstRegularPeriodStartDate" - else if lastRegEndDate > terminationDate then - Some "terminationDate must be on or after lastRegularPeriodEndDate" - else - None - --- | HIDE -generateUnadjustedDatesAndStubInfo : - PeriodicSchedule -> Frequency -> - ([Date], Optional StubPeriodTypeEnum, Optional StubPeriodTypeEnum) -generateUnadjustedDatesAndStubInfo PeriodicSchedule{effectiveDate; terminationDate; - firstRegularPeriodStartDate; lastRegularPeriodEndDate; stubPeriodType} frequency = - let - firstRegStartDate = fromOptional effectiveDate firstRegularPeriodStartDate - lastRegEndDate = fromOptional terminationDate lastRegularPeriodEndDate - explicitInitStub = firstRegStartDate /= effectiveDate - explicitFinalStub = lastRegEndDate /= terminationDate - stubType = getImplicitStubType stubPeriodType explicitInitStub explicitFinalStub - in - case stubType of - -- Roll forward for implicit final stub - Some stubType | stubType == ShortFinal || stubType == LongFinal -> do - let - dates = rollForward effectiveDate terminationDate frequency.period - frequency.rollConvention - -- No real stub - if head dates == terminationDate then (reverse dates, None, None) - else - let - relevantDates = - if stubType == LongFinal && length dates > 1 then tail dates else dates - in (reverse $ terminationDate::relevantDates, None, Some stubType) - -- Roll backwards for implicit initial stub - Some stubType | stubType == ShortInitial || stubType == LongInitial -> do - let - dates = rollBackwards effectiveDate terminationDate frequency.period - frequency.rollConvention - -- No real stub - if head dates == effectiveDate then (dates, None, None) - else - let - relevantDates = - if stubType == LongInitial && length dates > 1 then tail dates else dates - in (effectiveDate::relevantDates, Some stubType, None) - -- Roll backwards for explicit stubs - _ -> - -- Regular Periods - let - dates = rollBackwards firstRegStartDate lastRegEndDate frequency.period - frequency.rollConvention - _ = if head dates /= firstRegStartDate - then error "expecting regular schedule between regular dates" - else () - -- Stubs - (withFinalStub, stubTypeFinal) = - if explicitFinalStub - then - ( dates++[terminationDate] - , if terminationDate < addPeriod lastRegEndDate frequency.period - then Some ShortFinal - else Some LongFinal - ) - else (dates, None) - (withInitialStub, stubTypeInitial) = - if explicitInitStub - then - ( effectiveDate::withFinalStub - , if addPeriod effectiveDate frequency.period > firstRegStartDate - then Some ShortInitial - else Some LongInitial - ) - else (withFinalStub, None) - in (withInitialStub, stubTypeInitial, stubTypeFinal) - --- | HIDE -getImplicitStubType : Optional StubPeriodTypeEnum -> Bool -> Bool -> Optional StubPeriodTypeEnum -getImplicitStubType None _ _ = None -getImplicitStubType (Some stubType) explicitInitialStub explicitFinalStub = - case stubType of - ShortInitial -> - if explicitFinalStub - then error "explicit final stub implied, but ShortInitial stub set." - else isExplicitFinalStub ShortInitial - LongInitial -> - if explicitFinalStub - then error "explicit final stub implied, but LongInitial stub set." - else isExplicitFinalStub LongInitial - ShortFinal -> - if explicitInitialStub - then error "explicit initial stub implied, but ShortFinal stub set." - else isExplicitFinalStub ShortFinal - LongFinal -> - if explicitInitialStub - then error "explicit initial stub implied, but LongFinal stub set." - else isExplicitFinalStub LongFinal - where - isExplicitFinalStub stub = if explicitFinalStub then None else Some stub - --- | HIDE --- Roll forward until next date would be strictly after end date (dates are returned in reverse --- order). -rollForward : Date -> Date -> Period -> RollConventionEnum -> [Date] -rollForward start end period rc = rollForwardImpl end period rc [start] - --- | HIDE -rollForwardImpl : Date -> Period -> RollConventionEnum -> [Date] -> [Date] -rollForwardImpl end period rc dates = - case dates of - [] -> error "no dates provided" - d::ds | d > end -> ds - d::ds -> - let nextDate = next d period rc - in rollForwardImpl end period rc (nextDate::dates) - --- | HIDE --- Roll backwards until previous date would be strictly before start date. -rollBackwards : Date -> Date -> Period -> RollConventionEnum -> [Date] -rollBackwards start end period rc = rollBackwardsImpl start period rc [end] - --- | HIDE -rollBackwardsImpl : Date -> Period -> RollConventionEnum -> [Date] -> [Date] -rollBackwardsImpl start period rc dates = - case dates of - [] -> error "no dates provided" - d::ds | d < start -> ds - d::ds -> - let previousDate = previous d period rc - in rollBackwardsImpl start period rc (previousDate::dates) - --- | HIDE -adjust : [HolidayCalendarData] - -> BusinessDayAdjustment - -> Optional BusinessDayAdjustment - -> Optional BusinessDayAdjustment - -> [Date] - -> [Date] -adjust cals bdAdj optBdAdjStart optBdAdjEnd dates = - let - bdAdjStart = fromOptional bdAdj optBdAdjStart - convStart = bdAdjStart.convention - calStart = getCalendar cals bdAdjStart.calendarIds - bdAdjEnd = fromOptional bdAdj optBdAdjEnd - convEnd = bdAdjEnd.convention - calEnd = getCalendar cals bdAdjEnd.calendarIds - convRegular = bdAdj.convention - calRegular = getCalendar cals bdAdj.calendarIds - convAll = convStart :: (replicate (length dates - 2) convRegular) ++ [convEnd] - calAll = calStart :: (replicate (length dates - 2) calRegular) ++ [calEnd] - in - zipWith3 adjustDate calAll convAll dates - where - getCalendar : [HolidayCalendarData] -> [Text] -> HolidayCalendarData - getCalendar cals calIds = merge $ map (\calId -> - fromSomeNote ("calendar with id " <> calId <> " missing.") $ find ((== calId) . (.id)) cals - ) calIds - --- | HIDE -toSchedule : [Date] - -> [Date] - -> Optional StubPeriodTypeEnum - -> Optional StubPeriodTypeEnum - -> Schedule -toSchedule unadj adj stubTypeInitial stubTypeFinal = - let - pairs = zip unadj adj - stubTypesDefault = replicate (length unadj - 1) None - stubTypesInclInitial = if isSome stubTypeInitial - then stubTypeInitial :: (tail stubTypesDefault) - else stubTypesDefault - stubTypes = if isSome stubTypeFinal - then (init stubTypesInclInitial) ++ [stubTypeFinal] - else stubTypesInclInitial - in - zipWith3 toPeriod (init pairs) (tail pairs) stubTypes - where - toPeriod : (Date, Date) -> (Date, Date) -> Optional StubPeriodTypeEnum -> SchedulePeriod - toPeriod (unadjustedStartDate, adjustedStartDate) (unadjustedEndDate, adjustedEndDate) stubType - = SchedulePeriod with - adjustedEndDate; adjustedStartDate; unadjustedEndDate; unadjustedStartDate; stubType diff --git a/src/main/daml/Daml/Finance/Util/V4/Disclosure.daml b/src/main/daml/Daml/Finance/Util/V4/Disclosure.daml deleted file mode 100644 index 5ec6f1da0..000000000 --- a/src/main/daml/Daml/Finance/Util/V4/Disclosure.daml +++ /dev/null @@ -1,116 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This module contains default implementations for the methods of the `Disclosure` interface. --- These are used across multiple templates in the library. -module Daml.Finance.Util.V4.Disclosure where - -import DA.Foldable qualified as F (mapA_) -import DA.Map qualified as Map (delete, insert, lookup) -import DA.Optional (fromOptional) -import DA.Set (Set) -import DA.Set qualified as Set (difference, intersection, null, union) -import DA.Traversable qualified as T (mapA) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I, RemoveObservers(..), SetObservers(..)) - --- | Default implementation for `setObservers`. --- The `refUpdate` argument is used to update the corresponding contract `Reference` and --- can be set to `None` if your template does not have an accompanying `Reference` contract. -setObserversImpl : - forall t i. - ( HasCreate t - , HasField "observers" t PartiesMap - , HasFromInterface t Disclosure.I - , HasToInterface t Disclosure.I - , HasInterfaceTypeRep i - , HasToInterface i Disclosure.I - , HasToInterface t i - ) => t - -> Optional (PartiesMap -> ContractId i -> Update (ContractId Disclosure.I)) - -> Disclosure.SetObservers - -> Update (ContractId Disclosure.I) -setObserversImpl this refUpdate Disclosure.SetObservers{disclosers; newObservers} = do - let v = view $ toInterface @Disclosure.I this - assertMsg - ("controller (" <> show disclosers <> ") must be authorized to SetObservers") $ - mustIntersect disclosers v.disclosureControllers - cid <- toInterfaceContractId @i <$> create this with observers = newObservers - F.mapA_ (\f -> f newObservers cid) refUpdate - pure $ toInterfaceContractId @Disclosure.I cid - --- | Default implementation for `addObservers`. --- The `refUpdate` argument is used to update the corresponding contract `Reference` and --- can be set to `None` if your template does not have an accompanying `Reference` contract. -addObserversImpl : - forall t i. - ( HasCreate t - , HasField "observers" t PartiesMap - , HasFromInterface t Disclosure.I - , HasToInterface t Disclosure.I - , HasInterfaceTypeRep i - , HasToInterface i Disclosure.I - , HasToInterface t i - ) => t - -> Optional (PartiesMap -> ContractId i -> Update (ContractId Disclosure.I)) - -> Disclosure.AddObservers - -> Update (ContractId Disclosure.I) -addObserversImpl this refUpdate Disclosure.AddObservers{disclosers; observersToAdd} = do - let - v = view $ toInterface @Disclosure.I this - context = fst observersToAdd - contextParties = fromOptional mempty $ Map.lookup context v.observers - value = contextParties <> snd observersToAdd - newObservers = Map.insert context value v.observers - assertMsg - ("controller (" <> show disclosers <> ") must be authorized to SetObservers") $ - mustIntersect disclosers v.disclosureControllers - cid <- toInterfaceContractId @i <$> create this with observers = newObservers - F.mapA_ (\f -> f newObservers cid) refUpdate - pure $ toInterfaceContractId @Disclosure.I cid - --- | Default implementation for `removeObservers`. --- The `refUpdate` argument is used to update the corresponding contract `Reference` and --- can be set to `None` if your template does not have an accompanying `Reference` contract. -removeObserversImpl : - forall t i. - ( HasCreate t - , HasField "observers" t PartiesMap - , HasFromInterface t Disclosure.I - , HasToInterface t Disclosure.I - , HasInterfaceTypeRep i - , HasToInterface i Disclosure.I - , HasToInterface t i - ) => t - -> Optional (PartiesMap -> ContractId i -> Update (ContractId Disclosure.I)) - -> ContractId Disclosure.I -> Disclosure.RemoveObservers - -> Update (Optional (ContractId Disclosure.I)) -removeObserversImpl this refUpdate self - Disclosure.RemoveObservers{disclosers; observersToRemove} = do - let - v = view $ toInterface @Disclosure.I this - context = fst observersToRemove - contextParties = fromOptional mempty $ Map.lookup context v.observers - assertMsg "disclosers must be authorized to RemoveObservers when removing other parties" $ - mustIntersect disclosers (v.disclosureControllers `Set.union` contextParties) - fromOptional None <$> - T.mapA - (\viewers -> do - let updatedViewers = viewers `Set.difference` snd observersToRemove - if updatedViewers == viewers then - pure None - else do - archive self - let - newObservers = if Set.null updatedViewers - then Map.delete context v.observers - else Map.insert context updatedViewers v.observers - cid <- toInterfaceContractId @i <$> create this with observers = newObservers - F.mapA_ (\f -> f newObservers cid) refUpdate - pure $ Some (toInterfaceContractId @Disclosure.I cid) - ) - (Map.lookup context v.observers) - --- | HIDE -mustIntersect : Ord k => Set k -> Set k -> Bool -mustIntersect a b = not . Set.null $ a `Set.intersection` b diff --git a/src/main/daml/Daml/Finance/Util/V4/Lockable.daml b/src/main/daml/Daml/Finance/Util/V4/Lockable.daml deleted file mode 100644 index 5f46d5b59..000000000 --- a/src/main/daml/Daml/Finance/Util/V4/Lockable.daml +++ /dev/null @@ -1,60 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.V4.Lockable where - -import DA.Action (when) -import DA.Optional (fromSomeNote) -import DA.Set qualified as Set (delete, fromList, insert, isSubsetOf, notMember, null, singleton) -import Daml.Finance.Interface.Util.V3.Lockable (Acquire(..), Lock(..), LockType(..), Lockable, Release(..)) - --- | Default implementation of `acquire` from the `Lockable` interface. -acquireImpl : - ( HasCreate t - , HasSignatory t - , HasFromInterface t Lockable - , HasToInterface t Lockable - ) => Optional Lock -> (Optional Lock -> t) -> Acquire -> Update (ContractId Lockable) -acquireImpl currentLock setLock Acquire{newLockers; context; lockType} = do - assertMsg "New lockers must be non-empty" (not $ Set.null newLockers) - newLock <- Some <$> case currentLock of - None -> pure Lock with lockers = newLockers; context = Set.singleton context; lockType - Some existingLock -> do - case lockType of - Reentrant -> do - assertMsg "New lockers must match the existing lockers" - $ existingLock.lockers == newLockers - assertMsg "New lock type must match the existing lock type" - $ existingLock.lockType == lockType - assertMsg "Contract must not be already locked for the provided context" - $ Set.notMember context existingLock.context - pure existingLock with - context = context `Set.insert` existingLock.context - Semaphore -> - abort "A Semaphore lock can not be locked multiple times." - let newLockable = setLock newLock - assertMsg "New lockers must be signatories of the new lockable" - $ newLockers `Set.isSubsetOf` Set.fromList (signatory newLockable) - toInterfaceContractId <$> create newLockable - --- | Default implementation of `release` from the `Lockable` interface. -releaseImpl : - ( HasCreate t - , HasFromInterface t Lockable - , HasToInterface t Lockable - ) => Optional Lock -> (Optional Lock -> t) -> Release -> Update (ContractId Lockable) -releaseImpl currentLock setLock Release{context} = do - let - lock = fromSomeNote "Must be locked" currentLock - newContext = context `Set.delete` lock.context - updatedLock = - if lock.lockType == Reentrant && not (Set.null newContext) - then Some $ lock with context = newContext - else None - when (newContext == lock.context) $ abort "Incorrect context provided" - fmap toInterfaceContractId . create . setLock $ updatedLock - --- | Check validity of lock. --- The lockers field must be non-empty if set. -isValidLock : Optional Lock -> Bool -isValidLock lock = optional True (not . Set.null . (.lockers)) lock diff --git a/src/test/daml/ContingentClaims/Test/Currency.daml b/src/test/daml/ContingentClaims/Test/Currency.daml deleted file mode 100644 index 7e4ca0d21..000000000 --- a/src/test/daml/ContingentClaims/Test/Currency.daml +++ /dev/null @@ -1,10 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Test.Currency where - --- ISO Currencies -data Currency - = GBP - | USD - deriving (Eq, Show) diff --git a/src/test/daml/ContingentClaims/Test/FinancialContract.daml b/src/test/daml/ContingentClaims/Test/FinancialContract.daml deleted file mode 100644 index 0d69b9c99..000000000 --- a/src/test/daml/ContingentClaims/Test/FinancialContract.daml +++ /dev/null @@ -1,73 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Test.FinancialContract where - -import ContingentClaims.Core.V3.Claim (Claim) -import ContingentClaims.Lifecycle.V3.Lifecycle qualified as Lifecycle -import DA.Date -import DA.Set (fromList) - -type T = FinancialContract -type Days = Int -type Instrument = Text -type Observable = Text - -template Quote - with - instrument: Instrument - quoteDate: Date - close: Decimal - source: Party - where - signatory source - key (instrument, quoteDate, source) : (Instrument, Date, Party) - maintainer key._3 - -template FinancialContract - with - bearer: Party - counterparty: Party - claims: Claim Date Decimal Instrument Observable - acquisitionTime : Date - where - signatory fromList [bearer, counterparty] - - -- Create dummy contracts to settle 'current' claims - choice Clear : [ContractId ProposeSettlement] - controller bearer - -- CLAIMS_LIFECYCLE_TEST_BEGIN - do - t <- toDateUTC <$> getTime - let - getSpotRate isin t = do - (_, Quote{close}) <- fetchByKey (isin, t, bearer) - pure close - lifecycleResult <- Lifecycle.lifecycle getSpotRate claims acquisitionTime t - -- CLAIMS_LIFECYCLE_TEST_END - settlements <- forA lifecycleResult.pending \pending -> - create ProposeSettlement with - payer = counterparty - receiver = bearer - instrument = pending.asset - quantity = pending.amount - tradeDate = pending.t - create this with claims = lifecycleResult.remaining - pure settlements - --- Dummy contract to propose settlement -template ProposeSettlement - with - payer: Party - receiver: Party - quantity: Decimal - instrument: Instrument - tradeDate : Date - where - signatory payer, receiver - - choice Confirm : () - controller receiver - do - debug $ "Settled: " <> show this - pure () diff --git a/src/test/daml/ContingentClaims/Test/Initialization.daml b/src/test/daml/ContingentClaims/Test/Initialization.daml deleted file mode 100644 index 97511762f..000000000 --- a/src/test/daml/ContingentClaims/Test/Initialization.daml +++ /dev/null @@ -1,25 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Test.Initialization where - -import ContingentClaims.Core.V3.Builders -import ContingentClaims.Core.V3.Claim -import ContingentClaims.Test.FinancialContract -import DA.Date (Month(..), date, toDateUTC) -import DA.Time (time) -import Daml.Script - -createContracts = script do - let - now = time (date 2020 Dec 9) 13 20 30 - today = toDateUTC now - setTime now - buyer <- allocatePartyByHint (PartyIdHint "Buyer") - -- vod_l <- submit buyer . createCmd $ Quote "GB00BH4HKS39" (date 2021 Feb 8) 127.36 buyer - let - mkContract t c = submit buyer . createCmd $ - FinancialContract with bearer = buyer; counterparty = buyer; claims = c; acquisitionTime = t - mkContract today $ zcb (date 2021 Mar 3) 3400.0 "USD" - mkContract today $ fixed 100.0 4.0 "GBP" (unrollDates 2021 2025 [Jan, Aug] 5) - mkContract today $ european (date 2021 Feb 8) (one "GB00BH4HKS39") diff --git a/src/test/daml/ContingentClaims/Test/Lifecycle.daml b/src/test/daml/ContingentClaims/Test/Lifecycle.daml deleted file mode 100644 index 60d220813..000000000 --- a/src/test/daml/ContingentClaims/Test/Lifecycle.daml +++ /dev/null @@ -1,576 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Test.Lifecycle where - -import ContingentClaims.Core.V3.Builders (american, european, fixed) -import ContingentClaims.Core.V3.Claim (Inequality(..), and, anytime, at, cond, give, one, or, scale, until, when, zero, (<=)) -import ContingentClaims.Core.V3.Internal.Claim (Claim(..), ClaimF(..)) -import ContingentClaims.Core.V3.Observation qualified as O -import ContingentClaims.Core.V3.Util.Recursion (apoM) -import ContingentClaims.Lifecycle.V3.Lifecycle qualified as Lifecycle -import DA.Assert ((===)) -import DA.Date (Month(..), date, toDateUTC, toGregorian) -import DA.Time (time) -import DA.Tuple (thd3) -import Daml.Control.Arrow ((&&&)) -import Daml.Control.Monad.Trans.Writer (runWriterT) -import Daml.Control.Recursion (apo, embed, project) -import Daml.Script -import Prelude hiding (and, or, zero, (<=)) - -type C = Claim Date Decimal Text Text -type F = ClaimF Date Decimal Text Text - --- | Assets -a : Text -b : Text -c : Text -[a, b, c] = ["a", "b", "c"] - --- | Dates (t0 < t1 < t2) -t0 : Date -t0 = date 1970 Jan 1 -t1 : Date -t1 = succ t0 -t2 : Date -t2 = succ t1 - --- | Observations -two : O.Observation t Decimal o -two = O.pure 2.0 - --- | Functions performing observations -observe25 : Text -> Date -> Script Decimal -observe25 = const . const . pure $ 25.0 -observeDayOfMonth : Applicative f => p -> Date -> f Decimal -observeDayOfMonth _ d = pure . intToDecimal . thd3 . toGregorian $ d - --- | Inequalities -false : Inequality Date x o -false = TimeGte $ date 3000 Jan 1 -true : Inequality Date x o -true = TimeGte $ date 1970 Jan 1 - --- | Helper functions -getDate : Script Date -getDate = toDateUTC <$> getTime -setDate : Date -> Script () -setDate = setTime . midnight where midnight d = time d 0 0 0 - --- | This test marks leaves (i.e. `one`/`zero`) with `acquired` if they were reached. -testAcquire : Script () -testAcquire = script do - let - acquiredF asset = OneF $ "acquired " <> asset - acquired asset : C = embed $ acquiredF asset - g c acqTime t0 = - apoM coalg (acqTime, c) - where - coalg = fmap process . (Lifecycle.acquire' observe25 t0) - process (OneF asset) = acquiredF asset - process ZeroF = acquiredF "0" - process other = other - - -- One - res <- g (one a) t0 t0 - res === acquired a - - -- Zero - res <- g zero t0 t1 - res === acquired "0" - - -- When - res <- g (when (TimeGte t1) (one a)) t0 t0 - res === when (TimeGte t1) (one a) - - res <- g (when (TimeGte t0) (when (TimeGte t1) (one a))) t0 t1 - res === when (TimeGte t0) (when (TimeGte t1) (acquired a)) - - res <- g (when (TimeGte t1) (when (TimeLte t0) (one a))) t0 t1 - res === when (TimeGte t1) (when (TimeLte t0) (one a)) - - res <- g (when (TimeLte t0) (one a)) t0 t1 - res === when (TimeLte t0) (acquired a) - -- ^ acquisition date is taken into account rather than lifecycle date - - -- When + Scale - res <- g (when (at t1) $ scale two (one a)) t0 t0 - res === when (at t1) (scale two (one a)) - - res <- g (when (at t1) $ scale two (one a)) t0 t1 - res === when (at t1) (scale two (acquired a)) - - res <- g (cond (at t1) (one a) (one b)) t0 t0 - res === cond (at t1) (one a) (acquired b) - - res <- g (cond (at t1) (one a) (one b)) t1 t1 - res === cond (at t1) (acquired a) (one b) - - res <- g (when (TimeGte t0) (when (TimeGte t1) (one a))) t0 t1 - res === when (TimeGte t0) (when (TimeGte t1) (acquired a)) - - -- Or - res <- g (("a", one a) `or` ("b", one b)) t0 t0 - res === ("a", acquired a) `or` ("b", acquired b) - - -- Anytime - res <- g (anytime true "a" (one a)) t0 t0 - res === anytime true "a" (acquired a) - - res <- g (anytime false "a" (one a)) t0 t0 - res === anytime false "a" (one a) - - -- Until - res <- g (until false (one a)) t0 t0 - res === until false (acquired a) - - res <- g (until true (one a)) t0 t0 - res === until true (one a) - - res <- g (until (TimeLte t0) (one a)) t0 t1 - res === until (TimeLte t0) (one a) - -- ^ acquisition date is taken into account rather than lifecycle date - --- | Expire sub-trees that cannot be acquired. -testExpire : Script () -testExpire = script do - let - g c acqTime t0 = - apoM coalg (acqTime, c) - where - coalg = fmap Lifecycle.expire' <$> Lifecycle.acquire' observe25 t0 - - -- 1. contract acquired too late is worthless - res <- g (when (TimeGte t1) (when (TimeLte t0) (one a))) t0 t1 - res === when (TimeGte t1) zero - - -- 2. non-acquired branches of `Cond` nodes are replaced with `Zero` - res <- g (cond (at t1) (one a) (one b)) t0 t0 - res === cond (at t1) zero (one b) - - res <- g (cond (at t1) (one a) (one b)) t1 t1 - res === cond (at t1) (one a) zero - - -- 3. contract acquired after exercise window has ended is worthless - res <- g (anytime (TimeLte t0) "a" (one a)) t1 t1 - res === zero - - -- 3. contract lifecycled after exercise window has ended is worthless - res <- g (anytime (TimeLte t0) "a" (one a)) t0 t1 - res === zero - - -- 4. sub-trees of `Until` where the predicate is `True` are worthless - res <- g (until true (one a)) t0 t0 - res === zero - - -- 4a. acquisition date is taken into account rather than lifecycle date - res <- g (until (TimeLte t0) (one a)) t0 t1 - res === zero - --- | Replace acquired `When pred c` nodes with `When (TimeGte t) c` when the predicate is --- non-deterministic. In this context, "non-deterministic" means that the predicate is of the form --- `o1 <= o2` for a pair of observations `o1, o2`. -testFixAcquisitionTime : Script () -testFixAcquisitionTime = script do - let - g c acqTime t0 = - apoM coalg (acqTime, c) - where - coalg = fmap Lifecycle.fixAcquisitionTime' <$> Lifecycle.acquire' observe25 t0 - o1 = O.pure 1.0 - o2 = O.pure 2.0 - - res <- g (when (o1 <= o2) (one a)) t0 t1 - res === when (TimeGte t1) (one a) - - res <- g (when (o2 <= o1) (one a)) t0 t1 - res === when (o2 <= o1) (one a) - --- | This test replaces all leaves with zeros, logging their qty/asset pair into a `Writer`. --- It ignores `when/cond` nodes altogether. -testSettle : Script () -testSettle = script do - let - f = fmap (uncurry $ flip Lifecycle.Result) - . runWriterT - . apoM coalg - . (1.0, ) - where - coalg = (Lifecycle.lifecycle' observe25) . process - process = fmap ( Prelude.fst &&& acquired) - -- process the input so that lifecycle' <<< process is a co-algebra that can be used for - -- testing - acquired (t, c) = Right . (t, ) <$> project c -- map a claim to an acquired claim - - Lifecycle.Result{pending, remaining} <- f (t0, scale two zero) - remaining === (scale two zero : C) - pending === [] - - Lifecycle.Result{pending, remaining} <- f (t0, scale two (one a)) - remaining === scale two zero - pending === [Lifecycle.Pending t0 2.0 a] - - Lifecycle.Result{pending, remaining} <- f (t0, give (one a)) - remaining === give zero - pending === [Lifecycle.Pending t0 (-1.0) a] - - Lifecycle.Result{pending, remaining} <- f (t0, scale two (one a `and` one b)) - -- using the explicit constructor because the smart constructor reduces this to `Zero` - remaining === scale two (zero `And` zero $ []) - pending === [Lifecycle.Pending t0 2.0 a, Lifecycle.Pending t0 2.0 b] - - Lifecycle.Result{pending, remaining} <- f (t0, scale two (one a) `and` scale two (one b)) - remaining === scale two zero `and` scale two zero - pending === [Lifecycle.Pending t0 2.0 a, Lifecycle.Pending t0 2.0 b] - - -- This is a case we don't hit in practice, as it is prevented from acquire' - Lifecycle.Result{pending, remaining} <- f (t0, when false (one a)) - remaining === when false zero - pending === [Lifecycle.Pending t0 1.0 a] - - Lifecycle.Result{pending, remaining} <- f (t0, anytime true "a" (one a)) - remaining === anytime true "a" (one a) - pending === [] - - -- There is no need to test what happens with `Cond` nodes, because lifecycle' is always used in - -- combination with acquire' (which consume `Cond` nodes) - - pure () - --- | Replace any `or/anytime` nodes with the elections that have been made. -testExercise : Script () -testExercise = script do - let - acquired (t, c) = Right . (t, ) <$> project c -- map a claim to an acquired claim - -- process the input so that exercise' <<< process is a co-algebra that can be used for testing - process = fmap (Prelude.fst &&& acquired) - coalg election t0 = (Lifecycle.exercise' election t0) . process - f election = apo (coalg election t0) . (True, ) - - -- Or - - let c1 = ("a", one a) `or` ("b", one b) - - let rem = f (True, "a") (t0, c1) - rem === (one a : C) - - let rem = f (True, "b") (t0, c1) - rem === one b - - let rem = f (True, "c") (t0, c1) - rem === c1 - - -- wrong `Or` election date - let rem = apo (coalg (True, "a") t1) . (True, ) . (t0, ) $ c1 - rem === c1 - - -- Anytime - let c2 = anytime true "a" $ one a - - let rem = f (True, "a") (t0, c2) - rem === When (TimeGte t0) (one a) - - -- below conditions are handled by the `Lifecyle.acquire'` function, so in practice we should - -- never hit this case - let rem = f (True, "a") (t0, anytime false "a" $ one a) - rem === When (TimeGte t0) (one a) - - let rem = f (True, "b") (t0, c2) - rem === c2 - - -- nested choice: the outer one must be exercised before the inner! - let rem = f (True, "a") (t0, anytime true "Outer tag" $ c2) - rem === (anytime true "Outer tag" c2) - - -- wrong `Anytime` election date - -- This case should never happen in practice as it is prevented by acquire' - let rem = apo (coalg (True, "a") t1) . (True, ) . (t0, ) $ c2 - rem === c2 - - -- "Ambiguous" case, tag matches exclusive sub-trees: - -- we follow the traversal order - let rem = f (True, "x") (t0, ("x", one a) `or` ("x", one b)) - rem === one a - - -- "Ambiguous" case, tag matches an acquired election on different nodes: - -- election is applied to both nodes - let rem = f (True, "a") (t0, c1 `and` c1) - rem === one a `and` one a - pure () - -testgiveExercise : Script () -testgiveExercise = script do - let - f election = apo (coalg election t0) . (True, ) - where - coalg election t0 = (Lifecycle.exercise' election t0) . (fmap ( Prelude.fst &&& acquired)) - acquired (t, c) = Right . (t, ) <$> project c -- map a claim to an acquired claim - - let - c = anytime true "a" $ one a - rem = f (False, "a") (t0, c) - expected : C = c - rem === expected - - let - rem = f (False, "a") (t0, give c) - expected : C = give (When (TimeGte t0) (one a)) - rem === expected - - let - rem = f (True, "a") (t0, give . give $ c) - expected : C = give (give (When (TimeGte t0) (one a))) - rem === expected - --- | Lifecycle a bond with three fixing dates (mocked time version) -testBond : Script () -testBond = script do - let - principal = 1_000.0 - coupon = principal * 0.015 - a = "BondHolder" -- replace with actual party if needed - t0 = date 2024 Jan 15 - t1 = date 2024 Jul 15 - t2 = date 2025 Jan 15 - bond = fixed principal coupon a - - -- Simulate lifecycle at t0 - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 (bond [t0, t1, t2]) t0 t0 - remaining === bond [t1, t2] - pending === [Lifecycle.Pending t0 coupon a] - - -- Simulate lifecycle at t1 - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 remaining t0 t1 - remaining === bond [t2] - pending === [Lifecycle.Pending t1 coupon a] - - -- Check bond coupon doesn't get processed twice - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 remaining t0 t1 - remaining === bond [t2] - pending === [] - - -- Simulate lifecycle at t2 (maturity) - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 remaining t0 t2 - remaining === zero - pending === [Lifecycle.Pending t2 coupon a, Lifecycle.Pending t2 principal a] - - pure () - - --- | Test a European call option lifecycle with mocked time (no ledger time effects) -testEuropeanCall : Script () -testEuropeanCall = script do - let - strike = 23.0 - a = "OptionHolder" -- Replace with actual party or variable if needed - t0 = date 2024 Jan 15 - t1 = date 2025 Jan 15 - payoff = scale (O.observe "spot" - O.pure strike) (one a) - option = european t1 payoff - bearer = True - - -- Before maturity (simulated t = t0) - let t = t0 - - -- Exercise is a no-op - remaining <- Lifecycle.exercise observe25 (bearer, "EXERCISE") option t0 t - remaining === option - - -- Settlement is also a no-op before maturity - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 option t0 t - remaining === option - pending === [] - - -- At maturity (simulated t = t1) - let t = t1 - - -- Exercise at maturity - remaining <- Lifecycle.exercise observe25 (bearer, "EXERCISE") option t0 t - remaining === when (at t1) payoff - - -- Lifecycle at maturity — should produce pending payoff - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 remaining t0 t - remaining === zero - pending === [Lifecycle.Pending t 2.0 a] - - pure () - - --- | Test for an American option (mocked time version). --- The contract is acquired at time `t0` and can be exercised between `t1` and `t2`. -testAmericanPut : Script () -testAmericanPut = script do - let - strike = 30.0 - a = "OptionHolder" -- replace with actual party if available - t0 = date 2024 Jan 15 - t1 = date 2024 Jul 15 - t2 = date 2025 Jan 15 - payoff = scale (O.pure strike - O.observe "spot") (one a) - option = american t1 t2 payoff - bearer = True - - -- Scenario 1) Before knock-in (t = t0) - let t = t0 - - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 option t0 t - remaining === option - pending === [] - - remaining <- Lifecycle.exercise observe25 (bearer, "EXERCISE") remaining t0 t - remaining === option -- not in acquisition range yet - - - -- Scenario 2) In acquisition range (t = t1) - let t = t1 - - -- Settlement before exercise is a no-op - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 option t0 t - remaining === option - pending === [] - - -- Exercise “anytime” - remaining <- Lifecycle.exercise observe25 (bearer, "EXERCISE") option t0 t - remaining === when (TimeGte t1) (when (TimeGte t1) payoff) - - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 remaining t0 t - remaining === zero - pending === [Lifecycle.Pending t 5.0 a] - - - -- Scenario 3) At maturity (t = t2) - let t = t2 - - -- Settlement before exercise has been done is a no-op - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 option t0 t - remaining === option - pending === [] - - -- Exercise “anytime” - remaining <- Lifecycle.exercise observe25 (bearer, "EXERCISE") option t0 t - remaining === when (TimeGte t1) (when (TimeGte t2) payoff) - - -- Claim payment - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 remaining t0 t - remaining === zero - pending === [Lifecycle.Pending t 5.0 a] - - - -- Scenario 4) After expiration (t = succ t2) - let t = succ t2 - - remaining <- Lifecycle.exercise observe25 (bearer, "EXERCISE") option t0 t - remaining === option -- past maturity; no exercise possible - - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observe25 option t0 t - remaining === zero -- past maturity; contract is now worthless - pending === [] - - pure () - --- | Ensure that acquisition time is propagated correctly (deterministic time). -testFloatingRateNote : Script () -testFloatingRateNote = script do - let - acquisitionDate = date 2022 Mar 01 - fixingDate = date 2022 Mar 05 - paymentDate = date 2022 Mar 10 - - -- Floating Rate Note written using nested `When` nodes - frn1 = when (TimeGte fixingDate) $ scale (O.Observe a) $ when (TimeGte paymentDate) $ one b - - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn1 acquisitionDate $ date 2022 Feb 28 - remaining === frn1 - - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn1 acquisitionDate $ date 2022 Mar 07 - remaining === frn1 - - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn1 acquisitionDate $ date 2022 Mar 10 - remaining === Zero - pending === [Lifecycle.Pending (date 2022 Mar 10) 5.0 b] - - -- The same FRN, written using `ObserveAt` - let frn2 = when (TimeGte paymentDate) $ scale (O.ObserveAt a fixingDate) $ One b - - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn2 acquisitionDate $ date 2022 Feb 28 - remaining === frn2 - - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn2 acquisitionDate $ date 2022 Mar 07 - remaining === frn2 - - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn2 acquisitionDate $ date 2022 Mar 10 - remaining === Zero - pending === [Lifecycle.Pending (date 2022 Mar 10) 5.0 b] - - pure () - --- | Ensure that acquisition time is propagated correctly (stochastic time) -testKnockOutBarrier : Script () -testKnockOutBarrier = script do - let - start = date 2022 Mar 01 - inequality = O.Const 25.0 <= O.Observe a - innerFrn = Scale (O.Observe a) $ When (TimeGte $ date 2022 Mar 27) $ One b - frn = When (at start) $ When inequality innerFrn - - -- Predicate is False, contract should be unchanged - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn start $ date 2022 Mar 01 - remaining === frn - - -- Predicate becomes True and `When pred` should be replaced by `When (TimeGte τ)` - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth frn start $ date 2022 Mar 25 - remaining === When (at start) (When (TimeGte $ date 2022 Mar 25) innerFrn) - pending === [] - - -- Payment of the correct amount is made on payment date - Lifecycle.Result{pending, remaining} <- - Lifecycle.lifecycle observeDayOfMonth remaining start $ date 2022 Mar 27 - remaining === Zero - pending === [Lifecycle.Pending (date 2022 Mar 27) 25.0 b] - - -- With a stochastic predicate, if we lifecycle too late (e.g. on the 26th rather than on the - -- 25th) we end up with an incorrect claim - wrongLifecycleResult <- Lifecycle.lifecycle observeDayOfMonth frn start $ date 2022 Mar 26 - wrongLifecycleResult.remaining === When (at start) (When (TimeGte $ date 2022 Mar 26) innerFrn) - - pure () - --- | Ensure that `Cond` nodes are lifecycled appropriately -testCondLifecycle : Script () -testCondLifecycle = script do - let - c = When true $ Cond true (One a) (One b) - expected : C = zero - - Lifecycle.Result{pending, remaining} <- Lifecycle.lifecycle observeDayOfMonth c t0 t0 - remaining === expected - pending === [Lifecycle.Pending t0 1.0 a] - - pure () - --- | Ensure that `Until` nodes are lifecycled appropriately -testUntilNodes : Script () -testUntilNodes = script do - let - payment = When (TimeGte t1) (One "EUR") - claim = - Until (TimeGte t1) $ payment - - Lifecycle.Result{pending; remaining} <- Lifecycle.lifecycle observe25 claim t0 t0 - pending === [] - remaining === claim - - Lifecycle.Result{pending; remaining} <- Lifecycle.lifecycle observe25 claim t0 t1 - pending === [] - remaining === zero - - pure () diff --git a/src/test/daml/ContingentClaims/Test/Pricing.daml b/src/test/daml/ContingentClaims/Test/Pricing.daml deleted file mode 100644 index accb71588..000000000 --- a/src/test/daml/ContingentClaims/Test/Pricing.daml +++ /dev/null @@ -1,137 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Test.Pricing where - -import ContingentClaims.Core.V3.Builders (european) -import ContingentClaims.Core.V3.Claim (Claim, Inequality(..), anytime, one, scale) -import ContingentClaims.Core.V3.Observation qualified as O -import ContingentClaims.Valuation.V0.MathML qualified as MathML (ToXml, presentation) -import ContingentClaims.Valuation.V0.Stochastic (Expr(..), IsIdentifier(..), Process, fapf, gbm, riskless, unitIdentity) -import DA.Assert ((===)) -import Daml.Control.Recursion (cata) -import Daml.Script -import Prelude hiding (max) - -data Instrument - = USD - | EUR - | AMZN - | APPL - deriving (Show, Eq) - -data Observable - = Spot_AMZN - | Spot_APPL - deriving (Show, Eq) - -spot : Instrument -> Observable -spot AMZN = Spot_AMZN -spot APPL = Spot_APPL -spot other = error $ "disc: " <> show other - -call : Instrument -> Decimal -> Instrument -> Claim t Decimal Instrument Observable -call s k a = scale (O.observe (spot s) - O.pure k) $ one a - -margrabe : Additive x => Instrument -> Instrument -> a -> Claim t x a Observable -margrabe s1 s2 a = scale (O.observe (spot s1) - O.observe (spot s2)) $ one a - -disc : Instrument -> Process Text -disc USD = riskless "r_USD" -disc EUR = riskless "r_EUR" -disc other = error $ "disc: " <> show other - -val : Observable -> Process Text -val Spot_AMZN = gbm "μ_AMZN" "σ_AMZN" -val Spot_APPL = gbm "μ_APPL" "σ_APPL" - -exch : (Show a1, Show a2) => a1 -> a2 -> a3 -exch a a' = error $ "exch: " <> show a <> "/" <> show a' - -t : Text -t = "t" -- today -t' : Text -t' = "T" -- maturity - -instance IsIdentifier Text where - localVar i = "τ_" <> show i - -instance Additive (Expr t) where - x + y = Sum [x, y] - negate = Neg - aunit = Const 0.0 - -instance Multiplicative (Expr t) where - (*) = curry Mul - x ^ y = curry Pow x $ Const (intToDecimal y) - munit = Const 1.0 - -instance Divisible (Expr t) where - x / y = curry Mul x . curry Pow y . Neg . Const $ 1.0 - -instance Number (Expr t) where - -max : Expr t -> Expr t -> Expr t -max x y = I (x, y) * x + I (y, x) * y - --- This is needed because scale x (one USD) = x * 1.0. It would make writing the expressions by hand --- tedious -multIdentity : Expr Text -> Expr Text -multIdentity = cata unitIdentity - --- Helper to compare the output in XML format (paste this into a browser) -print : (Action m, MathML.ToXml a) => a -> a -> m () -print f e = do - debug $ "Formula:" <> prnt f - debug $ "Expected:" <> prnt e - where prnt = show . MathML.presentation - -valueCall : Script () -valueCall = script do - let - formula = fapf USD disc exch val t $ european t' (call AMZN 3300.0 USD) - s = Proc "Spot_AMZN" (val Spot_AMZN) - k = Const 3300.0 - usd = Proc "USD" (disc USD) - expect = usd t * E (max (s t' - k) aunit / usd t') t - print formula expect - multIdentity formula === expect - -valueMargrabe : Script () -valueMargrabe = script do - let - formula = fapf USD disc exch val t $ european t' (margrabe AMZN APPL USD) - s = Proc "Spot_AMZN" (val Spot_AMZN) - s' = Proc "Spot_APPL" (val Spot_APPL) - usd = Proc "USD" (disc USD) - expect = usd t * E (max (s t' - s' t') aunit / usd t') t - print formula expect - multIdentity formula === expect - --- valueAmerican = script do --- let --- formula = fapf USD disc exch t $ american t t' (call APPL 142.50 USD) --- s = Proc "APPL" (exch APPL USD) --- k = Const 142.50 --- usd = Proc "USD" (disc USD) --- τ = "τ_0" --- expect = Sup t τ (usd t * E (max (s τ - k) aunit * I (Ident τ, Ident t') / usd τ ) t) --- print formula expect --- multIdentity formula === expect - --- Check to see that the subscript numbering works -testMonadicBind : Script () -testMonadicBind = script do - let - τ₀ = "τ_0" - τ₁ = "τ_1" - t₀ = "t_0" - t₁ = "t_1" - usd = Proc "USD" (disc USD) - formula = - fapf USD disc exch val t $ anytime (TimeGte t₀) "Tag" (anytime (TimeGte t₁) "Tag" (one USD)) - expect = - -- note the innermost 1/USD_τ₁ is mult identity - Sup t₀ τ₀ (usd t * E (Sup t₁ τ₁ (usd τ₀ * E (munit / usd τ₁) τ₀) / usd τ₀) t) - print formula expect - multIdentity formula === multIdentity expect diff --git a/src/test/daml/ContingentClaims/Test/Templating.daml b/src/test/daml/ContingentClaims/Test/Templating.daml deleted file mode 100644 index e005d13ec..000000000 --- a/src/test/daml/ContingentClaims/Test/Templating.daml +++ /dev/null @@ -1,50 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This gives an example of how to 'template' claims. --- The basic idea is to store variable names in the 'holes' in the `Observable` leaves; this creates --- a template with placeholders for the actual values we want. We then map these parameters to --- values when we're ready to 'issue' the instrument, using `mapParams`. -module ContingentClaims.Test.Templating where - -import ContingentClaims.Core.V3.Builders (european) -import ContingentClaims.Core.V3.Claim (Inequality(..), mapParams, one, or, scale, when, zero) -import ContingentClaims.Core.V3.Observation qualified as O -import DA.Assert ((===)) -import DA.Date (Month(..), addDays, date, subDate) -import DA.Map qualified as Map -import DA.Optional (fromSomeNote) -import Daml.Script -import Prelude hiding (or, zero) - -instance Additive Text where - aunit = "0" - x + y = x <> "+" <> y - negate x = "-" <> x - -instance Multiplicative Text where - munit = "1" - x * y = x <> "*" <> y - x ^ i = x <> "^" <> show i - -ccy : Text -ccy = "ccy" -usd : Text -usd = "USD" - -demoTemplate : Script () -demoTemplate = script do - let - today = date 2021 Jun 8 - call spot strike = O.observe spot - O.pure strike - aTemplate = european (date 2021 Jul 15 `subDate` today) (scale (call "s" "k") (one ccy)) - aTemplate === when (TimeGte 37) - (("EXERCISE", scale (O.observe "s" - O.pure "k") (one ccy)) `or` ("EXPIRE", zero)) - let - constants : Map.Map Text Decimal = Map.fromList [("k", 99.8)] - assets : Map.Map Text Text = Map.fromList [(ccy, usd)] - observables : Map.Map Text Text = Map.fromList [("s", "VOD.L")] - get dict k = fromSomeNote ("failed to template " <> k) (Map.lookup k dict) - f = mapParams (`subDate` today) (today `addDays`) (get assets) (get observables) (get constants) - f aTemplate === when (TimeGte $ date 2021 Jul 15) - (("EXERCISE", scale (O.observe "VOD.L" - O.pure 99.8) (one usd)) `or` ("EXPIRE", zero)) diff --git a/src/test/daml/ContingentClaims/Test/Util.daml b/src/test/daml/ContingentClaims/Test/Util.daml deleted file mode 100644 index 1015b3d16..000000000 --- a/src/test/daml/ContingentClaims/Test/Util.daml +++ /dev/null @@ -1,27 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module ContingentClaims.Test.Util where - -import ContingentClaims.Core.V3.Builders (european, forward) -import ContingentClaims.Core.V3.Claim (Claim(..), one, scale) -import ContingentClaims.Core.V3.Observation qualified as O -import ContingentClaims.Lifecycle.V3.Util(expiry, payoffs) -import DA.Assert ((===)) -import DA.Date (Month(..), date) -import Daml.Script - -type C = Claim Date Decimal Text Text - -utils : Script () -utils = script do - let - call : O.Observation Date Decimal Text = O.observe "VOD.L" - O.pure 103.4 - t = date 2021 Jul 30 - multiplier : O.Observation Date Decimal Text = O.pure 50_000.0 - - expiry (european t (scale call $ one "USD")) === Some t - payoffs (european t (scale call $ one "USD")) === [(call, "USD")] - - expiry (forward t multiplier (one "USD")) === Some t - payoffs (forward t multiplier (one "USD")) === [(multiplier, "USD")] diff --git a/src/test/daml/Daml/Finance/Account/Test/Account.daml b/src/test/daml/Daml/Finance/Account/Test/Account.daml deleted file mode 100644 index 8830c66f7..000000000 --- a/src/test/daml/Daml/Finance/Account/Test/Account.daml +++ /dev/null @@ -1,35 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Account.Test.Account where - -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (I, Remove(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, submitExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Script - --- | Test the creation and removal of an account. -test : Script () -test = do - -- Create parties - [custodian, investor] <- createParties ["Custodian", "Investor"] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory custodian [] - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers = mempty - - -- Create account - investorAccount <- Account.createAccount "Default Account" [] accountFactoryCid holdingFactory [] - Account.Owner custodian investor - - -- Remove account - Account.submitExerciseInterfaceByKeyCmd @Account.I [custodian, investor] [] investorAccount - Account.Remove - - pure () diff --git a/src/test/daml/Daml/Finance/Account/Test/Controllers.daml b/src/test/daml/Daml/Finance/Account/Test/Controllers.daml deleted file mode 100644 index 982bd449e..000000000 --- a/src/test/daml/Daml/Finance/Account/Test/Controllers.daml +++ /dev/null @@ -1,130 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Account.Test.Controllers where - -import DA.Map qualified as Map (fromList, toList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.Test.Common (TestInitialState(..), TestParties(..), setupInitialState, setupParties) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Test.Util.Account (ControlledBy(..)) -import Daml.Script - --- | Verify that custodian can transfer (in its sole discretion). -custodianControlled : Script () -custodianControlled = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; publicParty} <- setupParties - let pp = Map.fromList [("PublicParty", Set.singleton publicParty)] - - -- Initialize state - TestInitialState {issuerAccount; investorAccount; issuerHoldingCid} <- setupInitialState - tp - Holding.Factory with - provider = custodian; id = Id "Holding Factory @ custodian"; observers = pp - TransferableFungible - [] - Custodian - - -- Owners can't transfer - submitMustFail (actAs [issuer, investor] <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with actors = Set.singleton issuer; newOwnerAccount = investorAccount - - -- Custodian can transfer - submit (actAs custodian <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with actors = Set.singleton custodian; newOwnerAccount = investorAccount - - pure () - --- | Verify that owner and new owner can transfer jointly. -ownerControlled : Script () -ownerControlled = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; publicParty} <- setupParties - let pp = Map.fromList [("PublicParty", Set.singleton publicParty)] - - -- Initialize state - TestInitialState {issuerAccount; investorAccount; issuerHoldingCid} <- setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers = pp - TransferableFungible - [] - Owner - - -- Custodian can't transfer. - submitMustFail (actAs custodian <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with actors = Set.singleton custodian; newOwnerAccount = investorAccount - - -- Owners can transfer. - submit (actAs [issuer, investor] <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with - actors = Set.fromList [issuer, investor]; newOwnerAccount = investorAccount - - pure () - --- | Verify that owner, custodian, and new owner can transfer jointly. -ownerAndCustodianControlled : Script () -ownerAndCustodianControlled = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; publicParty} <- setupParties - let pp = Map.fromList [("PublicParty", Set.singleton publicParty)] - - -- Initialize state - TestInitialState {issuerAccount; investorAccount; issuerHoldingCid} <- setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers = pp - TransferableFungible - [] - OwnerAndCustodian - - -- Owners can't transfer. - submitMustFail (actAs [issuer, investor] <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with - actors = Set.fromList [issuer, investor]; newOwnerAccount = investorAccount - - -- Custodian can't transfer. - submitMustFail (actAs custodian <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with actors = Set.singleton custodian; newOwnerAccount = investorAccount - - -- Owners and Custodian can transfer. - submit (actAs [custodian, issuer, investor] <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with - actors = Set.fromList [custodian, issuer, investor]; newOwnerAccount = investorAccount - - pure () - --- | Verify that owner can transfer (in its sole discretion). -ownerControlledWithAutoApproval : Script () -ownerControlledWithAutoApproval = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; publicParty} <- setupParties - let pp = Map.fromList [("PublicParty", Set.singleton publicParty)] - - -- Initialize state - TestInitialState {issuerAccount; investorAccount; issuerHoldingCid} <- setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers = pp - TransferableFungible - (Map.toList pp) - OwnerWithAutoApproval - - -- Custodian can't transfer. - submitMustFail (actAs [custodian] <> readAs [publicParty]) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with actors = Set.singleton custodian; newOwnerAccount = investorAccount - - -- Owner can transfer. - submit (actAs issuer <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with actors = Set.singleton issuer; newOwnerAccount = investorAccount - - pure () diff --git a/src/test/daml/Daml/Finance/Account/Test/Lock.daml b/src/test/daml/Daml/Finance/Account/Test/Lock.daml deleted file mode 100644 index 817e080de..000000000 --- a/src/test/daml/Daml/Finance/Account/Test/Lock.daml +++ /dev/null @@ -1,104 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Account.Test.Lock where - -import DA.Set (fromList, insert, singleton, toList) -import Daml.Finance.Holding.Test.Common (TestInitialState(..), TestParties(..), setupInitialState, setupParties) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (Acquire(..), I, LockType(..), Release(..)) -import Daml.Finance.Test.Util.Account qualified as Account (submitExerciseInterfaceByKeyCmd, submitMustFailExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Account qualified as ControlledBy (ControlledBy(..)) -import Daml.Script - --- | Enum indicating to which parties the account is being locked. -data Lockers - = CustodianOnly - | RegulatorOnly - | CustodianAndRegulator - --- | Verify that custodian can lock an account with a party. -lockWith : Lockers -> Bool -> Script () -lockWith f lockOutgoingAccount = script do - -- Create parties. - tp@TestParties{custodian; issuer; investor; regulator} <- setupParties - - -- Initialize state. - TestInitialState {issuerAccount; investorAccount; issuerHoldingCid} <- setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers = mempty - Transferable - [] - ControlledBy.Custodian - let - lockers = case f of - CustodianOnly -> singleton custodian - RegulatorOnly -> singleton regulator - CustodianAndRegulator -> fromList [custodian, regulator] - custodianAndLockers = toList . insert custodian $ lockers - accountToBeFrozen = if lockOutgoingAccount then issuerAccount else investorAccount - context = "Frozen" - - -- Can't acquire lock with no new lockers. - Account.submitMustFailExerciseInterfaceByKeyCmd @Lockable.I [custodian] [] issuerAccount $ - Lockable.Acquire with - newLockers = mempty; context; lockType = Lockable.Semaphore - - -- A third party (here the regulator) can't acquire the lock for itself (even if they would see - -- it). - Account.submitMustFailExerciseInterfaceByKeyCmd @Lockable.I [regulator] [custodian] issuerAccount - $ Lockable.Acquire with - newLockers = singleton regulator; context; lockType = Lockable.Semaphore - - -- Custodian and the lockers can lock the account to the lockers. - Account.submitExerciseInterfaceByKeyCmd @Lockable.I custodianAndLockers [] - accountToBeFrozen $ Lockable.Acquire with - newLockers = lockers; context; lockType = Lockable.Semaphore - - -- They can't lock twice (as locktype is Semaphore). - Account.submitMustFailExerciseInterfaceByKeyCmd @Lockable.I custodianAndLockers [] - accountToBeFrozen $ Lockable.Acquire with - newLockers = lockers; context; lockType = Lockable.Semaphore - - -- Custodian can't transfer (as account is locked). - submitMustFail custodian do - exerciseCmd (coerceInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with - actors = singleton custodian - newOwnerAccount = investorAccount - - -- Lockers can't release the lock using an incorrect context. - Account.submitMustFailExerciseInterfaceByKeyCmd @Lockable.I (toList lockers) [] - accountToBeFrozen $ Lockable.Release with - context = "DifferentContext" - - -- Lockers can release the lock. - Account.submitExerciseInterfaceByKeyCmd @Lockable.I (toList lockers) [] accountToBeFrozen $ - Lockable.Release with context - - -- Custodian can transfer (as account is unlocked). - submit custodian do - exerciseCmd (coerceInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with actors = singleton custodian; newOwnerAccount = investorAccount - - pure () - -test1 : Script () -test1 = lockWith CustodianOnly True - -test2 : Script () -test2 = lockWith CustodianOnly False - -test3 : Script () -test3 = lockWith RegulatorOnly True - -test4 : Script () -test4 = lockWith RegulatorOnly False - -test5 : Script () -test5 = lockWith CustodianAndRegulator True - -test6 : Script () -test6 = lockWith CustodianAndRegulator False diff --git a/src/test/daml/Daml/Finance/Data/Test/DateClock.daml b/src/test/daml/Daml/Finance/Data/Test/DateClock.daml deleted file mode 100644 index 01cccccd7..000000000 --- a/src/test/daml/Daml/Finance/Data/Test/DateClock.daml +++ /dev/null @@ -1,46 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.Test.DateClock where - -import DA.Assert ((===)) -import DA.Date (addDays, toDateUTC) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Time.DateClock qualified as DateClock (DateClock(..), T) -import Daml.Finance.Data.V4.Time.DateClock.Types (Unit(..)) -import Daml.Finance.Interface.Data.V4.Reference.Time qualified as Time (Advance(..), I, Rewind(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..)) -import Daml.Script - -testDateClock : Script () -testDateClock = script do - bank <- allocatePartyByHint (PartyIdHint "Bank") - now <- getTime - - let - dateNow = toDateUTC now - dateClock = DateClock.DateClock with - providers = singleton bank - date = Unit dateNow - id = Id "CLOCK" - description = "Clock" - observers = mempty - - -- test advance - dateClockCid <- toInterfaceContractId @Time.I <$> submit bank do createCmd dateClock - (dateClockCid, _) <- submit bank $ - exerciseCmd dateClockCid Time.Advance with - eventId = Id "T1" - eventDescription = "Time advance" - - Some dateClock <- queryContractId bank $ fromInterfaceContractId @DateClock.T dateClockCid - dateClock.date === Unit (dateNow `addDays` 1) - - -- test rewind - (dateClockCid, _) <- submit bank $ - exerciseCmd dateClockCid Time.Rewind with - eventId = Id "T2" - eventDescription = "Time rewind" - - Some dateClock <- queryContractId bank $ fromInterfaceContractId @DateClock.T dateClockCid - dateClock.date === Unit dateNow diff --git a/src/test/daml/Daml/Finance/Data/Test/HolidayCalendar.daml b/src/test/daml/Daml/Finance/Data/Test/HolidayCalendar.daml deleted file mode 100644 index b3f4c6a55..000000000 --- a/src/test/daml/Daml/Finance/Data/Test/HolidayCalendar.daml +++ /dev/null @@ -1,70 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.Test.HolidayCalendar where - -import DA.Date (DayOfWeek(..), Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (Factory(..)) -import Daml.Finance.Interface.Data.V4.Reference.HolidayCalendar (GetView(..), UpdateCalendar(..)) -import Daml.Finance.Interface.Data.V4.Reference.HolidayCalendar.Factory qualified as HolidayCalendarFactory (Create(..), I) -import Daml.Finance.Interface.Types.Date.V3.Calendar (HolidayCalendarData(..)) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Script - --- | Test holiday calendars by a reference data provider. -testHolidayCalendar : Script () -testHolidayCalendar = script do - [reuters, publicParty] <- createParties ["Reuters", "PublicParty"] - - let - calendar = HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [date 2018 Jan 02, date 2018 Jan 31, date 2018 Feb 1] - observers = [("PublicParty", singleton publicParty)] - - -- Reuters defines the USNY holiday calendar - -- Create calendar via factory - calendarFactoryCid <- toInterfaceContractId @HolidayCalendarFactory.I <$> submit reuters do - createCmd Factory with provider = reuters; observers = mempty - - usnyCalendarCid <- submit reuters do - exerciseCmd calendarFactoryCid HolidayCalendarFactory.Create with - provider = reuters - calendar - observers = Map.fromList observers - - -- Retrieve the calendar view from the ledger - usnyCalendarView <- submit reuters do exerciseCmd usnyCalendarCid GetView with viewer = reuters - - -- Define a new calendar locally - let - cal2 = HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [date 2018 Jan 02] - - -- Ensure that publicParty cannot update the calendar - submitMustFail publicParty do - exerciseCmd usnyCalendarCid UpdateCalendar with - newCalendar = cal2 - - -- Reuters updates the USNY calendar - usnyCalendarCid2 <- submit reuters do - exerciseCmd usnyCalendarCid UpdateCalendar with - newCalendar = cal2 - - -- Retrieve the updated calendar from the ledger - usnyCalendarView2 <- submit reuters do exerciseCmd usnyCalendarCid2 GetView with viewer = reuters - - -- Verify that the updated calendar now has different holidays - assertMsg "The calendars should now have different holidays" - $ usnyCalendarView.calendar.holidays /= usnyCalendarView2.calendar.holidays - - -- Archive calendar - submit reuters do - archiveCmd calendarFactoryCid - - pure () diff --git a/src/test/daml/Daml/Finance/Data/Test/Observation.daml b/src/test/daml/Daml/Finance/Data/Test/Observation.daml deleted file mode 100644 index 138baf495..000000000 --- a/src/test/daml/Daml/Finance/Data/Test/Observation.daml +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Data.Test.Observation where - -import DA.Assert ((===)) -import DA.Date (Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import DA.Time (time) -import Daml.Finance.Data.V4.Numeric.Observation (Factory(..)) -import Daml.Finance.Interface.Data.V4.Numeric.Observation (GetView(..)) -import Daml.Finance.Interface.Data.V4.Numeric.Observation.Factory qualified as NumbericObservationFactory (Create(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Observable.NumericObservable qualified as NumericObservable (I, Observe(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..)) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Script - --- | Test `Observation`. -testObservation : Script () -testObservation = script do - [reuters, publicParty] <- createParties ["Reuters", "PublicParty"] - - let - toTime d = time d 0 0 0 - observations = Map.fromList $ fmap (\(d, v) -> (toTime d, v)) - [ (date 2019 Jan 16, -0.00311) - , (date 2019 Feb 16, -0.00266) - ] - observers = Map.fromList [("PublicParty", singleton publicParty)] - - -- Create observation via factory - observationFactoryCid <- toInterfaceContractId @NumbericObservationFactory.I <$> submit reuters do - createCmd Factory with provider = reuters; observers - observationCid <- submit reuters do - exerciseCmd observationFactoryCid NumbericObservationFactory.Create with - provider = reuters - observations - observers - id = Id "Observation" - - -- Get view - view <- submit reuters do - exerciseCmd observationCid GetView with viewer = reuters - - view.observations === observations - - -- Observe - o <- submit reuters do - exerciseCmd (toInterfaceContractId @NumericObservable.I observationCid) - NumericObservable.Observe with t = toTime $ date 2019 Jan 16; actors = singleton reuters - - o === -0.00311 - - -- Archive observation - submit reuters do - archiveCmd observationFactoryCid - - pure () diff --git a/src/test/daml/Daml/Finance/Holding/Test/Common.daml b/src/test/daml/Daml/Finance/Holding/Test/Common.daml deleted file mode 100644 index 62879b435..000000000 --- a/src/test/daml/Daml/Finance/Holding/Test/Common.daml +++ /dev/null @@ -1,95 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.Test.Common where - -import Daml.Finance.Interface.Account.V4.Factory qualified as AccountFactory (I) -import Daml.Finance.Interface.Holding.V4.Factory qualified as HoldingFactory (I) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey, HoldingFactoryKey, HoldingStandard, InstrumentKey, Parties) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Parties involved in the initial test state. -data TestParties = TestParties - with - custodian : Party - -- ^ Acts as custodian of holdings. It also acts as depository of the instrument. - issuer : Party - -- ^ Acts as the issuer of the instrument. Is also the initial owner of the holding. - investor : Party - -- ^ Owner of the holding. - locker : Party - -- ^ Locker of the holding. - locker2 : Party - -- ^ Additional lockers of the holding. - regulator : Party - -- ^ Regulator of the market. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- | Initial test state. -data TestInitialState = TestInitialState - with - investorAccount : AccountKey - -- ^ Investor account at the custodian. - issuerAccount : AccountKey - -- ^ Issuer account at the custodian. - instrument : InstrumentKey - -- ^ Key of the instrument. - issuerHoldingCid : ContractId Api.HoldingV1.Holding - -- ^ Initial holding of the issuer. - accountFactoryCid : ContractId AccountFactory.I - -- ^ Account factory of the custodian. - holdingFactory : HoldingFactoryKey - -- ^ Holding factory of the custodian. - --- | Setup test parties. -setupParties : Script TestParties -setupParties = do - -- Create parties - [custodian, issuer, investor, locker, locker2, regulator, publicParty] <- createParties - ["Custodian", "Issuer", "Investor", "Locker", "Locker2", "regulator", "PublicParty"] - pure TestParties{..} - --- | Setup test initial state. -setupInitialState : - ( HasToInterface a HoldingFactory.I - , HasSignatory a - , HasObserver a - , HasEnsure a - , HasCreate a - , HasFetch a - , HasArchive a - , HasTemplateTypeRep a - , HasToAnyTemplate a - , HasFromAnyTemplate a - ) - => TestParties -> a -> HoldingStandard -> [(Text, Parties)] - -> Account.ControlledBy -> Script (TestInitialState) -setupInitialState (tp : TestParties) (holdingFactory : a) holdingStandard accountObservers - controlledBy = do - let TestParties{..} = tp - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory custodian [] - - -- Create holding factory - holdingFactory <- createHoldingFactory holdingFactory - - -- Create account - [issuerAccount, investorAccount] <- - mapA (Account.createAccount "Default Account" [] accountFactoryCid holdingFactory - accountObservers controlledBy custodian) [issuer, investor] - - -- Originate instrument - now <- getTime - instrument <- originate custodian issuer "ABC.DE" holdingStandard "Stock" [] now - - -- Credit asset - issuerHoldingCid <- Account.credit [] instrument 1_000.0 issuerAccount - - pure TestInitialState{..} diff --git a/src/test/daml/Daml/Finance/Holding/Test/Transfer.daml b/src/test/daml/Daml/Finance/Holding/Test/Transfer.daml deleted file mode 100644 index ed4d46053..000000000 --- a/src/test/daml/Daml/Finance/Holding/Test/Transfer.daml +++ /dev/null @@ -1,149 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.Test.Transfer where - -import DA.Action (foldlA) -import DA.Assert ((===)) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton, toList) -import Daml.Finance.Holding.Test.Common (TestInitialState(..), TestParties(..), setupInitialState, setupParties) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (Acquire(..), GetView(..), I, LockType(..), Release(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..)) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Test transfer and preservation of locks. -testTransfer : Bool -> Script () -testTransfer useReentrantLockTransferService = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; locker; publicParty} <- setupParties - - -- Initialize state - let pp = Map.fromList [("PublicParty", Set.singleton publicParty)] - TestInitialState {issuerAccount; issuerHoldingCid; investorAccount} <- setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers = pp - Transferable - [] - Account.Owner - - -- Lock asset (with 2 contexts) - let lockableCid = coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid - - lockableCid <- submit [issuer, locker] do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = Set.singleton locker; context = "C1"; lockType = Lockable.Reentrant - - lockableCid <- submit [issuer, locker] do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = Set.singleton locker; context = "C2"; lockType = Lockable.Reentrant - - lockableCid <- if useReentrantLockTransferService then - do - -- Create re-entrant lock transfer service - reentrantTransferUtilityCid <- submit [custodian, issuer, investor, locker] do - createCmd ReentrantLockTransferService with - custodian - locker - observers = [issuer, investor] - - -- Transfer with re-entrant locks - transferableCid <- submit (actAs [issuer, investor, locker] <> readAs publicParty) do - exerciseCmd reentrantTransferUtilityCid TransferWithLocks with - sender = issuer - receiverAccount = investorAccount - transferableCid = fromInterfaceContractId @Transferable.I lockableCid - - pure $ toInterfaceContractId @Lockable.I transferableCid - else - do - -- Transfer - submitMustFail (actAs [issuer, investor, locker] <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I lockableCid) Transferable.Transfer with - actors = Set.fromList [issuer, investor, locker]; newOwnerAccount = investorAccount - - -- Unlock - lockableCid <- submit locker do - exerciseCmd lockableCid Lockable.Release with - context = "C1" - lockableCid <- submit locker do - exerciseCmd lockableCid Lockable.Release with - context = "C2" - - -- Transfer - newTransferableCid <- submit (actAs [issuer, investor] <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I lockableCid) Transferable.Transfer with - actors = Set.fromList [issuer, investor]; newOwnerAccount = investorAccount - - -- Lock asset (using same contexts) - lockableCid <- submit [investor, locker] do - exerciseCmd (toInterfaceContractId @Lockable.I newTransferableCid) Lockable.Acquire with - newLockers = Set.singleton locker; context = "C1"; lockType = Lockable.Reentrant - - submit [investor, locker] do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = Set.singleton locker; context = "C2"; lockType = Lockable.Reentrant - - -- Verify lock is maintained - Some lock <- (.lock) <$> submit locker do - exerciseCmd lockableCid Lockable.GetView with viewer = locker - lock.lockers === Set.singleton locker - lock.context === Set.fromList ["C1", "C2"] - lock.lockType === Lockable.Reentrant - - pure () - --- | Example template with re-entrant lock logic. -template ReentrantLockTransferService - with - custodian : Party - locker : Party - observers : [Party] - where - signatory custodian, locker - observer observers - - nonconsuming choice TransferWithLocks : ContractId Transferable.I - with - sender : Party - receiverAccount : AccountKey - transferableCid : ContractId Transferable.I - controller sender, receiverAccount.owner - do - let lockableCid = toInterfaceContractId @Lockable.I transferableCid - vLockable <- view <$> fetch lockableCid - -- Release all locks - let - releaseAll cid lock = - foldlA (\acc context -> exercise acc Lockable.Release with context) cid - (Set.toList lock.context) - transferableCid <- fromInterfaceContractId @Transferable.I <$> - optional (pure lockableCid) (releaseAll lockableCid) vLockable.lock - -- Transfer - newTransferableCid <- exercise transferableCid - Transferable.Transfer with - actors = Set.fromList [sender, receiverAccount.owner] - newOwnerAccount = receiverAccount - - -- Safely convert - let newLockableCid = toInterfaceContractId @Lockable.I newTransferableCid - -- Reapply locks - let - reapplyLocks cid lock = - foldlA - (\acc context -> exercise acc Lockable.Acquire with - newLockers = lock.lockers; context; lockType = lock.lockType - ) - cid (Set.toList lock.context) - fromInterfaceContractId @Transferable.I <$> - optional (pure newLockableCid) (reapplyLocks newLockableCid) vLockable.lock - -test1 : Script() -test1 = testTransfer True - -test2 : Script() -test2 = testTransfer False diff --git a/src/test/daml/Daml/Finance/Holding/Test/Transferable.daml b/src/test/daml/Daml/Finance/Holding/Test/Transferable.daml deleted file mode 100644 index 0321b33b7..000000000 --- a/src/test/daml/Daml/Finance/Holding/Test/Transferable.daml +++ /dev/null @@ -1,71 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.Test.Transferable where - -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.Test.Common (TestInitialState(..), TestParties(..), setupInitialState, setupParties) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Debit(..), I) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, Split(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (Acquire(..), I, LockType(..), Release(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), submitExerciseInterfaceByKeyCmd, submitMustFailExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerOfHolding) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - -run : Script () -run = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; locker; publicParty} <- setupParties - let observers = Map.fromList [("PublicParty", Set.singleton publicParty)] - - -- Initialize state - TestInitialState {investorAccount; issuerAccount; issuerHoldingCid} <- setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers - Transferable - [] - Account.Owner - - -- Cannot split - submitMustFail (actAs [issuer, investor]) do - exerciseCmd (fromInterfaceContractId @Fungible.I issuerHoldingCid) - Fungible.Split with amounts = [100.0] - - -- Lock asset - let lockableCid = coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid - lockableCid <- submit [issuer, locker] do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = Set.singleton locker; context = "Test Lock"; lockType = Lockable.Semaphore - - -- Cannot transfer - submitMustFail (actAs [issuer, investor]) do - exerciseCmd (fromInterfaceContractId @Transferable.I lockableCid) - Transferable.Transfer with actors = Set.singleton investor; newOwnerAccount = investorAccount - - -- Cannot debit - Account.submitMustFailExerciseInterfaceByKeyCmd @Account.I [custodian, issuer] [] issuerAccount $ - Account.Debit with holdingCid = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid - - -- Unlock asset - lockableCid <- submit locker do - exerciseCmd lockableCid Lockable.Release with context = "Test Lock" - - -- Transfer - transferableCid <- submit (actAs [issuer, investor] <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I lockableCid) - Transferable.Transfer with - actors = Set.fromList [issuer, investor]; newOwnerAccount = investorAccount - - -- Assert state - Holding.verifyOwnerOfHolding [(investor, toInterfaceContractId @Api.HoldingV1.Holding transferableCid)] - - -- Debit asset - Account.submitExerciseInterfaceByKeyCmd @Account.I [custodian, investor] [] investorAccount $ - Account.Debit with holdingCid = toInterfaceContractId @Api.HoldingV1.Holding transferableCid - - pure () diff --git a/src/test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml b/src/test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml deleted file mode 100644 index fe553ff96..000000000 --- a/src/test/daml/Daml/Finance/Holding/Test/TransferableFungible.daml +++ /dev/null @@ -1,198 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.Test.TransferableFungible where - -import DA.Assert ((===)) -import DA.Map qualified as Map (fromList) -import DA.Optional (fromSome) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.Test.Common (TestInitialState(..), TestParties(..), setupInitialState, setupParties) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Holding.V4.TransferableFungible qualified as TransferableFungible (T) -import Daml.Finance.Holding.V4.Util qualified as Fungible (getRestAmount) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Debit(..), I) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, Merge(..), Split(..), SplitResult(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Util.V3.HoldingSplice (getAmount) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Common (verify) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (Acquire(..), I, LockType(..), Release(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), submitExerciseInterfaceByKeyCmd, submitMustFailExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Common (validateAssertionFailure) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerOfHolding) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - -run : Script () -run = script do - -- Create parties - tp@TestParties{custodian; issuer; investor; locker; publicParty} <- setupParties - - -- Initialize state - TestInitialState {investorAccount; issuerAccount; issuerHoldingCid} <- setupInitialState - tp - Holding.Factory with - provider = custodian - id = Id "Holding Factory" - observers = Map.fromList [("PublicParty", Set.singleton publicParty)] - TransferableFungible - [] - Account.Owner - - -- Lock asset - let lockableCid = coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding issuerHoldingCid - lockableCid <- submit [issuer, locker] do - exerciseCmd lockableCid Lockable.Acquire with - newLockers = Set.singleton locker; context = "Test Lock"; lockType = Lockable.Semaphore - - -- Cannot split - submitMustFail issuer do - exerciseCmd (fromInterfaceContractId @Fungible.I (coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid)) Fungible.Split with - amounts = [500.0, 250.0] - - -- Cannot transfer - submitMustFail (actAs [issuer, investor]) do - exerciseCmd (fromInterfaceContractId @Transferable.I (coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid)) - Transferable.Transfer with - actors = Set.fromList [issuer, investor]; newOwnerAccount = investorAccount - - -- Cannot debit - Account.submitMustFailExerciseInterfaceByKeyCmd @Account.I [custodian, issuer] [] issuerAccount $ - Account.Debit with holdingCid = coerceInterfaceContractId @Api.HoldingV1.Holding @Lockable.I lockableCid - - -- Unlock asset - fungibleCid <- fromInterfaceContractId @Fungible.I <$> submit locker do - exerciseCmd lockableCid Lockable.Release with context = "Test Lock" - - -- Attempt to split more than the amount available fails - submitMustFail issuer do - exerciseCmd fungibleCid Fungible.Split with amounts = [1_000.1] - submitMustFail issuer do - exerciseCmd fungibleCid Fungible.Split with amounts = [1_000.0, 0.1] - - -- Attempt to split negative amount fails - submitMustFail issuer do - exerciseCmd fungibleCid Fungible.Split with amounts = [-20.0] - submitMustFail issuer do - exerciseCmd fungibleCid Fungible.Split with amounts = [100.0, -20.0] - submitMustFail issuer do - exerciseCmd fungibleCid Fungible.Split with amounts = [0.0] - - -- Attempt to split with empty list fails - submitMustFail issuer do - exerciseCmd fungibleCid Fungible.Split with amounts = [] - - -- Fungible (before split) - fungible <- fmap (toInterface @Fungible.I . fromSome) <$> - queryContractId @TransferableFungible.T issuer $ fromInterfaceContractId fungibleCid - - -- Split fungible - Fungible.SplitResult [splitCid1, splitCid2] (Some restCid) <- - submit issuer do - exerciseCmd fungibleCid Fungible.Split with amounts = [500.0, 250.0] - - -- Fungibles (after split) - [fungible1, fungible2, rest] <- forA - [splitCid1, splitCid2, restCid] - \cid -> do - Some fungible <- queryContractId @TransferableFungible.T issuer $ fromInterfaceContractId cid - pure $ toInterface @Fungible.I fungible - - -- Test utility function `verifyAmountPreserving` - verifyAmountPreserving [] [] - verifyAmountPreserving [fungible] [fungible1, fungible2, rest] - verifyAmountPreserving - [fungible, fungible] [fungible1, fungible2, rest, fungible1, fungible2, rest] - verifyAmountPreserving [fungible, fungible, fungible] [fungible, fungible, fungible] - validateAssertionFailure (verifyAmountPreserving [fungible, fungible] [fungible]) $ - "Fungible::verifyAmountPreserving - Sum of fungible amounts do not match the expected " <> - "amount. newAmountTotal=2000.0, previousAmountTotal=1000.0" - validateAssertionFailure (verifyAmountPreserving [fungible] []) $ - "Fungible::verifyAmountPreserving - Sum of fungible amounts do not match the expected " <> - "amount. newAmountTotal=1000.0, previousAmountTotal=0.0" - validateAssertionFailure (verifyAmountPreserving [] [fungible]) $ - "Fungible::verifyAmountPreserving - Sum of fungible amounts do not match the expected " <> - "amount. newAmountTotal=0.0, previousAmountTotal=1000.0" - - -- Test utility function `verifySplit` - Fungible.getRestAmount [1.0] 10.0 >>= (Some 9.0 ===) - validateAssertionFailure(Fungible.getRestAmount [1.0, 2.0, 3.0, 4.0] 9.0) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[1.0,2.0,3.0,4.0], splitAmountSum=10.0, currentAmount=9.0" - Fungible.getRestAmount [1.0, 2.0, 3.0, 4.0] 10.0 >>= (None ===) - validateAssertionFailure (Fungible.getRestAmount [1.0, 0.0, 3.0, 4.0] 10.0) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[1.0,0.0,3.0,4.0], splitAmountSum=8.0, currentAmount=10.0" - Fungible.getRestAmount [1.0, 3.0, 4.0] 10.0 >>= (Some 2.0 ===) - Fungible.getRestAmount [1.0, 2.0, 3.0, 4.0] 11.0 >>= (Some 1.0 ===) - validateAssertionFailure (Fungible.getRestAmount [1.0, -2.0, 3.0, 4.0, 2.0] 10.0) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[1.0,-2.0,3.0,4.0,2.0], splitAmountSum=8.0, currentAmount=10.0" - validateAssertionFailure (Fungible.getRestAmount [1.0, 2.0, 30.0, 4.0] 10.0) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[1.0,2.0,30.0,4.0], splitAmountSum=37.0, currentAmount=10.0" - validateAssertionFailure (Fungible.getRestAmount [] 10.0) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[], splitAmountSum=0.0, currentAmount=10.0" - validateAssertionFailure (Fungible.getRestAmount [-1.0] 10.0) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[-1.0], splitAmountSum=-1.0, currentAmount=10.0" - validateAssertionFailure (Fungible.getRestAmount [] 0.0) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[], splitAmountSum=0.0, currentAmount=0.0" - validateAssertionFailure (Fungible.getRestAmount [] (-1.0)) $ - "Fungible::verifySplit - Amounts must be non-empty, strictly positive, and not exceed " <> - "current amount. amounts=[], splitAmountSum=0.0, currentAmount=-1.0" - - -- Attempt to merge with empty list fails - submitMustFail issuer do - exerciseCmd restCid Fungible.Merge with fungibleCids = [] - - -- Attempt to merge with an issuer@issuer holding fails - Some t <- queryContractId issuer $ fromInterfaceContractId @TransferableFungible.T splitCid1 - cid <- toInterfaceContractId @Fungible.I <$> submit issuer do - createCmd t with account = (t.account with custodian = issuer); amount = 1_000_000.0 - submitMustFail issuer do exerciseCmd restCid Fungible.Merge with fungibleCids = [cid] - - -- Merge fungibles - fungibleCid <- submit issuer do - exerciseCmd restCid Fungible.Merge with fungibleCids = [splitCid1, splitCid2] - - -- Fungibles (after merge) - fungible' <- fmap (toInterface @Fungible.I . fromSome) <$> - queryContractId @TransferableFungible.T issuer $ fromInterfaceContractId fungibleCid - verifyAmountPreserving [fungible] [fungible'] - - -- Transfer - let - transferableCid = - fromInterfaceContractId @Transferable.I - (toInterfaceContractId @Api.HoldingV1.Holding fungibleCid) - - transferableCid <- submit (actAs [issuer, investor] <> readAs publicParty) do - exerciseCmd transferableCid - Transferable.Transfer with - actors = Set.fromList [issuer, investor] - newOwnerAccount = investorAccount - - -- Assert state - Holding.verifyOwnerOfHolding [(investor, toInterfaceContractId @Api.HoldingV1.Holding transferableCid)] - - -- Debit asset - Account.submitExerciseInterfaceByKeyCmd @Account.I [custodian, investor] [] investorAccount $ - Account.Debit with holdingCid = toInterfaceContractId transferableCid - - pure () - --- | Verifies that the original amount is preserved after a merge or a split. -verifyAmountPreserving : CanAssert m => [Fungible.I] -> [Fungible.I] -> m () -verifyAmountPreserving newFungibles previousFungibles = do - let - sumAmounts fungibles = sum $ getAmount . toInterface @Api.HoldingV1.Holding <$> fungibles - new = sumAmounts newFungibles - previous = sumAmounts previousFungibles - verify (new == previous) $ "Fungible::" - <> "verifyAmountPreserving - Sum of fungible amounts do not match the expected amount. " - <> "newAmountTotal=" <> show new - <> ", previousAmountTotal=" <> show previous diff --git a/src/test/daml/Daml/Finance/Holding/Test/Upgrade.daml b/src/test/daml/Daml/Finance/Holding/Test/Upgrade.daml deleted file mode 100644 index 6aecbd477..000000000 --- a/src/test/daml/Daml/Finance/Holding/Test/Upgrade.daml +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Holding.Test.Upgrade where - -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import DA.Optional(isSome) -import Daml.Finance.Holding.Test.Common (TestInitialState(..), TestParties(..), setupInitialState, setupParties) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Holding.V4.Transferable qualified as Transferable (T) -import Daml.Finance.Interface.Holding.V4.Factory qualified as HoldingFactory (I, Remove(..)) -import Daml.Finance.Interface.Holding.V4.Transferable qualified as Transferable (I, Transfer(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..)) -import Daml.Finance.Test.Util.HoldingDuplicates.Factory qualified as HoldingNew (Factory(..)) -import Daml.Finance.Test.Util.HoldingDuplicates.Transferable qualified as TransferableNew (T) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory, submitExerciseInterfaceByKeyCmd) -import Daml.Script - -run : Script () -run = do - -- 1. Create parties - tp@TestParties{custodian; issuer; investor; locker; publicParty} <- setupParties - let observers = Map.fromList [("PublicParty", singleton publicParty)] - - -- 2. Initialize state - TestInitialState {investorAccount; issuerAccount; issuerHoldingCid; accountFactoryCid; holdingFactory} <- - setupInitialState - tp - Holding.Factory with provider = custodian; id = Id "Holding Factory"; observers - Transferable - [] - Account.Owner - - -- 3. Remove old holding factory - submitExerciseInterfaceByKeyCmd @HoldingFactory.I [custodian] [] holdingFactory - HoldingFactory.Remove - - -- 4. Check if the old holding still exists - maybeOldHolding <- queryContractId custodian (fromInterfaceContractId @Transferable.T issuerHoldingCid) - - assertMsg - "Old transferable holding not found after factory removal (may be expected if factory removal cascades)." - (isSome maybeOldHolding) - - -- 5. Create the new holding factory - createHoldingFactory $ - HoldingNew.Factory with provider = custodian; id = Id "Holding Factory"; observers - - -- 6. Perform a transfer to self to trigger upgrade - newCid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd (fromInterfaceContractId @Transferable.I issuerHoldingCid) - Transferable.Transfer with - actors = singleton issuer - newOwnerAccount = issuerAccount - - -- 7. Inspect the new upgraded holding - maybeNew <- queryContractId custodian (fromInterfaceContractId @TransferableNew.T newCid) - - assertMsg "New transferable holding not found after upgrade." (isSome maybeNew) - pure () \ No newline at end of file diff --git a/src/test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml b/src/test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml deleted file mode 100644 index a617ed6e5..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Bond/Test/Callable.daml +++ /dev/null @@ -1,1241 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.Test.Callable where - -import DA.Date (DayOfWeek(..), Month(..), date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Bond.Test.Util (originateCallableBond, originateCallableBondMustFail, originateMultiScheduleCallableBond) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (DateRelativeToEnum(..), FloatingRate(..), ReferenceRateTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DateOffset (DateOffset(..), DayTypeEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (electAndVerifyPaymentEffects, ensureElectionNotPossible, lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Finance.Test.Util.Time (createPaymentPeriodicSchedule, createPeriodicSchedule) -import Daml.Script - --- Create and lifecycle a fixed coupon callable bond. -run : Script () -run = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" pp now - - -- Create and distribute bond - -- 1.1% coupon every 12M - -- CREATE_FIXED_CALLABLE_BOND_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstCouponDate = date 2019 May 15 - secondCouponDate = date 2020 May 15 - maturityDate = date 2021 May 15 - maturityDateAdj = date 2021 May 17 - notional = 1.0 - floatingRate = None - couponRate = 0.011 - capRate = None - floorRate = None - couponPeriod = M - couponPeriodMultiplier = 12 - dayCountConvention = Act365Fixed - useAdjustedDatesForDcf = True - businessDayConvention = Following - noticeDays = 0 - -- CREATE_FIXED_CALLABLE_BOND_VARIABLES_END - holidayCalendarIds = ["EUR"] - calendar = - HolidayCalendarData with - id = "EUR" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - bondInstrument <- originateCallableBond issuer issuer "BONDTEST1" TransferableFungible - "Callable Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier cashInstrument notional - noticeDays publicParty - - -- One day before the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstCouponDate 1) bondInstrument issuer [] - - let - amount = 1.0 - electorIsOwner = False - - -- First coupon date: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0035863014 cashInstrument] - (Some bondInstrumentAfterFirstCoupon, effectCid) <- electAndVerifyPaymentEffects firstCouponDate - amount bondInstrument electorIsOwner issuer investor [publicParty] "NOT CALLED" [] - expectedConsumed expectedProduced - - -- Second coupon date: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.011030137 cashInstrument] - (Some bondInstrumentAfterSecondCoupon, effectCid) <- electAndVerifyPaymentEffects - secondCouponDate amount bondInstrumentAfterFirstCoupon electorIsOwner issuer investor - [publicParty] "NOT CALLED" [] expectedConsumed expectedProduced - - -- lifecycle on the maturity date - let - expectedConsumed = [] - expectedProduced = [qty 0.011060274 cashInstrument, qty 1.0 cashInstrument] - bondInstrumentAfterThirdCoupon <- electAndVerifyPaymentEffects maturityDateAdj amount - bondInstrumentAfterSecondCoupon electorIsOwner issuer investor [publicParty] "NOT CALLED" [] - expectedConsumed expectedProduced - - pure () - --- Verify that a callable bond with an invalid schedule fails. -runCallableBondValidationFail : Script () -runCallableBondValidationFail = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" pp now - - -- Create and distribute bond - -- 1.1% coupon every 12M - let - issueDate = date 2019 Jan 16 - firstCouponDateIncorrect = date 2019 May 16 -- This results in a roll convention mismatch - firstCouponDateCorrect = date 2019 May 15 -- This is ok - secondCouponDate = date 2020 May 15 - maturityDate = date 2021 May 15 - maturityDateAdj = date 2021 May 17 - notional = 1.0 - floatingRate = None - couponRate = 0.011 - capRate = None - floorRate = None - couponPeriod = M - couponPeriodMultiplier = 12 - dayCountConvention = Act365Fixed - useAdjustedDatesForDcf = True - businessDayConvention = Following - noticeDays = 0 - holidayCalendarIds = ["EUR"] - calendar = - HolidayCalendarData with - id = "EUR" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - originateCallableBondMustFail issuer issuer "BONDTEST1" TransferableFungible "Callable Bond" pp - now issueDate holidayCalendarIds calendarDataProvider firstCouponDateIncorrect maturityDate - dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate couponRate capRate - floorRate couponPeriod couponPeriodMultiplier cashInstrument notional noticeDays publicParty - - bondInstrument <- originateCallableBond issuer issuer "BONDTEST1" TransferableFungible - "Callable Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDateCorrect - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier cashInstrument notional - noticeDays publicParty - - pure () - --- Create and lifecycle a floating coupon callable bond. --- Issuer calls the bond before maturity. -runFloatingCall : Script () -runFloatingCall = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" pp now - - -- Create and distribute bond - -- Libor + 0.1% coupon every 12M - -- CREATE_12M_FLOATING_CALLABLE_BOND_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstCouponDate = date 2019 May 15 - secondCouponDate = date 2020 May 15 - maturityDate = date 2021 May 15 - maturityDateAdj = date 2021 May 17 - notional = 1.0 - couponRate = 0.001 - capRate = None - floorRate = None - couponPeriod = M - couponPeriodMultiplier = 12 - dayCountConvention = Act365Fixed - useAdjustedDatesForDcf = True - businessDayConvention = Following - referenceRateId = "EUR/EURIBOR/12M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["EUR"] - noticeDays = 0 - -- CREATE_12M_FLOATING_CALLABLE_BOND_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 14, 0.010) - , (dateToDateClockTime $ date 2019 May 13, 0.010) - ] - holidayCalendarIds = ["EUR"] - calendar = - HolidayCalendarData with - id = "EUR" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - bondInstrument <- originateCallableBond issuer issuer "BONDTEST1" TransferableFungible - "Callable Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier cashInstrument notional - noticeDays publicParty - - -- One day before the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstCouponDate 1) bondInstrument issuer - [observableCid] - - let - amount = 1.0 - electorIsOwner = False - - -- First coupon date: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0035863014 cashInstrument] - (Some bondInstrumentAfterFirstCoupon, effectCid) <- electAndVerifyPaymentEffects firstCouponDate - amount bondInstrument electorIsOwner issuer investor [publicParty] "NOT CALLED" [observableCid] - expectedConsumed expectedProduced - - -- Second coupon date: Lifecycle and verify that there is an effect for one coupon. - -- Issuer calls the bond - let - expectedConsumed = [] - expectedProduced = [qty 0.011030137 cashInstrument, qty 1.0 cashInstrument] - (bondInstrumentAfterSecondCoupon, effectCid) <- electAndVerifyPaymentEffects - secondCouponDate amount bondInstrumentAfterFirstCoupon electorIsOwner issuer investor - [publicParty] "CALLED" [observableCid] expectedConsumed expectedProduced - - pure () - --- Create and lifecycle a floating coupon callable bond. --- 2Y, 3M Libor + 0.1% p.a. --- Issuer does not call the bond before maturity. -runFloating : Script () -runFloating = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - -- Libor + 0.1% coupon every 3M - -- CREATE_3M_FLOATING_CALLABLE_BOND_VARIABLES_BEGIN - let - issueDate = date 2022 Jan 15 - firstCouponDate = date 2022 Apr 15 - maturityDate = date 2024 Jan 15 - notional = 1.0 - couponRate = 0.001 - capRate = None - floorRate = None - couponPeriod = M - couponPeriodMultiplier = 3 - dayCountConvention = Act360 - useAdjustedDatesForDcf = True - businessDayConvention = Following - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - noticeDays = 0 - -- CREATE_3M_FLOATING_CALLABLE_BOND_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 13, 0.010) - , (dateToDateClockTime $ date 2022 Apr 13, 0.010) - , (dateToDateClockTime $ date 2022 Jul 13, 0.010) - , (dateToDateClockTime $ date 2022 Oct 13, 0.010) - , (dateToDateClockTime $ date 2023 Jan 12, 0.010) - , (dateToDateClockTime $ date 2023 Apr 13, 0.010) - , (dateToDateClockTime $ date 2023 Jul 13, 0.010) - , (dateToDateClockTime $ date 2023 Oct 12, 0.010) - ] - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - bondInstrument <- originateCallableBond issuer issuer "BONDTEST1" TransferableFungible - "Callable Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier cashInstrument notional - noticeDays publicParty - - -- One day before the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstCouponDate 1) bondInstrument issuer - [observableCid] - - let - amount = 1.0 - electorIsOwner = False - - -- Coupon date 1: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0026888889 cashInstrument] - (Some bondInstrumentAfterCoupon1, effectCid) <- electAndVerifyPaymentEffects (date 2022 Apr 15) - amount bondInstrument electorIsOwner issuer investor [publicParty] "NOT CALLED" [observableCid] - expectedConsumed expectedProduced - - -- Coupon date 2: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon2, effectCid) <- electAndVerifyPaymentEffects (date 2022 Jul 15) - amount bondInstrumentAfterCoupon1 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 3: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0028722222 cashInstrument] - (Some bondInstrumentAfterCoupon3, effectCid) <- electAndVerifyPaymentEffects (date 2022 Oct 17) - amount bondInstrumentAfterCoupon2 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 4: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon4, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jan 16) - amount bondInstrumentAfterCoupon3 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 5: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon5, effectCid) <- electAndVerifyPaymentEffects (date 2023 Apr 17) - amount bondInstrumentAfterCoupon4 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 6: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon6, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jul 17) - amount bondInstrumentAfterCoupon5 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 7: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon7, effectCid) <- electAndVerifyPaymentEffects (date 2023 Oct 16) - amount bondInstrumentAfterCoupon6 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- lifecycle on the maturity date - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument, qty 1.0 cashInstrument] - (Some _, effectCid) <- electAndVerifyPaymentEffects (date 2024 Jan 15) - amount bondInstrumentAfterCoupon7 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - pure () - --- Create and lifecycle a floating coupon callable bond. --- 2Y, 3M Libor + 0.1% p.a. --- cap: 1.5%, floor: 0% --- Issuer does not call the bond before maturity. -runFloatingFloorCap : Script () -runFloatingFloorCap = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - -- CREATE_3M_CAP_FLOOR_FLOATING_CALLABLE_BOND_VARIABLES_BEGIN - -- Libor + 0.1% coupon every 3M (with a 0% floor and a 1.5% cap) - let - issueDate = date 2022 Jan 15 - firstCouponDate = date 2022 Apr 15 - maturityDate = date 2024 Jan 15 - notional = 1.0 - couponRate = 0.001 - capRate = Some 0.015 - floorRate = Some $ 0.0 - couponPeriod = M - couponPeriodMultiplier = 3 - dayCountConvention = Act360 - useAdjustedDatesForDcf = True - businessDayConvention = Following - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - noticeDays = 0 - -- CREATE_3M_CAP_FLOOR_FLOATING_CALLABLE_BOND_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 13, 0.010) - , (dateToDateClockTime $ date 2022 Apr 13, 0.020) - , (dateToDateClockTime $ date 2022 Jul 13, -0.005) - , (dateToDateClockTime $ date 2022 Oct 13, 0.010) - , (dateToDateClockTime $ date 2023 Jan 12, 0.010) - , (dateToDateClockTime $ date 2023 Apr 13, 0.010) - , (dateToDateClockTime $ date 2023 Jul 13, 0.010) - , (dateToDateClockTime $ date 2023 Oct 12, 0.010) - ] - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - bondInstrument <- originateCallableBond issuer issuer "BONDTEST1" TransferableFungible - "Callable Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier cashInstrument notional - noticeDays publicParty - - let - amount = 1.0 - electorIsOwner = False - - -- Coupon date 1: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0026888889 cashInstrument] - (Some bondInstrumentAfterCoupon1, effectCid) <- electAndVerifyPaymentEffects (date 2022 Apr 15) - amount bondInstrument electorIsOwner issuer investor [publicParty] "NOT CALLED" [observableCid] - expectedConsumed expectedProduced - - -- Coupon date 2: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0037916667 cashInstrument] - (Some bondInstrumentAfterCoupon2, effectCid) <- electAndVerifyPaymentEffects (date 2022 Jul 15) - amount bondInstrumentAfterCoupon1 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 3: Lifecycle and verify that there are no effects (0% coupon due to floor) - let - expectedConsumed = [] - expectedProduced = [] - (Some bondInstrumentAfterCoupon3, effectCid) <- electAndVerifyPaymentEffects (date 2022 Oct 17) - amount bondInstrumentAfterCoupon2 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 4: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon4, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jan 16) - amount bondInstrumentAfterCoupon3 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 5: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon5, effectCid) <- electAndVerifyPaymentEffects (date 2023 Apr 17) - amount bondInstrumentAfterCoupon4 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 6: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon6, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jul 17) - amount bondInstrumentAfterCoupon5 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 7: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - (Some bondInstrumentAfterCoupon7, effectCid) <- electAndVerifyPaymentEffects (date 2023 Oct 16) - amount bondInstrumentAfterCoupon6 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- lifecycle on the maturity date - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument, qty 1.0 cashInstrument] - (Some _, effectCid) <- electAndVerifyPaymentEffects (date 2024 Jan 15) - amount bondInstrumentAfterCoupon7 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - pure () - --- Create and lifecycle a floating coupon callable bond. --- 2Y, 3M Libor + 0.1% p.a. --- cap: 1.5%, floor: 0% --- callable on every second coupon date (6M schedule), except the last one (regular maturity date) --- Issuer does not call the bond before maturity. -runFloatingFloorCapCallable6M : Script () -runFloatingFloorCapCallable6M = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - -- CREATE_3M_CAP_FLOOR_FLOATING_6M_CALLABLE_BOND_VARIABLES_BEGIN - -- Libor + 0.1% coupon every 3M (with a 0% floor and a 1.5% cap) - let - rollDay = 15 - issueDate = date 2022 Jan rollDay - firstCouponDate = date 2022 Apr rollDay - maturityDate = date 2024 Jan rollDay - notional = 1.0 - couponRate = 0.001 - capRate = Some 0.015 - floorRate = Some $ 0.0 - couponPeriod = M - couponPeriodMultiplier = 3 - dayCountConvention = Act360 - useAdjustedDatesForDcf = True - businessDayConvention = Following - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - -- CREATE_3M_CAP_FLOOR_FLOATING_6M_CALLABLE_BOND_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 13, 0.010) - , (dateToDateClockTime $ date 2022 Apr 13, 0.020) - , (dateToDateClockTime $ date 2022 Jul 13, -0.005) - , (dateToDateClockTime $ date 2022 Oct 13, 0.010) - , (dateToDateClockTime $ date 2023 Jan 12, 0.010) - , (dateToDateClockTime $ date 2023 Apr 13, 0.010) - , (dateToDateClockTime $ date 2023 Jul 13, 0.010) - , (dateToDateClockTime $ date 2023 Oct 12, 0.010) - ] - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - let - -- CREATE_3M_CAP_FLOOR_FLOATING_6M_CALLABLE_BOND_COUPON_SCHEDULE_BEGIN - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - -- CREATE_3M_CAP_FLOOR_FLOATING_6M_CALLABLE_BOND_COUPON_SCHEDULE_END - - -- CREATE_3M_CAP_FLOOR_FLOATING_6M_CALLABLE_BOND_SCHEDULE_BEGIN - -- Define a schedule for callability. The bond is callable on the *last* date of each schedule - -- period. - -- In this example, it is possible to call the bond every 6M (every second coupon date). - callScheduleStartDate = issueDate - callScheduleEndDate = maturityDate - callPeriod = couponPeriod - callPeriodMultiplier = 6 - callScheduleFirstRegular = None -- Only used in case of an irregular schedule - callSchedule = createPeriodicSchedule callScheduleFirstRegular holidayCalendarIds - businessDayConvention callPeriod callPeriodMultiplier callScheduleStartDate - callScheduleEndDate rollDay - noticeDays = 5 - -- CREATE_3M_CAP_FLOOR_FLOATING_6M_CALLABLE_BOND_SCHEDULE_END - - bondInstrument <- originateMultiScheduleCallableBond issuer issuer "BONDTEST1" - TransferableFungible "Callable Bond" pp now holidayCalendarIds calendarDataProvider - dayCountConvention useAdjustedDatesForDcf floatingRate couponRate capRate floorRate - cashInstrument notional couponSchedule callSchedule noticeDays publicParty - - let - amount = 1.0 - electorIsOwner = False - - -- Coupon date 1 (not a call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0026888889 cashInstrument]; - maybeBondInstrumentAfterCoupon1 <- lifecycleAndVerifyPaymentEffects [publicParty] (date 2022 Apr 15) - bondInstrument issuer [observableCid] expectedConsumed expectedProduced; - - bondInstrumentAfterCoupon1 <- case maybeBondInstrumentAfterCoupon1 of - Some key -> do - pure key - None -> do - pure bondInstrument - - - -- Call date before Coupon date 2: Lifecycle to get the new instrument. - let - expectedConsumed = [] - expectedProduced = [] - (Some bondInstrumentAfterCallDate2, effectCid) <- electAndVerifyPaymentEffects (date 2022 Jul 8) - amount bondInstrumentAfterCoupon1 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 2: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0037916667 cashInstrument] - maybeBondInstrumentAfterCoupon2 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 15) bondInstrumentAfterCallDate2 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon2 <- case maybeBondInstrumentAfterCoupon2 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCallDate2 - - - -- Coupon date 3 (not a call date): Lifecycle and verify that there are no effects (0% coupon due to floor) - let - expectedConsumed = [] - expectedProduced = [] - maybeBondInstrumentAfterCoupon3 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Oct 17) bondInstrumentAfterCoupon2 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon3 <- case maybeBondInstrumentAfterCoupon3 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCoupon2 - - - -- Call date before Coupon date 4: Lifecycle to get the new instrument. - let - expectedConsumed = [] - expectedProduced = [] - (Some bondInstrumentAfterCallDate4, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jan 9) - amount bondInstrumentAfterCoupon3 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 4 (call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - maybeBondInstrumentAfterCoupon4 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jan 16) bondInstrumentAfterCallDate4 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon4 <- case maybeBondInstrumentAfterCoupon4 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCallDate4 - - -- 5 business days before coupon date 5 (not a call date): Try to call the bond and verify that - -- this is not possible. - ensureElectionNotPossible (date 2023 Apr 10) amount bondInstrumentAfterCoupon4 electorIsOwner - issuer investor [publicParty] "CALLED" [observableCid] - - -- Coupon date 5 (not a call date): Try to call the bond and verify that this is not possible. - ensureElectionNotPossible (date 2023 Apr 17) amount bondInstrumentAfterCoupon4 electorIsOwner - issuer investor [publicParty] "CALLED" [observableCid] - - -- Coupon date 5 (not a call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument] - maybeBondInstrumentAfterCoupon5 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Apr 17) bondInstrumentAfterCoupon4 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon5 <- case maybeBondInstrumentAfterCoupon5 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCoupon4 - - -- Coupon date 6 (call date): Call the bond and get the new instrument. - let - expectedConsumed = [] - expectedProduced = [] - (Some bondInstrumentAfterCallDate6, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jul 10) - amount bondInstrumentAfterCoupon5 electorIsOwner issuer investor [publicParty] "CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 6 (call date): Lifecycle one coupon and the early redemption amount. - let - expectedConsumed = [] - expectedProduced = [qty 1.0027805556 cashInstrument] - maybeBondInstrumentAfterCoupon6 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jul 17) bondInstrumentAfterCallDate6 issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon6 <- case maybeBondInstrumentAfterCoupon6 of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCallDate6 - - pure () - --- Create and lifecycle a floating coupon callable bond. --- 6M bond, two coupons: 3M Libor + 0.1% p.a. --- Issuer does not call the bond. -runTwoCoupons : Script () -runTwoCoupons = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - -- Libor + 0.1% coupon every 3M - -- CREATE_3M_FLOATING_CALLABLE_BOND_VARIABLES_BEGIN - let - issueDate = date 2022 Jan 15 - firstCouponDate = date 2022 Apr 15 - maturityDate = date 2022 Jul 15 - notional = 1.0 - couponRate = 0.001 - capRate = None - floorRate = None - couponPeriod = M - couponPeriodMultiplier = 3 - dayCountConvention = Act360 - useAdjustedDatesForDcf = True - businessDayConvention = Following - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - noticeDays = 0 - -- CREATE_3M_FLOATING_CALLABLE_BOND_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 13, 0.010) - , (dateToDateClockTime $ date 2022 Apr 13, 0.010) - ] - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - bondInstrument <- originateCallableBond issuer issuer "BONDTEST1" TransferableFungible - "Callable Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier cashInstrument notional - noticeDays publicParty - - -- One day before the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstCouponDate 1) bondInstrument issuer - [observableCid] - - let - amount = 1.0 - electorIsOwner = False - - -- Coupon date 1: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0026888889 cashInstrument] - (Some bondInstrumentAfterCoupon1, effectCid) <- electAndVerifyPaymentEffects (date 2022 Apr 15) - amount bondInstrument electorIsOwner issuer investor [publicParty] "NOT CALLED" [observableCid] - expectedConsumed expectedProduced - - -- Coupon date 2: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0027805556 cashInstrument, qty 1.0 cashInstrument] - (Some bondInstrumentAfterCoupon2, effectCid) <- electAndVerifyPaymentEffects (date 2022 Jul 15) - amount bondInstrumentAfterCoupon1 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - pure () - --- Create and lifecycle a fixed coupon callable bond. --- 2Y, 4.5% p.a. (Following Unadjusted) --- callable on every coupon date (6M schedule) after 1Y. --- Issuer does not call the bond. -runFixCouponUnadjustedCallable6M : Script () -runFixCouponUnadjustedCallable6M = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - let - rollDay = 15 - issueDate = date 2022 Jan rollDay - firstCouponDate = date 2022 Jul rollDay - maturityDate = date 2024 Jan rollDay - notional = 1000.0 - couponRate = 0.045 - capRate = None - floorRate = None - couponPeriod = M - couponPeriodMultiplier = 6 - dayCountConvention = Basis30360 - useAdjustedDatesForDcf = False - businessDayConvention = Following - floatingRate = None - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - noticeDays = 0 - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - let - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- CREATE_6M_FIXED_COUPON_CALLABLE_BOND_SCHEDULE_BEGIN - -- Define a schedule for callability. The bond is callable on the *last* date of each schedule - -- period. - -- In this example, it is possible to call the bond every 6M, but only starting in the second - -- coupon period (after one year). - callScheduleStartDate = date 2022 Jul rollDay - callScheduleEndDate = date 2023 Jul rollDay - callPeriod = couponPeriod - callPeriodMultiplier = couponPeriodMultiplier - callScheduleFirstRegular = None -- Only used in case of an irregular schedule - callSchedule = createPeriodicSchedule callScheduleFirstRegular holidayCalendarIds - businessDayConvention callPeriod callPeriodMultiplier callScheduleStartDate - callScheduleEndDate rollDay - -- CREATE_6M_FIXED_COUPON_CALLABLE_BOND_SCHEDULE_END - - bondInstrument <- originateMultiScheduleCallableBond issuer issuer "BONDTEST1" - TransferableFungible "Callable Bond" pp now holidayCalendarIds calendarDataProvider - dayCountConvention useAdjustedDatesForDcf floatingRate couponRate capRate floorRate - cashInstrument notional couponSchedule callSchedule noticeDays publicParty - - let - electorIsOwner = False - - -- Coupon date 1 (not a call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 22.5 cashInstrument] - maybeBondInstrumentAfterCoupon1 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 15) bondInstrument issuer [] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon1 <- case maybeBondInstrumentAfterCoupon1 of - Some key -> do - pure key - None -> do - pure bondInstrument - - -- Coupon date 2 (call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 22.5 cashInstrument] - (Some bondInstrumentAfterCoupon2, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jan 16) - notional bondInstrumentAfterCoupon1 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [] expectedConsumed expectedProduced - - -- Coupon date 3 (call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 22.5 cashInstrument] - (Some bondInstrumentAfterCoupon3, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jul 17) - notional bondInstrumentAfterCoupon2 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [] expectedConsumed expectedProduced - - -- Redemption date (not a call date): Lifecycle and verify that there is an effect for one coupon - -- and the redemption amount. - let - expectedConsumed = [] - expectedProduced = [qty 1022.5 cashInstrument] - maybeBondInstrumentAfterRedemption <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2024 Jan 15) bondInstrumentAfterCoupon3 issuer [] expectedConsumed expectedProduced - - bondInstrumentAfterRedemption <- case maybeBondInstrumentAfterRedemption of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterCoupon3 - - pure () - --- Create and lifecycle a floating coupon callable bond. --- 2Y, compounded SOFR (calculated via SOFR Index) + 0.5% p.a. --- cap: 6.0%, floor: 0% --- callable on every coupon date (6M schedule) after 1Y. --- Issuer calls the bond before maturity. -runSofrFloorCapCallable6M : Script () -runSofrFloorCapCallable6M = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - -- SOFR + 0.5% coupon every 6M (with a 0% floor and a 6% cap) - let - rollDay = 15 - issueDate = date 2022 Jan rollDay - firstCouponDate = date 2022 Jul rollDay - maturityDate = date 2024 Jan rollDay - notional = 1000.0 - couponRate = 0.005 - capRate = Some 0.06 - floorRate = Some $ 0.0 - couponPeriod = M - couponPeriodMultiplier = 6 - dayCountConvention = Act360 - useAdjustedDatesForDcf = True - businessDayConvention = Following - -- CREATE_6M_SOFR_CALLABLE_BOND_VARIABLES_BEGIN - referenceRateId = "SOFR/INDEX" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = CompoundedIndex Act360 - -- CREATE_6M_SOFR_CALLABLE_BOND_VARIABLES_END - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 13, 1.04240111) - , (dateToDateClockTime $ date 2022 Jul 13, 1.04509941) - , (dateToDateClockTime $ date 2023 Jan 12, 1.06145226) - , (dateToDateClockTime $ date 2023 Jul 13, 1.08019012) - ] - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - let - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- CREATE_6M_SOFR_CALLABLE_BOND_SCHEDULE_BEGIN - -- Define a schedule for callability. The bond is callable on the *last* date of each schedule - -- period. - -- In this example, it is possible to call the bond every 6M, but only starting in the second - -- coupon period (after one year). - callScheduleStartDate = date 2022 Jul rollDay - callScheduleEndDate = date 2023 Jul rollDay - callPeriod = couponPeriod - callPeriodMultiplier = couponPeriodMultiplier - callScheduleFirstRegular = None -- Only used in case of an irregular schedule - callSchedule = createPeriodicSchedule callScheduleFirstRegular holidayCalendarIds - businessDayConvention callPeriod callPeriodMultiplier callScheduleStartDate - callScheduleEndDate rollDay - noticeDays = 0 - -- CREATE_6M_SOFR_CALLABLE_BOND_SCHEDULE_END - - bondInstrument <- originateMultiScheduleCallableBond issuer issuer "BONDTEST1" - TransferableFungible "Callable Bond" pp now holidayCalendarIds calendarDataProvider - dayCountConvention useAdjustedDatesForDcf floatingRate couponRate capRate floorRate - cashInstrument notional couponSchedule callSchedule noticeDays publicParty - - let - electorIsOwner = False - - -- Coupon date 1 (not a call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 7.5885429 cashInstrument] - maybeBondInstrumentAfterCoupon1 <- lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 15) bondInstrument issuer [observableCid] expectedConsumed expectedProduced - - bondInstrumentAfterCoupon1 <- case maybeBondInstrumentAfterCoupon1 of - Some key -> do - pure key - None -> do - pure bondInstrument - - -- Coupon date 2 (call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 20.6471718 cashInstrument] - (Some bondInstrumentAfterCoupon2, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jan 16) - notional bondInstrumentAfterCoupon1 electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- Coupon date 3 (call date): Try to call, which works as expected: one coupon and early - -- redemption amount. - let - expectedConsumed = [] - expectedProduced = [qty 22.6530408 cashInstrument, qty 1000.0 cashInstrument] - (Some bondInstrumentAfterCoupon3, effectCid) <- electAndVerifyPaymentEffects (date 2023 Jul 17) - notional bondInstrumentAfterCoupon2 electorIsOwner issuer investor [publicParty] "CALLED" - [observableCid] expectedConsumed expectedProduced - - pure () - --- Create and lifecycle a floating coupon callable bond. --- 1Y bond, two coupons: 3M Libor + 0.5% p.a. (Following Unadjusted) --- Issuer does not call the bond. -runFloatingCouponUnadjustedCallable1Y : Script () -runFloatingCouponUnadjustedCallable1Y = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - let - rollDay = 25 - issueDate = date 2022 Jan rollDay - firstCouponDate = date 2022 Jul rollDay - firstCouponDateAdj = date 2022 Jul 26 - maturityDate = date 2023 Jul rollDay - notional = 1000.0 - couponRate = 0.005 - capRate = None - floorRate = None - couponPeriod = Y - couponPeriodMultiplier = 1 - dayCountConvention = Basis30360 - useAdjustedDatesForDcf = False - businessDayConvention = Following - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["TARGET2"] - noticeDays = 0 - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 21, 0.040) - , (dateToDateClockTime $ date 2022 Jul 21, 0.040) - ] - holidayCalendarIds = ["USD"] - calUS = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2022 Jul 25] - calTarget2 = - HolidayCalendarData with - id = "TARGET2" - weekend = [Saturday, Sunday] - holidays = [] - - -- A reference data provider publishes the holiday calendar on the ledger - submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar = calUS - observers = Map.fromList pp - submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar = calTarget2 - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - let - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - bondInstrument <- originateCallableBond issuer issuer "BONDTEST1" TransferableFungible - "Callable Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier cashInstrument notional - noticeDays publicParty - - let - electorIsOwner = False - - -- Coupon date 1 (call date): Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 22.5 cashInstrument] - (Some bondInstrumentAfterCoupon1, _effectCid) <- electAndVerifyPaymentEffects firstCouponDateAdj - notional bondInstrument electorIsOwner issuer investor [publicParty] "NOT CALLED" - [observableCid] expectedConsumed expectedProduced - - -- lifecycle on the maturity date - let - expectedConsumed = [] - expectedProduced = [qty 45.0 cashInstrument, qty 1000.0 cashInstrument] - electAndVerifyPaymentEffects maturityDate notional bondInstrumentAfterCoupon1 electorIsOwner - issuer investor [publicParty] "NOT CALLED" [observableCid] expectedConsumed expectedProduced - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Bond/Test/FixedRate.daml b/src/test/daml/Daml/Finance/Instrument/Bond/Test/FixedRate.daml deleted file mode 100644 index 5c6534def..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Bond/Test/FixedRate.daml +++ /dev/null @@ -1,132 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.Test.FixedRate where - -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Instrument.Bond.Test.Util (originateFixedRateBond) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Penultimate coupon payment on a bond showing creation of new instrument version -run : Script () -run = script do - [depository, custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["CSD", "Custodian", "Issuer", "Investor", "Calendar Data Provider", - "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate depository issuer "EUR" TransferableFungible "Euro" pp now - - -- Create and distribute bond - -- Ireland 1.1% coupon every 12M - -- todo: change dayCountConvention to ActAct (implement this first) - -- CREATE_FIXED_RATE_BOND_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstCouponDate = date 2019 May 15 - maturityDate = date 2020 May 15 - notional = 1.0 - couponRate = 0.011 - couponPeriod = M - couponPeriodMultiplier = 12 - dayCountConvention = Act365Fixed - businessDayConvention = Following - -- CREATE_FIXED_RATE_BOND_VARIABLES_END - -- Test specifying 2 calendars (the union of the two will be used) - holidayCalendarIds = ["EUR", "EUR2"] - calendar = - HolidayCalendarData with - id = "EUR" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - cal2 = - HolidayCalendarData with - id = "EUR2" - weekend = [Saturday, Sunday] - holidays = [date 2020 Dec 19] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - calendarCid2 <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar = cal2 - observers = Map.fromList pp - - bondInstrument <- originateFixedRateBond issuer issuer "BONDTEST1" TransferableFungible - "Fixed Rate Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention businessDayConvention couponRate couponPeriod - couponPeriodMultiplier cashInstrument notional publicParty - - -- One day before the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstCouponDate 1) bondInstrument issuer [] - - -- First coupon date: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0035863014 cashInstrument] - - maybeBondInstrumentAfterFirstCoupon <- - lifecycleAndVerifyPaymentEffects - [publicParty] - firstCouponDate - bondInstrument - issuer - [] - expectedConsumed - expectedProduced - - bondInstrumentAfterFirstCoupon <- case maybeBondInstrumentAfterFirstCoupon of - Some key -> pure key - None -> pure bondInstrument - - -- One day after the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstCouponDate 1) bondInstrumentAfterFirstCoupon - issuer [] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - bondInstrumentAfterFirstCoupon issuer [] - - -- Lifecycle on the expiry date: Verify lifecycle effects for one coupon and redemption amount. - let - expectedConsumed = [] - expectedProduced = [qty 0.011030137 cashInstrument, qty 1.0 cashInstrument] - - maybeBondInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects - [publicParty] - maturityDate - bondInstrumentAfterFirstCoupon - issuer - [] - expectedConsumed - expectedProduced - - case maybeBondInstrumentAfterMaturity of - Some key -> pure key - None -> pure bondInstrumentAfterFirstCoupon - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml b/src/test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml deleted file mode 100644 index 8592801bc..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Bond/Test/FloatingRate.daml +++ /dev/null @@ -1,258 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.Test.FloatingRate where - -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Bond.Test.Util (originateFloatingRateBond) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (DateRelativeToEnum(..), FloatingRate(..), ReferenceRateTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DateOffset (DateOffset(..), DayTypeEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Penultimate coupon payment on a bond showing creation of new instrument version -run : Script () -run = script do - [depository, custodian, issuer, calendarDataProvider, settler, publicParty] <- - createParties ["CSD", "Custodian", "Issuer", "Calendar Data Provider", "Settler", "PublicParty"] - let settlers = singleton settler - - -- Distribute commercial-bank cash - now <- getTime - let pp = [("PublicParty", singleton publicParty)] - cashInstrument <- originate depository issuer "EUR" TransferableFungible "Euro" pp now - - -- Create and distribute bond - -- Floating rate bond: Euribor 3M + 1.1% p.a. coupon every 3M - -- CREATE_FLOATING_RATE_BOND_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstCouponDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceRateId = "EUR/EURIBOR/3M" - floatingRate = FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = 0 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["EUR"] - notional = 1.0 - couponSpread = 0.011 - couponPeriod = M - couponPeriodMultiplier = 3 - dayCountConvention = Act365Fixed - businessDayConvention = Following - -- CREATE_FLOATING_RATE_BOND_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, -0.00311) - , (dateToDateClockTime $ date 2019 Feb 15, -0.00266) - ] - calendar = HolidayCalendarData with - id = "EUR" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - - bondInstrument <- originateFloatingRateBond issuer issuer "BONDTEST1" TransferableFungible - "Floating Rate Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention businessDayConvention couponSpread couponPeriod - couponPeriodMultiplier cashInstrument notional floatingRate publicParty - - -- One day before the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstCouponDate 1) bondInstrument issuer - [observableCid] - - -- First coupon date: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0006484932 cashInstrument] - maybeBondInstrumentAfterFirstCoupon <- - lifecycleAndVerifyPaymentEffects - [publicParty] - firstCouponDate - bondInstrument - issuer - [observableCid] - expectedConsumed - expectedProduced - - bondInstrumentAfterFirstCoupon <- case maybeBondInstrumentAfterFirstCoupon of - Some key -> do - pure key - None -> do - pure bondInstrument - - - -- One day after the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstCouponDate 1) bondInstrumentAfterFirstCoupon - issuer [observableCid] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - bondInstrumentAfterFirstCoupon issuer [observableCid] - - -- Lifecycle on the expiry date. Verify the lifecycle effects for one coupon and the redemption - -- amount - let - expectedConsumed = [] - expectedProduced = [qty 0.002033589 cashInstrument, qty 1.0 cashInstrument] - maybeBondInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects - [publicParty] - maturityDate - bondInstrumentAfterFirstCoupon - issuer - [observableCid] - expectedConsumed - expectedProduced - - bondInstrumentAfterMaturity <- case maybeBondInstrumentAfterMaturity of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterFirstCoupon - - - pure () - --- Create and lifecycle a floating coupon bond. --- 2Y, compounded SOFR (calculated via SOFR Index) + 0.5% p.a. -runSofr : Script () -runSofr = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", singleton publicParty)] - - -- Originate commercial-bank cash - now <- getTime - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" pp now - - -- Create and distribute bond - -- SOFR + 0.5% coupon every 6M (with a 0% floor and a 6% cap) - let - rollDay = 15 - issueDate = date 2022 Jan rollDay - firstCouponDate = date 2022 Jul rollDay - maturityDate = date 2024 Jan rollDay - notional = 1000.0 - couponSpread = 0.005 - couponPeriod = M - couponPeriodMultiplier = 6 - dayCountConvention = Act360 - useAdjustedDatesForDcf = True - businessDayConvention = Following - -- CREATE_6M_SOFR_FLOATING_BOND_VARIABLES_BEGIN - referenceRateId = "SOFR/INDEX" - floatingRate = FloatingRate with - referenceRateId - referenceRateType = CompoundedIndex Act360 - -- CREATE_6M_SOFR_FLOATING_BOND_VARIABLES_END - fixingDates = DateOffset with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 13, 1.04240111) - , (dateToDateClockTime $ date 2022 Jul 13, 1.04509941) - , (dateToDateClockTime $ date 2023 Jan 12, 1.06145226) - , (dateToDateClockTime $ date 2023 Jul 13, 1.08019012) - , (dateToDateClockTime $ date 2024 Jan 11, 1.08999999) - ] - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id $ referenceRateId; observations; observers = mempty - - bondInstrument <- originateFloatingRateBond issuer issuer "BONDTEST1" TransferableFungible - "Floating Rate Bond" pp now issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention businessDayConvention couponSpread couponPeriod - couponPeriodMultiplier cashInstrument notional floatingRate publicParty - - -- Coupon date 1: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 7.5885429 cashInstrument] - maybeBondInstrumentAfterFirstCoupon <- - lifecycleAndVerifyPaymentEffects - [publicParty] - firstCouponDate - bondInstrument - issuer - [observableCid] - expectedConsumed - expectedProduced - - bondInstrumentAfterFirstCoupon <- case maybeBondInstrumentAfterFirstCoupon of - Some key -> do - pure key - None -> do - pure bondInstrument - - - -- Coupon date 2: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 20.6471718 cashInstrument] - maybeBondInstrumentAfterSecondCoupon <- - lifecycleAndVerifyPaymentEffects - [publicParty] - (date 2023 Jan 16) - bondInstrumentAfterFirstCoupon - issuer - [observableCid] - expectedConsumed - expectedProduced - - case maybeBondInstrumentAfterSecondCoupon of - Some key -> do - pure key - None -> do - pure bondInstrumentAfterFirstCoupon - - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Bond/Test/InflationLinked.daml b/src/test/daml/Daml/Finance/Instrument/Bond/Test/InflationLinked.daml deleted file mode 100644 index 1f5467d56..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Bond/Test/InflationLinked.daml +++ /dev/null @@ -1,129 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.Test.InflationLinked where - -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation(Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Bond.Test.Util (originateInflationLinkedBond) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Penultimate coupon payment on a bond showing creation of new instrument version -run : Script () -run = script do - [depository, custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["CSD", "Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let pp = [("PublicParty", singleton publicParty)] - cashInstrument <- originate depository issuer "EUR" TransferableFungible "Euro" pp now - - -- Create and distribute bond - -- Sample inflation linked bond - -- CREATE_INFLATION_LINKED_BOND_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstCouponDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - inflationIndexId = "CPI" - notional = 1.0 - couponRate = 0.011 - couponPeriod = M - couponPeriodMultiplier = 3 - dayCountConvention = Act365Fixed - businessDayConvention = Following - -- CREATE_INFLATION_LINKED_BOND_VARIABLES_END - inflationIndexBaseValue = 200.0 - inflationIndexAtMaturity = 220.0 - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Feb 15, 210.0) - , (dateToDateClockTime $ date 2019 May 15, inflationIndexAtMaturity) - ] - calendar = HolidayCalendarData with - id = "EUR" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id inflationIndexId; observations; observers = mempty - - bondInstrument <- originateInflationLinkedBond issuer issuer "BONDTEST1" TransferableFungible - "Inflation Linked Bond" pp now issueDate holidayCalendarIds calendarDataProvider - firstCouponDate maturityDate dayCountConvention businessDayConvention couponRate couponPeriod - couponPeriodMultiplier cashInstrument notional inflationIndexId inflationIndexBaseValue - publicParty - - -- One day before the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstCouponDate 1) bondInstrument issuer - [observableCid] - - -- First coupon date: Lifecycle and verify that there is an effect for one coupon. - let - expectedConsumed = [] - expectedProduced = [qty 0.0009493151 cashInstrument] - maybeBondInstrumentAfterFirstCoupon <- - lifecycleAndVerifyPaymentEffects - [publicParty] - firstCouponDate - bondInstrument - issuer - [observableCid] - expectedConsumed - expectedProduced - - bondInstrumentAfterFirstCoupon <- case maybeBondInstrumentAfterFirstCoupon of - Some key -> pure key - None -> pure bondInstrument - - -- One day after the first coupon date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstCouponDate 1) bondInstrumentAfterFirstCoupon - issuer [observableCid] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - bondInstrumentAfterFirstCoupon issuer [observableCid] - - -- Lifecycle on the expiry date. Verify the lifecycle effects for one coupon and the - -- inflation-adjusted redemption amount - let - expectedConsumed = [] - expectedProduced = [qty 0.002950411 cashInstrument, qty 1.1 cashInstrument] - maybeBondInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects - [publicParty] - maturityDate - bondInstrumentAfterFirstCoupon - issuer - [observableCid] - expectedConsumed - expectedProduced - - bondInstrumentAfterMaturity <- case maybeBondInstrumentAfterMaturity of - Some key -> pure key - None -> pure bondInstrumentAfterFirstCoupon - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Bond/Test/Util.daml b/src/test/daml/Daml/Finance/Instrument/Bond/Test/Util.daml deleted file mode 100644 index 9b325aa30..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Bond/Test/Util.daml +++ /dev/null @@ -1,357 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.Test.Util where - -import DA.Map (fromList) -import Daml.Finance.Instrument.Bond.V3.Callable.Factory qualified as CallableBond (Factory(..)) -import Daml.Finance.Instrument.Bond.V3.FixedRate.Factory qualified as FixedRateBond (Factory(..)) -import Daml.Finance.Instrument.Bond.V3.FloatingRate.Factory qualified as FloatingRateBond (Factory(..)) -import Daml.Finance.Instrument.Bond.V3.InflationLinked.Factory qualified as InflationLinkedBond (Factory(..)) -import Daml.Finance.Instrument.Bond.V3.ZeroCoupon.Factory qualified as ZeroCouponBond (Factory(..)) -import Daml.Finance.Interface.Claims.V4.Types (Deliverable) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Factory qualified as CallableBondFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.Callable.Types (Callable(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Factory qualified as FixedRateBondFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FixedRate.Types (FixedRate(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Factory qualified as FloatingRateBondFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.FloatingRate.Types qualified as FloatingRateBond (FloatingRate(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Factory qualified as InflationLinkedBondFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.InflationLinked.Types (InflationLinked(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Factory qualified as ZeroCouponBondFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Bond.V3.ZeroCoupon.Types (ZeroCoupon(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), Parties) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule) -import Daml.Finance.Test.Util.Time (createPaymentPeriodicSchedule) -import Daml.Script - -originateFixedRateBond : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> Date -> [Text] -> Party -> Date-> Date -> - DayCountConventionEnum -> BusinessDayConventionEnum -> Decimal -> PeriodEnum -> Int -> - InstrumentKey -> Decimal -> Party -> Script InstrumentKey -originateFixedRateBond depository issuer label holdingStandard description observers - lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate maturityDate - dayCountConvention businessDayConvention couponRate couponPeriod couponPeriodMultiplier - currency notional publicParty - = do - let - periodicSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- Create a fixed rate bond factory - fixedRateBondFactoryCid <- toInterfaceContractId @FixedRateBondFactory.I <$> submit issuer do - createCmd FixedRateBond.Factory with - provider = issuer - observers = mempty - - -- CREATE_FIXED_RATE_BOND_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd fixedRateBondFactoryCid FixedRateBondFactory.Create with - fixedRate = FixedRate with - instrument - description - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - observers = fromList observers - -- CREATE_FIXED_RATE_BOND_INSTRUMENT_END - pure instrument - -originateCallableBond : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> Date -> - [Text] -> Party -> Date -> Date -> - DayCountConventionEnum -> Bool -> BusinessDayConventionEnum -> Optional FloatingRate -> Decimal -> - Optional Decimal -> Optional Decimal -> PeriodEnum -> Int -> InstrumentKey -> Decimal -> Int -> - Party -> Script InstrumentKey -originateCallableBond depository issuer label holdingStandard description observers - lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate maturityDate - dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate couponRate - capRate floorRate couponPeriod couponPeriodMultiplier currency notional noticeDays - publicParty = do - let - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - callSchedule = couponSchedule - - -- Create a callable rate bond factory - callableBondFactoryCid <- toInterfaceContractId @CallableBondFactory.I <$> submit issuer do - createCmd CallableBond.Factory with - provider = issuer - observers = mempty - - -- CREATE_CALLABLE_BOND_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd callableBondFactoryCid CallableBondFactory.Create with - callable = Callable with - instrument - description - floatingRate - couponRate - capRate - floorRate - couponSchedule - noticeDays - callSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - useAdjustedDatesForDcf - currency - notional - lastEventTimestamp - prevEvents = [] - observers = fromList observers - -- CREATE_CALLABLE_BOND_INSTRUMENT_END - pure instrument - -originateCallableBondMustFail : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> [Text] -> Party -> Date -> - Date -> DayCountConventionEnum -> Bool -> BusinessDayConventionEnum -> Optional FloatingRate -> - Decimal -> Optional Decimal -> Optional Decimal -> PeriodEnum -> Int -> InstrumentKey -> - Decimal -> Int -> Party -> - Script () -originateCallableBondMustFail depository issuer label holdingStandard description - observers lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention useAdjustedDatesForDcf businessDayConvention floatingRate - couponRate capRate floorRate couponPeriod couponPeriodMultiplier currency - notional noticeDays publicParty = do - let - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - callSchedule = couponSchedule - - -- Create a callable rate bond factory - callableBondFactoryCid <- toInterfaceContractId @CallableBondFactory.I <$> submit issuer do - createCmd CallableBond.Factory with - provider = issuer - observers = mempty - - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - submitMustFail (actAs issuer <> readAs publicParty) do - exerciseCmd callableBondFactoryCid CallableBondFactory.Create with - callable = Callable with - instrument - description - floatingRate - couponRate - capRate - floorRate - couponSchedule - noticeDays - callSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - useAdjustedDatesForDcf - currency - notional - lastEventTimestamp - prevEvents = [] - observers = fromList observers - pure () - -originateMultiScheduleCallableBond : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> [Text] -> Party -> DayCountConventionEnum -> - Bool -> Optional FloatingRate -> Decimal -> Optional Decimal -> Optional Decimal -> - InstrumentKey -> Decimal -> PeriodicSchedule -> PeriodicSchedule -> Int -> Party -> - Script InstrumentKey -originateMultiScheduleCallableBond depository issuer label holdingStandard description - observers lastEventTimestamp holidayCalendarIds calendarDataProvider dayCountConvention - useAdjustedDatesForDcf floatingRate couponRate capRate floorRate - currency notional couponSchedule callSchedule noticeDays publicParty = do - -- Create a callable rate bond factory - callableBondFactoryCid <- toInterfaceContractId @CallableBondFactory.I <$> submit issuer do - createCmd CallableBond.Factory with - provider = issuer - observers = mempty - - -- CREATE_MULTI_SCHEDULE_CALLABLE_BOND_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd callableBondFactoryCid CallableBondFactory.Create with - callable = Callable with - instrument - description - floatingRate - couponRate - capRate - floorRate - couponSchedule - noticeDays - callSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - useAdjustedDatesForDcf - currency - notional - lastEventTimestamp - prevEvents = [] - observers = fromList observers - -- CREATE_MULTI_SCHEDULE_CALLABLE_BOND_INSTRUMENT_END - pure instrument - -originateZeroCouponBond : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> Date -> Date -> Deliverable -> Decimal -> Party -> Script InstrumentKey -originateZeroCouponBond depository issuer label holdingStandard description observers - lastEventTimestamp issueDate maturityDate currency notional publicParty = do - -- Create a zero coupon bond factory - zeroCouponBondFactoryCid <- toInterfaceContractId @ZeroCouponBondFactory.I <$> submit issuer do - createCmd ZeroCouponBond.Factory with - provider = issuer - observers = mempty - - -- CREATE_ZERO_COUPON_BOND_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd zeroCouponBondFactoryCid ZeroCouponBondFactory.Create with - zeroCoupon = ZeroCoupon with - instrument - description - currency - issueDate - maturityDate - notional - lastEventTimestamp - observers = fromList observers - -- CREATE_ZERO_COUPON_BOND_INSTRUMENT_END - pure instrument - -originateFloatingRateBond : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> [Text] -> Party -> Date -> - Date -> DayCountConventionEnum -> BusinessDayConventionEnum -> Decimal -> PeriodEnum -> - Int -> InstrumentKey -> Decimal -> FloatingRate -> Party -> Script InstrumentKey -originateFloatingRateBond depository issuer label holdingStandard description - observers lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention businessDayConvention couponSpread couponPeriod - couponPeriodMultiplier currency notional floatingRate publicParty = do - let - periodicSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- Create a floating rate bond factory - floatingRateBondFactoryCid <- toInterfaceContractId @FloatingRateBondFactory.I <$> - submit issuer do - createCmd FloatingRateBond.Factory with - provider = issuer - observers = mempty - - -- CREATE_FLOATING_RATE_BOND_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd floatingRateBondFactoryCid FloatingRateBondFactory.Create with - floatingRate = FloatingRateBond.FloatingRate with - instrument - description - floatingRate - couponSpread - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - currency - notional - lastEventTimestamp - observers = fromList observers - -- CREATE_FLOATING_RATE_BOND_INSTRUMENT_END - pure instrument - -originateInflationLinkedBond : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> [Text] -> Party -> Date -> - Date -> DayCountConventionEnum -> BusinessDayConventionEnum -> Decimal -> PeriodEnum -> - Int -> InstrumentKey -> Decimal -> Text -> Decimal -> Party -> Script InstrumentKey -originateInflationLinkedBond depository issuer label holdingStandard description - observers lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention businessDayConvention couponRate couponPeriod - couponPeriodMultiplier currency notional inflationIndexId inflationIndexBaseValue publicParty = do - let - periodicSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- Create an inflation linked bond factory - inflationLinkedBondFactoryCid <- toInterfaceContractId @InflationLinkedBondFactory.I <$> - submit issuer do - createCmd InflationLinkedBond.Factory with - provider = issuer - observers = mempty - - -- CREATE_INFLATION_LINKED_BOND_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd inflationLinkedBondFactoryCid InflationLinkedBondFactory.Create with - inflationLinked = InflationLinked with - instrument - description - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - couponRate - inflationIndexId - inflationIndexBaseValue - currency - notional - lastEventTimestamp - observers = fromList observers - -- CREATE_INFLATION_LINKED_BOND_INSTRUMENT_END - pure instrument diff --git a/src/test/daml/Daml/Finance/Instrument/Bond/Test/ZeroCoupon.daml b/src/test/daml/Daml/Finance/Instrument/Bond/Test/ZeroCoupon.daml deleted file mode 100644 index 2d6c6627c..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Bond/Test/ZeroCoupon.daml +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Bond.Test.ZeroCoupon where - -import DA.Date (Month(..), date, subtractDays) -import DA.Set (singleton) -import Daml.Finance.Instrument.Bond.Test.Util (originateZeroCouponBond) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Test creation and lifecycling of a zero coupon bond -run : Script () -run = script do - [depository, custodian, issuer, publicParty] <- - createParties ["CSD", "Custodian", "Issuer", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let pp = [("PublicParty", singleton publicParty)] - cashInstrument <- - originate depository issuer "USD" TransferableFungible "United States Dollar" pp now - - -- Create and distribute bond - -- Zero coupon bond example - -- CREATE_ZERO_COUPON_BOND_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - maturityDate = date 2020 May 15 - notional = 1000.0 - -- CREATE_ZERO_COUPON_BOND_VARIABLES_END - - bondInstrument <- originateZeroCouponBond issuer issuer "BONDTEST1" TransferableFungible - "Zero Coupon Bond" pp now issueDate maturityDate cashInstrument notional publicParty - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) bondInstrument issuer [] - - -- Lifecycle on the expiry date. Verify the lifecycle effect for the redemption amount - let - expectedConsumed = [] - expectedProduced = [qty 1000.0 cashInstrument] - maybeBondInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects - [publicParty] - maturityDate - bondInstrument - issuer - [] - expectedConsumed - expectedProduced - - bondInstrumentAfterMaturity <- case maybeBondInstrumentAfterMaturity of - Some key -> pure key - None -> pure bondInstrument - - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Equity/Test/DivOption.daml b/src/test/daml/Daml/Finance/Instrument/Equity/Test/DivOption.daml deleted file mode 100644 index 265318969..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Equity/Test/DivOption.daml +++ /dev/null @@ -1,227 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.Test.DivOption where - -import DA.Date (Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Equity.Test.Util -import Daml.Finance.Instrument.Option.Test.Util (electAndVerifyDivOptionPaymentEffects, originateDividendOption) -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Equity (DeclareDistribution(..), I) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (ElectionTypeEnum(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Lifecycle.V4.Rule.Distribution qualified as Distribution (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerAndAmountOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Script - --- Issue dividend option and do an election: lifecycling and settlement -run : Script () -run = script do - ----------------------------- - -- Issue a dividend option -- - ----------------------------- - - -- Create parties - [cb, issuer, custodian, investor, publicParty] <- - createParties ["CentralBank", "Issuer", "Custodian", "Investor", "PublicParty"] - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory issuer pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with - provider = custodian; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorAccount <- - Account.createAccount "Investor Account" [publicParty] accountFactoryCid holdingFactory [] - Account.Owner custodian investor - - let - expiryDate = date 2019 May 15 - - -- Originate instruments - now <- getTime - cashInstrument <- originate cb cb "USD" TransferableFungible "United States Dollar" pp now - eurInstrument <- originate cb cb "EUR" TransferableFungible "Euro" pp now - cumEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "0" TransferableFungible "ABC" pp now - exEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "1" TransferableFungible "ABC" [] now - - let - cashQuantity = qty 0.19 cashInstrument - sharesQuantity = Some $ qty 0.0041 exEquityInstrument - fxQuantity = Some $ qty 0.17 eurInstrument - - longDivOptionInstrument <- originateDividendOption issuer issuer "long div option" - TransferableFungible "Option" pp now expiryDate cashQuantity sharesQuantity fxQuantity - publicParty - - -- Distribute holdings: fractional holdings are also supported. - investorEquityCid <- Account.credit [publicParty] cumEquityInstrument 1000.0 investorAccount - - -- Create distribution rule for the dividend option - distributionRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit issuer do - createCmd Distribution.Rule with - providers =Set.singleton issuer - lifecycler = issuer - observers = Set.singleton publicParty - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument following a distribution event" - - -- Create dividend option event: 1.0 per share (this also works with fractional shares) - distributionEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "ABC - " <> show now - description = "Dividend options issue" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [qty 1.0 longDivOptionInstrument] - - -- Lifecycle dividend option distribution - (_, [effectCid]) <- submit issuer do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = distributionEventCid - instrument = cumEquityInstrument - - -- Claim effect - routeProviderCid <- toInterfaceContractId <$> submit custodian do - createCmd SingleCustodian with - provider = custodian; observers = Set.singleton publicParty; custodian - settlementFactoryCid <- toInterfaceContractId <$> submit custodian do - createCmd Factory with provider = custodian; observers = Set.singleton publicParty - -- Enable netting so that there is only one holding with the new correct quantity - let settlers = Set.fromList [investor, custodian] - claimRuleCid <- toInterfaceContractId @Claim.I <$> submit custodian do - createCmd Claim.Rule with - provider = custodian - claimers = Set.fromList [investor, custodian] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = True - - -- The effect is claimed and then settled by the custodian, but it could also be claimed and then - -- settled by the investor. - result <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd claimRuleCid Claim.ClaimEffect with - claimer = custodian - holdingCids = [investorEquityCid] - effectCid - batchId = Id "DivOptionSettlement" - - let - [investorInstrumentInstructionCid, custodianInstrumentInstructionCid, - custodianDivOptionInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = Pledge $ fromInterfaceContractId investorEquityCid - (custodianInstrumentInstructionCid, _) <- submit custodian do - exerciseCmd custodianInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - (custodianDivOptionInstructionCid, _) <- submit custodian do - exerciseCmd custodianDivOptionInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit custodian do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton custodian; approval = DebitSender - custodianInstrumentInstructionCid <- submit investor do - exerciseCmd custodianInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - custodianDivOptionInstructionCid <- submit investor do - exerciseCmd custodianDivOptionInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - - -- Settle batch - [investorEquityHoldingCid, investorDivOptionHoldingCid] <- - submit (actAs custodian <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = Set.singleton custodian - - -- Assert state - Holding.verifyOwnerAndAmountOfHolding [(investor, 1000.00, investorEquityHoldingCid), - (investor, 1000.00, investorDivOptionHoldingCid)] - - ------------------------------------------------ - -- Election: Choose which dividend to receive -- - ------------------------------------------------ - - -- The investor can now choose what kind of dividend to receive by exercising the dividend option, - -- either in parts or in whole. - -- The example below shows how an investor chooses to receive the dividend in shares. - -- It is also possible to receive part in shares and part in cash. For that, you would simply have - -- to split the option holding and apply the workflow twice: once for shares and once for cash. - - let - electAmount = 1000.0 -- Elect to receive shares for 1000 units of Dividend options - expectedConsumed = [] - expectedProduced = [qty 0.0041 exEquityInstrument] - (_, divOptionEffect) <- electAndVerifyDivOptionPaymentEffects [publicParty] expiryDate - electAmount longDivOptionInstrument issuer investor Shares expectedConsumed expectedProduced - - -- Create a claim rule - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit custodian do - createCmd Claim.Rule with - provider = custodian - claimers = Set.fromList [investor, issuer] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - -- Cannot claim effect for a different amount than what was elected - -- In particular, electing for more than the size of the holding does not work: - investorDivOptionSmallHoldingCid <- Account.credit [publicParty] longDivOptionInstrument 3.0 - investorAccount - submitMustFail (actAs [investor] <> readAs [publicParty]) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorDivOptionSmallHoldingCid] - effectCid = divOptionEffect - batchId = Id "DivOptionExerciseSettlement" - - -- Electing for less than the size of the holding does not work either: - -- (you would have to split the holding first) - investorDivOptionBigHoldingCid <- Account.credit [publicParty] longDivOptionInstrument 30000.0 - investorAccount - submitMustFail (actAs [investor] <> readAs [publicParty]) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorDivOptionBigHoldingCid] - effectCid = divOptionEffect - batchId = Id "DivOptionExerciseSettlement" - - -- Electing for the same amount as the size of the holding works: - submit (actAs investor <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorDivOptionHoldingCid] - effectCid = divOptionEffect - batchId = Id "DivOptionExerciseSettlement" - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Equity/Test/Dividend.daml b/src/test/daml/Daml/Finance/Instrument/Equity/Test/Dividend.daml deleted file mode 100644 index 24c3479f7..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Equity/Test/Dividend.daml +++ /dev/null @@ -1,310 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.Test.Dividend where - -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Equity.Test.Util (originateEquity) -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Equity (DeclareDistribution(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Lifecycle.V4.Rule.Distribution qualified as Distribution (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerAndAmountOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Script - --- Cash dividend (and bonus issue) lifecycling and settlement -run : Script () -run = script do - -- Create parties - [cb, issuer, custodian, investor, publicParty] <- - createParties ["CentralBank", "Issuer", "Custodian", "Investor", "PublicParty"] - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory issuer pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = custodian; id =Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorAccount <- - Account.createAccount "Account" [publicParty] accountFactoryCid holdingFactory [] - Account.Owner custodian investor - - -- Originate instruments - now <- getTime - cashInstrument <- originate cb cb "USD" TransferableFungible "United States Dollar" pp now - -- CREATE_EQUITY_INSTRUMENTS_BEGIN - cumEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "0" TransferableFungible "ABC" pp now - exEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "1" TransferableFungible "ABC" [] now - -- CREATE_EQUITY_INSTRUMENTS_END - - -- CREATE_EQUITY_HOLDING_BEGIN - -- Distribute holdings: fractional holdings are also supported. - investorEquityCid <- Account.credit [publicParty] cumEquityInstrument 1000.25 investorAccount - -- CREATE_EQUITY_HOLDING_END - - -- CREATE_EQUITY_DISTRIBUTION_RULE_BEGIN - -- Create cash dividend rule - distributionRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit issuer do - createCmd Distribution.Rule with - providers = Set.singleton issuer - lifecycler = issuer - observers = Set.singleton publicParty - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument following a distribution event" - -- CREATE_EQUITY_DISTRIBUTION_RULE_END - - -- CREATE_EQUITY_DISTRIBUTION_EVENT_BEGIN - -- Create cash dividend event: USD 2 per share (this also works with fractional shares) - distributionEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "ABC - " <> show now - description = "Cash Dividend" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [qty 2.0 cashInstrument] - -- CREATE_EQUITY_DISTRIBUTION_EVENT_END - - -- LIFECYCLE_CASH_DIVIDEND_BEGIN - -- Lifecycle cash dividend - (_, [effectCid]) <- submit issuer do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = distributionEventCid - instrument = cumEquityInstrument - -- LIFECYCLE_CASH_DIVIDEND_END - - -- Claim effect - routeProviderCid <- toInterfaceContractId <$> submit custodian do - createCmd SingleCustodian with - provider = custodian; observers = Set.singleton publicParty; custodian - settlementFactoryCid <- toInterfaceContractId <$> submit custodian do - createCmd Factory with provider = custodian; observers = Set.singleton publicParty - -- Enable netting so that there is only one holding with the new correct quantity - claimRuleCid <- toInterfaceContractId @Claim.I <$> submit custodian do - createCmd Claim.Rule with - provider = custodian - claimers = Set.fromList [investor, custodian] - settlers = Set.fromList [investor, custodian] - routeProviderCid - settlementFactoryCid - netInstructions = True - - -- The effect is claimed and then settled by the custodian, but it could also be claimed and then - -- settled by the investor. - result <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd claimRuleCid Claim.ClaimEffect with - claimer = custodian - holdingCids = [investorEquityCid] - effectCid - batchId = Id "DividendSettlement" - - let - [investorInstrumentInstructionCid, custodianInstrumentInstructionCid, - custodianCashInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = Pledge $ fromInterfaceContractId investorEquityCid - (custodianInstrumentInstructionCid, _) <- submit custodian do - exerciseCmd custodianInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - (custodianCashInstructionCid, _) <- submit custodian do - exerciseCmd custodianCashInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit custodian do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton custodian; approval = DebitSender - custodianInstrumentInstructionCid <- submit investor do - exerciseCmd custodianInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - custodianCashInstructionCid <- submit investor do - exerciseCmd custodianCashInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - - -- Settle batch - [investorCashHoldingCid, investorEquityHoldingCid] <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = Set.singleton custodian - - -- Assert state - Holding.verifyOwnerAndAmountOfHolding [(investor, 1000.25, investorEquityHoldingCid), - (investor, 2000.50, investorCashHoldingCid)] - - -- Test bonus issue (works in a similar way to the dividend above) - - -- Distribute holdings: fractional holdings are also supported. - investorEquityCid <- Account.credit [publicParty] cumEquityInstrument 1000.25 investorAccount - - -- CREATE_EQUITY_BONUS_ISSUE_DISTRIBUTION_EVENT_BEGIN - -- Create bonus issue event: receive 2 additional shares for each share currently held - -- (this also works with fractional shares) - distributionEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "ABC - " <> show now - description = "Bonus issue" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [qty 2.0 exEquityInstrument] - -- CREATE_EQUITY_BONUS_ISSUE_DISTRIBUTION_EVENT_END - - -- Lifecycle bonus issue - (_, [effectCid]) <- submit issuer do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = distributionEventCid - instrument = cumEquityInstrument - - -- The effect is claimed and then settled by the custodian, but it could also be claimed and then - -- settled by the investor. - result <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd claimRuleCid Claim.ClaimEffect with - claimer = custodian - holdingCids = [investorEquityCid] - effectCid - batchId = Id "BonusIssueSettlement" - - let - [investorInstrumentInstructionCid, custodianInstrumentInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = Pledge $ fromInterfaceContractId investorEquityCid - (custodianInstrumentInstructionCid, _) <- submit custodian do - exerciseCmd custodianInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit custodian do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton custodian; approval = DebitSender - custodianInstrumentInstructionCid <- submit investor do - exerciseCmd custodianInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - - -- Settle batch - [investorEquityHoldingCid] <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = Set.singleton custodian - - -- Assert state - Holding.verifyOwnerAndAmountOfHolding [(investor, 3000.75, investorEquityHoldingCid)] - - -- Test dividend option: the shareholder can choose (only) one out of several dividend effects. - - -- Distribute holdings: fractional holdings are also supported. - investorEquityCid <- Account.credit [publicParty] cumEquityInstrument 1000.25 investorAccount - - -- CREATE_EQUITY_DIVIDEND_OPTION_DISTRIBUTION_EVENT_BEGIN - -- Create dividend option event. - -- For each share currently held, the shareholder can choose to either receive cash (USD 10.5) or - -- stock (1.5 additional shares). - -- perUnitDistribution is an arbitrary list, so this can be extended with additional options, e.g. - -- warrants or cash in a different currency. - distributionEventCashCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "ABC - " <> show now - description = "Dividend option: cash" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [qty 10.5 cashInstrument] - - distributionEventStockCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "ABC - " <> show now - description = "Dividend option: stock" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [qty 1.5 exEquityInstrument] - -- CREATE_EQUITY_DIVIDEND_OPTION_DISTRIBUTION_EVENT_END - - -- LIVECYCLE_DIVIDEND_OPTION_BEGIN - -- Lifecycle dividend option - (_, [effectCashCid]) <- submit issuer do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = distributionEventCashCid - instrument = cumEquityInstrument - - (_, [effectStockCid]) <- submit issuer do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = distributionEventStockCid - instrument = cumEquityInstrument - -- LIVECYCLE_DIVIDEND_OPTION_END - - -- INVESTOR_CLAIMS_DIVIDEND_OPTION_BEGIN - -- The investor chooses the stock dividend - result <- submit (actAs investor <> readAs publicParty) do - exerciseCmd claimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorEquityCid] - effectCid = effectStockCid - batchId = Id "DividendOptionSettlement" - -- INVESTOR_CLAIMS_DIVIDEND_OPTION_END - - let - [investorInstrumentInstructionCid, custodianInstrumentInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = Pledge $ fromInterfaceContractId investorEquityCid - (custodianInstrumentInstructionCid, _) <- submit custodian do - exerciseCmd custodianInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit custodian do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton custodian; approval = DebitSender - custodianInstrumentInstructionCid <- submit investor do - exerciseCmd custodianInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - - -- Settle batch - [investorEquityHoldingCid] <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = Set.singleton custodian - - -- Assert state - Holding.verifyOwnerAndAmountOfHolding [(investor, 2500.625, investorEquityHoldingCid)] - - -- The investor then tries to choose the cash dividend as well. - -- This fails as expected, because the investor has already chosen the stock - -- dividend and during that settlement the cum dividend equity holding was consumed. - submitMustFail (actAs [investor] <> readAs [publicParty]) do - exerciseCmd claimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorEquityCid] - effectCid = effectCashCid - batchId = Id "DividendOptionSettlement" - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Equity/Test/Merger.daml b/src/test/daml/Daml/Finance/Instrument/Equity/Test/Merger.daml deleted file mode 100644 index 888fe493d..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Equity/Test/Merger.daml +++ /dev/null @@ -1,142 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.Test.Merger where - -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Equity.Test.Util (originateEquity) -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Equity (DeclareReplacement(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Lifecycle.V4.Rule.Replacement qualified as Replacement (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Script - --- Merger lifecycling and settlement --- This is a mandatory corporate action: no election is required by the shareholder. -run : Script () -run = script do - -- Create parties - [merging, merged, custodian, investor, publicParty] <- - createParties ["MergingIssuer", "MergedIssuer", "Custodian", "Investor", "PublicParty"] - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory custodian pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with - provider = custodian; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorSecuritiesAccount <- Account.createAccount "Securities Account" [] accountFactoryCid - holdingFactory [] Account.Owner custodian investor - - -- CREATE_EQUITY_REPLACEMENT_RULE_BEGIN - -- Create lifecycle rules - replacementRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit merging do - createCmd Replacement.Rule with - providers = Set.singleton merging - lifecycler = merging - observers = Set.singleton publicParty - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument following a replacement event" - -- CREATE_EQUITY_REPLACEMENT_RULE_END - - -- Originate instruments - now <- getTime - -- CREATE_EQUITY_INSTRUMENTS_BEGIN - mergingInstrument <- - originateEquity merging merging "INST-1" "0" TransferableFungible "ABC" pp now - mergedInstrument <- - originateEquity merged merged "INST-2" "0" TransferableFungible "XYZ" pp now - -- CREATE_EQUITY_INSTRUMENTS_END - - -- Distribute holdings - investorEquityCid <- Account.credit [] mergingInstrument 2_000.0 investorSecuritiesAccount - - -- CREATE_EQUITY_REPLACEMENT_EVENT_BEGIN - -- Create replacement event - -- perUnitReplacement is an arbitrary list of instruments, so the investor can also receive a - -- combination of shares and cash. - replacementEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [merging] [] mergingInstrument - Equity.DeclareReplacement with - id = Id $ "ABC merge - " <> show now - description = "Merge" - effectiveTime = now - perUnitReplacement = [qty 0.5 mergedInstrument] - -- CREATE_EQUITY_REPLACEMENT_EVENT_END - - -- LIFECYCLE_MERGER_BEGIN - -- Lifecycle replacement event - (_, [effectCid]) <- submit merging do - exerciseCmd replacementRuleCid Lifecycle.Evolve with - eventCid = replacementEventCid - observableCids = [] - instrument = mergingInstrument - -- LIFECYCLE_MERGER_END - - -- Claim effect - routeProviderCid <- toInterfaceContractId <$> submit custodian do - createCmd SingleCustodian with - provider = custodian; observers = Set.singleton publicParty; custodian - settlementFactoryCid <- toInterfaceContractId <$> submit custodian do - createCmd Factory with provider = custodian; observers = Set.singleton publicParty - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit custodian do - createCmd Claim.Rule with - provider = custodian - claimers = Set.fromList [custodian, investor] - settlers = Set.fromList [custodian, investor] - routeProviderCid - settlementFactoryCid - netInstructions = False - - result <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = custodian - holdingCids = [investorEquityCid] - effectCid - batchId = Id "MergerSettlement" - - -- Allocate instructions - let [consumeInstructionCid, produceInstructionCid] = result.instructionCids - (consumeInstructionCid, _) <- submit investor do - exerciseCmd consumeInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = Pledge $ fromInterfaceContractId investorEquityCid - (produceInstructionCid, _) <- submit custodian do - exerciseCmd produceInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - - -- Approve instructions - consumeInstructionCid <- submit custodian do - exerciseCmd consumeInstructionCid Instruction.Approve with - actors = Set.singleton custodian; approval = DebitSender - produceInstructionCid <- submit investor do - exerciseCmd produceInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorSecuritiesAccount - - -- Settle batch - [investorEquityCid] <- submit custodian do - exerciseCmd result.batchCid Batch.Settle with actors = Set.singleton custodian - - -- Assert state - Holding.verifyOwnerOfHolding [(investor, investorEquityCid)] - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Equity/Test/RightsIssue.daml b/src/test/daml/Daml/Finance/Instrument/Equity/Test/RightsIssue.daml deleted file mode 100644 index 02f010d79..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Equity/Test/RightsIssue.daml +++ /dev/null @@ -1,260 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.Test.RightsIssue where - -import DA.Date (Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Equity.Test.Util (originateEquity) -import Daml.Finance.Instrument.Option.Test.Util (originateEuropeanPhysicalOption) -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Equity (DeclareDistribution(..), I) -import Daml.Finance.Interface.Instrument.Option.V0.Types (OptionTypeEnum(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Lifecycle.V4.Rule.Distribution qualified as Distribution (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerAndAmountOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Lifecycle (electAndVerifyPaymentEffects) -import Daml.Script - --- Rights issue and subscription: lifecycling and settlement -run : Script () -run = script do - ------------------ - -- Rights issue -- - ------------------ - - -- Create parties - [cb, issuer, custodian, investor, publicParty] <- - createParties ["CentralBank", "Issuer", "Custodian", "Investor", "PublicParty"] - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory issuer pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with - provider = custodian; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorAccount <- - Account.createAccount "Investor Account" [publicParty] accountFactoryCid holdingFactory [] - Account.Owner custodian investor - issuerAccount <- - Account.createAccount "Issuer Account" [publicParty] accountFactoryCid holdingFactory [] - Account.Owner custodian issuer - - let - expiryDate = date 2019 May 15 - strikeLow = 40.0 - isLong = True - - -- Originate instruments - now <- getTime - cashInstrument <- originate cb cb "USD" TransferableFungible "United States Dollar" pp now - cumEquityInstrument <- originateEquity issuer issuer "EQUITY-INST-1" "0" TransferableFungible - "ABC" pp now - exEquityInstrument <- originateEquity issuer issuer "EQUITY-INST-1" "1" TransferableFungible "ABC" - [] now - rightsInstrument <- originateEuropeanPhysicalOption issuer issuer "Long Call" TransferableFungible - "Option" pp now expiryDate Call strikeLow cashInstrument exEquityInstrument isLong publicParty - - -- Distribute holdings: fractional holdings are also supported. - investorEquityCid <- Account.credit [publicParty] cumEquityInstrument 1000.0 investorAccount - - -- Create distribution rule for the rights issue - distributionRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit issuer do - createCmd Distribution.Rule with - providers = Set.singleton issuer - lifecycler = issuer - observers = Set.singleton publicParty - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument following a distribution event" - - -- Create rights issue event: 0.1 per share (this also works with fractional shares) - distributionEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "ABC - " <> show now - description = "Rights issue" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [qty 0.1 rightsInstrument] - - -- Lifecycle rights issue - (_, [effectCid]) <- submit issuer do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = distributionEventCid - instrument = cumEquityInstrument - - -- Claim effect - routeProviderCid <- toInterfaceContractId <$> submit custodian do - createCmd SingleCustodian with - provider = custodian; observers = Set.singleton publicParty; custodian - settlementFactoryCid <- toInterfaceContractId <$> submit custodian do - createCmd Factory with provider = custodian; observers = Set.singleton publicParty - -- Enable netting so that there is only one holding with the new correct quantity - let settlers = Set.fromList [investor, custodian] - claimRuleCid <- toInterfaceContractId @Claim.I <$> submit custodian do - createCmd Claim.Rule with - provider = custodian - claimers = Set.fromList [investor, custodian] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = True - - -- The effect is claimed and then settled by the custodian, but it could also be claimed and then - -- settled by the investor. - result <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd claimRuleCid Claim.ClaimEffect with - claimer = custodian - holdingCids = [investorEquityCid] - effectCid - batchId = Id "RightsSettlement" - - let - [investorInstrumentInstructionCid, custodianInstrumentInstructionCid, - custodianRightsInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = Pledge $ fromInterfaceContractId investorEquityCid - (custodianInstrumentInstructionCid, _) <- submit custodian do - exerciseCmd custodianInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - (custodianRightsInstructionCid, _) <- submit custodian do - exerciseCmd custodianRightsInstructionCid Instruction.Allocate with - actors = Set.singleton custodian; allocation = CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit custodian do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton custodian; approval = DebitSender - custodianInstrumentInstructionCid <- submit investor do - exerciseCmd custodianInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - custodianRightsInstructionCid <- submit investor do - exerciseCmd custodianRightsInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - - -- Settle batch - [investorEquityHoldingCid, investorRightsHoldingCid] <- submit (actAs custodian <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = Set.singleton custodian - - -- Assert state - Holding.verifyOwnerAndAmountOfHolding [(investor, 1000.00, investorEquityHoldingCid), - (investor, 100.00, investorRightsHoldingCid)] - - ------------------------- - -- Rights subscription -- - ------------------------- - - -- The investor can now subscribe by electing to exercise the call option, either in parts - -- or in whole. - -- It is also possible to to apply for excess subscription. For example, an investor would - -- like to subscribe for 150 shares but has regular rights for only 100 shares. - -- In that case, the investor would: - -- 1. Exercise the call option in whole to subscribe for the guaranteed part (100 shares). - -- 2. Write a put option for the excess part (50 shares). The issuer could then exercise this in - -- part or in whole. - - let - sharesWanted = 150.0 - sharesGuaranteed = 100.0 - sharesExcess = sharesWanted - sharesGuaranteed - - -- 1. Exercise the call option in whole to subscribe for the guaranteed part (100 shares). - let - expectedConsumed = [qty 40.0 cashInstrument] - expectedProduced = [qty 1.0 exEquityInstrument] - (_, effectLongCallCid) <- electAndVerifyPaymentEffects expiryDate sharesGuaranteed - rightsInstrument isLong issuer investor [publicParty] "EXERCISE" [] expectedConsumed - expectedProduced - - -- Create a claim rule - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit custodian do - createCmd Claim.Rule with - provider = custodian - claimers = Set.fromList [custodian, investor] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - -- Cannot claim effect for a different amount than what was elected - -- In particular, electing for more than the size of the holding does not work: - investorRightsSmallHoldingCid <- Account.credit [publicParty] rightsInstrument 3.0 investorAccount - submitMustFail (actAs investor <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorRightsSmallHoldingCid] - effectCid = effectLongCallCid - batchId = Id "OptionExerciseSettlement" - - -- Electing for less than the size of the holding does not work either: - -- (you would have to split the holding first) - investorRightsBigHoldingCid <- Account.credit [publicParty] rightsInstrument 300.0 investorAccount - submitMustFail (actAs [investor] <> readAs [publicParty]) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorRightsBigHoldingCid] - effectCid = effectLongCallCid - batchId = Id "OptionExerciseSettlement" - - -- Electing for the same amount as the size of the holding works: - submit (actAs investor <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorRightsHoldingCid] - effectCid = effectLongCallCid - batchId = Id "CallOptionExerciseSettlement" - - -- 2. Write a put option for the excess part (50 shares). The issuer could then exercise this in - -- part or in whole. - - let isLong = False - shortPutInstrument <- originateEuropeanPhysicalOption issuer issuer "Short Put" - TransferableFungible "Option" pp now expiryDate Put strikeLow cashInstrument exEquityInstrument - isLong publicParty - - -- Verify that election on the short put results in the same (per unit) as the long call. - -- In other words, subscription of guaranteed rights and excess rights have the same output: - -- one unit of stock at a constant price, per unit of subscribed and allotted right. - let - expectedConsumed = [qty 40.0 cashInstrument] - expectedProduced = [qty 1.0 exEquityInstrument] - (_, effectShortPutCid) <- electAndVerifyPaymentEffects expiryDate sharesExcess - shortPutInstrument isLong issuer custodian [publicParty] "EXERCISE" [] expectedConsumed - expectedProduced - - investorShortPutHoldingCid <- Account.credit [publicParty] shortPutInstrument sharesExcess - investorAccount - - -- Electing for the same amount as the size of the holding works: - submit (actAs custodian <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = custodian - holdingCids = [investorShortPutHoldingCid] - effectCid = effectShortPutCid - batchId = Id "PutOptionExerciseSettlement" - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml b/src/test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml deleted file mode 100644 index cba83a65c..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Equity/Test/StockSplit.daml +++ /dev/null @@ -1,142 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.Test.StockSplit where - -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Equity.Test.Util (originateEquity) -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Equity (DeclareStockSplit(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Lifecycle.V4.Rule.Replacement qualified as Replacement (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Script - --- import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I) --- import Daml.Finance.Interface.Types.Common.V3.Types (Quantity(..)) --- import Daml.Finance.Lifecycle.V4.Event.Replacement as ReplacementEvent - --- Stock split lifecycling and settlement -run : Script () -run = script do - -- Create parties - [issuer, investor, publicParty] <- createParties ["Issuer", "Investor", "PublicParty"] - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create factories - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory issuer pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = issuer; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorSecuritiesAccount <- Account.createAccount "Securities Account" [] accountFactoryCid - holdingFactory [] Account.Owner issuer investor - - -- CREATE_EQUITY_REPLACEMENT_RULE_BEGIN - -- Create lifecycle rule - replacementRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit issuer do - createCmd Replacement.Rule with - providers = Set.singleton issuer - lifecycler = issuer - observers = Set.singleton publicParty - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument following a replacement event" - -- CREATE_EQUITY_REPLACEMENT_RULE_END - - -- Originate instruments - now <- getTime - -- CREATE_EQUITY_INSTRUMENTS_BEGIN - preEquityInstrument <- - originateEquity issuer issuer "INST-1" "0" TransferableFungible "AAPL" pp now - postEquityInstrument <- - originateEquity issuer issuer "INST-1" "1" TransferableFungible "AAPL" pp now - -- CREATE_EQUITY_INSTRUMENTS_END - - -- Distribute holdings - investorEquityCid <- Account.credit [publicParty] preEquityInstrument 1_000.0 - investorSecuritiesAccount - - -- CREATE_EQUITY_REPLACEMENT_EVENT_BEGIN - -- Create stock split event - replacementEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] preEquityInstrument - Equity.DeclareStockSplit with - id = Id $ "APPL - " <> show now - description = "Stocksplit" - effectiveTime = now - newInstrument = postEquityInstrument - adjustmentFactor = 0.5 - -- CREATE_EQUITY_REPLACEMENT_EVENT_END - - -- LIFECYCLE_STOCK_SPLIT_BEGIN - -- Lifecycle stock split - (_, [effectCid]) <- submit issuer do - exerciseCmd replacementRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = replacementEventCid - instrument = preEquityInstrument - -- LIFECYCLE_STOCK_SPLIT_END - - -- Claim effect - routeProviderCid <- toInterfaceContractId <$> submit issuer do - createCmd SingleCustodian with - provider = issuer; observers = Set.singleton publicParty; custodian = issuer - settlementFactoryCid <- toInterfaceContractId <$> submit issuer do - createCmd Factory with provider = issuer; observers = Set.singleton publicParty - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit issuer do - createCmd Claim.Rule with - provider = issuer - claimers = Set.fromList [investor, issuer] - settlers = Set.fromList [investor, issuer] - routeProviderCid - settlementFactoryCid - netInstructions = False - - result <- submit issuer do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = issuer - holdingCids = [investorEquityCid] - effectCid - batchId = Id "StockSplitSettlement" - - -- Allocate instructions - let [consumeInstructionCid, produceInstructionCid] = result.instructionCids - (consumeInstructionCid, _) <- submit investor do - exerciseCmd consumeInstructionCid Instruction.Allocate with - actors = Set.singleton investor - allocation = Pledge $ fromInterfaceContractId investorEquityCid - (produceInstructionCid, _) <- submit issuer do - exerciseCmd produceInstructionCid Instruction.Allocate with - actors = Set.singleton issuer; allocation = CreditReceiver - - -- Approve instructions - consumeInstructionCid <- submit issuer do - exerciseCmd consumeInstructionCid Instruction.Approve with - actors = Set.singleton issuer; approval = DebitSender - produceInstructionCid <- submit investor do - exerciseCmd produceInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorSecuritiesAccount - - -- Settle batch - [investorEquityCid] <- submit (actAs investor <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = Set.singleton investor - - -- Assert state - Holding.verifyOwnerOfHolding [(investor, investorEquityCid)] - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Equity/Test/Util.daml b/src/test/daml/Daml/Finance/Instrument/Equity/Test/Util.daml deleted file mode 100644 index 5f0f4dbeb..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Equity/Test/Util.daml +++ /dev/null @@ -1,27 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Equity.Test.Util where - -import DA.Map (fromList) -import Daml.Finance.Instrument.Equity.V0.Factory (Factory(..)) -import Daml.Finance.Interface.Instrument.Equity.V0.Factory qualified as EquityFactory (Create(..), I) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), Parties) -import Daml.Script - --- | Originate an `Equity` Instrument. -originateEquity : Party -> Party -> Text -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> Script InstrumentKey -originateEquity depository issuer label version holdingStandard description observers - timestamp = do - equityFactoryCid <- toInterfaceContractId @EquityFactory.I <$> submit issuer do - createCmd Factory with provider = issuer; observers = mempty - let - instrument = InstrumentKey with depository; issuer; version; id = Id label; holdingStandard - submit [depository, issuer] do - exerciseCmd equityFactoryCid EquityFactory.Create with - instrument; description - observers = fromList observers - validAsOf = timestamp - submit [depository, issuer] do archiveCmd equityFactoryCid - pure instrument diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/CallableBond.daml b/src/test/daml/Daml/Finance/Instrument/Generic/Test/CallableBond.daml deleted file mode 100644 index 004ea2f24..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/CallableBond.daml +++ /dev/null @@ -1,324 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.Test.CallableBond where - -import ContingentClaims.Core.V3.Claim (and, at, give, one, or, scale, when) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Assert ((===)) -import DA.Date as D (Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import DA.Time (time) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Holding.V4.TransferableFungible () -import Daml.Finance.Instrument.Generic.Test.Election.Workflow (CreateElectionCandidate(..), ElectionOffer(..), ValidateElectionCandidate(..)) -import Daml.Finance.Instrument.Generic.Test.Util (mapClaimToUTCTime, originateGeneric) -import Daml.Finance.Instrument.Generic.V4.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Interface.Account.V4.Util () -import Daml.Finance.Interface.Claims.V4.Types (C, Deliverable) -import Daml.Finance.Interface.Util.V3.HoldingSplice () -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (Apply(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), Parties) -import Daml.Finance.Lifecycle.V4.Election qualified as Election (Factory(..)) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Finance.Test.Util.Time (createDateClock) -import Daml.Script -import Prelude hiding (and, or) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - - --- This script tests the election mechanism on an Instrument.Generic using the example of a callable --- bond. The custodian of the callable bond holding has the right to call back the bond and repay --- the principal to the owner before maturity. - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ Acts as custodian in the respective holdings (both cash holdings and instrument - -- holdings). It also acts as depository in the bond instrument. It has the right to call - -- back the bond before maturity. - issuer : Party - -- ^ Acts as issuer of the bond instrument. It is also the party tasked with lifecycling the - -- contract and processing elections. - centralBank : Party - -- ^ The Central Bank is the depository and the issuer of the cash instrument. - investor : Party - -- ^ Owner of the bond holding. Chooses to exercise the right of the call bond. - settlers : Parties - -- ^ Any of the parties can trigger the settlement of fully allocated settlement instructions. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- | Creates the claim for a callable bond (with 2 coupons) and the corresponding elections. -bootstrapBond : Date -> Date -> Date -> Decimal -> Decimal -> Decimal -> Deliverable -> C -bootstrapBond cpn1Date cpn2Date maturity couponAmount principalAmount callPrincipalAmount ccy = - let - coupon = give $ scale (Const couponAmount) $ one ccy - principal = give $ scale (Const principalAmount) $ one ccy - callPrincipal = give $ scale (Const callPrincipalAmount) $ one ccy - called = ("CALLED",) callPrincipal - notCalledFinal = ("NOT CALLED",) $ when (at maturity) $ principal - notCalled = ("NOT CALLED",) $ when (at cpn2Date) $ and coupon $ or called notCalledFinal - callableBond = when (at cpn1Date) $ give $ and coupon $ or called notCalled - in mapClaimToUTCTime callableBond - -run : Script () -run = script do - - -------------- - -- 0. SETUP -- - -------------- - - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorAccount <- Account.createAccount "Default Account" [] accountFactoryCid holdingFactory - [] Account.Owner bank investor - - -- Originate cash - now <- getTime - cashInstrument <- Instrument.originate centralBank centralBank "USD" TransferableFungible - "United States Dollar" pp now - - -- Create and distribute a generic derivative - let - acquisitionTime = time (D.date 2022 Jul 01) 0 0 0 - coupon1Date = D.date 2022 Jul 07 - coupon2Date = D.date 2023 Jul 07 - maturityDate = D.date 2024 Jul 07 - couponAmount = 1_000.0 - principalAmount = 100_000.0 - callPrincipalAmount = 101_000.0 - bond = bootstrapBond coupon1Date coupon2Date maturityDate couponAmount principalAmount - callPrincipalAmount cashInstrument - genericInstrument <- originateGeneric bank issuer "ABC.DE 1% 07/07/23 Corp" TransferableFungible - "Callable Bond" acquisitionTime bond pp now - - -- Create election offer to allow the custodian to create elections - electionFactoryCid <- submit issuer do - toInterfaceContractId <$> createCmd Election.Factory with - provider = issuer - observers = Map.fromList [("Custodian", Set.singleton bank)] - - currentTimeCid <- createDateClock (Set.singleton issuer) coupon1Date mempty - - -- Create a lifecycle rule - lifecycleRuleCid <- toInterfaceContractId <$> submit bank do - createCmd Lifecycle.Rule with - providers = Set.singleton bank - observers = mempty - lifecycler = issuer - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - - --------------------------------- - -- 1. ELECTION : CALL THE BOND -- - --------------------------------- - - investorGenericHoldingCid <- Account.credit [publicParty] genericInstrument 1.0 investorAccount - - callElectionFactoryCid <- submit issuer do - createCmd ElectionOffer with - provider = issuer - id = Id "bondcall1" - description = "Bond - Call" - claim = "CALLED" - observers = Set.singleton publicParty - instrument = genericInstrument - factoryCid = electionFactoryCid - - -- One cannot exercise for more units than they own - submitMustFail (actAs [bank] <> readAs [publicParty]) do - exerciseCmd callElectionFactoryCid CreateElectionCandidate with - elector = bank - electionTime = dateToDateClockTime coupon1Date - holdingCid = investorGenericHoldingCid - amount = 5000.0 - - -- Create election - electionProposalCid <- submit (actAs bank <> readAs publicParty) do - exerciseCmd callElectionFactoryCid CreateElectionCandidate with - elector = bank - electionTime = dateToDateClockTime coupon1Date - holdingCid = fromInterfaceContractId investorGenericHoldingCid - amount = 1.0 - - electionCid <- submit issuer do - exerciseCmd electionProposalCid ValidateElectionCandidate with - currentTimeCid - - -- Apply election to generate new instrument version + effects - (_, [effectCid]) <- submit issuer do - exerciseCmd electionCid Election.Apply with - observableCids = [] - exercisableCid = lifecycleRuleCid - - -- Create route provider - routeProviderCid <- toInterfaceContractId <$> submit bank do - createCmd SingleCustodian with provider = bank; observers = mempty; custodian = bank - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId <$> submit bank do - createCmd Factory with provider = bank; observers = mempty - - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit bank do - createCmd Claim.Rule with - provider = bank - claimers = Set.fromList [bank, investor] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = True - - -- Claim effect - result <- submit (actAs bank <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = bank - holdingCids = [investorGenericHoldingCid] - effectCid - batchId = Id "BondCallSettlement" - - let - [investorInstrumentInstructionCid, bankCashInstructionCouponAndPrincipalCid] = - result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor; allocation = SettlementTypes.Pledge investorGenericHoldingCid - (bankCashInstructionCouponAndPrincipalCid, _) <- submit bank do - exerciseCmd bankCashInstructionCouponAndPrincipalCid Instruction.Allocate with - actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit bank do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = SettlementTypes.DebitSender - bankCashInstructionCouponAndPrincipalCid <- submit investor do - exerciseCmd bankCashInstructionCouponAndPrincipalCid Instruction.Approve with - actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorAccount - - -- Settle batch - [investorCashHoldingCouponAndPrincipalCid: ContractId Api.HoldingV1.Holding] <- submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - -- Assert state - Some investorCouponAndPrincipal <- - queryInterfaceContractId @Api.HoldingV1.Holding @Api.HoldingV1.HoldingView investor investorCashHoldingCouponAndPrincipalCid - investorCouponAndPrincipal.amount === couponAmount + callPrincipalAmount - investorCouponAndPrincipal.owner === investor - - ---------------------------------------- - -- 2. ELECTION : DO NOT CALL THE BOND -- - ---------------------------------------- - - investorGenericHoldingCid <- Account.credit [publicParty] genericInstrument 1.0 investorAccount - - dontCallElectionFactoryCid <- submit issuer do - createCmd ElectionOffer with - provider = issuer - id = Id "bondDontCall1" - description = "Bond - Do not Call" - claim = "NOT CALLED" - observers = Set.singleton publicParty - instrument = genericInstrument - factoryCid = electionFactoryCid - - -- Create election - electionProposalCid <- submit (actAs bank <> readAs publicParty) do - exerciseCmd dontCallElectionFactoryCid CreateElectionCandidate with - elector = bank - electionTime = dateToDateClockTime coupon1Date - holdingCid = fromInterfaceContractId investorGenericHoldingCid - amount = 1.0 - - electionCid <- submit issuer do - exerciseCmd electionProposalCid ValidateElectionCandidate with - currentTimeCid - - -- Apply election to generate new instrument version + effects - (_, [effectCid]) <- submit issuer do - exerciseCmd electionCid Election.Apply with - observableCids = [] - exercisableCid = lifecycleRuleCid - - -- Claim effect - result <- submit (actAs bank <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = bank - holdingCids = [investorGenericHoldingCid] - effectCid - batchId = Id "BondDontCallSettlement" - - let - [investorInstrumentInstructionCid, bankInstrumentInstructionCid, - bankCashInstructionCouponAndPrincipalCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor; allocation = SettlementTypes.Pledge investorGenericHoldingCid - (bankInstrumentInstructionCid, _) <- submit bank do - exerciseCmd bankInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver - (bankCashInstructionCouponAndPrincipalCid, _) <- submit bank do - exerciseCmd bankCashInstructionCouponAndPrincipalCid Instruction.Allocate with - actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit bank do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = SettlementTypes.DebitSender - bankInstrumentInstructionCid <- submit investor do - exerciseCmd bankInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorAccount - bankCashInstructionCouponAndPrincipalCid <- submit investor do - exerciseCmd bankCashInstructionCouponAndPrincipalCid Instruction.Approve with - actors = Set.singleton investor; approval = SettlementTypes.TakeDelivery investorAccount - - -- Settle batch - [investorInstrumentAfterCouponHoldingCid, investorCashHoldingCouponAndPrincipalCid] - <- submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - -- Assert state - Some investorCouponAndPrincipal <- - queryInterfaceContractId @Api.HoldingV1.Holding @Api.HoldingV1.HoldingView investor investorCashHoldingCouponAndPrincipalCid - investorCouponAndPrincipal.amount === couponAmount - investorCouponAndPrincipal.owner === investor - - Some investorBondAfterCoupon <- - queryInterfaceContractId @Api.HoldingV1.Holding @Api.HoldingV1.HoldingView investor investorInstrumentAfterCouponHoldingCid - investorBondAfterCoupon.amount === 1.0 - investorBondAfterCoupon.owner === investor - - pure () - -setupParties : Script TestParties -setupParties = do - [bank, issuer, centralBank, investor, settler, publicParty] <- - createParties ["Bank", "issuer", "Central Bank", "Investor", "Settler", "PublicParty"] - pure TestParties with - bank; issuer; centralBank; investor; settlers = Set.singleton settler; publicParty diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/Election/Workflow.daml b/src/test/daml/Daml/Finance/Instrument/Generic/Test/Election/Workflow.daml deleted file mode 100644 index ac71d08f1..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/Election/Workflow.daml +++ /dev/null @@ -1,147 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - --- | This module includes helper contracts to delegate the right to create `Election`\s --- referencing a specific `Instrument`. A number of sensible sanity-checks are performed. --- The provider of the `ElectionOffer` delegates the ability to create `Election`\s to any party --- that has visibility on the `ElectionOffer` contract. --- In order to create an `ElectionCandidate`, a valid `Holding` must be presented which identifies --- the choice controller as either the owner or the custodian to the `Holding`. --- The `ElectionCandidate` then needs to be validated in order to create an `Election`. --- This module is not part of the main Daml Finance library as we consider the delegation / --- sanity-checking logic herein to be application-specific rather than generic. -module Daml.Finance.Instrument.Generic.Test.Election.Workflow where - -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import DA.TextMap qualified as TextMap -import DA.Optional (fromOptional) -import DA.Text (sha256) -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (I) -import Daml.Finance.Interface.Lifecycle.V4.Election.Factory qualified as ElectionFactory (Create(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Observable.TimeObservable qualified as TimeObservable (GetTime(..), I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), InstrumentKey(..), Parties) -import Daml.Finance.Interface.Util.V3.Common (verify) -import Daml.Finance.Interface.Util.V3.HoldingSplice(getInstrument, textToParty) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Template used to facilitate creation of an `Election`. -template ElectionOffer - with - provider : Party - -- ^ The provider. - id : Id - -- ^ Election identifier. - description : Text - -- ^ A human readable description of the election claim. - claim : Text - -- ^ The tag corresponding to the elected sub-tree. - instrument : InstrumentKey - -- ^ Key of the instrument to which the election applies. - factoryCid : ContractId ElectionFactory.I - -- ^ Election factory contract. - observers : Parties - -- ^ Observers of the contract. - where - signatory provider - observer observers - - nonconsuming choice CreateElectionCandidate : ContractId ElectionCandidate - -- ^ Creates an `Election` on an instrument. This choice must be exercised by the `elector`. - with - elector : Party - -- ^ Entity making the election. - electionTime : Time - -- ^ Time at which the election is put forward. - holdingCid : ContractId Api.HoldingV1.Holding - -- ^ A holding used to verify that the elector is entitled to make the election. - amount : Decimal - -- ^ Number of units of instrument to which the election applies. - controller elector - do - holding <- fetch holdingCid - let - holdingInstrumentKey = getInstrument holding - holdingView = view holding - - -- Verify that the holding corresponds to the expected instrument - verify (holdingInstrumentKey == instrument) - "Invalid holding presented : reference instrument" - - -- Verify sufficient amount in the holding - verify (holdingView.amount >= amount) $ - "Invalid holding presented : amount is " - <> show holdingView.amount - <> " but elected amount is " - <> show amount - - let - metaValues = holdingView.meta.values - custodianTxt = fromOptional "Missing metadata: custodian " (TextMap.lookup "custodian" metaValues) - custodian = textToParty custodianTxt - owner = holdingView.owner - electorIsOwner - | elector == owner = True - | elector == custodian = False - | otherwise = error "Election can be made only on behalf of the owner or the custodian" - counterparty = if electorIsOwner then elector else custodian - - create ElectionCandidate with - validator = provider; id; description; claim; instrument; factoryCid; elector - electionTime; amount; counterparty; electorIsOwner - --- | An `Election` that has to be validated. -template ElectionCandidate - with - validator : Party - -- ^ The party responsible for validating the election candidate. - elector : Party - -- ^ Entity making the election. - counterparty : Party - -- ^ The counterparty to the election. - id : Id - -- ^ Election identifier. - description : Text - -- ^ A human readable description of the election claim. - claim : Text - -- ^ The tag corresponding to the elected sub-tree. - instrument : InstrumentKey - -- ^ Key of the instrument to which the election applies. - factoryCid : ContractId ElectionFactory.I - -- ^ Election factory contract. - electionTime : Time - -- ^ Time at which the election is put forward. - amount : Decimal - -- ^ Number of units of instrument to which the election applies. - electorIsOwner : Bool - -- ^ Flag indicating if the elector is the holding owner or the custodian. - where - signatory elector - observer validator - - choice ValidateElectionCandidate : ContractId Election.I - with - currentTimeCid : ContractId TimeObservable.I - controller validator - do - -- Sanity check against current time - currentTime <- exercise currentTimeCid TimeObservable.GetTime with - actors = Set.singleton validator - assertMsg ("Election time " <> show electionTime - <> " must be greater or equal than current time " <> show currentTime) - $ electionTime >= currentTime - - -- Create election - exercise factoryCid ElectionFactory.Create with - actors = Set.fromList [elector, validator] - id = Id . sha256 $ show id <> show claim <> show elector <> show electionTime - description - claim - electionTime - electorIsOwner - elector - counterparty - instrument - amount - observers = Map.fromList [("Holders", Set.fromList [validator, elector, counterparty])] - provider = validator diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/EuropeanOption.daml b/src/test/daml/Daml/Finance/Instrument/Generic/Test/EuropeanOption.daml deleted file mode 100644 index 61038ca4e..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/EuropeanOption.daml +++ /dev/null @@ -1,348 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.Test.EuropeanOption where - -import ContingentClaims.Core.V3.Builders (european) -import ContingentClaims.Core.V3.Claim (one, scale) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Assert ((===)) -import DA.Date (addDays, toDateUTC) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Holding.V4.TransferableFungible () -import Daml.Finance.Instrument.Generic.Test.Election.Workflow (CreateElectionCandidate(..), ElectionOffer(..), ValidateElectionCandidate(..)) -import Daml.Finance.Instrument.Generic.Test.Util (mapClaimToUTCTime, originateGeneric) -import Daml.Finance.Instrument.Generic.V4.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Interface.Account.V4.Util () -import Daml.Finance.Interface.Claims.V4.Types (C, Deliverable, Observable) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, Split(..), SplitResult(..)) -import Daml.Finance.Interface.Util.V3.HoldingSplice () -import Daml.Finance.Interface.Lifecycle.V4.Election qualified as Election (Apply(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), Parties) -import Daml.Finance.Lifecycle.V4.Election qualified as Election (Factory(..)) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Finance.Test.Util.Time (createDateClock) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- This script tests the election mechanism on an Instrument.Generic using the example of a --- cash-settled European Call option. The owner of the option holding has the right to exercise it --- at maturity. - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ Acts as custodian in the respective holdings (both cash holdings and instrument - -- holdings). It also acts as depository in the option instrument. - broker : Party - -- ^ Acts as issuer of the option instrument. It is also the party tasked with lifecycling the - -- contract and processing elections. - centralBank : Party - -- ^ The Central Bank is the depository and the issuer of the cash instrument. - investor1 : Party - -- ^ Owner of the option holding. Chooses to exercise the right of the call option. - investor2 : Party - -- ^ Owner of the option holding. Chooses to not exercise the right of the call option. - settlers : Parties - -- ^ Any of the parties can trigger the settlement of fully allocated settlement instructions. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- | Creates the claim for a European Call option and the corresponding elections -bootstrapOption : Date -> Decimal -> Observable -> Deliverable -> C -bootstrapOption maturity strike spot ccy = - -- CREATE_CC_OPTION_INSTRUMENT_VARIABLES_BEGIN - let - exerciseClaim = scale (Observe spot - Const strike) $ one ccy - option = european maturity exerciseClaim - -- CREATE_CC_OPTION_INSTRUMENT_VARIABLES_END - in mapClaimToUTCTime option - -run : Script () -run = script do - - -------------- - -- 0. SETUP -- - -------------- - - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - [investor1Account, investor2Account] <- mapA (Account.createAccount "Default Account" [] - accountFactoryCid holdingFactory [] Account.Owner bank) [investor1, investor2] - - -- Originate cash - now <- getTime - cashInstrument <- Instrument.originate centralBank centralBank "USD" TransferableFungible - "United States Dollar" pp now - - -- Create observable for the underlying fixing - let - maturity = addDays (toDateUTC now) 1 - observations = Map.fromList [(dateToDateClockTime maturity, 200.0)] - observableCid <- toInterfaceContractId <$> submit broker do - createCmd Observation with - provider = broker; id = Id "SPOT/AAPL"; observations; observers = mempty - - -- Create and distribute a generic derivative - let - equityObservable = "SPOT/AAPL" - option = bootstrapOption maturity 150.0 equityObservable - cashInstrument - genericInstrument <- originateGeneric bank broker "OPTION-AAPL" TransferableFungible - "European Option" now option pp now - investor1GenericHoldingCid <- - Account.credit [publicParty] genericInstrument 1_000.0 investor1Account - investor2GenericHoldingCid <- - Account.credit [publicParty] genericInstrument 1_000.0 investor2Account - - -- CREATE_ELECTION_FACTORY_BEGIN - -- Create election offers to allow holders to create elections - electionFactoryCid <- submit broker do - toInterfaceContractId <$> createCmd Election.Factory with - provider = broker - observers = Map.fromList pp - -- CREATE_ELECTION_FACTORY_END - - -- CREATE_ELECTION_OFFER_EXERCISE_BEGIN - exerciseElectionFactoryCid <- submit broker do - createCmd ElectionOffer with - provider = broker - id = Id "EXERCISE" - description = "OPTION-AAPL - Exercise" - claim = "EXERCISE" - observers = Set.singleton publicParty - instrument = genericInstrument - factoryCid = electionFactoryCid - -- CREATE_ELECTION_OFFER_EXERCISE_END - - -- CREATE_ELECTION_OFFER_EXPIRE_BEGIN - expireElectionFactoryCid <- submit broker do - createCmd ElectionOffer with - provider = broker - id = Id "EXPIRE" - description = "OPTION-AAPL - Expire" - claim = "EXPIRE" - observers = Set.singleton publicParty - instrument = genericInstrument - factoryCid = electionFactoryCid - -- CREATE_ELECTION_OFFER_EXPIRE_END - - ----------------------------------------- - -- 1. ELECTION 1 : EXERCISE THE OPTION -- - ----------------------------------------- - - -- CREATE_TOO_BIG_ELECTION_CANDIDATE_BEGIN - -- One cannot exercise for more units than they own - submitMustFail (actAs investor1 <> readAs publicParty) do - exerciseCmd exerciseElectionFactoryCid CreateElectionCandidate with - elector = investor1 - electionTime = dateToDateClockTime maturity - holdingCid = investor1GenericHoldingCid - amount = 5000.0 - -- CREATE_TOO_BIG_ELECTION_CANDIDATE_END - - -- CREATE_ELECTION_CANDIDATE_BEGIN - -- Create election - exerciseOptionProposalCid <- submit (actAs investor1 <> readAs publicParty) do - exerciseCmd exerciseElectionFactoryCid CreateElectionCandidate with - elector = investor1 - electionTime = dateToDateClockTime maturity - holdingCid = investor1GenericHoldingCid - amount = 500.0 - -- CREATE_ELECTION_CANDIDATE_END - - -- CREATE_CLOCK_BEGIN - currentTimeCid <- createDateClock (Set.singleton broker) maturity mempty - -- CREATE_CLOCK_END - - -- CREATE_ELECTION_BEGIN - exerciseOptionCid <- submit broker do - exerciseCmd exerciseOptionProposalCid ValidateElectionCandidate with - currentTimeCid - -- CREATE_ELECTION_END - - -- CREATE_LIFECYCLE_RULE_BEGIN - -- Apply election to generate new instrument version + effects - lifecycleRuleCid <- toInterfaceContractId <$> submit bank do - createCmd Lifecycle.Rule with - providers = Set.singleton bank - observers = mempty - lifecycler = broker - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - -- CREATE_LIFECYCLE_RULE_END - - -- APPLY_ELECTION_BEGIN - (Some exercisedOption, [effectCid]) <- submit broker do - exerciseCmd exerciseOptionCid Election.Apply with - observableCids = [observableCid] - exercisableCid = lifecycleRuleCid - -- APPLY_ELECTION_END - - -- Create route provider - routeProviderCid <- toInterfaceContractId <$> submit investor1 do - createCmd SingleCustodian with provider = investor1; observers = mempty; custodian = bank - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId <$> submit investor1 do - createCmd Factory with provider = investor1; observers = mempty - - -- Claim effect - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit bank do - createCmd Claim.Rule with - provider = bank - claimers = Set.fromList [bank, investor1] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - -- Cannot claim effect for a different amount than what was elected - submitMustFail (actAs [investor1] <> readAs [publicParty]) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor1 - holdingCids = [investor1GenericHoldingCid] - effectCid - batchId = Id "OptionExerciseSettlement" - - -- Split fungible in order to claim with the right amount - let fungibleCid = fromInterfaceContractId @Fungible.I investor1GenericHoldingCid - Fungible.SplitResult [splitCid] (Some restCid) <- submit investor1 do - exerciseCmd fungibleCid Fungible.Split with amounts = [500.0] - - result <- submit (actAs investor1 <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor1 - holdingCids = [toInterfaceContractId splitCid] - effectCid - batchId = Id "OptionExerciseSettlement" - - let [investorInstrumentInstructionCid, bankCashInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor1 do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor1; allocation = SettlementTypes.Pledge $ toInterfaceContractId splitCid - (bankCashInstructionCid, _) <- submit bank do - exerciseCmd bankCashInstructionCid Instruction.Allocate with - actors = Set.singleton bank; allocation = SettlementTypes.CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit bank do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = SettlementTypes.DebitSender - bankCashInstructionCid <- submit investor1 do - exerciseCmd bankCashInstructionCid Instruction.Approve with - actors = Set.singleton investor1; approval = SettlementTypes.TakeDelivery investor1Account - - -- Settle batch - [investorCashHoldingCid : ContractId Api.HoldingV1.Holding] <- submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - -- Verify result - Some investorCash <- queryInterfaceContractId @Api.HoldingV1.Holding @Api.HoldingV1.HoldingView investor1 investorCashHoldingCid - investorCash.amount === 25_000.0 - investorCash.owner === investor1 - - ----------------------------------------- - -- 1. ELECTION 2 : EXPIRE THE OPTION -- - ----------------------------------------- - - expireOptionProposalCid <- submit (actAs investor2 <> readAs publicParty) do - exerciseCmd expireElectionFactoryCid CreateElectionCandidate with - elector = investor2 - electionTime = dateToDateClockTime maturity - holdingCid = investor2GenericHoldingCid - amount = 1000.0 - - expireOptionCid <- submit broker do - exerciseCmd expireOptionProposalCid ValidateElectionCandidate with - currentTimeCid - - (Some expiredOption, [effectCid]) <- submit broker do - exerciseCmd expireOptionCid Election.Apply with - observableCids = [observableCid] - exercisableCid = lifecycleRuleCid - - -- Create route provider - routeProviderCid <- toInterfaceContractId <$> submit investor2 do - createCmd SingleCustodian with provider = investor2; observers = mempty; custodian = bank - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId <$> submit investor2 do - createCmd Factory with provider = investor2; observers = mempty - - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit bank do - createCmd Claim.Rule with - provider = bank - claimers = Set.fromList [bank, investor2] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - -- Investor 1 cannot claim an effect for an election made by Investor 2 - submitMustFail (actAs [investor1] <> readAs [publicParty]) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor1 - holdingCids = [investor1GenericHoldingCid] - effectCid - batchId = Id "OptionExpirySettlement" - - -- Claim effect - result <- submit (actAs investor2 <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor2 - holdingCids = [investor2GenericHoldingCid] - effectCid - batchId = Id "OptionExpirySettlement" - - let [investorInstrumentInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor2 do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor2; allocation = SettlementTypes.Pledge investor2GenericHoldingCid - - -- Approve instructions - investorInstrumentInstructionCid <- submit bank do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = SettlementTypes.DebitSender - - -- Settle batch - [] <- submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - pure () - -setupParties : Script TestParties -setupParties = do - [bank, broker, centralBank, investor1, investor2, settler, publicParty] <- createParties - ["Bank", "Broker", "Central Bank", "Investor 1", "Investor 2", "Settler", "PublicParty"] - pure TestParties with - bank; broker; centralBank; investor1; investor2; settlers = Set.singleton settler; publicParty diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardCash.daml b/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardCash.daml deleted file mode 100644 index a45950c65..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardCash.daml +++ /dev/null @@ -1,169 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.Test.ForwardCash where - -import ContingentClaims.Core.V3.Claim (at, one, scale, when) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Date (addDays, toDateUTC) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Generic.Test.Util (originateGeneric) -import Daml.Finance.Instrument.Generic.V4.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), Parties) -import Daml.Finance.Lifecycle.V4.Rule.Claim qualified as Claim (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Finance.Test.Util.Time (createClockUpdateEvent) -import Daml.Script - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ Acts as custodian in the respective holdings (both cash holdings and instrument - -- holdings). It also acts as depository in the forward instrument. - broker : Party - -- ^ Acts as issuer of the forward contract. It is also the party tasked with lifecycling of - -- the contract. - centralBank : Party - -- ^ The Central Bank is the depository and the issuer of the cash instrument. - investor : Party - -- ^ Owner of the equity forward holding. - settlers : Parties - -- ^ Any of the parties can trigger the settlement of fully allocated settlement instructions. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- Cash-settled forward trade lifecycling and settlement (needs observations) -run : Script () -run = script do - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorAccount <- Account.createAccount "Default Account" [] accountFactoryCid holdingFactory - [] Account.Owner bank investor - - -- Distribute cash - now <- getTime - cashInstrument <- Instrument.originate centralBank centralBank "USD" TransferableFungible - "United States Dollar" pp now - - -- Create observable - let - maturity = addDays (toDateUTC now) 1 - observations = Map.fromList [(dateToDateClockTime maturity, 200.0)] - observableCid <- toInterfaceContractId <$> submit broker do - createCmd Observation with - provider = broker; id = Id "SPOT/AAPL"; observations; observers = mempty - - -- Create and distribute a gerneric derivative - let - equityObservable = "SPOT/AAPL" - claims = when (at $ dateToDateClockTime maturity) - $ scale (Observe equityObservable - Const 150.0) - $ one cashInstrument - genericInstrument <- originateGeneric bank broker "FWD-AAPL" TransferableFungible - "Forward Contract" now claims pp now - investorGenericHoldingCid <- - Account.credit [publicParty] genericInstrument 1_000.0 investorAccount - - -- create clock update event - clockEventCid <- createClockUpdateEvent (Set.singleton broker) maturity mempty - - -- Lifecycle derivative - lifecycleRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit bank do - createCmd Lifecycle.Rule with - providers = Set.singleton bank - observers = mempty - lifecycler = broker - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - - (_, [effectCid]) <- submit broker do - exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids = [observableCid] - instrument = genericInstrument - - -- Create route provider - routeProviderCid <- toInterfaceContractId <$> submit bank do - createCmd SingleCustodian with provider = bank; observers = mempty; custodian = bank - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId <$> submit bank do - createCmd Factory with provider = bank; observers = mempty - - -- Claim effect - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> submit bank do - createCmd Claim.Rule with - provider = bank - claimers = Set.fromList [bank, investor] - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - result <- submit (actAs bank <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = bank - holdingCids = [investorGenericHoldingCid] - effectCid - batchId = Id "ForwardCashSettlement" - - let [investorInstrumentInstructionCid, bankCashInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid - Instruction.Allocate with - actors = Set.singleton investor; allocation = Pledge investorGenericHoldingCid - (bankCashInstructionCid, _) <- submit bank do - exerciseCmd bankCashInstructionCid Instruction.Allocate with - actors = Set.singleton bank; allocation = CreditReceiver - - -- Approve instructions - investorInstrumentInstructionCid <- submit bank do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = DebitSender - bankCashInstructionCid <- submit investor do - exerciseCmd bankCashInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - - -- Settle batch - [investorCashHoldingCid] <- submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - -- Assert state - Holding.verifyOwnerOfHolding [(investor, investorCashHoldingCid)] - - pure () - -setupParties : Script TestParties -setupParties = do - [bank, broker, centralBank, investor, settler, publicParty] <- - createParties ["Bank", "Broker", "Central Bank", "Investor", "Settler", "PublicParty"] - pure TestParties with - bank; broker; centralBank; investor; settlers = Set.singleton settler; publicParty diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardPhysical.daml b/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardPhysical.daml deleted file mode 100644 index b5bb592c7..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/ForwardPhysical.daml +++ /dev/null @@ -1,182 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.Test.ForwardPhysical where - -import ContingentClaims.Core.V3.Claim (and, at, give, one, scale, when) -import ContingentClaims.Core.V3.Observation (Observation(..)) -import DA.Date (addDays, toDateUTC) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (singleton) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Instrument.Generic.Test.Util (originateGeneric) -import Daml.Finance.Instrument.Generic.V4.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Claim qualified as Claim (ClaimEffect(..), I) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..)) -import Daml.Finance.Interface.Settlement.V4.Types (Allocation(..), Approval(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), Parties) -import Daml.Finance.Lifecycle.V4.Rule.Claim (Rule(..)) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Finance.Test.Util.Time (createClockUpdateEvent) -import Daml.Script -import Prelude hiding (and) - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ Acts as custodian in the respective holdings (both cash holdings and instrument - -- holdings). It also acts as depository in the forward instrument and the equity - -- instrument. - broker : Party - -- ^ Acts as issuer of the forward contract. It is also the party tasked with lifecycling of - -- the contract. - centralBank : Party - -- ^ The Central Bank is the depository and the issuer of the cash instrument. - equityIssuer : Party - -- ^ Acts as issuer of the underlying equity contract. - investor : Party - -- ^ Owner of the equity forward holding. - settlers : Parties - -- ^ Any of the parties can trigger the settlement of fully allocated settlement instructions. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- Physically-settled forward trade lifecycling and settlement (no observations) -run : Script () -run = script do - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - investorAccount <- Account.createAccount "Default Account" [] accountFactoryCid holdingFactory - [] Account.Owner bank investor - - -- Distribute assets - now <- getTime - equityInstrument <- Instrument.originate bank equityIssuer "AAPL" TransferableFungible - "Apple Inc." pp now - cashInstrument <- Instrument.originate centralBank centralBank "USD" TransferableFungible - "United States Dollar" pp now - investorCashHoldingCid <- Account.credit [publicParty] cashInstrument 200_000.0 investorAccount - - -- Create and distribute a generic derivative - let - maturity = addDays (toDateUTC now) 1 - cashInstrumentDeliverable = one cashInstrument - equityInstrumentDeliverable = one equityInstrument - claims = when (at $ dateToDateClockTime maturity) - $ and equityInstrumentDeliverable - $ scale (Const 200.0) - $ give cashInstrumentDeliverable - genericInstrument <- originateGeneric bank broker "FWD-AAPL" TransferableFungible - "Forward Contract" now claims [("PublicParty", Set.singleton publicParty)] now - investorGenericHoldingCid <- Account.credit [publicParty] genericInstrument 1_000.0 - investorAccount - - -- create clock update event - clockEventCid <- createClockUpdateEvent (Set.singleton broker) maturity mempty - - -- Lifecycle a generic derivative - lifecycleRuleCid <- toInterfaceContractId @Lifecycle.I <$> - submit bank do - createCmd Lifecycle.Rule with - providers = Set.singleton bank - observers = mempty - lifecycler = broker - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - - (Some finalInstrument, [effectCid]) <- submit broker do - exerciseCmd lifecycleRuleCid Lifecycle.Evolve with - eventCid = clockEventCid - observableCids = [] - instrument = genericInstrument - - -- Create route provider - routeProviderCid <- toInterfaceContractId <$> - submit investor do - createCmd SingleCustodian with - provider = investor; observers = mempty; custodian = bank - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId <$> - submit investor do createCmd Factory with provider = investor; observers = mempty - - -- Claim effect - lifecycleClaimRuleCid <- toInterfaceContractId @Claim.I <$> - submit [bank, investor] do - createCmd Rule with - provider = bank - claimers = Set.singleton investor - settlers - routeProviderCid - settlementFactoryCid - netInstructions = False - - result <- submit (actAs investor <> readAs publicParty) do - exerciseCmd lifecycleClaimRuleCid Claim.ClaimEffect with - claimer = investor - holdingCids = [investorGenericHoldingCid] - effectCid - batchId = Id "ForwardPhysicalSettlement" - - let - [investorInstrumentInstructionCid, investorCashInstructionCid, - bankEquityInstructionCid] = result.instructionCids - - -- Allocate instructions - (investorInstrumentInstructionCid, _) <- submit investor do - exerciseCmd investorInstrumentInstructionCid Instruction.Allocate with - actors = Set.singleton investor; allocation = Pledge investorGenericHoldingCid - (bankEquityInstructionCid, _) <- submit bank do - exerciseCmd bankEquityInstructionCid Instruction.Allocate with - actors = Set.singleton bank; allocation = CreditReceiver - (investorCashInstructionCid, _) <- submit investor do - exerciseCmd investorCashInstructionCid Instruction.Allocate with - actors = Set.singleton investor; allocation = Pledge investorCashHoldingCid - - -- Approve instructions - investorInstrumentInstructionCid <- submit bank do - exerciseCmd investorInstrumentInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = DebitSender - investorCashInstructionCid <- submit bank do - exerciseCmd investorCashInstructionCid Instruction.Approve with - actors = Set.singleton bank; approval = DebitSender - bankEquityInstructionCid <- submit investor do - exerciseCmd bankEquityInstructionCid Instruction.Approve with - actors = Set.singleton investor; approval = TakeDelivery investorAccount - - -- Settle batch - [investorEquityHoldingCid] <- - submit (actAs settlers <> readAs publicParty) do - exerciseCmd result.batchCid Batch.Settle with actors = settlers - - -- Assert state - Holding.verifyOwnerOfHolding [(investor, investorEquityHoldingCid)] - - pure () - -setupParties : Script TestParties -setupParties = do - [bank, broker, centralBank, equityIssuer, investor, settler, publicParty] <- createParties - ["Bank", "Broker", "Central Bank", "Equity Issuer", "Investor", "Settler", "PublicParty"] - pure TestParties with - bank; broker; centralBank; equityIssuer; investor; settlers = Set.singleton settler; publicParty diff --git a/src/test/daml/Daml/Finance/Instrument/Generic/Test/Util.daml b/src/test/daml/Daml/Finance/Instrument/Generic/Test/Util.daml deleted file mode 100644 index 475bd9ad8..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Generic/Test/Util.daml +++ /dev/null @@ -1,50 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Generic.Test.Util where - -import ContingentClaims.Core.V3.Claim (Claim) -import DA.Map (fromList) -import Daml.Finance.Claims.V3.Util (toTime) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Generic.V4.Factory (Factory(..)) -import Daml.Finance.Interface.Claims.V4.Types (C, Deliverable, Observable) -import Daml.Finance.Interface.Instrument.Generic.V4.Factory qualified as GenericFactory (Create(..), I) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), Parties) -import Daml.Script - --- | Maps a `Date` claim to a `Time` claim using the rule in the `DateClock`. -mapClaimToUTCTime : Claim Date Decimal Deliverable Observable -> C -mapClaimToUTCTime = toTime dateToDateClockTime - --- | Originate generic instrument -originateGeneric : Party -> Party -> Text -> HoldingStandard -> Text -> Time -> C -> - [(Text, Parties)] -> Time -> Script InstrumentKey -originateGeneric depository issuer label holdingStandard description acquisitionTime claims - observers lastEventTimestamp = do - - -- Create a generic instrument factory - genericFactoryCid <- toInterfaceContractId @GenericFactory.I <$> submit issuer do - createCmd Factory with - provider = issuer - observers = mempty - - -- Create instrument - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - submit [issuer, depository] do - exerciseCmd genericFactoryCid GenericFactory.Create with - instrument - description - claims - acquisitionTime - lastEventTimestamp - observers = fromList observers - - pure instrument diff --git a/src/test/daml/Daml/Finance/Instrument/Option/Test/Dividend.daml b/src/test/daml/Daml/Finance/Instrument/Option/Test/Dividend.daml deleted file mode 100644 index 549d5fd05..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Option/Test/Dividend.daml +++ /dev/null @@ -1,77 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.Test.Dividend where - -import DA.Date (Month(..), date) -import DA.Set (singleton) -import Daml.Finance.Instrument.Option.Test.Util (electAndVerifyDivOptionPaymentEffects, originateDividendOption) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (ElectionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Script - --- Define and lifecycle dividend options, which are manually exercised and physically settled. -run : Script () -run = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - eurInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers now - aaplInstrument <- originate custodian issuer "AAPL" TransferableFungible "AAPL stock" observers - now - - -- Create and distribute option - let - -- CREATE_DIVIDEND_OPTION_VARIABLES_BEGIN - expiryDate = date 2019 May 15 - cashQuantity = qty 0.19 cashInstrument - sharesQuantity = Some $ qty 0.0041 aaplInstrument - fxQuantity = Some $ qty 0.17 eurInstrument - -- CREATE_DIVIDEND_OPTION_VARIABLES_END - - -- Issue instrument with only cash dividend or shares - longCashOrSharesDivOptionInstrument <- originateDividendOption issuer issuer "cash or shares" - TransferableFungible "Option" observers now expiryDate cashQuantity sharesQuantity None - publicParty - - -- issue instrument with only cash dividend or fx cash - longCashOrFxDivOptionInstrument <- originateDividendOption issuer issuer "cash or fx cash" - TransferableFungible "Option" observers now expiryDate cashQuantity None fxQuantity - publicParty - - -- Issue dividend instruments with 3 choices: cash, shares or fx cash - longDivOptionInstrument <- originateDividendOption issuer issuer "long div option" - TransferableFungible "Option" observers now expiryDate cashQuantity sharesQuantity fxQuantity - publicParty - - let amount = 1.0 - - -- Elect shares, long dividend option: Lifecycle and verify the lifecycle effects. - let - expectedConsumed = [] - expectedProduced = [qty 0.0041 aaplInstrument] - electAndVerifyDivOptionPaymentEffects [publicParty] expiryDate amount - longDivOptionInstrument issuer investor Shares expectedConsumed expectedProduced - - -- Elect cash, long dividend option: Lifecycle and verify the lifecycle effects. - let - expectedConsumed = [] - expectedProduced = [qty 0.19 cashInstrument] - electAndVerifyDivOptionPaymentEffects [publicParty] expiryDate amount - longDivOptionInstrument issuer investor Cash expectedConsumed expectedProduced - - -- Elect FX cash, long dividend option: Lifecycle and verify the lifecycle effects. - let - expectedConsumed = [] - expectedProduced = [qty 0.17 eurInstrument] - electAndVerifyDivOptionPaymentEffects [publicParty] expiryDate amount - longDivOptionInstrument issuer investor CashFx expectedConsumed expectedProduced - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanCash.daml b/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanCash.daml deleted file mode 100644 index 1a1e7ff69..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanCash.daml +++ /dev/null @@ -1,137 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.Test.EuropeanCash where - -import DA.Date (Month(..), date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Option.Test.Util (originateEuropeanCashOption) -import Daml.Finance.Interface.Instrument.Option.V0.Types (OptionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Define and lifecycle European call/put options, which are automatically exercised and cash --- settled. -run : Script () -run = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute option - let - strikeLow = 40.0 - -- CREATE_EUROPEAN_OPTION_VARIABLES_BEGIN - strike = 50.0 - expiryDate = date 2019 May 15 - referenceAssetId = "AAPL-CLOSE" - -- CREATE_EUROPEAN_OPTION_VARIABLES_END - longOption = True - shortOption = False - - -- CREATE_EUROPEAN_OPTION_OBSERVATIONS_BEGIN - let observations = Map.fromList [(dateToDateClockTime $ date 2019 May 15, 48.78)] - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - -- CREATE_EUROPEAN_OPTION_OBSERVATIONS_END - - -- Issue instruments - itmLongCallInstrument <- originateEuropeanCashOption issuer issuer "Long ITM Call" - TransferableFungible "Option" observers now expiryDate Call strikeLow cashInstrument - referenceAssetId longOption publicParty - itmShortCallInstrument <- originateEuropeanCashOption issuer issuer "Short ITM Call" - TransferableFungible "Option" observers now expiryDate Call strikeLow cashInstrument - referenceAssetId shortOption publicParty - otmLongCallInstrument <- originateEuropeanCashOption issuer issuer "Long OTM Call" - TransferableFungible "Option" observers now expiryDate Call strike cashInstrument - referenceAssetId longOption publicParty - otmShortCallInstrument <- originateEuropeanCashOption issuer issuer "Short OTM Call" - TransferableFungible "Option" observers now expiryDate Call strike cashInstrument - referenceAssetId shortOption publicParty - itmLongPutInstrument <- originateEuropeanCashOption issuer issuer "Long ITM Put" - TransferableFungible "Option" observers now expiryDate Put strike cashInstrument - referenceAssetId longOption publicParty - itmShortPutInstrument <- originateEuropeanCashOption issuer issuer "Short ITM Put" - TransferableFungible "Option" observers now expiryDate Put strike cashInstrument - referenceAssetId shortOption publicParty - otmLongPutInstrument <- originateEuropeanCashOption issuer issuer "Long OTM Put" - TransferableFungible "Option" observers now expiryDate Put strikeLow cashInstrument - referenceAssetId longOption publicParty - otmShortPutInstrument <- originateEuropeanCashOption issuer issuer "Short OTM Put" - TransferableFungible "Option" observers now expiryDate Put strikeLow cashInstrument - referenceAssetId shortOption publicParty - - -- One day before the expiry date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays expiryDate 1) itmLongCallInstrument issuer - [observableCid] - - -- Long call: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [] - expectedProduced = [qty 8.78 cashInstrument] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - itmLongCallInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Short call: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [qty 8.78 cashInstrument] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - itmShortCallInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Long call: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - otmLongCallInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Short call: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - otmShortCallInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Long put: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [] - expectedProduced = [qty 1.22 cashInstrument] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - itmLongPutInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Short put: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [qty 1.22 cashInstrument] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - itmShortPutInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Long put: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - otmLongPutInstrument issuer [observableCid] expectedConsumed expectedProduced - - -- Short put: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] expiryDate - otmShortPutInstrument issuer [observableCid] expectedConsumed expectedProduced - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanPhysical.daml b/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanPhysical.daml deleted file mode 100644 index f8511134e..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Option/Test/EuropeanPhysical.daml +++ /dev/null @@ -1,133 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.Test.EuropeanPhysical where - -import DA.Date (Month(..), date) -import DA.Set (singleton) -import Daml.Finance.Instrument.Option.Test.Util (originateEuropeanPhysicalOption) -import Daml.Finance.Interface.Instrument.Option.V0.Types (OptionTypeEnum(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (electAndVerifyPaymentEffects) -import Daml.Script - --- Define and lifecycle European call/put options, which are are manually exercised and physically --- settled. -run : Script () -run = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - aaplInstrument <- originate custodian issuer "AAPL" TransferableFungible "AAPL stock" observers - now - - -- Create and distribute option - let - strikeLow = 40.0 - -- CREATE_EUROPEAN_PHYSICAL_OPTION_VARIABLES_BEGIN - strike = 50.0 - expiryDate = date 2019 May 15 - -- CREATE_EUROPEAN_PHYSICAL_OPTION_VARIABLES_END - longOption = True - shortOption = False - - -- Issue instruments - itmLongCallInstrument <- originateEuropeanPhysicalOption issuer issuer "Long ITM Call" - TransferableFungible "Option" observers now expiryDate Call strikeLow cashInstrument - aaplInstrument longOption publicParty - itmShortCallInstrument <- originateEuropeanPhysicalOption issuer issuer "Short ITM Call" - TransferableFungible "Option" observers now expiryDate Call strikeLow cashInstrument - aaplInstrument shortOption publicParty - otmLongCallInstrument <- originateEuropeanPhysicalOption issuer issuer "Long OTM Call" - TransferableFungible "Option" observers now expiryDate Call strike cashInstrument aaplInstrument - longOption publicParty - otmShortCallInstrument <- originateEuropeanPhysicalOption issuer issuer "Short OTM Call" - TransferableFungible "Option" observers now expiryDate Call strike cashInstrument aaplInstrument - shortOption publicParty - itmLongPutInstrument <- originateEuropeanPhysicalOption issuer issuer "Long ITM Put" - TransferableFungible "Option" observers now expiryDate Put strike cashInstrument aaplInstrument - longOption publicParty - itmShortPutInstrument <- originateEuropeanPhysicalOption issuer issuer "Short ITM Put" - TransferableFungible "Option" observers now expiryDate Put strike cashInstrument aaplInstrument - shortOption publicParty - otmLongPutInstrument <- originateEuropeanPhysicalOption issuer issuer "Long OTM Put" - TransferableFungible "Option" observers now expiryDate Put strikeLow cashInstrument - aaplInstrument longOption publicParty - otmShortPutInstrument <- originateEuropeanPhysicalOption issuer issuer "Short OTM Put" - TransferableFungible "Option" observers now expiryDate Put strikeLow cashInstrument - aaplInstrument shortOption publicParty - - let amount = 1.0 - - -- Long call: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [qty 40.0 cashInstrument] - expectedProduced = [qty 1.0 aaplInstrument] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - itmLongCallInstrument longOption issuer investor [publicParty] "EXERCISE" [] expectedConsumed - expectedProduced - - -- Short call: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [qty 1.0 aaplInstrument] - expectedProduced = [qty 40.0 cashInstrument] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - itmShortCallInstrument shortOption issuer custodian [publicParty] "EXERCISE" [] expectedConsumed - expectedProduced - - -- Long call: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - otmLongCallInstrument longOption issuer investor [publicParty] "EXPIRE" [] expectedConsumed - expectedProduced - - -- Short call: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - otmShortCallInstrument shortOption issuer custodian [publicParty] "EXPIRE" [] expectedConsumed - expectedProduced - - -- Long put: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [qty 1.0 aaplInstrument] - expectedProduced = [qty 50.0 cashInstrument] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - itmLongPutInstrument longOption issuer investor [publicParty] "EXERCISE" [] expectedConsumed - expectedProduced - - -- Short put: Lifecycle and verify the lifecycle effects for an in-the-money option. - let - expectedConsumed = [qty 50.0 cashInstrument] - expectedProduced = [qty 1.0 aaplInstrument] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - itmShortPutInstrument shortOption issuer custodian [publicParty] "EXERCISE" [] expectedConsumed - expectedProduced - - -- Long put: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - otmLongPutInstrument longOption issuer investor [publicParty] "EXPIRE" [] expectedConsumed - expectedProduced - - -- Short put: Lifecycle and verify the lifecycle effects for an out-of-the-money option. - let - expectedConsumed = [] - expectedProduced = [] - optionInstrumentAfterFirstPayment <- electAndVerifyPaymentEffects expiryDate amount - otmShortPutInstrument shortOption issuer custodian [publicParty] "EXPIRE" [] expectedConsumed - expectedProduced - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Option/Test/Util.daml b/src/test/daml/Daml/Finance/Instrument/Option/Test/Util.daml deleted file mode 100644 index b12ddf755..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Option/Test/Util.daml +++ /dev/null @@ -1,234 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Option.Test.Util where - -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Claims.V3.Lifecycle.Rule qualified as Lifecycle (Rule(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Option.V0.BarrierEuropeanCash.Factory qualified as BarrierEuropeanCashOption (Factory(..)) -import Daml.Finance.Instrument.Option.V0.Dividend.Election qualified as DividendOptionElection (Factory(..)) -import Daml.Finance.Instrument.Option.V0.Dividend.Factory qualified as DividendOption (Factory(..)) -import Daml.Finance.Instrument.Option.V0.EuropeanCash.Factory qualified as EuropeanCashOption (Factory(..)) -import Daml.Finance.Instrument.Option.V0.EuropeanPhysical.Factory qualified as EuropeanPhysicalOption (Factory(..)) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Factory qualified as BarrierEuropeanCashOptionFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Option.V0.BarrierEuropeanCash.Types (BarrierEuropean(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Election.Factory qualified as DividendOptionElectionFactory (Create(..), I) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Factory qualified as DividendOption (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Dividend.Types (Dividend(..), ElectionTypeEnum(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Factory qualified as EuropeanCashOptionFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanCash.Types qualified as EuropeanCashOption (European(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Factory qualified as EuropeanPhysicalOptionFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Option.V0.EuropeanPhysical.Types qualified as EuropeanPhysicalOption (European(..)) -import Daml.Finance.Interface.Instrument.Option.V0.Types (BarrierTypeEnum, OptionTypeEnum) -import Daml.Finance.Interface.Lifecycle.V4.Effect qualified as Effect (I) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), InstrumentQuantity, Parties) -import Daml.Finance.Test.Util.Lifecycle (applyElectionAndVerify) -import Daml.Script - --- | Originate a cash-settled European option. -originateEuropeanCashOption : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> OptionTypeEnum -> Decimal -> InstrumentKey -> Text -> Bool -> - Party -> Script InstrumentKey -originateEuropeanCashOption depository issuer label holdingStandard description - observers lastEventTimestamp expiryDate optionType strike currency referenceAssetId ownerReceives - publicParty = do - -- Create a cash-settled European option factory - europeanCashOptionFactoryCid <- toInterfaceContractId @EuropeanCashOptionFactory.I <$> - submit issuer do - createCmd EuropeanCashOption.Factory with - provider = issuer - observers = mempty - - -- CREATE_EUROPEAN_OPTION_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd europeanCashOptionFactoryCid EuropeanCashOptionFactory.Create with - european = EuropeanCashOption.European with - instrument - description - expiryDate - optionType - strike - referenceAssetId - ownerReceives - currency - lastEventTimestamp - observers = Map.fromList observers - -- CREATE_EUROPEAN_OPTION_INSTRUMENT_END - pure instrument - --- | Originate a cash-settled European option. -originateBarrierEuropeanCashOption : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> OptionTypeEnum -> Decimal -> Decimal -> BarrierTypeEnum -> - Date -> InstrumentKey -> Text -> Bool -> Party -> Script InstrumentKey -originateBarrierEuropeanCashOption depository issuer label holdingStandard description - observers lastEventTimestamp expiryDate optionType strike barrier barrierType - barrierStartDate currency referenceAssetId ownerReceives publicParty = do - -- Create a barrier option factory - barrierOptionFactoryCid <- toInterfaceContractId @BarrierEuropeanCashOptionFactory.I <$> - submit issuer do - createCmd BarrierEuropeanCashOption.Factory with - provider = issuer - observers = mempty - - -- CREATE_BARRIER_EUROPEAN_OPTION_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd barrierOptionFactoryCid BarrierEuropeanCashOptionFactory.Create with - barrierEuropean = BarrierEuropean with - instrument - description - expiryDate - optionType - strike - barrier - barrierType - barrierStartDate - referenceAssetId - ownerReceives - currency - lastEventTimestamp - observers = Map.fromList observers - -- CREATE_BARRIER_EUROPEAN_OPTION_INSTRUMENT_END - pure instrument - --- | Originate a physically settled European option. -originateEuropeanPhysicalOption : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> OptionTypeEnum -> Decimal -> InstrumentKey -> - InstrumentKey -> Bool -> Party -> Script InstrumentKey -originateEuropeanPhysicalOption depository issuer label holdingStandard description - observers lastEventTimestamp expiryDate optionType strike currency - referenceAsset ownerReceives publicParty = do - -- Create a cash-settled European option factory - europeanPhysicalOptionFactoryCid <- toInterfaceContractId @EuropeanPhysicalOptionFactory.I <$> - submit issuer do - createCmd EuropeanPhysicalOption.Factory with - provider = issuer - observers = mempty - - -- CREATE_EUROPEAN_PHYSICAL_OPTION_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd europeanPhysicalOptionFactoryCid EuropeanPhysicalOptionFactory.Create with - european = EuropeanPhysicalOption.European with - instrument - description - expiryDate - optionType - strike - referenceAsset - ownerReceives - currency - lastEventTimestamp - prevEvents = [] - observers = Map.fromList observers - -- CREATE_EUROPEAN_PHYSICAL_OPTION_INSTRUMENT_END - pure instrument - --- | Originate a physically settled Dividend option. -originateDividendOption : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> Date -> InstrumentQuantity -> Optional InstrumentQuantity -> Optional InstrumentQuantity - -> Party - -> Script InstrumentKey -originateDividendOption depository issuer label holdingStandard description observers - lastEventTimestamp expiryDate cashQuantity sharesQuantity fxQuantity - publicParty = do - -- Create a dividend option factory - dividendOptionFactoryCid <- toInterfaceContractId @DividendOption.I <$> submit issuer - do - createCmd DividendOption.Factory with - provider = issuer - observers = mempty - - -- CREATE_DIVIDEND_OPTION_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd dividendOptionFactoryCid DividendOption.Create with - dividend = Dividend with - instrument - description - expiryDate - cashQuantity - sharesQuantity - fxQuantity - lastEventTimestamp - prevEvents = [] - observers = Map.fromList observers - -- CREATE_DIVIDEND_OPTION_INSTRUMENT_END - pure instrument - --- | Verify the payments of an instrument after an election (excluding settlement) -electAndVerifyDivOptionPaymentEffects : [Party] -> Date -> Decimal -> InstrumentKey -> Party -> - Party -> ElectionTypeEnum -> [InstrumentQuantity] -> [InstrumentQuantity] - -> Script (Optional InstrumentKey, ContractId Effect.I) -electAndVerifyDivOptionPaymentEffects readers today amount instrument issuer - elector electedTag expectedConsumed expectedProduced = do - -- Create election factory to allow holders to create elections - electionFactoryCid <- submit issuer do - toInterfaceContractId @DividendOptionElectionFactory.I <$> - createCmd DividendOptionElection.Factory with - provider = issuer - observers = Map.fromList [("Observers", Set.fromList [elector, issuer])] - - -- Create a lifecycle rule - lifecycleRuleCid <- toInterfaceContractId <$> submit issuer do - createCmd Lifecycle.Rule with - providers = Set.singleton issuer - observers = mempty - lifecycler = issuer - id = Id "LifecycleRule" - description = "Rule to lifecycle a generic instrument" - - -- Create the Election - let - electorIsOwner = True - counterparty = issuer - description = "election for physically settled option" - electionCid <- submit (actAs elector <> readAs readers) - do - exerciseCmd electionFactoryCid DividendOptionElectionFactory.Create with - actors = Set.singleton elector - id = Id "election id" - description - claimType = electedTag - electionTime = dateToDateClockTime today - electorIsOwner - elector - counterparty - instrument - amount - observers = Map.fromList [("Holders", Set.fromList [issuer, elector, counterparty])] - provider = issuer - - applyElectionAndVerify issuer readers [] expectedConsumed expectedProduced electionCid - lifecycleRuleCid diff --git a/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/AutoCallable.daml b/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/AutoCallable.daml deleted file mode 100644 index 6a1b97dc4..000000000 --- a/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/AutoCallable.daml +++ /dev/null @@ -1,229 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.Test.AutoCallable where - -import DA.Date (DayOfWeek(..), Month(..), date) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.StructuredProduct.Test.Util (originateAutoCallable) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Finance.Test.Util.Time (createPaymentPeriodicSchedule) -import Daml.Script - --- Define and lifecycle an AutoCallable Yield Note. -run : Script () -run = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Account and holding factory - let pp = [("FactoryProvider", Set.singleton publicParty)] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute option - let - couponBarrierHigh = 0.75 - callBarrierLow = 0.95 - finalBarrierHigh = 1.00 - -- CREATE_AUTO_CALLABLE_VARIABLES_BEGIN - putStrike = 1.00 -- 100% of the underlying closing price on the initial fixing date - couponBarrier = 0.65 -- 65% of the underlying closing price on the initial fixing date - callBarrier = 1.00 - finalBarrier = 0.875 - referenceAssetId = "AAPL-CLOSE" - couponRate = 0.05 - dayCountConvention = Basis1 -- coupon rate is paid each period, not per annum. - businessDayConvention = Following - couponPeriod = M - couponPeriodMultiplier = 3 - initialFixingDate = date 2024 Jan 10 - issueDate = date 2024 Jan 16 - firstRegularObervationDate = date 2024 Mar 28 - firstCouponDate = date 2024 Apr 2 - secondCouponDate = date 2024 Jul 2 - expiryDate = date 2024 Sep 28 - maturityDate = date 2024 Oct 2 - -- CREATE_AUTO_CALLABLE_VARIABLES_END - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [] - couponSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - observationSchedule = createPaymentPeriodicSchedule firstRegularObervationDate - holidayCalendarIds businessDayConvention couponPeriod couponPeriodMultiplier - initialFixingDate expiryDate - notional = 1.0 - - -- CREATE_AUTO_CALLABLE_OBSERVATIONS_BEGIN - let - observations = Map.fromList - [ (dateToDateClockTime $ date 2024 Jan 10, 40.0) - , (dateToDateClockTime $ date 2024 Mar 28, 28.78) - , (dateToDateClockTime $ date 2024 Jun 28, 39.78) - , (dateToDateClockTime $ date 2024 Sep 30, 36.0) - ] - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - -- CREATE_AUTO_CALLABLE_OBSERVATIONS_END - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList pp - - ----------------------------------------------------------------------- - -- 1. AutoCallable without barrier events (and no early redemption) -- - ----------------------------------------------------------------------- - - acInstrument <- originateAutoCallable issuer issuer "AC" TransferableFungible "AutoCallable" - observers now putStrike couponBarrier callBarrier finalBarrier cashInstrument - referenceAssetId couponRate observationSchedule couponSchedule holidayCalendarIds - dayCountConvention notional calendarDataProvider publicParty - - -- First coupon payment - let - expectedConsumed = [] - expectedProduced = [qty 0.05 cashInstrument] - - maybeAcAfterCoupon1 <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstCouponDate acInstrument issuer [observableCid] - expectedConsumed expectedProduced - - acAfterCoupon1 <- case maybeAcAfterCoupon1 of - Some key -> pure key - None -> pure acInstrument - - -- Second coupon payment - let - expectedConsumed = [] - expectedProduced = [qty 0.05 cashInstrument] - - maybeAcAfterCoupon2 <- - lifecycleAndVerifyPaymentEffects [publicParty] - secondCouponDate acAfterCoupon1 issuer [observableCid] - expectedConsumed expectedProduced - - acAfterCoupon2 <- case maybeAcAfterCoupon2 of - Some key -> pure key - None -> pure acAfterCoupon1 - - -- Maturity (full redemption) - let - expectedConsumed = [] - expectedProduced = [qty 1.05 cashInstrument] - - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate acAfterCoupon2 issuer [observableCid] - expectedConsumed expectedProduced - - -------------------------------------------------------------------- - -- 2. AutoCallable with barrier events (and no early redemption) -- - -------------------------------------------------------------------- - - acInstrument <- originateAutoCallable issuer issuer "AC2" TransferableFungible "AutoCallable" - observers now putStrike couponBarrierHigh callBarrier finalBarrierHigh cashInstrument - referenceAssetId couponRate observationSchedule couponSchedule holidayCalendarIds - dayCountConvention notional calendarDataProvider publicParty - - -- First coupon date (no payment) - let - expectedConsumed = [] - expectedProduced = [] - - maybeAcAfterCoupon1 <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstCouponDate acInstrument issuer [observableCid] - expectedConsumed expectedProduced - - acAfterCoupon1 <- case maybeAcAfterCoupon1 of - Some key -> pure key - None -> pure acInstrument - - -- Second coupon date (coupon paid) - let - expectedConsumed = [] - expectedProduced = [qty 0.05 cashInstrument] - - maybeAcAfterCoupon2 <- - lifecycleAndVerifyPaymentEffects [publicParty] - secondCouponDate acAfterCoupon1 issuer [observableCid] - expectedConsumed expectedProduced - - acAfterCoupon2 <- case maybeAcAfterCoupon2 of - Some key -> pure key - None -> pure acAfterCoupon1 - - -- Maturity (barrier hit, partial redemption) - let - expectedConsumed = [] - expectedProduced = [qty 0.95 cashInstrument] - - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate acAfterCoupon2 issuer [observableCid] - expectedConsumed expectedProduced - - -------------------------------------------- - -- 3. AutoCallable with early redemption -- - -------------------------------------------- - - acInstrument <- originateAutoCallable issuer issuer "AC3" TransferableFungible "AutoCallable" - observers now putStrike couponBarrierHigh callBarrierLow finalBarrier cashInstrument - referenceAssetId couponRate observationSchedule couponSchedule holidayCalendarIds - dayCountConvention notional calendarDataProvider publicParty - - -- The first coupon is not paid because the coupon barrier is hit - -- First coupon date (no effect) - let - expectedConsumed = [] - expectedProduced = [] - - maybeAcAfterCoupon1 <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstCouponDate acInstrument issuer [observableCid] - expectedConsumed expectedProduced - - acAfterCoupon1 <- case maybeAcAfterCoupon1 of - Some key -> pure key - None -> pure acInstrument - - -- Auto-call on second coupon date (principal + coupon) - let - expectedConsumed = [] - expectedProduced = [qty 1.05 cashInstrument] - - maybeAcAfterAutoCall <- - lifecycleAndVerifyPaymentEffects [publicParty] - secondCouponDate acAfterCoupon1 issuer [observableCid] - expectedConsumed expectedProduced - - acAfterAutoCall <- case maybeAcAfterAutoCall of - Some key -> pure key - None -> pure acAfterCoupon1 - - -- Ensure no lifecycle effects on a called instrument - verifyNoLifecycleEffects [publicParty] maturityDate acAfterAutoCall issuer - [observableCid] - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/Util.daml b/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/Util.daml deleted file mode 100644 index 3bc7d35db..000000000 --- a/src/test/daml/Daml/Finance/Instrument/StructuredProduct/Test/Util.daml +++ /dev/null @@ -1,111 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.StructuredProduct.Test.Util where - -import DA.Map qualified as Map (fromList) -import Daml.Finance.Instrument.StructuredProduct.V0.AutoCallable.Factory qualified as AutoCallable (Factory(..)) -import Daml.Finance.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Factory qualified as BarrierReverseConvertible (Factory(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Factory qualified as AutoCallableFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.AutoCallable.Types (AutoCallable(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Factory qualified as BarrierReverseConvertibleFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.StructuredProduct.V0.BarrierReverseConvertible.Types (BarrierReverseConvertible(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), Parties) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Schedule (PeriodicSchedule(..)) -import Daml.Script - --- | Originate a barrier reverse convertible (BRC) instrument. -originateBarrierReverseConvertible : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> Decimal -> Decimal -> Date -> InstrumentKey -> Text - -> Decimal -> PeriodicSchedule -> [Text] -> DayCountConventionEnum -> Decimal - -> Party -> Party -> Script InstrumentKey -originateBarrierReverseConvertible depository issuer label holdingStandard description - observers lastEventTimestamp expiryDate strike barrier barrierStartDate currency referenceAssetId - couponRate periodicSchedule holidayCalendarIds dayCountConvention notional - calendarDataProvider publicParty = do - -- Create a BRC factory - brcFactoryCid <- toInterfaceContractId @BarrierReverseConvertibleFactory.I <$> submit issuer do - createCmd BarrierReverseConvertible.Factory with - provider = issuer - observers = mempty - - -- CREATE_BARRIER_REVERSE_CONVERTIBLE_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd brcFactoryCid BarrierReverseConvertibleFactory.Create with - barrierReverseConvertible = BarrierReverseConvertible with - instrument - description - expiryDate - strike - barrier - barrierStartDate - referenceAssetId - couponRate - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - notional - currency - lastEventTimestamp - prevEvents = [] - observers = Map.fromList observers - -- CREATE_BARRIER_REVERSE_CONVERTIBLE_INSTRUMENT_END - pure instrument - --- | Originate an AutoCallable instrument. -originateAutoCallable : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] - -> Time -> Decimal -> Decimal -> Decimal -> Decimal -> InstrumentKey -> Text - -> Decimal -> PeriodicSchedule -> PeriodicSchedule -> [Text] -> DayCountConventionEnum -> Decimal - -> Party -> Party -> Script InstrumentKey -originateAutoCallable depository issuer label holdingStandard description observers - lastEventTimestamp putStrike couponBarrier callBarrier finalBarrier currency referenceAssetId - couponRate observationSchedule periodicSchedule holidayCalendarIds dayCountConvention notional - calendarDataProvider publicParty = do - -- Create an AutoCallable factory - factoryCid <- toInterfaceContractId @AutoCallableFactory.I <$> submit issuer do - createCmd AutoCallable.Factory with - provider = issuer - observers = mempty - - -- CREATE_AUTO_CALLABLE_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd factoryCid AutoCallableFactory.Create with - autoCallable = AutoCallable with - instrument - description - putStrike - couponBarrier - callBarrier - finalBarrier - referenceAssetId - couponRate - observationSchedule - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - notional - currency - lastEventTimestamp - prevEvents = [] - observers = Map.fromList observers - -- CREATE_AUTO_CALLABLE_INSTRUMENT_END - pure instrument diff --git a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Asset.daml b/src/test/daml/Daml/Finance/Instrument/Swap/Test/Asset.daml deleted file mode 100644 index 6397c1e39..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Asset.daml +++ /dev/null @@ -1,619 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.Test.Asset where - -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Equity.Test.Util (originateEquity) -import Daml.Finance.Instrument.Swap.Test.Util (originateAssetSwap) -import Daml.Finance.Instrument.Swap.V0.Asset.DistributionRule (DistributionRule(..)) -import Daml.Finance.Interface.Instrument.Equity.V0.Instrument qualified as Equity (DeclareDistribution(..), I) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Types (Underlying(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (DateRelativeToEnum(..), FloatingRate(..), ReferenceRateTypeEnum(..)) -import Daml.Finance.Interface.Lifecycle.V4.Rule.Lifecycle qualified as Lifecycle (Evolve(..), I) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DateOffset (DateOffset(..), DayTypeEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyConsumedAndProduced, verifyNoLifecycleEffects) -import Daml.Script - --- Calculate payments on an asset swap, including lifecycling and creation of new instrument --- version. -run : Script () -run = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Equity vs fix asset swap: AAPL total return vs 2.01% p.a. payment every 3M - -- CREATE_ASSET_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceAssetId = "AAPL-CLOSE-ADJ" - ownerReceivesFix = False - floatingRate = None - fixRate = 0.0201 - paymentPeriod = M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - -- CREATE_ASSET_SWAP_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 43.54) - , (dateToDateClockTime $ date 2019 Feb 15, 47.03) - , (dateToDateClockTime $ date 2019 May 15, 48.78) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - aapl = InstrumentKey with - depository = custodian - issuer - id = Id "AAPL" - version = "0" - holdingStandard = BaseHolding - underlyings = [Underlying with - referenceAsset = aapl - referenceAssetId - weight = 1.0 - initialPrice = 43.54] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - - (swapInstrument, _) <- originateAssetSwap issuer issuer "SwapTest1" BaseHolding "Asset swap" - observers now issueDate holidayCalendarIds calendarDataProvider firstPaymentDate maturityDate - dayCountConvention businessDayConvention floatingRate fixRate paymentPeriod - paymentPeriodMultiplier cashInstrument underlyings ownerReceivesFix publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - [observableCid] - - -- First payment date: Lifecycle and verify the lifecycle effects for fixed rate and asset performance payments. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [qty 0.0801561782 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer [observableCid] - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - -- One day before expiry: verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - -- Second payment date (expiry): Lifecycle and verify the lifecycle effects for fixed rate and asset performance payments. - let - expectedConsumed = [qty 0.0049691667 cashInstrument] - expectedProduced = [qty 0.0372102913 cashInstrument] - - maybeSwapInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer [observableCid] - expectedConsumed expectedProduced - - case maybeSwapInstrumentAfterMaturity of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () - --- Calculate payments on an asset swap, including lifecycling and creation of new instrument --- version. This example has a floating rate leg. -runFloat : Script () -runFloat = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Equity vs fix asset swap: AAPL total return vs 2.01% p.a. payment every 3M - -- CREATE_FLOAT_ASSET_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceAssetId = "AAPL-CLOSE-ADJ" - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = 0 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - ownerReceivesRate = False - fixRate = 0.0 - paymentPeriod = M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - -- CREATE_FLOAT_ASSET_SWAP_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 43.54) - , (dateToDateClockTime $ date 2019 Feb 15, 47.03) - , (dateToDateClockTime $ date 2019 May 15, 48.78) - ] - rateObservations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 0.0027406) - , (dateToDateClockTime $ date 2019 Feb 15, 0.002035) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - aapl = InstrumentKey with - depository = custodian - issuer - id = Id "AAPL" - version = "0" - holdingStandard = BaseHolding - underlyings = [Underlying with - referenceAsset = aapl - referenceAssetId - weight = 1.0 - initialPrice = 43.54] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - - rateObservableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations = rateObservations - observers = mempty - - let observableCids = [observableCid, rateObservableCid] - - (swapInstrument, _) <- originateAssetSwap issuer issuer "SwapTest1" BaseHolding "Asset swap" - observers now issueDate holidayCalendarIds calendarDataProvider firstPaymentDate maturityDate - dayCountConvention businessDayConvention floatingRate fixRate paymentPeriod - paymentPeriodMultiplier cashInstrument underlyings ownerReceivesRate publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - observableCids - - -- First payment date: Lifecycle and verify the lifecycle effects for fixed rate and asset performance payments. - let - expectedConsumed = [qty 0.0002283833 cashInstrument] - expectedProduced = [qty 0.0801561782 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- One day before expiry: verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- Second payment date (expiry): Lifecycle and verify the lifecycle effects for fixed rate and asset performance payments. - let - expectedConsumed = [qty 0.0005030972 cashInstrument] - expectedProduced = [qty 0.0372102913 cashInstrument] - - maybeSwapInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - case maybeSwapInstrumentAfterMaturity of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () - --- Calculate payments on an asset swap, including lifecycling and creation of new instrument --- version. This example has a single underlying stock with dividend passthrough. --- It still represents a total return swap, but the instrument only models the price performance --- (using an unadjusted price series). The dividends are paid using a separate distribution rule. -runDividendPassthrough : Script () -runDividendPassthrough = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Equity vs rate asset swap: AAPL price return (dividends paid separately) vs floating rate - -- payment. - -- CREATE_DIV_PASSTHROUGH_ASSET_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceAssetId = "AAPL-CLOSE-UNADJ" -- Unadjusted price series - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = 0 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - ownerReceivesRate = False - fixRate = 0.0 - paymentPeriod = M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - -- CREATE_DIV_PASSTHROUGH_ASSET_SWAP_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 43.54) - , (dateToDateClockTime $ date 2019 Feb 15, 47.03) - , (dateToDateClockTime $ date 2019 May 15, 47.78) - ] - rateObservations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 0.0027406) - , (dateToDateClockTime $ date 2019 Feb 15, 0.002035) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - - cumEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "0" TransferableFungible "AAPL" observers now - exEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "1" TransferableFungible "AAPL" [] now - - let - underlyings = [Underlying with - referenceAsset = cumEquityInstrument - referenceAssetId - weight = 1.0 - initialPrice = 43.54] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - - rateObservableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations = rateObservations - observers = mempty - - let observableCids = [observableCid, rateObservableCid] - - (swapInstrument, assetSwapFactoryCid) <- originateAssetSwap issuer issuer "SwapTest1" BaseHolding - "Asset swap" observers now issueDate holidayCalendarIds calendarDataProvider firstPaymentDate - maturityDate dayCountConvention businessDayConvention floatingRate fixRate paymentPeriod - paymentPeriodMultiplier cashInstrument underlyings ownerReceivesRate publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - observableCids - - -- First payment date: Lifecycle and verify the lifecycle effects for fix rate and asset - -- performance payments. - let - expectedConsumed = [qty 0.0002283833 cashInstrument] - expectedProduced = [qty 0.0801561782 cashInstrument] - - Some swapInstrumentAfterFirstPayment <- lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer observableCids expectedConsumed expectedProduced - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- Create cash dividend rule (specific for asset swaps) - distributionRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit issuer do - createCmd DistributionRule with - providers = Set.singleton issuer - lifecycler = issuer - observers = Set.singleton publicParty - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument following a distribution event" - assetSwapFactoryCid - newInstrumentObservers = observers - - -- Create cash dividend event: USD 1 per share (this also works with fractional shares) - aaplDividendDistributionEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "AAPL - " <> show now - description = "Cash Dividend" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [qty 1.0 cashInstrument] - - -- ASSET_SWAP_DIV_LIFECYCLING_START - -- Lifecycle the asset swap to create an effect for the dividend. - (Some swapInstrumentAfterDividend, [effectCid]) <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = aaplDividendDistributionEventCid - instrument = swapInstrumentAfterFirstPayment - -- ASSET_SWAP_DIV_LIFECYCLING_END - - let - expectedConsumedQuantities = [] - expectedProducedQuantities = [qty 0.0229673863 cashInstrument] - - verifyConsumedAndProduced expectedConsumedQuantities expectedProducedQuantities effectCid issuer - - -- Lifecycle on the second payment date, which is also the expiry date. Verify the lifecycle - -- effects for fix rate and asset performance payments. - let - expectedConsumed = [qty 0.0005030972 cashInstrument] - expectedProduced = [qty 0.0159472677 cashInstrument] - - lifecycleAndVerifyPaymentEffects [publicParty] maturityDate swapInstrumentAfterDividend - issuer observableCids expectedConsumed expectedProduced - - pure () - --- Calculate payments on an asset swap, including lifecycling and creation of new instrument --- version. This example has a basket of stock underlyings with dividend passthrough. --- It still represents a total return swap, but the instrument only models the price performance --- (using unadjusted price series). The dividends are paid using a separate distribution rule. -runBasketDividendPassthrough : Script () -runBasketDividendPassthrough = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", Set.singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Equity vs rate asset swap: AAPL price return (dividends paid separately) vs floating rate - -- payment. - -- CREATE_BASKET_ASSET_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceAssetId = "AAPL-CLOSE-UNADJ" -- Unadjusted price series - referenceAsset2Id = "MSFT-CLOSE-UNADJ" -- Unadjusted price series - referenceRateId = "USD/LIBOR/3M" - floatingRate = Some FloatingRate with - referenceRateId - referenceRateType = SingleFixing CalculationPeriodStartDate - fixingDates = DateOffset with - periodMultiplier = 0 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = ["USD"] - ownerReceivesRate = False - fixRate = 0.0 - paymentPeriod = M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - -- CREATE_BASKET_ASSET_SWAP_VARIABLES_END - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 43.54) - , (dateToDateClockTime $ date 2019 Feb 15, 47.03) - , (dateToDateClockTime $ date 2019 May 15, 47.78) - ] - observations2 = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 105.38) - , (dateToDateClockTime $ date 2019 Feb 15, 108.22) - , (dateToDateClockTime $ date 2019 May 15, 120.87) - ] - rateObservations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 16, 0.0027406) - , (dateToDateClockTime $ date 2019 Feb 15, 0.002035) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - - cumEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "0" TransferableFungible "AAPL" observers now - exEquityInstrument <- - originateEquity issuer issuer "EQUITY-INST-1" "1" TransferableFungible "AAPL" [] now - - cumEquity2Instrument <- - originateEquity issuer issuer "EQUITY-INST-2" "0" TransferableFungible "MSFT" observers now - exEquity2Instrument <- - originateEquity issuer issuer "EQUITY-INST-2" "1" TransferableFungible "MSFT" [] now - - let - underlyings = [(Underlying with - referenceAsset = cumEquityInstrument - referenceAssetId - weight = 0.5 - initialPrice = 43.54), - (Underlying with - referenceAsset = cumEquity2Instrument - referenceAssetId = referenceAsset2Id - weight = 0.5 - initialPrice = 105.38)] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAssetId; observations; observers = mempty - observable2Cid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceAsset2Id; observations = observations2; observers = mempty - - rateObservableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations = rateObservations - observers = mempty - - let observableCids = [observableCid, observable2Cid, rateObservableCid] - - (swapInstrument, assetSwapFactoryCid) <- originateAssetSwap issuer issuer "SwapTest1" BaseHolding - "Asset swap" observers now issueDate holidayCalendarIds calendarDataProvider firstPaymentDate - maturityDate dayCountConvention businessDayConvention floatingRate fixRate paymentPeriod - paymentPeriodMultiplier cashInstrument underlyings ownerReceivesRate publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - observableCids - - -- First payment date: Lifecycle and verify the lifecycle effects for fix rate and asset - -- performance payments. - let - expectedConsumed = [qty 0.0002283833 cashInstrument] - expectedProduced = [qty 0.0535531318 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer observableCids - - -- Create cash dividend rule (specific for asset swaps) - distributionRuleCid <- toInterfaceContractId @Lifecycle.I <$> submit issuer do - createCmd DistributionRule with - providers = Set.singleton issuer - lifecycler = issuer - observers = Set.singleton publicParty - id = Id "LifecycleRule" - description = "Rule to lifecycle an instrument following a distribution event" - assetSwapFactoryCid - newInstrumentObservers = observers - - -- Create a cash dividend event with 2 distributions: 0.5 and 1.5 USD per share, respectively - -- (to test multiple distributions). - distributionEventCid <- - Instrument.submitExerciseInterfaceByKeyCmd @Equity.I [issuer] [] cumEquityInstrument - Equity.DeclareDistribution with - id = Id $ "AAPL - " <> show now - description = "Cash Dividend" - effectiveTime = now - newInstrument = exEquityInstrument - perUnitDistribution = [(qty 0.5 cashInstrument), (qty 1.5 cashInstrument)] - - -- Lifecycle the asset swap to create an effect for the dividend. - (Some swapInstrumentAfterDividend, [effectCid]) <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd distributionRuleCid Lifecycle.Evolve with - observableCids = [] - eventCid = distributionEventCid - instrument = swapInstrumentAfterFirstPayment - let - expectedConsumed = [] - expectedProduced = [(qty 0.0057418466 cashInstrument), (qty 0.0172255398 cashInstrument)] - verifyConsumedAndProduced expectedConsumed expectedProduced effectCid issuer - - -- Lifecycle on the second payment date, which is also the expiry date. Verify the lifecycle - -- effects for fix rate and asset performance payments. - let - expectedConsumed = [qty 0.0005030972 cashInstrument] - expectedProduced = [qty 0.0664193924 cashInstrument] - - maybeSwapInstrumentAfterMaturity <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterMaturity <- case maybeSwapInstrumentAfterMaturity of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Currency.daml b/src/test/daml/Daml/Finance/Instrument/Swap/Test/Currency.daml deleted file mode 100644 index 88c522c12..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Currency.daml +++ /dev/null @@ -1,110 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.Test.Currency where - -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Instrument.Swap.Test.Util (originateCurrencySwap) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Calculate fix rate payments on a currency swap, including lifecycling and creation of new --- instrument version. -run : Script () -run = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - -- CREATE_CURRENCY_SWAP_CASH_INSTRUMENTS_BEGIN - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - foreignCashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers - now - -- CREATE_CURRENCY_SWAP_CASH_INSTRUMENTS_END - - -- Create and distribute swap - -- Fix vs fix currency swap: 3% p.a. in USD vs 2% p.a. in EUR, payment every 3M - -- CREATE_CURRENCY_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - ownerReceivesBase = False - baseRate = 0.03 - foreignRate = 0.02 - fxRate = 1.1 - paymentPeriod = M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - -- CREATE_CURRENCY_SWAP_VARIABLES_END - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - - -- A reference data provider publishes the holiday calendar on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider - calendar - observers = Map.fromList observers - - swapInstrument <- originateCurrencySwap issuer issuer "SwapTest1" BaseHolding "Currency swap" - observers now issueDate holidayCalendarIds calendarDataProvider firstPaymentDate maturityDate - dayCountConvention businessDayConvention baseRate foreignRate paymentPeriod - paymentPeriodMultiplier cashInstrument foreignCashInstrument fxRate ownerReceivesBase - publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer [] - - -- First payment date: Lifecycle and verify the lifecycle effects for base currency and foreign - -- currency payments. - let - expectedConsumed = [qty 0.0025 cashInstrument] - expectedProduced = [qty 0.0018333333 foreignCashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer [] expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer [] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer [] - - -- Lifecycle on the second payment date, which is also the expiry date. Verify the lifecycle - -- effects for base currency and foreign currency payments. - let - expectedConsumed = [qty 0.0074166667 cashInstrument] - expectedProduced = [qty 0.0054388889 foreignCashInstrument] - - maybeSwapInstrumentAfterFinalPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer [] expectedConsumed expectedProduced - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Swap/Test/ForeignExchange.daml b/src/test/daml/Daml/Finance/Instrument/Swap/Test/ForeignExchange.daml deleted file mode 100644 index b410a813d..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Swap/Test/ForeignExchange.daml +++ /dev/null @@ -1,85 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.Test.ForeignExchange where - -import DA.Date (Month(..), addDays, date, subtractDays) -import DA.Set (singleton) -import Daml.Finance.Instrument.Swap.Test.Util (originateForeignExchangeSwap) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script - --- Calculate the fx payments of a foreign exchange swap, including lifecycling and creation of new --- instrument version. -run : Script () -run = script do - [custodian, issuer, publicParty] <- - createParties ["Custodian", "Issuer", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - - -- CREATE_FX_SWAP_CASH_INSTRUMENTS_BEGIN - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - foreignCashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers - now - -- CREATE_FX_SWAP_CASH_INSTRUMENTS_END - - -- Create and distribute swap - -- Foreign exchange swap: USD vs EUR - -- CREATE_FX_SWAP_VARIABLES_BEGIN - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - firstFxRate = 1.1 - finalFxRate = 1.2 - -- CREATE_FX_SWAP_VARIABLES_END - fxRateSameCurrency = 1.0 - - swapInstrument <- originateForeignExchangeSwap issuer issuer "SwapTest1" BaseHolding - "Foreign exchange swap" observers now issueDate firstPaymentDate maturityDate cashInstrument - foreignCashInstrument firstFxRate finalFxRate publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer [] - - -- First payment date: Lifecycle and verify the lifecycle effects for the fx payments. - let - expectedConsumed = [qty fxRateSameCurrency cashInstrument] - expectedProduced = [qty firstFxRate foreignCashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer [] expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer [] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer [] - - -- Lifecycle on the second payment date, which is also the expiry date. Verify the lifecycle - -- effects for the fx payments. - let - expectedConsumed = [qty finalFxRate foreignCashInstrument] - expectedProduced = [qty fxRateSameCurrency cashInstrument] - - maybeSwapInstrumentAfterFinalPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer [] expectedConsumed expectedProduced - - pure () diff --git a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml b/src/test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml deleted file mode 100644 index 056e2774a..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Fpml.daml +++ /dev/null @@ -1,4244 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.Test.Fpml where - -import DA.Assert ((===)) -import DA.Date (DayOfWeek(..), Month(..), addDays, date, subtractDays) -import DA.Map qualified as Map (fromList) -import DA.Set (singleton) -import Daml.Finance.Data.V4.Numeric.Observation (Observation(..)) -import Daml.Finance.Data.V4.Reference.HolidayCalendar (HolidayCalendar(..)) -import Daml.Finance.Data.V4.Time.DateClock (dateToDateClockTime) -import Daml.Finance.Instrument.Swap.Test.Util (originateFpmlSwap) -import Daml.Finance.Instrument.Swap.V0.Fpml.Util (roundRate) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.FpmlTypes -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period(..), PeriodEnum(..), RollConventionEnum(..)) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument (originate) -import Daml.Finance.Test.Util.Lifecycle (lifecycleAndVerifyPaymentEffects, verifyNoLifecycleEffects) -import Daml.Script -import Prelude hiding (Down) - --- Calculate interest rate payment on an interest rate swap (represented using FpML swapStreams), --- including lifecycling and creation of new instrument version. -run : Script () -run = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Fix vs floating interest rate swap: Libor 3M vs 2.01% p.a. payment every 3M - let - issueDate = date 2019 Jan 16 - firstPaymentDate = date 2019 Feb 15 - maturityDate = date 2019 May 15 - referenceRateId = "USD/LIBOR/3M" - fixRate = 0.0201 - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2019 Jan 11, 0.0027406) - , (dateToDateClockTime $ date 2019 Feb 13, 0.002035) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - fixingHolidayCalendarId = ["LIB"] - fixingCal = - HolidayCalendarData with - id = "LIB" - weekend = [Saturday, Sunday] - holidays = [date 2019 Jan 14] - - issuerPartyRef = "Counterparty" - clientPartyRef = "ExecutingParty" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstPaymentDate - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM 15 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = Some firstPaymentDate - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 1.0 - step = [] - currency = "USD" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplier - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = dayCountConvention - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstPaymentDate - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM 15 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = Some firstPaymentDate - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 1.0 - step = [] - currency = "USD" - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = dayCountConvention - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstPaymentDate 1) swapInstrument issuer - [observableCid] - - -- First payment date: Lifecycle and verify the lifecycle effects for fix and floating payments. - let - expectedConsumed = [qty 0.001675 cashInstrument] - expectedProduced = [qty 0.0002283833 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstPaymentDate swapInstrument issuer [observableCid] expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - - -- One day after the first payment date: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (addDays firstPaymentDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - -- One day before expiry: try to lifecycle and verify that there are no lifecycle effects. - verifyNoLifecycleEffects [publicParty] (subtractDays maturityDate 1) - swapInstrumentAfterFirstPayment issuer [observableCid] - - - -- Lifecycle on the second payment date, which is also the expiry date. Verify the lifecycle effects for fix and floating payments. - let - expectedConsumed = [qty 0.0049691667 cashInstrument] - expectedProduced = [qty 0.0005030972 cashInstrument] - maybeSwapInstrumentAfterFinalPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFirstPayment issuer [observableCid] expectedConsumed expectedProduced - - swapInstrumentAfterFinalPayment <- case maybeSwapInstrumentAfterFinalPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () - --- Test interpolation of two floating rates for a stub period, according to the calculation here: --- https://www.isda.org/a/aWkgE/Linear-interpolation-04022022.pdf -runStubRateInterpolation : Script () -runStubRateInterpolation = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create swap - let - issueDate = date 2022 Jan 10 - firstRegularPeriodDate = date 2022 Mar 20 - lastRegularPeriodDate = date 2022 Jun 20 - maturityDate = date 2022 Jun 20 - referenceRateId = "USD/LIBOR/3M" - referenceRateOneMonthId = "USD/LIBOR/1M" - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - -- Use basis 1/1 in order to compare the interpolated rate calculation with the ISDA paper - dayCountConvention = Basis1 - businessDayConvention = ModifiedFollowing - observationsLibor3M = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 06, 0.0023129) - , (dateToDateClockTime $ date 2022 Mar 17, 0.002035) - ] - observationsLibor1M = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 06, 0.0010414) - , (dateToDateClockTime $ date 2022 Mar 17, 0.002035) - ] - - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - fixingHolidayCalendarId = ["LIB"] - fixingCal = - HolidayCalendarData with - id = "LIB" - weekend = [Saturday, Sunday] - holidays = [date 2019 Jan 14] - - issuerPartyRef = "Counterparty" - clientPartyRef = "ExecutingParty" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularPeriodDate - lastRegularPeriodEndDate = Some lastRegularPeriodDate - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM 20 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = Some firstRegularPeriodDate - lastRegularPaymentDate = Some lastRegularPeriodDate - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 1.0 - step = [] - currency = "USD" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplier - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = dayCountConvention - compoundingMethodEnum = None - stubCalculationPeriodAmount = Some StubCalculationPeriodAmount with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - initialStub = Some $ StubValue_FloatingRate - [ StubFloatingRate with - floatingRateIndex = referenceRateOneMonthId - indexTenor = Some (Period with period=M; periodMultiplier = 1) - , StubFloatingRate with - floatingRateIndex=referenceRateId - indexTenor = Some (Period with period = M; periodMultiplier = 3) - ] - finalStub = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg] - currencies = [cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableLibor3MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations=observationsLibor3M - observers = mempty - observableLibor1MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateOneMonthId; observations=observationsLibor1M - observers = mempty - let observableCids = [observableLibor3MCid, observableLibor1MCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date (after weekend adjustment): Lifecycle stub period and verify the lifecycle - -- effects for floating payment. - let - expectedConsumed = [] - -- interpolated stub rate from the ISDA paper - expectedProduced = [qty 0.001867875 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (addDays firstRegularPeriodDate 1) - swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - pure () - --- Test sample trade with two stub periods (intial and final) in the same trade. -runDualStubSampleTrade : Script () -runDualStubSampleTrade = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Fix vs floating interest rate swap: Libor 3M vs 2.0% p.a. - -- CREATE_FPML_SWAP_VARIABLES_BEGIN - let - issueDate = date 2022 Sep 14 - firstRegularPeriodDate = date 2022 Sep 20 - lastRegularPeriodDate = date 2023 Jun 20 - maturityDate = date 2023 Sep 14 - firstRegularPeriodDateFixLeg = date 2022 Sep 20 - lastRegularPeriodDateFixLeg = firstRegularPeriodDateFixLeg - referenceRateId = "USD/LIBOR/3M" - referenceRateOneMonthId = "USD/LIBOR/1M" - fixRate = 0.02 - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - issuerPartyRef = "Counterparty" - clientPartyRef = "ExecutingParty" - -- CREATE_FPML_SWAP_VARIABLES_END - secondRegularPeriodDate = date 2022 Dec 20 - thirdRegularPeriodDate = date 2023 Mar 20 - observationsLibor3M = Map.fromList - [ (dateToDateClockTime $ date 2022 Sep 16, 0.013) - , (dateToDateClockTime $ date 2022 Dec 16, 0.013) - , (dateToDateClockTime $ date 2023 Mar 16, 0.013) - , (dateToDateClockTime $ date 2023 Jun 16, 0.013) - ] - observationsLibor1M = Map.fromList - [ (dateToDateClockTime $ date 2022 Jan 06, 0.0020) - , (dateToDateClockTime $ date 2022 Sep 16, 0.015) - , (dateToDateClockTime $ date 2022 Dec 16, 0.016) - , (dateToDateClockTime $ date 2023 Mar 16, 0.017) - , (dateToDateClockTime $ date 2023 Jun 16, 0.02) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - fixingHolidayCalendarId = ["LIB"] - fixingCal = - HolidayCalendarData with - id = "LIB" - weekend = [Saturday, Sunday] - holidays = [date 2019 Jan 14] - - -- CREATE_FPML_SWAP_FLOAT_LEG_BEGIN - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularPeriodDate - lastRegularPeriodEndDate = Some lastRegularPeriodDate - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM 20 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = Some firstRegularPeriodDate - lastRegularPaymentDate = Some lastRegularPeriodDate - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 1000000.0 - step = [] - currency = "USD" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplier - period = M - spreadSchedule = [SpreadSchedule with initialValue = 0.005] - finalRateRounding = None - dayCountFraction = dayCountConvention - compoundingMethodEnum = Some Straight - stubCalculationPeriodAmount = Some StubCalculationPeriodAmount with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - initialStub = Some $ StubValue_StubRate 0.015 - finalStub = Some $ StubValue_FloatingRate - [ StubFloatingRate with - floatingRateIndex=referenceRateOneMonthId - indexTenor = Some (Period with period = M; periodMultiplier = 1) - , StubFloatingRate with - floatingRateIndex = referenceRateId - indexTenor = Some (Period with period = M; periodMultiplier = 3) - ] - principalExchanges = None - -- CREATE_FPML_SWAP_FLOAT_LEG_END - - -- CREATE_FPML_SWAP_FIX_LEG_BEGIN - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularPeriodDateFixLeg - lastRegularPeriodEndDate = Some lastRegularPeriodDateFixLeg - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = 1 - period = Regular Y - rollConvention = DOM 20 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = 1 - period = Regular Y - firstPaymentDate = Some firstRegularPeriodDateFixLeg - lastRegularPaymentDate = Some lastRegularPeriodDateFixLeg - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 1000000.0 - step = [] - currency = "USD" - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = dayCountConvention - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - -- CREATE_FPML_SWAP_FIX_LEG_END - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableLibor3MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations=observationsLibor3M - observers = mempty - observableLibor1MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateOneMonthId; observations=observationsLibor1M - observers = mempty - let observableCids = [observableLibor3MCid, observableLibor1MCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstRegularPeriodDate 1) swapInstrument - issuer observableCids - - -- First payment date: Lifecycle and verify the fix and floating payments (stub period). - let - expectedConsumed = [qty 333.3333 cashInstrument] - expectedProduced = [qty 250.0 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstRegularPeriodDate swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- Second payment date: Lifecycle and verify the floating payment (regular period, 3M). - let - expectedConsumed = [] - expectedProduced = [qty 4550.0 cashInstrument] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - secondRegularPeriodDate swapInstrumentAfterFirstPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrument - - -- Third payment date: Lifecycle and verify the floating payment (regular period, 3M). - let - expectedConsumed = [] - expectedProduced = [qty 4500.0 cashInstrument] - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - thirdRegularPeriodDate swapInstrumentAfterSecondPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - - -- Fourth payment date: Lifecycle and verify the floating payment (regular period, 3M). - let - expectedConsumed = [] - expectedProduced = [qty 4600.0 cashInstrument] - maybeSwapInstrumentAfterFourthPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - lastRegularPeriodDate swapInstrumentAfterThirdPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFourthPayment <- case maybeSwapInstrumentAfterFourthPayment of - Some key -> pure key - None -> pure swapInstrumentAfterThirdPayment - - -- Final payment date: Lifecycle and verify the fix and floating payments (stub period). - let - expectedConsumed = [qty 19944.4444 cashInstrument] - expectedProduced = [qty 3267.3835 cashInstrument] - maybeSwapInstrumentAfterFinalPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterFourthPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFinalPayment <- case maybeSwapInstrumentAfterFinalPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFourthPayment - - pure () - --- Test sample trade with a payment frequency different from the calculation frequency. -runSeparatePaymentFrequencySampleTrade : Script () -runSeparatePaymentFrequencySampleTrade = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Fix vs floating interest rate swap: Libor 6M vs 2.0% p.a. - let - issueDate = date 2022 Oct 17 - firstRegularPeriodDate = date 2022 Oct 26 - maturityDate = date 2027 Oct 26 - referenceRateId = "USD/LIBOR/6M" - referenceRate1MId = "USD/LIBOR/1M" - referenceRate1DId = "USD/LIBOR/1D" - fixRate = 0.02 - dayCountConventionFixLeg = Basis30360 - dayCountConventionFloatingLeg = Act360 - businessDayConvention = ModifiedFollowing - issuerPartyRef = "Counterparty" - clientPartyRef = "ExecutingParty" - observationsLibor6M = Map.fromList - [ (dateToDateClockTime $ date 2022 Oct 24, 0.01) - , (dateToDateClockTime $ date 2023 Apr 24, 0.01) - , (dateToDateClockTime $ date 2023 Oct 24, 0.01) - ] - - observationsLibor1M = Map.fromList [(dateToDateClockTime $ date 2022 Oct 13, 0.02)] - observationsLibor1D = Map.fromList [(dateToDateClockTime $ date 2022 Oct 13, 0.03)] - holidayCalendarIds = ["USD"] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - fixingHolidayCalendarId = ["LIB"] - fixingCal = - HolidayCalendarData with - id = "LIB" - weekend = [Saturday, Sunday] - holidays = [date 2019 Jan 14] - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularPeriodDate - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = 6 - period = Regular M - rollConvention = DOM 26 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = 1 - period = Regular Y - firstPaymentDate = Some firstRegularPeriodDate - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - resetFrequency = ResetFrequency with - periodMultiplier = 6 - period = Regular M - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 5000000.0 - step = [] - currency = "USD" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = 6 - period = M - spreadSchedule = [SpreadSchedule with initialValue = 0.0025] - finalRateRounding = None - dayCountFraction = dayCountConventionFloatingLeg - compoundingMethodEnum = None - stubCalculationPeriodAmount = Some StubCalculationPeriodAmount with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - initialStub = Some $ StubValue_FloatingRate - [ StubFloatingRate with - floatingRateIndex = referenceRate1MId - indexTenor = Some (Period with period = M; periodMultiplier = 1) - , StubFloatingRate with - floatingRateIndex = referenceRate1DId - indexTenor = Some (Period with period = D; periodMultiplier = 1) - ] - finalStub = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularPeriodDate - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = 3 - period = Regular M - rollConvention = DOM 26 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = 3 - period = Regular M - firstPaymentDate = Some firstRegularPeriodDate - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 5000000.0 - step = [] - currency = "USD" - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = dayCountConventionFixLeg - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableLibor6MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations = observationsLibor6M - observers = mempty - observableLibor1MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRate1MId; observations=observationsLibor1M - observers = mempty - observableLibor1DCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRate1DId; observations=observationsLibor1D - observers = mempty - let observableCids = [observableLibor6MCid, observableLibor1MCid, observableLibor1DCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- One day before the first payment date: try to lifecycle and verify that there are no lifecycle - -- effects. - verifyNoLifecycleEffects [publicParty] (subtractDays firstRegularPeriodDate 1) swapInstrument - issuer observableCids - - -- First payment date: Lifecycle and verify the fix and floating payments (stub period). - let - expectedConsumed = [qty 2500.0 cashInstrument] - expectedProduced = [qty 3416.6665 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstRegularPeriodDate swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- Lifecycle and verify the fix payment (regular period, 3M). - let - expectedConsumed = [qty 25000.0 cashInstrument] - expectedProduced = [] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jan 26) swapInstrumentAfterFirstPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - -- Lifecycle and verify the fix (regular period, 3M). The 6M float payment is calculated but only - -- paid every 12M. - let - expectedConsumed = [qty 25000.0 cashInstrument] - expectedProduced = [] - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Apr 26) swapInstrumentAfterSecondPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - - -- Lifecycle and verify the fix payment (regular period, 3M). - let - expectedConsumed = [qty 25000.0 cashInstrument] - expectedProduced = [] - maybeSwapInstrumentAfterFourthPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jul 26) swapInstrumentAfterThirdPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFourthPayment <- case maybeSwapInstrumentAfterFourthPayment of - Some key -> pure key - None -> pure swapInstrumentAfterThirdPayment - - -- Lifecycle and verify the fix payment (regular period, 3M) + floating payment - -- (regular period, 12M). - let - expectedConsumed = [qty 25000.0 cashInstrument] - expectedProduced = [qty 63368.0555 cashInstrument] - maybeSwapInstrumentAfterFinalPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Oct 26) - swapInstrumentAfterFourthPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFinalPayment <- case maybeSwapInstrumentAfterFinalPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFourthPayment - - pure () - --- Test sample trade with different currencies and exchange of principal. -runCurrencySwapSampleTrade : Script () -runCurrencySwapSampleTrade = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrumentEur <- - originate custodian issuer "EUR" TransferableFungible "Euro" observers now - cashInstrumentUsd <- - originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Float vs float currency swap: Euribor 3M vs Libor 3M - let - issueDate = date 2022 Oct 17 - maturityDate = date 2023 Oct 17 - referenceRateUsdId = "USD/LIBOR/3M" - referenceRateEurId = "EUR/EURIBOR/3M" - referenceRateFxId = "WMRPSPOT01" - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - issuerPartyRef = "Counterparty" - clientPartyRef = "ExecutingParty" - observationsLibor3M = Map.fromList - [ (dateToDateClockTime $ date 2022 Oct 13, 0.02) - , (dateToDateClockTime $ date 2023 Jan 13, 0.02) - , (dateToDateClockTime $ date 2023 Apr 13, 0.02) - , (dateToDateClockTime $ date 2023 Jul 13, 0.02) - , (dateToDateClockTime $ date 2023 Oct 13, 0.02) - ] - observationsEuribor3M = Map.fromList - [ (dateToDateClockTime $ date 2022 Oct 13, 0.01) - , (dateToDateClockTime $ date 2023 Jan 13, 0.01) - , (dateToDateClockTime $ date 2023 Apr 13, 0.01) - , (dateToDateClockTime $ date 2023 Jul 13, 0.01) - , (dateToDateClockTime $ date 2023 Oct 13, 0.01) - ] - observationsFx = Map.fromList - [ (dateToDateClockTime $ date 2022 Oct 13, 1.02) - , (dateToDateClockTime $ date 2023 Jan 13, 1.03) - , (dateToDateClockTime $ date 2023 Apr 13, 1.05) - , (dateToDateClockTime $ date 2023 Jul 13, 1.04) - , (dateToDateClockTime $ date 2023 Oct 13, 1.03) - ] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - fixingHolidayCalendarId = ["LIB"] - fixingCal = - HolidayCalendarData with - id = "LIB" - weekend = [Saturday, Sunday] - holidays = [date 2019 Jan 14] - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "eurLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM 17 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "eurLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "eurLegCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "notionalScheduleConstant" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 5000000.0 - step = [] - currency = "EUR" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateEurId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplier - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = dayCountConvention - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = Some PrincipalExchanges with - initialExchange = True - intermediateExchange = True - finalExchange = True - - swapStreamFixedLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "usdLeg2CalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM 17 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "usdLeg2CalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "usdLeg2CalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_FxLinked FxLinkedNotionalSchedule with - constantNotionalScheduleReference = "notionalScheduleConstant" - initialValue = Some 5100000.0 - varyingNotionalCurrency = "USD" - varyingNotionalFixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - fxSpotRateSource = FxSpotRateSource with - primaryRateSource = InformationSource with - rateSource = "Reuters" - rateSourcePage = referenceRateFxId - fixingTime = Some BusinessCenterTime with - hourMinuteTime = "11:00:00" - businessCenter = "LIB" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateUsdId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplier - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = dayCountConvention - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = Some PrincipalExchanges with - initialExchange = True - intermediateExchange = True - finalExchange = True - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrumentEur, cashInstrumentUsd] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableLibor3MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateUsdId; observations=observationsLibor3M - observers = mempty - observableEuribor3MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateEurId; observations=observationsEuribor3M - observers = mempty - observableFxCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateFxId; observations=observationsFx - observers = mempty - let observableCids = [observableLibor3MCid, observableEuribor3MCid, observableFxCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - let settlers = singleton custodian - - -- Lifecycle and verify initial exchange of principal - let - expectedConsumed = [qty 5100000.0 cashInstrumentUsd] - expectedProduced = [qty 5000000.0 cashInstrumentEur] - maybeSwapInstrumentAfterFirstPrincipalExchangePayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Oct 17) swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPrincipalExchangePayment <- case maybeSwapInstrumentAfterFirstPrincipalExchangePayment of - Some key -> pure key - None -> pure swapInstrument - - - -- Lifecycle and verify Euribor vs Libor payment. - let - expectedConsumed = [qty 12777.778 cashInstrumentEur, qty 50000.0 cashInstrumentUsd] - expectedProduced = [qty 26066.66661 cashInstrumentUsd] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jan 17) swapInstrumentAfterFirstPrincipalExchangePayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPrincipalExchangePayment - - - -- Lifecycle and verify Euribor vs Libor payment. - let - expectedConsumed = [qty 12500.0 cashInstrumentEur, qty 100000.0 cashInstrumentUsd] - expectedProduced = [qty 25750.0 cashInstrumentUsd] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Apr 17) swapInstrumentAfterFirstPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - - -- Lifecycle and verify Euribor vs Libor payment. - let - expectedConsumed = [qty 12638.889 cashInstrumentEur] - expectedProduced = [qty 26541.6669 cashInstrumentUsd, qty 50000.0 cashInstrumentUsd] - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jul 17) swapInstrumentAfterSecondPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - - - -- Lifecycle and verify Euribor vs Libor payment (final period). - let - expectedConsumed = [qty 12777.778 cashInstrumentEur, qty 5000000.0 cashInstrumentEur] - expectedProduced = [qty 26577.77772 cashInstrumentUsd, qty 5200000.0 cashInstrumentUsd] - maybeSwapInstrumentAfterFinalPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Oct 17) swapInstrumentAfterThirdPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFinalPayment <- case maybeSwapInstrumentAfterFinalPayment of - Some key -> pure key - None -> pure swapInstrumentAfterThirdPayment - - - pure () - --- Test sample trade with amortizing notional. -runAmortizingNotionalSampleTrade : Script () -runAmortizingNotionalSampleTrade = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - - -- Create and distribute swap - -- Fix vs floating interest rate swap with amortizing notional: Libor 3M vs 2.0% p.a. - let - issueDate = date 2022 Oct 17 - firstRegularPeriodDate = date 2022 Oct 20 - lastRegularPeriodDate = date 2027 Oct 20 - maturityDate = date 2027 Oct 27 - firstRegularPeriodDateFixLeg = date 2022 Oct 20 - lastRegularPeriodDateFixLeg = date 2027 Oct 20 - referenceRateId = "USD/LIBOR/3M" - referenceRate1MId = "USD/LIBOR/1M" - referenceRate1DId = "USD/LIBOR/1D" - fixRate = 0.02 - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - dayCountConvention = Act360 - businessDayConvention = ModifiedFollowing - issuerPartyRef = "Counterparty" - clientPartyRef = "ExecutingParty" - secondRegularPeriodDate = date 2022 Oct 20 - thirdRegularPeriodDate = date 2027 Oct 20 - observationsLibor3M = Map.fromList $ - [ (dateToDateClockTime $ date 2022 Oct 18, 0.01) - , (dateToDateClockTime $ date 2023 Jan 18, 0.01) - , (dateToDateClockTime $ date 2023 Apr 18, 0.01) - , (dateToDateClockTime $ date 2023 Jul 18, 0.01) - , (dateToDateClockTime $ date 2023 Oct 18, 0.01) - , (dateToDateClockTime $ date 2024 Jan 18, 0.01) - , (dateToDateClockTime $ date 2024 Apr 18, 0.01) - , (dateToDateClockTime $ date 2024 Jul 18, 0.01) - , (dateToDateClockTime $ date 2024 Oct 17, 0.01) - , (dateToDateClockTime $ date 2025 Jan 16, 0.01) - , (dateToDateClockTime $ date 2025 Apr 17, 0.01) - , (dateToDateClockTime $ date 2025 Jul 17, 0.01) - , (dateToDateClockTime $ date 2025 Oct 16, 0.01) - ] - - observationsLibor1M = Map.fromList [(dateToDateClockTime $ date 2022 Oct 13, 0.02)] - observationsLibor1D = Map.fromList [(dateToDateClockTime $ date 2022 Oct 13, 0.03)] - calendar = - HolidayCalendarData with - id = "USD" - weekend = [Saturday, Sunday] - holidays = [date 2019 Dec 19] - holidayCalendarIds = [calendar.id] - fixingHolidayCalendarId = ["LIB"] - fixingCal = - HolidayCalendarData with - id = "LIB" - weekend = [Saturday, Sunday] - holidays = [date 2019 Jan 14] - - swapStreamFixedLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularPeriodDateFixLeg - lastRegularPeriodEndDate = Some lastRegularPeriodDateFixLeg - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = 6 - period = Regular M - rollConvention = DOM 20 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = 6 - period = Regular M - firstPaymentDate = Some firstRegularPeriodDateFixLeg - lastRegularPaymentDate = Some lastRegularPeriodDateFixLeg - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 5000000.0 - step = - [ Step with stepDate = date 2022 Oct 17; stepValue = 5000000.0 - , Step with stepDate = date 2022 Oct 20; stepValue = 4500000.0 - , Step with stepDate = date 2023 Apr 20; stepValue = 4000000.0 - , Step with stepDate = date 2023 Oct 20; stepValue = 3500000.0 - , Step with stepDate = date 2024 Apr 20; stepValue = 3000000.0 - , Step with stepDate = date 2024 Oct 20; stepValue = 2500000.0 - , Step with stepDate = date 2025 Apr 20; stepValue = 2000000.0 - , Step with stepDate = date 2025 Oct 20; stepValue = 1500000.0 - , Step with stepDate = date 2026 Apr 20; stepValue = 1000000.0 - , Step with stepDate = date 2026 Oct 20; stepValue = 1000000.0 - , Step with stepDate = date 2027 Apr 20; stepValue = 1000000.0 - , Step with stepDate = date 2027 Oct 20; stepValue = 1000000.0 - ] - currency = "USD" - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = Basis30360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingLegCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularPeriodDate - lastRegularPeriodEndDate = Some lastRegularPeriodDate - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM 20 - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = Some firstRegularPeriodDate - lastRegularPaymentDate = Some lastRegularPeriodDate - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingHolidayCalendarId - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = holidayCalendarIds - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 5000000.0 - step = - [ Step with stepDate = date 2022 Oct 17; stepValue = 5000000.0 - , Step with stepDate = date 2022 Oct 20; stepValue = 4500000.0 - , Step with stepDate = date 2023 Jan 20; stepValue = 4500000.0 - , Step with stepDate = date 2023 Apr 20; stepValue = 4000000.0 - , Step with stepDate = date 2023 Jul 20; stepValue = 4000000.0 - , Step with stepDate = date 2023 Oct 20; stepValue = 3500000.0 - , Step with stepDate = date 2024 Jan 20; stepValue = 3500000.0 - , Step with stepDate = date 2024 Apr 20; stepValue = 3000000.0 - , Step with stepDate = date 2024 Jul 20; stepValue = 3000000.0 - , Step with stepDate = date 2024 Oct 20; stepValue = 2500000.0 - , Step with stepDate = date 2025 Jan 20; stepValue = 2500000.0 - , Step with stepDate = date 2025 Apr 20; stepValue = 2000000.0 - , Step with stepDate = date 2025 Jul 20; stepValue = 2000000.0 - , Step with stepDate = date 2025 Oct 20; stepValue = 1500000.0 - , Step with stepDate = date 2026 Jan 20; stepValue = 1500000.0 - , Step with stepDate = date 2026 Apr 20; stepValue = 1000000.0 - , Step with stepDate = date 2026 Jul 20; stepValue = 1000000.0 - , Step with stepDate = date 2026 Oct 20; stepValue = 1000000.0 - , Step with stepDate = date 2027 Jan 20; stepValue = 1000000.0 - , Step with stepDate = date 2027 Apr 20; stepValue = 1000000.0 - , Step with stepDate = date 2027 Jul 20; stepValue = 1000000.0 - , Step with stepDate = date 2027 Oct 20; stepValue = 1000000.0 - ] - currency = "USD" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplier - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = dayCountConvention - compoundingMethodEnum = None - stubCalculationPeriodAmount = Some StubCalculationPeriodAmount with - calculationPeriodDatesReference = "floatingLegCalcPeriodDates" - initialStub = Some $ StubValue_FloatingRate - [ StubFloatingRate with - floatingRateIndex = referenceRate1MId - indexTenor = Some (Period with period = M; periodMultiplier = 1) - , StubFloatingRate with - floatingRateIndex = referenceRate1DId - indexTenor = Some (Period with period = D; periodMultiplier = 1) - ] - finalStub = Some $ StubValue_FloatingRate - [ StubFloatingRate with - floatingRateIndex = referenceRate1MId - indexTenor = Some (Period with period = M; periodMultiplier = 1) - , StubFloatingRate with - floatingRateIndex = referenceRate1DId - indexTenor = Some (Period with period = D; periodMultiplier = 1) - ] - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableLibor3MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations=observationsLibor3M - observers = mempty - observableLibor1MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRate1MId; observations=observationsLibor1M - observers = mempty - observableLibor1DCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRate1DId; observations=observationsLibor1D - observers = mempty - let observableCids = [observableLibor3MCid, observableLibor1MCid, observableLibor1DCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - let settlers = singleton custodian - - -- First payment date: Lifecycle and verify the fix and floating payments (stub period). - let - expectedConsumed = [qty 1222.222 cashInstrument] - expectedProduced = [qty 833.3335 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Oct 20) swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - - -- Second payment date: Lifecycle and verify the floating payment (regular period, 3M). - let - expectedConsumed = [qty 11500.0002 cashInstrument] - expectedProduced = [] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Jan 20) swapInstrumentAfterFirstPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - - -- Third payment date: Lifecycle and verify the fix and floating payments (regular period, 3M float vs 6M fix). - let - expectedConsumed = [qty 11250.0 cashInstrument] - expectedProduced = [qty 45000.0 cashInstrument] - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2023 Apr 20) swapInstrumentAfterSecondPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - pure () - --- fpml.org Example 1 - Fixed/Floating Single Currency Interest Rate Swap --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 -runFpml1 : Script () -runFpml1 = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers now - - -- Create swap - let - rollDay = 14 - issueDate = date 1994 Dec rollDay - maturityDate = date 1999 Dec rollDay - referenceRateId = "EUR/LIBOR/BBA/6M" - fixRate = 0.06 - notional = 50000000.0 - ccy = "EUR" - paymentPeriodFloat = Regular M - paymentPeriodMultiplierFloat = 6 - paymentPeriodFixed = Regular Y - paymentPeriodMultiplierFixed = 1 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 1994 Dec 12, 0.061) - , (dateToDateClockTime $ date 1995 Jun 12, 0.063) - , (dateToDateClockTime $ date 1995 Dec 12, 0.065) - , (dateToDateClockTime $ date 1996 Jun 12, 0.066) - , (dateToDateClockTime $ date 1996 Dec 12, 0.067) - , (dateToDateClockTime $ date 1997 Jun 12, 0.068) - , (dateToDateClockTime $ date 1997 Dec 11, 0.069) - , (dateToDateClockTime $ date 1998 Jun 11, 0.070) - , (dateToDateClockTime $ date 1998 Dec 10, 0.071) - , (dateToDateClockTime $ date 1999 Jun 10, 0.072) - , (dateToDateClockTime $ date 1999 Dec 10, 0.073) - ] - primaryBusinessCenters = ["DEFR"] - calendar = - HolidayCalendarData with - id = "DEFR" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party1" - clientPartyRef = "party2" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplierFloat - period = paymentPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplierFloat - period = paymentPeriodFloat - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplierFloat - period = paymentPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplierFloat - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplierFixed - period = paymentPeriodFixed - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplierFixed - period = paymentPeriodFixed - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - paymentDaysOffset = None - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = Basis30E360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify the floating payment (regular period, 6M). - let - expectedConsumed = [] - expectedProduced = [qty 1541944.445 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1995 Jun 14) swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- Second payment date: Lifecycle and verify the fix and floating payments (regular period, 6M float vs 12M fix). - let - expectedConsumed = [qty 3000000.0 cashInstrument] - expectedProduced = [qty 1601250.0 cashInstrument] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1995 Dec 14) swapInstrumentAfterFirstPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () - --- fpml.org Example 2 - Fixed/Floating Single Currency Interest Rate Swap with Initial Stub Period --- and Notional Amortization --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 -runFpml2 : Script () -runFpml2 = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers now - - -- Create swap - let - rollDay = 14 - issueDate = date 1995 Jan 16 - firstRegularDateFloat = date 1995 Jun rollDay - firstRegularDateFixed = date 1995 Dec rollDay - maturityDate = date 1999 Dec rollDay - referenceRateId = "EUR/LIBOR/BBA/6M" - referenceRate4MId = "EUR/LIBOR/BBA/4M" - referenceRate5MId = "EUR/LIBOR/BBA/5M" - fixRate = 0.06 - notional = 50000000.0 - ccy = "EUR" - paymentPeriodFloat = Regular M - paymentPeriodMultiplierFloat = 6 - paymentPeriodFixed = Regular Y - paymentPeriodMultiplierFixed = 1 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 1995 Jun 12, 0.063) - , (dateToDateClockTime $ date 1995 Dec 12, 0.065) - , (dateToDateClockTime $ date 1996 Jun 12, 0.065) - , (dateToDateClockTime $ date 1996 Dec 12, 0.065) - ] - observations4M = Map.fromList - [ (dateToDateClockTime $ date 1995 Jan 12, 0.050) - ] - observations5M = Map.fromList - [ (dateToDateClockTime $ date 1995 Jan 12, 0.060) - ] - primaryBusinessCenters = ["DEFR"] - calendar = - HolidayCalendarData with - id = "DEFR" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party1" - clientPartyRef = "party2" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularDateFloat - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplierFloat - period = paymentPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplierFloat - period = paymentPeriodFloat - firstPaymentDate = Some firstRegularDateFloat - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = paymentPeriodMultiplierFloat - period = paymentPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = - [ Step with stepDate = date 1995 Dec 14; stepValue = 40000000.0 - , Step with stepDate = date 1996 Dec 14; stepValue = 30000000.0 - , Step with stepDate = date 1997 Dec 14; stepValue = 20000000.0 - , Step with stepDate = date 1998 Dec 14; stepValue = 10000000.0 - ] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = paymentPeriodMultiplierFloat - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = Some StubCalculationPeriodAmount with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - initialStub = Some $ StubValue_FloatingRate - [ StubFloatingRate with - floatingRateIndex = referenceRate4MId - indexTenor = Some Period with period = M; periodMultiplier = 4 - , StubFloatingRate with - floatingRateIndex = referenceRate5MId - indexTenor = Some Period with period = M; periodMultiplier = 5 - ] - finalStub = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = Some firstRegularDateFixed - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplierFixed - period = paymentPeriodFixed - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplierFixed - period = paymentPeriodFixed - firstPaymentDate = Some firstRegularDateFixed - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - paymentDaysOffset = None - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = - [ Step with stepDate = date 1995 Dec 14; stepValue = 40000000.0 - , Step with stepDate = date 1996 Dec 14; stepValue = 30000000.0 - , Step with stepDate = date 1997 Dec 14; stepValue = 20000000.0 - , Step with stepDate = date 1998 Dec 14; stepValue = 10000000.0 - ] - currency = ccy - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = Basis30E360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - observable4MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRate4MId; observations=observations4M; observers = mempty - observable5MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRate5MId; observations=observations5M; observers = mempty - let observableCids = [observableCid, observable4MCid, observable5MCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify the floating payment (short stub period). - let - expectedConsumed = [] - expectedProduced = [qty 1228315.41 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1995 Jun 14) swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - - -- Second payment date: Lifecycle and verify the fix and floating payments - -- (regular 6M float period, short stub fix period). - let - expectedConsumed = [qty 2733333.335 cashInstrument] - expectedProduced = [qty 1601250.0 cashInstrument] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1995 Dec 14) swapInstrumentAfterFirstPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - - -- Third payment date: Lifecycle and verify the floating payment - -- (regular 6M period, amortized notional). - let - expectedConsumed = [] - expectedProduced = [qty 1321666.668 cashInstrument] - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1996 Jun 14) swapInstrumentAfterSecondPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - - - -- Fourth payment date: Lifecycle and verify the fix and floating payments - -- (regular periods: 6M float / 1Y fix, amortized notional). - let - expectedConsumed = [qty 2413333.332 cashInstrument] - expectedProduced = [qty 1336111.112 cashInstrument] - maybeSwapInstrumentAfterFourthPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1996 Dec 16) swapInstrumentAfterThirdPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFourthPayment <- case maybeSwapInstrumentAfterFourthPayment of - Some key -> pure key - None -> pure swapInstrumentAfterThirdPayment - - pure () - --- fpml.org Example 3 - Fixed/Floating Single Currency Interest Rate Swap with Compounding, Payment --- Delay and Final Rate Rounding --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 -runFpml3 : Script () -runFpml3 = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers now - - -- Create swap - let - rollDay = 27 - issueDate = date 2000 Apr rollDay - firstRegularDateFloat = date 1995 Jun rollDay - firstRegularDateFixed = date 1995 Dec rollDay - maturityDate = date 2002 Apr rollDay - referenceRateId = "EUR/LIBOR/BBA/3M" - fixRate = 0.0585 - notional = 100000000.0 - ccy = "EUR" - paymentPeriod = Regular M - paymentPeriodMultiplier = 6 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 3 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2000 Apr 25, 0.063) - , (dateToDateClockTime $ date 2000 Jul 25, 0.065) - , (dateToDateClockTime $ date 2000 Oct 25, 0.067) - , (dateToDateClockTime $ date 2001 Jan 25, 0.069) - , (dateToDateClockTime $ date 2001 Apr 25, 0.071) - , (dateToDateClockTime $ date 2001 Jul 23, 0.048) - , (dateToDateClockTime $ date 2001 Jul 25, 0.048) - , (dateToDateClockTime $ date 2001 Oct 25, 0.049) - , (dateToDateClockTime $ date 2002 Jan 24, 0.074) - , (dateToDateClockTime $ date 2002 Jan 25, 0.050) - ] - primaryBusinessCenters = ["GBLO", "USNY"] - calendar = - HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party2" - clientPartyRef = "party1" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = Some DateOffset with - periodMultiplier = 5 - period = D - dayType = Some Business - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [] - {- - finalRateRounding = Some Rounding with - roundingDirection = Nearest - precision = 7 - -} - finalRateRounding = None -- https://github.com/digital-asset/daml-finance/issues/518 - dayCountFraction = Act360 - compoundingMethodEnum = Some Flat - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = Some DateOffset with - periodMultiplier = 5 - period = D - dayType = Some Business - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = Basis30360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify the fix and floating payments (regular 6M period) - let - expectedConsumed = [qty 2925000.0 cashInstrument] - expectedProduced = [qty 3280064.30442675 cashInstrument] - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2000 Nov 3) swapInstrument issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - - -- Second payment date: Lifecycle and verify the fix and floating payments (regular 6M period) - let - expectedConsumed = [qty 2925000.0 cashInstrument] - expectedProduced = [qty 3465618.4062796481 cashInstrument] - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2001 May 4) swapInstrumentAfterFirstPayment issuer observableCids expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - pure () - --- Test Rate Rounding methods. --- https://www.fpml.org/spec/fpml-5-11-3-lcwd-1/html/confirmation/schemaDocumentation/schemas/fpml-shared-5-11_xsd/complexTypes/FloatingRateCalculation/finalRateRounding.html -runFpmlRateRounding : Script () -runFpmlRateRounding = script do - -- Test rounding direction, using the test cases here: - -- https://www.fpml.org/spec/fpml-5-11-3-lcwd-1/html/confirmation/schemaDocumentation/schemas/fpml-shared-5-11_xsd/complexTypes/Rounding/roundingDirection.html - 0.053 === roundRate 0.0521 Rounding with roundingDirection = Up; precision = 3 - 0.053 === roundRate 0.0525 Rounding with roundingDirection = Up; precision = 3 - 0.052 === roundRate 0.0529 Rounding with roundingDirection = Down; precision = 3 - 0.052 === roundRate 0.0525 Rounding with roundingDirection = Down; precision = 3 - 0.052 === roundRate 0.0524 Rounding with roundingDirection = Nearest; precision = 3 - 0.053 === roundRate 0.0525 Rounding with roundingDirection = Nearest; precision = 3 - - -- Test rounding precision, using the test case here: - -- https://www.fpml.org/spec/fpml-5-11-3-lcwd-1/html/confirmation/schemaDocumentation/schemas/fpml-shared-5-11_xsd/complexTypes/Rounding/precision.html - 0.0987654 === roundRate 0.09876543 Rounding with roundingDirection = Nearest; precision = 7 - - -- Test rounding direction of negative numbers - (-0.052) === roundRate (-0.0521) Rounding with roundingDirection = Up; precision = 3 - (-0.052) === roundRate (-0.0525) Rounding with roundingDirection = Up; precision = 3 - (-0.053) === roundRate (-0.0529) Rounding with roundingDirection = Down; precision = 3 - (-0.053) === roundRate (-0.0525) Rounding with roundingDirection = Down; precision = 3 - (-0.052) === roundRate (-0.0524) Rounding with roundingDirection = Nearest; precision = 3 - (-0.053) === roundRate (-0.0525) Rounding with roundingDirection = Nearest; precision = 3 - - pure () - --- ISDA calculation example for straight compounding, example 4.1: --- https://www.isda.org/a/2KiDE/isda-compounding-memo.pdf -runCompounding : Script () -runCompounding = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" observers now - - -- Create swap - let - rollDay = 27 - issueDate = date 2022 Apr rollDay - maturityDate = date 2023 Apr rollDay - referenceRateId = "USD/LIBOR/BBA/1M" - notional = 10000000.0 - ccy = "USD" - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 1 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Apr 25, 0.040) - , (dateToDateClockTime $ date 2022 May 25, 0.045) - , (dateToDateClockTime $ date 2022 Jun 23, 0.050) - , (dateToDateClockTime $ date 2022 Jul 25, 0.000) - , (dateToDateClockTime $ date 2022 Aug 25, 0.039) - , (dateToDateClockTime $ date 2022 Sep 23, 0.001) - , (dateToDateClockTime $ date 2022 Oct 25, 0.025) - , (dateToDateClockTime $ date 2022 Nov 24, 0.011) - , (dateToDateClockTime $ date 2022 Dec 23, 0.010) - , (dateToDateClockTime $ date 2023 Jan 25, 0.023) - , (dateToDateClockTime $ date 2023 Feb 23, 0.013) - , (dateToDateClockTime $ date 2023 Mar 23, 0.009) - ] - primaryBusinessCenters = ["GBLO", "USNY"] - calendar = - HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party2" - clientPartyRef = "party1" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [SpreadSchedule with initialValue = 0.001] - finalRateRounding = None - dayCountFraction = Basis30360ICMA - compoundingMethodEnum = Some Straight - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg] - currencies = [cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify the floating payment (3 compounded 1M periods). - let - expectedConsumed = [] - expectedProduced = [qty 115439.654 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 27) swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - pure () - --- ISDA calculation example for flat compounding, example 4.2: --- https://www.isda.org/a/2KiDE/isda-compounding-memo.pdf -runCompoundingFlat : Script () -runCompoundingFlat = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" observers now - - -- Create swap - let - rollDay = 27 - issueDate = date 2022 Apr rollDay - maturityDate = date 2023 Apr rollDay - referenceRateId = "USD/LIBOR/BBA/1M" - notional = 10000000.0 - ccy = "USD" - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 1 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Apr 25, 0.040) - , (dateToDateClockTime $ date 2022 May 25, 0.045) - , (dateToDateClockTime $ date 2022 Jun 23, 0.050) - , (dateToDateClockTime $ date 2022 Jul 25, 0.000) - , (dateToDateClockTime $ date 2022 Aug 25, 0.010) - , (dateToDateClockTime $ date 2022 Sep 23, 0.001) - , (dateToDateClockTime $ date 2022 Oct 25, 0.052) - , (dateToDateClockTime $ date 2022 Nov 24, 0.030) - , (dateToDateClockTime $ date 2022 Dec 23, 0.005) - , (dateToDateClockTime $ date 2023 Jan 25, 0.019) - , (dateToDateClockTime $ date 2023 Feb 23, 0.025) - , (dateToDateClockTime $ date 2023 Mar 23, 0.001) - ] - primaryBusinessCenters = ["GBLO", "USNY"] - calendar = - HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party2" - clientPartyRef = "party1" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [SpreadSchedule with initialValue = 0.001] - finalRateRounding = None - dayCountFraction = Basis30360ICMA - compoundingMethodEnum = Some Flat - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg] - currencies = [cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify the floating payment (3 compounded 1M periods). - let - expectedConsumed = [] - expectedProduced = [qty 115430.7421911761 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 27) swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - pure () - --- ISDA calculation example for compounding, example 4.3: --- https://www.isda.org/a/2KiDE/isda-compounding-memo.pdf --- treating Spread as simple interest -runCompoundingSpreadSimple : Script () -runCompoundingSpreadSimple = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" observers now - - -- Create swap - let - rollDay = 27 - issueDate = date 2022 Apr rollDay - maturityDate = date 2023 Apr rollDay - referenceRateId = "USD/LIBOR/BBA/1M" - notional = 10000000.0 - ccy = "USD" - paymentPeriod = Regular M - paymentPeriodMultiplier = 3 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 1 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2022 Apr 25, 0.040) - , (dateToDateClockTime $ date 2022 May 25, 0.045) - , (dateToDateClockTime $ date 2022 Jun 23, 0.050) - , (dateToDateClockTime $ date 2022 Jul 25, 0.000) - , (dateToDateClockTime $ date 2022 Aug 25, 0.000) - , (dateToDateClockTime $ date 2022 Sep 23, 0.000) - , (dateToDateClockTime $ date 2022 Oct 25, 0.000) - , (dateToDateClockTime $ date 2022 Nov 24, 0.000) - , (dateToDateClockTime $ date 2022 Nov 25, 0.000) - , (dateToDateClockTime $ date 2022 Dec 23, 0.000) - , (dateToDateClockTime $ date 2023 Jan 25, 0.000) - , (dateToDateClockTime $ date 2023 Feb 23, 0.000) - , (dateToDateClockTime $ date 2023 Mar 23, 0.000) - ] - primaryBusinessCenters = ["GBLO", "USNY"] - calendar = - HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party2" - clientPartyRef = "party1" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = paymentPeriodMultiplier - period = paymentPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [SpreadSchedule with initialValue = 0.001] - finalRateRounding = None - dayCountFraction = Basis30360ICMA - compoundingMethodEnum = Some SpreadExclusive - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg] - currencies = [cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify the floating payment (3 compounded 1M periods). - let - expectedConsumed = [] - expectedProduced = [qty 115420.659999 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2022 Jul 27) swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - pure () - --- fpml.org Example 4 - Fixed/Floating Single Currency Interest Rate Swap with Arrears Reset, --- Step-Up Coupon and Upfront Fee: --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 -runFpml4 : Script () -runFpml4 = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" observers now - - -- Create swap - let - rollDay = 27 - issueDate = date 2000 Apr rollDay - maturityDate = date 2002 Apr rollDay - referenceRateId = "USD/LIBOR/BBA/3M" - notional = 100000000.0 - ccy = "USD" - calcPeriodFix = Regular M - calcPeriodMultiplierFix = 6 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 3 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2000 Jul 25, 0.063) - , (dateToDateClockTime $ date 2000 Oct 25, 0.065) - , (dateToDateClockTime $ date 2001 Jan 25, 0.067) - , (dateToDateClockTime $ date 2001 Apr 25, 0.069) - , (dateToDateClockTime $ date 2001 Jul 25, 0.071) - , (dateToDateClockTime $ date 2001 Oct 25, 0.073) - , (dateToDateClockTime $ date 2002 Jan 24, 0.075) - , (dateToDateClockTime $ date 2002 Apr 25, 0.083) - ] - primaryBusinessCenters = ["GBLO", "USNY"] - calendar = - HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party2" - clientPartyRef = "party1" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodEndDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = NoAdjustment - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = 0.06 - step = [Step with stepDate = date 2001 Apr 27; stepValue = 0.065] - dayCountFraction = Basis30360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify a floating payment (regular 3M period) - let - expectedConsumed = [] - expectedProduced = [qty 1592500.0 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2000 Jul 27) swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - - -- Second payment date: Lifecycle and verify the fix (6M) and floating payments (3M) - let - expectedConsumed = [qty 3000000.0 cashInstrument] - expectedProduced = [qty 1661111.11 cashInstrument] - - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2000 Oct 27) swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - - -- Third payment date: Lifecycle and verify a floating payment (regular 3M period) - let - expectedConsumed = [] - expectedProduced = [qty 1749444.44 cashInstrument] - - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2001 Jan 29) swapInstrumentAfterSecondPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - - - -- Fourth payment date: Lifecycle and verify the fix (6M) and floating payments (3M) - let - expectedConsumed = [qty 3000000.0 cashInstrument] - expectedProduced = [qty 1686666.67 cashInstrument] - - maybeSwapInstrumentAfterFourthPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2001 Apr 27) swapInstrumentAfterThirdPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFourthPayment <- case maybeSwapInstrumentAfterFourthPayment of - Some key -> pure key - None -> pure swapInstrumentAfterThirdPayment - - - -- Fifth payment date: Lifecycle and verify a floating payment (regular 3M period) - let - expectedConsumed = [] - expectedProduced = [qty 1794722.22 cashInstrument] - - maybeSwapInstrumentAfterFifthPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2001 Jul 29) swapInstrumentAfterFourthPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFifthPayment <- case maybeSwapInstrumentAfterFifthPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFourthPayment - - - -- Sixth payment date: Lifecycle and verify the fix (6M) and floating payments (3M) - -- The fix rate is now higher, as configured in the step-up FpML element - let - expectedConsumed = [qty 3250000.0 cashInstrument] - expectedProduced = [qty 1906111.11 cashInstrument] - - maybeSwapInstrumentAfterSixthPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2001 Oct 29) swapInstrumentAfterFifthPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSixthPayment <- case maybeSwapInstrumentAfterSixthPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFifthPayment - - pure () - --- fpml.org Example 4a - Similar to Example 4, but with USD-SOFR-COMPOUND as reference rate: --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 -runFpml4a : Script () -runFpml4a = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "USD" TransferableFungible "US Dollar" observers now - - -- Create swap - let - rollDay = 15 - issueDate = date 2018 Nov rollDay - maturityDate = date 2020 Nov rollDay - referenceRateId = "USD-SOFR-COMPOUND" - notional = 86000000.0 - ccy = "USD" - calcPeriodFix = Regular M - calcPeriodMultiplierFix = 6 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 3 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2018 Nov 15, 1.01213) - , (dateToDateClockTime $ date 2019 Feb 15, 1.01836) - , (dateToDateClockTime $ date 2019 May 15, 1.02453) - , (dateToDateClockTime $ date 2019 Aug 15, 1.03077) - , (dateToDateClockTime $ date 2019 Nov 15, 1.03598) - , (dateToDateClockTime $ date 2020 Feb 17, 1.03398) - , (dateToDateClockTime $ date 2020 May 15, 1.03490) - , (dateToDateClockTime $ date 2020 Aug 17, 1.03612) - , (dateToDateClockTime $ date 2020 Nov 13, 1.03745) - , (dateToDateClockTime $ date 2020 Nov 16, 1.03845) - ] - - primaryBusinessCenters = ["USNY"] - calendar = - HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["USGS"] - fixingCal = - HolidayCalendarData with - id = "USGS" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "partyB" - clientPartyRef = "partyA" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "calculationPeriodDates-64209465-650" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "calculationPeriodDates-64209465-650" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = Some DateOffset with - periodMultiplier = 2 - period = D - dayType = Some Business - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "calculationPeriodDates-64209465-650" - resetRelativeTo = CalculationPeriodEndDate - fixingDates = FixingDates with - periodMultiplier = 0 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = Basis30360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "calculationPeriodDates-64209465-653" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = primaryBusinessCenters - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention = NoAdjustment - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "calculationPeriodDates-64209465-653" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = Some DateOffset with - periodMultiplier = 2 - period = D - dayType = Some Business - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = 0.013 - step = - [ Step with stepDate = date 2019 May 15; stepValue = 0.015 - , Step with stepDate = date 2019 Nov 15; stepValue = 0.017 - , Step with stepDate = date 2020 May 15; stepValue = 0.019 - ] - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First payment date: Lifecycle and verify a floating payment (regular 3M period) - let - expectedConsumed = [] - expectedProduced = [qty 517851.0769994972 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 Feb 19) swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - - -- Second payment date: Lifecycle and verify the fix (6M) and floating payments (3M) - let - expectedConsumed = [qty 562105.5546 cashInstrument] - expectedProduced = [qty 526907.9878205855 cashInstrument] - - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 May 17) swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - - -- Third payment date: Lifecycle and verify a floating payment (regular 3M period) - let - expectedConsumed = [] - expectedProduced = [qty 512404.6240873736 cashInstrument] - - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 Aug 19) swapInstrumentAfterSecondPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - - -- Fourth payment date: Lifecycle and verify the fix (6M) and floating payments (3M) - -- The fix rate is now higher, as configured in the step-up FpML element - let - expectedConsumed = [qty 659333.3362 cashInstrument] - expectedProduced = [qty 425235.0783194869 cashInstrument] - - maybeSwapInstrumentAfterFourthPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2019 Nov 19) swapInstrumentAfterThirdPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFourthPayment <- case maybeSwapInstrumentAfterFourthPayment of - Some key -> pure key - None -> pure swapInstrumentAfterThirdPayment - - pure () - --- fpml.org Example 5 - Fixed/Floating Single Currency Interest Rate Swap with Long Initial Stub and --- Short Final Stub --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 -runFpml5 : Script () -runFpml5 = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers now - - -- Create swap - let - rollDay = 5 - firstPeriodStartDate = date 2000 Mar rollDay - issueDate = date 2000 Apr rollDay - maturityDate = date 2005 Jan rollDay - firstRegularPeriodStartDate = date 2000 Oct rollDay - lastRegularPeriodEndDate = date 2004 Oct rollDay - referenceRateId = "EUR-EURIBOR-Telerate-6M" - stubReferenceRateId = "EUR-EURIBOR-Telerate-3M" - notional = 75000000.0 - ccy = "EUR" - fixRate = 0.0525 - calcPeriodFix = Regular Y - calcPeriodMultiplierFix = 1 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 6 - businessDayConvention = Following - observations = Map.fromList - [ (dateToDateClockTime $ date 2000 Oct 03, 0.063) - , (dateToDateClockTime $ date 2001 Apr 03, 0.069) - , (dateToDateClockTime $ date 2001 Oct 03, 0.073) - , (dateToDateClockTime $ date 2002 Apr 03, 0.075) - , (dateToDateClockTime $ date 2002 Oct 03, 0.075) - , (dateToDateClockTime $ date 2003 Apr 03, 0.075) - , (dateToDateClockTime $ date 2003 Oct 02, 0.075) - , (dateToDateClockTime $ date 2004 Apr 01, 0.075) - ] - stubObservations = Map.fromList - [ (dateToDateClockTime $ date 2004 Oct 01, 0.077) ] - primaryBusinessCenters = ["EUTA"] - calendar = - HolidayCalendarData with - id = "EUTA" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party1" - clientPartyRef = "party2" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - firstPeriodStartDate = Some AdjustableDate with - unadjustedDate = firstPeriodStartDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - firstRegularPeriodStartDate = Some firstRegularPeriodStartDate - lastRegularPeriodEndDate = Some lastRegularPeriodEndDate - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - firstPaymentDate = Some firstRegularPeriodStartDate - -- lastRegularPaymentDate is not provided in the original sample trade, but required - -- according to the FpML schema in order to define a final stub. - lastRegularPaymentDate = Some lastRegularPeriodEndDate - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = primaryBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [SpreadSchedule with initialValue = 0.001] - finalRateRounding = None - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = Some StubCalculationPeriodAmount with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - initialStub = Some $ StubValue_StubRate 0.05125 - finalStub = Some $ StubValue_FloatingRate - [ StubFloatingRate with - floatingRateIndex = stubReferenceRateId - indexTenor = Some (Period with period = M; periodMultiplier = 3) - ] - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - firstPeriodStartDate = Some AdjustableDate with - unadjustedDate = firstPeriodStartDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - firstRegularPeriodStartDate = Some firstRegularPeriodStartDate - lastRegularPeriodEndDate = Some lastRegularPeriodEndDate - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - firstPaymentDate = Some firstRegularPeriodStartDate - -- lastRegularPaymentDate is not provided in the original sample trade, but required - -- according to the FpML schema in order to define a final stub. - lastRegularPaymentDate = Some lastRegularPeriodEndDate - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = Basis30360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - stubObservableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id stubReferenceRateId; observations = stubObservations; - observers = mempty - let observableCids = [observableCid, stubObservableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- First regular payment date: 7M long initial stub - let - expectedConsumed = [qty 2_285_937.5025 cashInstrument] - expectedProduced = [qty 2_274_218.7525 cashInstrument] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - firstRegularPeriodStartDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- Fast-forward to the last regular payment date: lifecycle 4 years of fixed & floating payments - let - expectedConsumed = [qty 15_750_000.0075 cashInstrument] - expectedProduced = [qty 22_372_916.6625 cashInstrument] - - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - lastRegularPeriodEndDate swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - -- Maturity date: 3M short final stub - let - expectedConsumed = [qty 984_375.0 cashInstrument] - expectedProduced = [qty 1_475_833.335 cashInstrument] - - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterSecondPayment issuer observableCids - expectedConsumed expectedProduced - - pure () - --- fpml.org Example 6 - Fixed/Floating Cross Currency Interest Rate Swap --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 -runFpml6 : Script () -runFpml6 = script do - [custodian, issuer, investor, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Investor", "Calendar Data Provider", "PublicParty"] - - -- Distribute commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrumentUsd <- - originate custodian issuer "USD" TransferableFungible "US Dollars" observers now - cashInstrumentJpyCid <- - originate custodian issuer "JPY" TransferableFungible "Japanese yen" observers now - - -- Create and distribute swap - -- Float vs float currency swap: Euribor 3M vs Libor 3M - let - rollDay = 14 - issueDate = date 1994 Dec rollDay - maturityDate = date 1999 Dec rollDay - referenceRateUsdId = "USD/LIBOR/6M" - businessDayConvention = ModifiedFollowing - issuerPartyRef = "party2" - clientPartyRef = "party1" - fixRate = 0.06 - calcPeriodFix = Regular Y - calcPeriodMultiplierFix = 1 - calcPeriodFloat = Regular M - calcPeriodMultiplierFloat = 6 - businessDayConvention = ModifiedFollowing - observationsLibor3M = Map.fromList - [ (dateToDateClockTime $ date 1994 Dec 12, 0.047) - , (dateToDateClockTime $ date 1995 Jun 12, 0.060) - , (dateToDateClockTime $ date 1995 Dec 12, 0.062) - , (dateToDateClockTime $ date 1996 Jun 12, 0.060) - , (dateToDateClockTime $ date 1996 Dec 12, 0.062) - , (dateToDateClockTime $ date 1997 Jun 12, 0.060) - , (dateToDateClockTime $ date 1997 Dec 11, 0.062) - , (dateToDateClockTime $ date 1998 Jun 11, 0.060) - , (dateToDateClockTime $ date 1998 Dec 10, 0.062) - , (dateToDateClockTime $ date 1999 Jun 10, 0.062) - ] - primaryBusinessCenters = ["GBLO", "JPTO", "USNY"] - calendar = - HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [] - jpCal = - HolidayCalendarData with - id = "JPTO" - weekend = [Saturday, Sunday] - holidays = [] - fixingBusinessCenters = ["GBLO"] - fixingCal = - HolidayCalendarData with - id = "GBLO" - weekend = [Saturday, Sunday] - holidays = [] - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - paymentDaysOffset = None - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodStartDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = NoAdjustment - businessCenters = fixingBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplierFloat - period = calcPeriodFloat - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "notionalScheduleConstant" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 10000000.00 - step = [] - currency = "USD" - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateUsdId - indexTenor = Some Period with - periodMultiplier = calcPeriodMultiplierFloat - period = M - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = Some PrincipalExchanges with - initialExchange = True - intermediateExchange = False - finalExchange = True - - swapStreamFixedLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - rollConvention = DOM rollDay - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplierFix - period = calcPeriodFix - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention = ModifiedFollowing - businessCenters = primaryBusinessCenters - paymentDaysOffset = None - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "notionalScheduleConstant" - notionalStepSchedule = NotionalStepSchedule with - initialValue = 1000000000.00 - step = [] - currency = "JPY" - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = Basis30E360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = Some PrincipalExchanges with - initialExchange = True - intermediateExchange = False - finalExchange = True - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrumentUsd, cashInstrumentJpyCid] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - jpCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = jpCal - observers = Map.fromList observers - fixingCalendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar = fixingCal - observers = Map.fromList observers - - observableLibor3MCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateUsdId; observations=observationsLibor3M - observers = mempty - let observableCids = [observableLibor3MCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - let settlers = singleton custodian - - -- Issue date: Lifecycle initial exchange of principal - let - expectedConsumed = [qty 1_000_000_000.0 cashInstrumentJpyCid] - expectedProduced = [qty 10_000_000.0 cashInstrumentUsd] - - maybeSwapInstrumentAfterFirstPrincipalExchangePayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - issueDate swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPrincipalExchangePayment <- case maybeSwapInstrumentAfterFirstPrincipalExchangePayment of - Some key -> pure key - None -> pure swapInstrument - - -- First payment date: Lifecycle a 6M USD Libor payment - let - expectedConsumed = [qty 237_611.111 cashInstrumentUsd] - expectedProduced = [] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1995 Jun 14) swapInstrumentAfterFirstPrincipalExchangePayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPrincipalExchangePayment - - -- Second payment date: Lifecycle 6M USD Libor + 1Y fixed JPY payments - let - expectedConsumed = [qty 305_000.0 cashInstrumentUsd] - expectedProduced = [qty 60_000_000.0 cashInstrumentJpyCid] - - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1995 Dec 14) swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - -- Fast-forward to the second last payment date: lifecycle 3.5 years of fixed & floating payments - let - expectedConsumed = [qty 2_170_499.998 cashInstrumentUsd] - expectedProduced = [qty 179_999_999.9 cashInstrumentJpyCid] - - maybeSwapInstrumentAfterThirdPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 1999 Jun 14) swapInstrumentAfterSecondPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterThirdPayment <- case maybeSwapInstrumentAfterThirdPayment of - Some key -> pure key - None -> pure swapInstrumentAfterSecondPayment - - -- Maturity date: Lifecycle final exchange of principal + fixed & floating payments - let - expectedConsumed = [ qty 315_166.667 cashInstrumentUsd - , qty 10_000_000.0 cashInstrumentUsd ] - expectedProduced = [ qty 60_000_000.0 cashInstrumentJpyCid - , qty 1_000_000_000.0 cashInstrumentJpyCid] - - maybeSwapInstrumentAfterFinalPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - maturityDate swapInstrumentAfterThirdPayment issuer observableCids - expectedConsumed expectedProduced - - pure () - --- fpml.org Example 7 - Fixed/Floating Overnight Interest Rate Swap (OIS) --- https://www.fpml.org/spec/fpml-5-11-7-rec-1/html/confirmation/fpml-5-11-examples.html#s2 --- modified to fix to 2 business days earlier -runFpml7 : Script () -runFpml7 = script do - [custodian, issuer, calendarDataProvider, publicParty] <- - createParties ["Custodian", "Issuer", "Calendar Data Provider", "PublicParty"] - - -- Create commercial-bank cash - now <- getTime - let observers = [("PublicParty", singleton publicParty)] - cashInstrument <- originate custodian issuer "EUR" TransferableFungible "Euro" observers now - - -- Create swap - let - rollDay = 29 - issueDate = date 2001 Jan rollDay - maturityDate = date 2001 Apr rollDay - referenceRateId = "EUR-EONIA-OIS-COMPOUND" - notional = 100000000.0 - ccy = "EUR" - fixRate = 0.051 - calcPeriod = T - calcPeriodMultiplier = 1 - businessDayConvention = ModifiedFollowing - observations = Map.fromList - [ (dateToDateClockTime $ date 2001 Jan 25, 100.0) - , (dateToDateClockTime $ date 2001 Apr 26, 101.25) - ] - primaryBusinessCenters = ["EUTA"] - calendar = - HolidayCalendarData with - id = "EUTA" - weekend = [Saturday, Sunday] - holidays = [] - - issuerPartyRef = "party1" - clientPartyRef = "party2" - - swapStreamFloatingLeg = SwapStream with - payerPartyReference = issuerPartyRef - receiverPartyReference = clientPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "floatingCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplier - period = calcPeriod - rollConvention = NoRollConvention - paymentDates = PaymentDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplier - period = calcPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = Some DateOffset with - periodMultiplier = 1 - period = D - dayType = Some Business - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - resetDates = Some ResetDates with - calculationPeriodDatesReference = "floatingCalcPeriodDates" - resetRelativeTo = CalculationPeriodEndDate - fixingDates = FixingDates with - periodMultiplier = -2 - period = D - dayType = Some Business - businessDayConvention = Preceding - businessCenters = primaryBusinessCenters - resetFrequency = ResetFrequency with - periodMultiplier = calcPeriodMultiplier - period = calcPeriod - resetDatesAdjustments = ResetDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "floatingLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Floating FloatingRateCalculation with - floatingRateIndex = referenceRateId - indexTenor = None - spreadSchedule = [] - finalRateRounding = None - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreamFixedLeg = SwapStream with - payerPartyReference = clientPartyRef - receiverPartyReference = issuerPartyRef - calculationPeriodDates = CalculationPeriodDates with - id = "fixedCalcPeriodDates" - effectiveDate = AdjustableDate with - unadjustedDate = issueDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention = NoAdjustment - businessCenters = [] - terminationDate = AdjustableDate with - unadjustedDate = maturityDate - dateAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - calculationPeriodDatesAdjustments = CalculationPeriodDatesAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - firstPeriodStartDate = None - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - calculationPeriodFrequency = CalculationPeriodFrequency with - periodMultiplier = calcPeriodMultiplier - period = calcPeriod - rollConvention = NoRollConvention - paymentDates = PaymentDates with - calculationPeriodDatesReference = "fixedCalcPeriodDates" - paymentFrequency = PaymentFrequency with - periodMultiplier = calcPeriodMultiplier - period = calcPeriod - firstPaymentDate = None - lastRegularPaymentDate = None - payRelativeTo = CalculationPeriodEndDate - paymentDaysOffset = None - paymentDatesAdjustments = BusinessDayAdjustments with - businessDayConvention - businessCenters = primaryBusinessCenters - resetDates = None - calculationPeriodAmount = CalculationPeriodAmount with - calculation = Calculation with - notionalScheduleValue = NotionalSchedule_Regular NotionalSchedule with - id = "fixedLegNotionalSchedule" - notionalStepSchedule = NotionalStepSchedule with - initialValue = notional - step = [] - currency = ccy - rateTypeValue = RateType_Fixed FixedRateSchedule with - initialValue = fixRate - step = [] - dayCountFraction = Act360 - compoundingMethodEnum = None - stubCalculationPeriodAmount = None - principalExchanges = None - - swapStreams = [swapStreamFloatingLeg, swapStreamFixedLeg] - currencies = [cashInstrument, cashInstrument] - - -- A reference data provider publishes the holiday calendars on the ledger - calendarCid <- submit calendarDataProvider do - createCmd HolidayCalendar with - provider = calendarDataProvider; calendar - observers = Map.fromList observers - - observableCid <- toInterfaceContractId <$> submit issuer do - createCmd Observation with - provider = issuer; id = Id referenceRateId; observations; observers = mempty - let observableCids = [observableCid] - - swapInstrument <- originateFpmlSwap issuer issuer "SwapTest1" BaseHolding "Interest rate swap" - observers now swapStreams calendarDataProvider currencies issuerPartyRef publicParty - - -- Adjusted maturity date: Lifecycle fixed payment - let - expectedConsumed = [qty 1_289_166.67 cashInstrument] - expectedProduced = [] - - maybeSwapInstrumentAfterFirstPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2001 Apr 30) swapInstrument issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterFirstPayment <- case maybeSwapInstrumentAfterFirstPayment of - Some key -> pure key - None -> pure swapInstrument - - -- Adjusted maturity date + 1: Lifecycle floating payment - let - expectedConsumed = [] - expectedProduced = [qty 1_250_000.0 cashInstrument] - - maybeSwapInstrumentAfterSecondPayment <- - lifecycleAndVerifyPaymentEffects [publicParty] - (date 2001 May 1) swapInstrumentAfterFirstPayment issuer observableCids - expectedConsumed expectedProduced - - swapInstrumentAfterSecondPayment <- case maybeSwapInstrumentAfterSecondPayment of - Some key -> pure key - None -> pure swapInstrumentAfterFirstPayment - - pure () - - diff --git a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml b/src/test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml deleted file mode 100644 index fbd167de8..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Swap/Test/Util.daml +++ /dev/null @@ -1,297 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Swap.Test.Util where - -import DA.Map (fromList) -import Daml.Finance.Instrument.Swap.V0.Asset.Factory qualified as AssetSwap (Factory(..)) -import Daml.Finance.Instrument.Swap.V0.CreditDefault.Factory qualified as CreditDefaultSwap (Factory(..)) -import Daml.Finance.Instrument.Swap.V0.Currency.Factory qualified as CurrencySwap (Factory(..)) -import Daml.Finance.Instrument.Swap.V0.ForeignExchange.Factory qualified as ForeignExchangeSwap (Factory(..)) -import Daml.Finance.Instrument.Swap.V0.Fpml.Factory qualified as FpmlSwap (Factory(..)) -import Daml.Finance.Instrument.Swap.V0.InterestRate.Factory qualified as InterestRateSwap (Factory(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Factory qualified as AssetSwapFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Asset.Types (Asset(..), Underlying) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Factory qualified as CreditDefaultSwapFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.CreditDefault.Types (CreditDefault(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Factory qualified as CurrencySwapFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Currency.Types (CurrencySwap(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Factory qualified as ForeignExchangeSwapFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.ForeignExchange.Types (ForeignExchange(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Factory qualified as FpmlSwapFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.FpmlTypes (SwapStream(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.Fpml.Types (Fpml(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Factory qualified as InterestRateSwapFactory (Create(..), I(..)) -import Daml.Finance.Interface.Instrument.Swap.V0.InterestRate.Types (InterestRate(..)) -import Daml.Finance.Interface.Instrument.Types.V2.FloatingRate (FloatingRate) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard, Id(..), InstrumentKey(..), Parties) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (PeriodEnum) -import Daml.Finance.Test.Util.Time (createPaymentPeriodicSchedule) -import Daml.Script - --- | Originate an interest rate swap. -originateInterestRateSwap : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> [Text] -> Party -> Date -> - Date -> DayCountConventionEnum -> BusinessDayConventionEnum -> Decimal -> PeriodEnum -> Int -> - InstrumentKey -> FloatingRate -> Bool -> Party -> Script InstrumentKey -originateInterestRateSwap depository issuer label holdingStandard description - observers lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention businessDayConvention fixRate couponPeriod couponPeriodMultiplier - currency floatingRate ownerReceivesFix publicParty = do - let - periodicSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- Create an interest rate swap factory - interestRateSwapFactoryCid <- toInterfaceContractId @InterestRateSwapFactory.I <$> - submit issuer do - createCmd InterestRateSwap.Factory with - provider = issuer - observers = mempty - - -- CREATE_INTEREST_RATE_SWAP_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd interestRateSwapFactoryCid InterestRateSwapFactory.Create with - interestRate = InterestRate with - instrument - description - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - floatingRate - fixRate - ownerReceivesFix - currency - lastEventTimestamp - observers = fromList observers - -- CREATE_INTEREST_RATE_SWAP_INSTRUMENT_END - pure instrument - --- | Originate a swap specified by FpML swapStream modules -originateFpmlSwap : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> [SwapStream] -> Party -> [InstrumentKey] -> Text -> Party -> Script InstrumentKey -originateFpmlSwap depository issuer label holdingStandard description observers - lastEventTimestamp swapStreams calendarDataProvider currencies issuerPartyRef publicParty = do - -- Create an FpML swap factory - fpmlSwapFactoryCid <- toInterfaceContractId @FpmlSwapFactory.I <$> submit issuer do - createCmd FpmlSwap.Factory with - provider = issuer - observers = mempty - - -- CREATE_FPML_SWAP_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd fpmlSwapFactoryCid FpmlSwapFactory.Create with - fpml = Fpml with - instrument - description - swapStreams - issuerPartyRef - currencies - calendarDataProvider - lastEventTimestamp - observers = fromList observers - -- CREATE_FPML_SWAP_INSTRUMENT_END - pure instrument - --- | Originate an asset swap. -originateAssetSwap : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> Date -> [Text] -> Party -> Date -> Date -> - DayCountConventionEnum -> BusinessDayConventionEnum -> Optional FloatingRate -> Decimal -> - PeriodEnum -> Int -> InstrumentKey -> [Underlying] -> Bool -> Party - -> Script (InstrumentKey, ContractId AssetSwapFactory.I) -originateAssetSwap depository issuer label holdingStandard description observers - lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate maturityDate - dayCountConvention businessDayConvention floatingRate fixRate - couponPeriod couponPeriodMultiplier currency underlyings ownerReceivesRate publicParty = do - let - periodicSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- Create an asset swap factory - assetSwapFactoryCid <- toInterfaceContractId @AssetSwapFactory.I <$> submit issuer do - createCmd AssetSwap.Factory with - provider = issuer - observers = mempty - - -- CREATE_ASSET_SWAP_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd assetSwapFactoryCid AssetSwapFactory.Create with - asset = Asset with - instrument - description - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - floatingRate - fixRate - ownerReceivesRate - underlyings - currency - lastEventTimestamp - observers = fromList observers - -- CREATE_ASSET_SWAP_INSTRUMENT_END - pure (instrument, assetSwapFactoryCid) - --- | Originate a credit default swap (CDS). -originateCreditDefaultSwap : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> [Text] -> Party -> Date -> - Date -> DayCountConventionEnum -> BusinessDayConventionEnum -> Decimal -> PeriodEnum -> Int -> - InstrumentKey -> Text -> Text -> Bool -> Party -> Script InstrumentKey -originateCreditDefaultSwap depository issuer label holdingStandard description - observers lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate - maturityDate dayCountConvention businessDayConvention fixRate couponPeriod couponPeriodMultiplier - currency defaultProbabilityReferenceId recoveryRateReferenceId ownerReceivesFix publicParty = do - let - periodicSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- Create a credit default swap factory - creditDefaultSwapFactoryCid <- toInterfaceContractId @CreditDefaultSwapFactory.I <$> - submit issuer do - createCmd CreditDefaultSwap.Factory with - provider = issuer - observers = mempty - - -- CREATE_CREDIT_DEFAULT_SWAP_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd creditDefaultSwapFactoryCid CreditDefaultSwapFactory.Create with - creditDefault = CreditDefault with - instrument - description - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - fixRate - ownerReceivesFix - defaultProbabilityReferenceId - recoveryRateReferenceId - currency - lastEventTimestamp - observers = fromList observers - -- CREATE_CREDIT_DEFAULT_SWAP_INSTRUMENT_END - pure instrument - --- | Originate a currency swap. -originateCurrencySwap : Party -> Party -> Text -> HoldingStandard -> Text -> [(Text, Parties)] -> - Time -> Date -> [Text] -> Party -> Date -> Date -> - DayCountConventionEnum -> BusinessDayConventionEnum -> Decimal -> Decimal -> PeriodEnum -> Int -> - InstrumentKey -> InstrumentKey -> Decimal -> Bool -> Party -> Script InstrumentKey -originateCurrencySwap depository issuer label holdingStandard description observers - lastEventTimestamp issueDate holidayCalendarIds calendarDataProvider firstCouponDate maturityDate - dayCountConvention businessDayConvention baseRate foreignRate couponPeriod couponPeriodMultiplier - baseCurrency foreignCurrency fxRate ownerReceivesBase publicParty = do - let - periodicSchedule = createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds - businessDayConvention couponPeriod couponPeriodMultiplier issueDate maturityDate - - -- Create a currency swap factory - currencySwapFactoryCid <- toInterfaceContractId @CurrencySwapFactory.I <$> submit issuer do - createCmd CurrencySwap.Factory with - provider = issuer - observers = mempty - - -- CREATE_CURRENCY_SWAP_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd currencySwapFactoryCid CurrencySwapFactory.Create with - currencySwap = CurrencySwap with - instrument - description - periodicSchedule - holidayCalendarIds - calendarDataProvider - dayCountConvention - ownerReceivesBase - baseRate - foreignRate - baseCurrency - foreignCurrency - fxRate - lastEventTimestamp - observers = fromList observers - -- CREATE_CURRENCY_SWAP_INSTRUMENT_BEGIN - pure instrument - --- | Originate an FX swap. -originateForeignExchangeSwap : Party -> Party -> Text -> HoldingStandard -> Text -> - [(Text, Parties)] -> Time -> Date -> Date -> Date -> InstrumentKey -> InstrumentKey -> - Decimal -> Decimal -> Party -> Script InstrumentKey -originateForeignExchangeSwap depository issuer label holdingStandard description - observers lastEventTimestamp issueDate firstPaymentDate maturityDate baseCurrency foreignCurrency - firstFxRate finalFxRate publicParty = do - -- Create an FX swap factory - foreignExchangeSwapFactoryCid <- toInterfaceContractId @ForeignExchangeSwapFactory.I <$> - submit issuer do - createCmd ForeignExchangeSwap.Factory with - provider = issuer - observers = mempty - - -- CREATE_FOREIGN_EXCHANGE_SWAP_INSTRUMENT_BEGIN - let - instrument = InstrumentKey with - issuer - depository - id = Id label - version = "0" - holdingStandard - - cid <- submit (actAs issuer <> readAs publicParty) do - exerciseCmd foreignExchangeSwapFactoryCid ForeignExchangeSwapFactory.Create with - foreignExchange = ForeignExchange with - instrument - description - baseCurrency - foreignCurrency - firstFxRate - finalFxRate - issueDate - firstPaymentDate - maturityDate - lastEventTimestamp - observers = fromList observers - -- CREATE_FOREIGN_EXCHANGE_SWAP_INSTRUMENT_END - pure instrument diff --git a/src/test/daml/Daml/Finance/Instrument/Token/Test/Token.daml b/src/test/daml/Daml/Finance/Instrument/Token/Test/Token.daml deleted file mode 100644 index 02ccb9646..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Token/Test/Token.daml +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Token.Test.Token where - -import Daml.Finance.Instrument.Token.Test.Util (originateToken) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as BaseInstrument (I, Remove(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..)) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (submitExerciseInterfaceByKeyCmd) -import Daml.Script -import Prelude hiding (and, or) - --- This script tests the ability to create and remove an Instrument.Token. - --- | Parties involved in the test script. -data TestParties = TestParties - with - issuer : Party - -- ^ Acts as issuer of the token instrument. - -run : Script () -run = script do - - -- Setup parties - TestParties{..} <- setupParties - - -- Originate token - now <- getTime - tokenInstrument <- originateToken issuer issuer "Token A" TransferableFungible "Token Issuer" now - [] - - -- Remove the token - Instrument.submitExerciseInterfaceByKeyCmd @BaseInstrument.I [issuer] [] tokenInstrument - BaseInstrument.Remove - - pure () - -setupParties : Script TestParties -setupParties = do - [issuer] <- createParties ["Issuer"] - pure TestParties with issuer diff --git a/src/test/daml/Daml/Finance/Instrument/Token/Test/Util.daml b/src/test/daml/Daml/Finance/Instrument/Token/Test/Util.daml deleted file mode 100644 index 0e84a5117..000000000 --- a/src/test/daml/Daml/Finance/Instrument/Token/Test/Util.daml +++ /dev/null @@ -1,32 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Instrument.Token.Test.Util where - -import DA.Map (fromList) -import Daml.Finance.Instrument.Token.V4.Factory (Factory(..)) -import Daml.Finance.Interface.Instrument.Token.V4.Factory qualified as TokenFactory (Create(..), I) -import Daml.Finance.Interface.Instrument.Token.V4.Types (Token(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard, Id(..), InstrumentKey(..), Parties) -import Daml.Script - --- | Originate token instrument. -originateToken : Party -> Party -> Text -> HoldingStandard -> Text -> Time -> [(Text, Parties)] -> - Script InstrumentKey -originateToken depository issuer label holdingStandard description validAsOf observers = do - - -- Create a token instrument factory - tokenFactoryCid <- toInterfaceContractId @TokenFactory.I <$> submit issuer do - createCmd Factory with provider = issuer; observers = mempty - - -- Create instrument - let - token = Token with - instrument = - InstrumentKey with issuer; depository; id = Id label; version = "0"; holdingStandard - description - validAsOf - submit [issuer, depository] do - exerciseCmd tokenFactoryCid TokenFactory.Create with token; observers = fromList observers - - pure token.instrument diff --git a/src/test/daml/Daml/Finance/Settlement/Test/Batch.daml b/src/test/daml/Daml/Finance/Settlement/Test/Batch.daml deleted file mode 100644 index 7857c3542..000000000 --- a/src/test/daml/Daml/Finance/Settlement/Test/Batch.daml +++ /dev/null @@ -1,221 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.Test.Batch where - -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Cancel(..), Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Factory qualified as SettlementFactory (I, Instruct(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..), Execute(..)) -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (Discover(..), I) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..), Step(..), Quantity(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Settlement.V4.Conversion (fromInstrumentKey) -import Daml.Finance.Settlement.V4.Factory (Factory(..)) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyNoObservers, verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Script - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ Acts as custodian in the respective holdings (for both the cash and equity instrument). - cb : Party - -- ^ Depository and issuer of the cash instrument. - csd : Party - -- ^ Depository of the equity instrument. - issuer : Party - -- ^ Issuer of the equity instrument. - buyer : Party - -- ^ Buyer of the equity instrument. - seller : Party - -- ^ Seller of the equity instrument. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- DvP via settlement chain and instructions. --- Seller transfers equity to buyer in exchange for cash. --- +----------------------------------------+ --- | Accounts | --- +----------------+-----------------------+ --- | structure: | used for: | --- +----------------+-----------------------+ --- | Bank | | --- | / \ | commercial bank money | --- | Buyer Seller | | --- | \ / | securities | --- | Bank | | --- +----------------+-----------------------+ -run: Bool -> Bool -> Script () -run settleCashOnledger bankIsInstructor = script do - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank [] - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Originate instruments - now <- getTime - equityInstrument <- Instrument.originate csd issuer "AAPL" TransferableFungible "Apple Inc." pp - now - cashInstrument <- Instrument.originate cb cb "USD" TransferableFungible "United States Dollar" pp - now - - -- Custody accounts - [buyerCustodyAccount, sellerCustodyAccount] <- - mapA (Account.createAccount "Custody Account" [] accountFactoryCid holdingFactory [] - Account.Owner bank) [buyer, seller] - - -- Cash accounts - [buyerCashAccount, sellerCashAccount] <- mapA (Account.createAccount "Cash Account" [] - accountFactoryCid holdingFactory [] Account.Owner bank) [buyer, seller] - - -- Distribute equity - equityHoldingCid <- Account.credit [publicParty] equityInstrument 1_000.0 sellerCustodyAccount - - -- Settlement steps - let - steps = - [SettlementTypes.Step with - sender = seller - receiver = buyer - quantity = SettlementTypes.Quantity - with unit = fromInstrumentKey equityInstrument; amount = 1_000.0 - , SettlementTypes.Step with - sender = buyer - receiver = seller - quantity = SettlementTypes.Quantity - with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 - ] - - -- Discover settlement routes - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do - createCmd SingleCustodian with - provider = bank; custodian = bank; observers = Set.singleton publicParty - routedSteps <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank; contextId = None; steps - - -- Setup settlement factory - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> - submit bank do - createCmd Factory with provider = bank; observers = Set.singleton publicParty - - -- Instruct settlement - let - instructor = if bankIsInstructor then bank else buyer - consenters = if bankIsInstructor then [] else [seller] - settlers = Set.fromList [buyer, seller] - instructCmd = submit (actAs (instructor :: consenters) <> readAs publicParty) do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor - consenters = Set.fromList consenters - settlers - id = Id "APPL 1000@200.0USD" - description = "DVP" - contextId = None - routedSteps - settlementTime = None - - -- Create batch and instructions, and then cancel - (batchCid, _) <- instructCmd - -- seller can't cancel batch - submitMustFail seller do exerciseCmd batchCid Batch.Cancel with actors = Set.singleton seller - -- instructor and consenters can cancel batch - submit (instructor :: consenters) do - exerciseCmd batchCid Batch.Cancel with actors = Set.fromList $ instructor :: consenters - - -- Create batch and instructions - (batchCid, [equityInstructionCid, cashInstructionCid]) <- instructCmd - - -- Allocate and approve equity instruction - (equityInstructionCid, _) <- submit seller do - exerciseCmd equityInstructionCid Instruction.Allocate with - actors = Set.singleton seller - allocation = SettlementTypes.Pledge equityHoldingCid - equityInstructionCid <- submit buyer do - exerciseCmd equityInstructionCid Instruction.Approve with - actors = Set.singleton buyer - approval = SettlementTypes.TakeDelivery buyerCustodyAccount - - -- Allocate and approve cash instruction - cashInstructionCid <- if settleCashOnledger - then - do - -- Settle by on-ledger transfer - cashHoldingCid <- Account.credit [publicParty] cashInstrument 200_000.0 buyerCashAccount - (cashInstructionCid, _) <- submit buyer do - exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton buyer; allocation = SettlementTypes.Pledge cashHoldingCid - submit seller do - exerciseCmd cashInstructionCid Instruction.Approve with - actors = Set.singleton seller; approval = SettlementTypes.TakeDelivery sellerCashAccount - else - do - -- Settle by off ledger transfer - (cashInstructionCid, _) <- submit [buyer, bank] do - exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.fromList [buyer, bank]; allocation = SettlementTypes.SettleOffledger - submit [seller, bank] do - exerciseCmd cashInstructionCid Instruction.Approve with - actors = Set.fromList [seller, bank]; approval = SettlementTypes.SettleOffledgerAcknowledge - - -- Settle batch - -- neither the bank, nor seller, nor buyer can execute an instruction - submitMustFail bank do - exerciseCmd cashInstructionCid Instruction.Execute with actors = Set.singleton bank - submitMustFail seller do - exerciseCmd cashInstructionCid Instruction.Execute with actors = Set.singleton seller - submitMustFail buyer do - exerciseCmd cashInstructionCid Instruction.Execute with actors = Set.singleton buyer - -- the bank can't settle the batch - if bankIsInstructor then - submitMustFail bank do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton bank - else - pure () - -- any of the settlers can settle the batch (i.e., buyer or seller) - cids <- submit (actAs buyer <> readAs publicParty) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton buyer - - -- Assert state - let ts = zip [buyer, seller] cids - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - --- Settle cash on-ledger --- with bank as instructor -run1 : Script () -run1 = run True True --- with buyer as instructor (and seller as consenter) -run2 : Script () -run2 = run True False - --- Settle cash off-ledger --- with bank as instructor -run3 : Script () -run3 = run False True --- with buyer as instructor (and seller as consenter) -run4 : Script () -run4 = run False False - --- | Settup parties for the scripts -setupParties : Script TestParties -setupParties = do - [cb, csd, bank, issuer, buyer, seller, publicParty] <- createParties - ["CentralBank", "CentralSecurityDepository", "Bank", "Issuer", "Buyer", "Seller", "PublicParty"] - pure TestParties with cb; csd; bank; issuer; buyer; seller; publicParty diff --git a/src/test/daml/Daml/Finance/Settlement/Test/Hierarchy.daml b/src/test/daml/Daml/Finance/Settlement/Test/Hierarchy.daml deleted file mode 100644 index ed119d3ed..000000000 --- a/src/test/daml/Daml/Finance/Settlement/Test/Hierarchy.daml +++ /dev/null @@ -1,54 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.Test.Hierarchy where - -import DA.Assert ((===)) -import Daml.Finance.Settlement.V4.Hierarchy (Hierarchy(..), getRoute, locateParty) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Script - --- Test path-finding within a hierarchy. --- --- Used hierarchy: --- --- a --- / \ --- b c --- / \ \ --- d e f -testHierarchyPaths : Script () -testHierarchyPaths = do - - [a, b, c, d, e, f, h] <- createParties ["a", "b", "c", "d", "e", "f", "h"] - - let hierarchy = Hierarchy with - rootCustodian = a - pathsToRootCustodian = - [ [d, b] - , [e, b] - , [f, c] - ] - - locateParty a hierarchy === Some [a, a] - locateParty b hierarchy === Some [b, a] - locateParty c hierarchy === Some [c, a] - locateParty d hierarchy === Some [d, b, a] - locateParty e hierarchy === Some [e, b, a] - locateParty f hierarchy === Some [f, c, a] - locateParty h hierarchy === None - - route hierarchy d a === Some [(d, b, b), (b, a, a)] - route hierarchy d b === Some [(d, b, b)] - route hierarchy b f === Some [(b, c, a), (c, f, c)] - route hierarchy a d === Some [(a, b, a), (b, d, b)] - route hierarchy d h === None - - pure () - --- | Get route between two parties, if it exists. -route : Hierarchy -> Party -> Party -> Optional [(Party, Party, Party)] -route h from to = do - fromPath <- locateParty from h - toPath <- locateParty to h - getRoute fromPath toPath diff --git a/src/test/daml/Daml/Finance/Settlement/Test/Intermediated.daml b/src/test/daml/Daml/Finance/Settlement/Test/Intermediated.daml deleted file mode 100644 index f22be159a..000000000 --- a/src/test/daml/Daml/Finance/Settlement/Test/Intermediated.daml +++ /dev/null @@ -1,384 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.Test.Intermediated where - -import DA.Date (addDays, toDateUTC) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import DA.Time (time) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..), I) -import Daml.Finance.Interface.Settlement.V4.Factory qualified as SettlementFactory (I, Instruct(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..), I, GetView(..)) -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (Discover(..), I) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..), Step(..), Quantity(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I, RemoveObservers(..), undisclose) -import Daml.Finance.Settlement.V4.Conversion (fromInstrumentKey) -import Daml.Finance.Settlement.V4.Factory qualified as Settlement (Factory(..)) -import Daml.Finance.Settlement.V4.Hierarchy (Hierarchy(..)) -import Daml.Finance.Settlement.V4.RouteProvider.IntermediatedStatic (IntermediatedStatic(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit, submitExerciseInterfaceByKeyCmd) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyNoObservers, verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - -data TestParties = TestParties - with - bank1 : Party - -- ^ Custodian of Buyer's cash holdings. - bank2 : Party - -- ^ Custodian of Seller's cash holdings. - cb : Party - -- ^ The Central Bank is the depository and the issuer of the cash instrument. It also acts as - -- custodian for the cash holdings of Bank 1 and Bank 2. - csd : Party - -- ^ The Central Security Depository is the depository of the equity instrument. It also acts - -- as custodian for the equity holdings of Custodian 1 and Custodian 2. - custodian1 : Party - -- ^ Custodian of Buyer's equity holdings. - custodian2 : Party - -- ^ Custodian of Seller's equity holdings. - issuer : Party - -- ^ Issuer of the equity instrument. - buyer : Party - -- ^ Sends money to Seller. - seller : Party - -- ^ Sends shares to Buyer. - agent : Party - -- ^ Party that requests and executes the settlement of the transaction between Buyer and - -- Seller. - delegatee : Party - -- ^ Party that is granted the right to allocate Buyer's holdings on her behalf. - provider : Party - -- ^ Acts as provider of account and holding factory. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- Cross-custodial payment with delegation. -run1 : Script () -run1 = run True - --- Cross-custodial payment without delegation. -run2 : Script () -run2 = run False - --- Cross-custodial payment --- Dvp of $ 200000 vs 1250 shares. --- +------------------------------------------------------+ --- | Accounts | --- +------------------------------+-----------------------+ --- | structure: | used for: | --- +------------------------------+-----------------------+ --- | Central Bank | | --- | / \ | central bank money | --- | Bank 1 Bank 2 | | --- | / \ | commercial bank money | --- | Buyer Seller | | --- | \ / | securities | --- | Custodian 2 Custodian 1 | | --- | \ / | securities | --- | Central Security Depository | | --- +------------------------------+-----------------------+ --- --- Setup and assumptions: --- 1. The cash settles via Bank 1 and Bank 2, and the Central Bank (CB), --- i.e., Buyer -> Bank 1 -> CB -> Bank 2 -> Seller. --- 2. The security settles via Custodian 1 and Custodian 2, and the Central Security Depository --- (CSD), i.e., Buyer <- Custodian 1 <- CSD -> Custodian 2 <- Seller. --- 3. The cash with CB as custodian (i.e., Central Bank Money) settles off ledger, all other cash --- and securities settle on ledger. --- 4. The CSD does not need credit/debit its accounts actively, rather this happens as a consequence --- of transfers of holdings (with CSD as custodian) between Custodian 1 and Custodian 2. --- 5. The intermediary banks/custodians allocate and approve their instructions with the --- Buyer/Seller by a direct credit/debit of the Buyer's/Seller's accounts. --- 6. Buyer and Seller allocate and approve their instructions by pledging holdings and taking --- delivery to their accounts, respectively. -run : Bool -> Script () -run useDelegatee = script do - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory provider pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - let - createAccounts description custodian = mapA (Account.createAccount description [publicParty] - accountFactoryCid holdingFactory [] Account.Owner custodian) - -- cash - [buyerCashAccount] <- createAccounts "Cash Account" bank1 [buyer] - [sellerCashAccount] <- createAccounts "Cash Account" bank2 [seller] - [bank1CashAccount, bank2CashAccount] <- createAccounts "Cash Account" cb [bank1, bank2] - -- asset - [custodian1DepoAccount, custodian2DepoAccount] <- createAccounts "Securities Account" csd - [custodian1, custodian2] - [buyerDepoAccount] <- createAccounts "Securities Account" custodian2 [buyer] - [custodian1OwnDepoAccount, sellerDepoAccount] <- createAccounts "Securities Account" custodian1 - [custodian1, seller] - - -- Distribute - -- cash - now <- getTime - cashInstrument <- Instrument.originate cb cb "USD" TransferableFungible "United States Dollar" [] - now - [buyerCashCid] <- mapA (Account.credit [publicParty] cashInstrument 200_000.0) [buyerCashAccount] - - -- assets - assetInstrument <- Instrument.originate csd issuer "SHARE" TransferableFungible "Stock" [] now - [sellerAssetCid, custodian1AssetCid] <- mapA - (Account.credit [publicParty] assetInstrument 1_250.0) - [sellerDepoAccount, custodian1DepoAccount] - - -- Settlement steps - let - cashQuantity = - SettlementTypes.Quantity - with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 - assetQuantity = - SettlementTypes.Quantity - with unit = fromInstrumentKey assetInstrument; amount = 1_250.0 - steps = - -- Payment step - [SettlementTypes.Step with - sender = buyer - receiver = seller - quantity = cashQuantity - -- Delivery step - , SettlementTypes.Step with - sender = seller - receiver = buyer - quantity = assetQuantity - ] - settlementTime = time (addDays (toDateUTC now) 1) 0 0 0 - - -- Discover settlement routes - paymentRoute = Hierarchy with - rootCustodian = cb - pathsToRootCustodian = [[buyer, bank1], [seller, bank2]] - deliveryRoute = Hierarchy with - rootCustodian = csd - pathsToRootCustodian = [[buyer, custodian2], [seller, custodian1]] - - paths = Map.fromList [("USD", paymentRoute), ("SHARE", deliveryRoute)] - - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit agent do - createCmd IntermediatedStatic with provider = agent; paths; observers = mempty - - routedSteps <- submit agent do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton agent; contextId = None; steps - - -- Instruct settlement - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> submit agent do - createCmd Settlement.Factory with provider = agent; observers = mempty - - (batchCid, - [ buyerInstructionCid -- Buyer → Bank1 - , bank1InstructionCid -- Bank1 → Bank2 - , bank2InstructionCid -- Bank2 → Seller - , sellerInstructionCid -- Seller → Custodian1 - , custodian1InstructionCid -- Custodian1 → Custodian2 - , custodian2InstructionCid -- Custodian2 → Buyer - ] - ) : (ContractId Batch.I, [ContractId Instruction.I]) <- - submit agent do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = agent - consenters = mempty - settlers = Set.singleton agent - id = Id "SHARE 200000.0@160.0USD DVP" - description = "Crosspayment" - contextId = None - routedSteps - settlementTime = Some settlementTime - - -- Allocate and approve instructions - (buyerInstructionCid, _) <- - if useDelegatee then - do - -- delegate - delegationCid <- submit buyer do - createCmd AllocationDelegation with delegator = buyer; delegatee - - -- disclose - let observerContext = ("delegation123", Set.singleton delegatee) - - buyerCashCid : ContractId Api.HoldingV1.Holding <- coerceContractId <$> submit buyer do - exerciseCmd (coerceInterfaceContractId @Disclosure.I @Api.HoldingV1.Holding buyerCashCid) - Disclosure.AddObservers with - disclosers = Set.singleton buyer; observersToAdd = observerContext - - buyerInstructionCid <- fromInterfaceContractId @Instruction.I <$> submit buyer do - exerciseCmd (toInterfaceContractId @Disclosure.I buyerInstructionCid) - Disclosure.AddObservers with - disclosers = Set.singleton buyer; observersToAdd = observerContext - - Account.submitExerciseInterfaceByKeyCmd @Disclosure.I [buyer] [] buyerCashAccount - Disclosure.AddObservers with - disclosers = Set.singleton buyer - observersToAdd = observerContext - - t <- submit delegatee do - exerciseCmd delegationCid OnBehalfAllocation with - id = observerContext._1 - instructionCid = buyerInstructionCid - holdingCid = buyerCashCid - - - -- undisclose - Account.submitExerciseInterfaceByKeyCmd @Disclosure.I [buyer] [] buyerCashAccount - Disclosure.RemoveObservers with - disclosers = Set.singleton buyer - observersToRemove = observerContext - pure t - else - submit buyer do - exerciseCmd buyerInstructionCid Instruction.Allocate with - actors = Set.singleton buyer - allocation = SettlementTypes.Pledge buyerCashCid - - buyerInstructionCid <- submit bank1 do - exerciseCmd buyerInstructionCid Instruction.Approve with - actors = Set.singleton bank1 - approval = SettlementTypes.DebitSender - - bank2InstructionCid <- submit seller do - exerciseCmd bank2InstructionCid Instruction.Approve with - actors = Set.singleton seller - approval = SettlementTypes.TakeDelivery sellerCashAccount - - (bank2InstructionCid, _) <- submit bank2 do - exerciseCmd bank2InstructionCid Instruction.Allocate with - actors = Set.singleton bank2 - allocation = SettlementTypes.CreditReceiver - - (bank1InstructionCid, _) <- submit [bank1, cb] do - exerciseCmd bank1InstructionCid Instruction.Allocate with - actors = Set.fromList [bank1, cb] - allocation = SettlementTypes.SettleOffledger - - bank1InstructionCid <- submit [bank2, cb] do - exerciseCmd bank1InstructionCid Instruction.Approve with - actors = Set.fromList [bank2, cb] - approval = SettlementTypes.SettleOffledgerAcknowledge - - (sellerInstructionCid, _) <- submit seller do - exerciseCmd sellerInstructionCid Instruction.Allocate with - actors = Set.singleton seller - allocation = SettlementTypes.Pledge sellerAssetCid - - sellerInstructionCid <- submit custodian1 do - exerciseCmd sellerInstructionCid Instruction.Approve with - actors = Set.singleton custodian1; approval = SettlementTypes.DebitSender - (custodian1InstructionCid, _) <- submit custodian1 do - exerciseCmd custodian1InstructionCid Instruction.Allocate with - actors = Set.singleton custodian1; allocation = SettlementTypes.Pledge custodian1AssetCid - custodian1InstructionCid <- submit custodian2 do - exerciseCmd custodian1InstructionCid Instruction.Approve with - actors = Set.singleton custodian2; approval = SettlementTypes.TakeDelivery custodian2DepoAccount - -- Can't settle batch before all `Instruction`s have been allocated and approved - submitMustFail (actAs [agent] <> readAs [publicParty]) do - exerciseCmd batchCid Batch.Settle with - actors = Set.singleton agent - (custodian2InstructionCid, _) <- submit custodian2 do - exerciseCmd custodian2InstructionCid Instruction.Allocate with - actors = Set.singleton custodian2; allocation = SettlementTypes.CreditReceiver - -- Buyer and Custodian2 approves instruction with an incompatible approval - custodian2InstructionCid <- submit [buyer, custodian2] do - exerciseCmd custodian2InstructionCid Instruction.Approve with - actors = Set.fromList [buyer, custodian2]; approval = SettlementTypes.SettleOffledgerAcknowledge - -- Settlement of batch must fail due to the incompatible approval - submitMustFail (actAs [agent] <> readAs [publicParty]) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton agent - -- Buyer and Custodian2 unapproves the instruction - custodian2InstructionCid <- submit [buyer, custodian2] do - exerciseCmd custodian2InstructionCid Instruction.Approve with - actors = Set.fromList [buyer, custodian2]; approval = SettlementTypes.Unapproved - -- Buyer approves her instruction with a compatible approval - custodian2InstructionCid <- submit buyer do - exerciseCmd custodian2InstructionCid Instruction.Approve with - actors = Set.singleton buyer; approval = SettlementTypes.TakeDelivery buyerDepoAccount - - -- Set time - --setTime settlementTime - -- In wallclock mode, we skip manual time advancement - - -- Settle batch - [sellerCashCid, custodian2AssetCid, buyerAssetCid] <- - submit (actAs agent <> readAs publicParty) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton agent - - -- Assert state - let ts = [(seller, sellerCashCid), (custodian2, custodian2AssetCid), (buyer, buyerAssetCid)] - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - -setupParties : Script TestParties -setupParties = do - [cb, csd, bank1, bank2, custodian2, custodian1, issuer, buyer, seller, agent, delegatee, provider, - publicParty] <- createParties ["CentralBank", "CSD", "Bank 1", "Bank 2", "Custodian 2", - "Custodian 1", "Issuer", "Buyer", "Seller", "Agent", "Delegatee", "Provider", "PublicParty"] - pure TestParties with - cb; csd; bank1; bank2; custodian2; custodian1; issuer; buyer; seller; agent; delegatee; provider; publicParty - - --- | Grants the `delegatee` the right to allocate holdings on behalf of the `delegator` -template AllocationDelegation - with - delegator : Party - delegatee : Party - where - signatory delegator - observer delegatee - - choice OnBehalfAllocation : (ContractId Instruction.I, Optional (ContractId Api.HoldingV1.Holding)) - with - holdingCid : ContractId Api.HoldingV1.Holding - -- ^ The holding to allocate. - instructionCid : ContractId Instruction.I - -- ^ The instruction that needs allocation. - id : Text - -- ^ Identifier of the observation context on the holding, allowing the delegatee to - -- undisclose themselves from a holding. - controller delegatee - do - _ <- exercise instructionCid Instruction.GetView with viewer = delegatee - - -- Convert to Disclosure interface (explicit coercion) - let holdingDisclosureCid : ContractId Disclosure.I = - coerceInterfaceContractId @Disclosure.I @Api.HoldingV1.Holding holdingCid - - -- Undisclose the delegatee (removes their observation context) - Some undisclosedDiscCid <- - Disclosure.undisclose - (id, Set.singleton delegatee) - (Set.singleton delegator) - holdingDisclosureCid - - -- Convert the new Disclosure.I CID back into Api.HoldingV1.Holding - let undisclosedHoldingCid : ContractId Api.HoldingV1.Holding = - coerceInterfaceContractId @Api.HoldingV1.Holding @Disclosure.I undisclosedDiscCid - - -- Perform allocation (pledge) using the *new undisclosed* holding - (instructionCid', _) <- - exercise instructionCid Instruction.Allocate with - actors = Set.singleton delegator - allocation = SettlementTypes.Pledge - (toInterfaceContractId @Api.HoldingV1.Holding undisclosedHoldingCid) - - -- Return the new instruction and the new holding - pure (instructionCid', Some undisclosedHoldingCid) - - diff --git a/src/test/daml/Daml/Finance/Settlement/Test/Transfer.daml b/src/test/daml/Daml/Finance/Settlement/Test/Transfer.daml deleted file mode 100644 index 25295e88c..000000000 --- a/src/test/daml/Daml/Finance/Settlement/Test/Transfer.daml +++ /dev/null @@ -1,712 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Settlement.Test.Transfer where - -import DA.Assert ((===)) -import DA.List (head) -import DA.Map qualified as Map (fromList) -import DA.Optional (isNone, isSome) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Account.V4.Account qualified as Account (T) -import Daml.Finance.Holding.V4.Factory qualified as Holding (Factory(..)) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (I, getKey) -import Daml.Finance.Interface.Holding.V4.Fungible qualified as Fungible (I, Split(..)) -import Daml.Finance.Interface.Settlement.V4.Batch qualified as Batch (Settle(..)) -import Daml.Finance.Interface.Settlement.V4.Factory qualified as SettlementFactory (I, Instruct(..)) -import Daml.Finance.Interface.Settlement.V4.Instruction qualified as Instruction (Allocate(..), Approve(..), I) -import Daml.Finance.Interface.Settlement.V4.RouteProvider qualified as RouteProvider (Discover(..), I) -import Daml.Finance.Interface.Settlement.V4.Types qualified as SettlementTypes (Allocation(..), Approval(..), Step(..), Quantity(..), InstructionKey(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), HoldingStandard(..), Id(..)) -import Daml.Finance.Interface.Util.V3.HoldingSplice() -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I) -import Daml.Finance.Settlement.V4.Conversion (fromInstrumentKey) -import Daml.Finance.Settlement.V4.Factory qualified as Settlement (Factory(..)) -import Daml.Finance.Settlement.V4.Instruction qualified as Instruction (T) -import Daml.Finance.Settlement.V4.RouteProvider.SingleCustodian (SingleCustodian(..)) -import Daml.Finance.Test.Util.Account qualified as Account (ControlledBy(..), createAccount, createFactory, credit) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Test.Util.Holding qualified as Holding (verifyNoObservers, verifyOwnerOfHolding) -import Daml.Finance.Test.Util.HoldingFactory (createHoldingFactory) -import Daml.Finance.Test.Util.Instrument qualified as Instrument (originate) -import Daml.Script -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - - - --- | Parties involved in the test script. -data TestParties = TestParties - with - bank : Party - -- ^ Acts as custodian in the respective holdings and provider of the holding factories. - cb : Party - -- ^ Depository and issuer of the cash instrument. - sender : Party - -- ^ Sends units of cash to receiver. - receiver : Party - -- ^ Receives units of cash from sender. - ccp : Party - -- ^ Central counterparty. Passes through cash from the sender to the receiver. - settler : Party - -- ^ Executes the settlement of the batch. - publicParty : Party - -- ^ The public party. Every party can readAs the public party. - --- Transfer of cash between two parties (sender -> receiver) facilitated by an intermediary (bank). --- +------------------------------------------+ --- | Accounts | --- +------------------+-----------------------+ --- | structure: | used for: | --- +------------------+-----------------------+ --- | Bank | | --- | / \ | commercial bank money | --- | Sender Receiver | | --- +------------------+-----------------------+ -run : Script () -run = script do - -- Create parties - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - [senderAccount, receiverAccount] <- mapA (Account.createAccount "Cash Account" [] - accountFactoryCid holdingFactory [] Account.Owner bank) [sender, receiver] - - -- Distribute asset - now <- getTime - cashInstrument <- Instrument.originate cb cb "USD" Transferable "United States Dollar" [] now - holdingCid <- Account.credit [] cashInstrument 200_000.0 senderAccount - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> - submit bank do createCmd Settlement.Factory with provider = bank; observers = mempty - - -- Settlement step - let - step = - SettlementTypes.Step with - sender = sender - receiver = receiver - quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 - - - -- Discover settlement route for the step - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do - createCmd SingleCustodian with provider = bank; observers = mempty; custodian = bank - routedSteps <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank; contextId = None; steps = [step] - - -- Instruct transfer - (batchCid, [cashInstructionCid]) <- submit bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.singleton bank - id = Id "transfer 1" - description = "transfer of USD 200000.0 payment" - contextId = None - routedSteps - settlementTime = None - - -- Allocate instruction - (cashInstructionCid, _) <- submit sender do - exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid - - -- Holding is locked - Some cashInstruction <- queryInterfaceContractId sender cashInstructionCid - let SettlementTypes.Pledge holdingCid = cashInstruction.allocation - Some lockable <- queryInterfaceContractId sender (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) - assertMsg "holding is locked" $ isSome lockable.lock - - -- Can't split the holding (as it is locked) - submitMustFail sender do - exerciseCmd (fromInterfaceContractId @Fungible.I holdingCid) Fungible.Split with - amounts = [1.0, 2.0] - - -- Cancel allocation - (cashInstructionCid, Some holdingCid) <- submit sender do - exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Unallocated - - -- Holding is not locked - Some lockable <- queryInterfaceContractId sender (coerceInterfaceContractId @Lockable.I @Api.HoldingV1.Holding holdingCid) - assertMsg "holding is not locked" $ isNone lockable.lock - - -- Allocate instruction - (cashInstructionCid, _) <- submit sender do - exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid - - -- Approve instruction - cashInstructionCid <- submit receiver do - exerciseCmd cashInstructionCid Instruction.Approve with - actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount - - -- Settle batch - [cashHoldingCid] <- submit (actAs bank <> readAs publicParty) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton bank - - -- Assert state - let ts = [(receiver, cashHoldingCid)] - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - --- Multiple transfers can be processed in any order. To achieve this, each transfer process --- discloses/undiscloses accounts/holdings under different contexts to not affect each other. In --- this test, the same accounts and parties are used for 3 cash transfers (sender -> receiver --- facilitated by an intermediary bank). --- +------------------------------------------+ --- | Accounts | --- +------------------+-----------------------+ --- | structure: | used for: | --- +------------------+-----------------------+ --- | Bank | | --- | / \ | commercial bank money | --- | Sender Receiver | | --- +------------------+-----------------------+ -run2 : Script () -run2 = script do - TestParties{..} <- setupParties - let pp = [("PublicParty", Set.singleton publicParty)] - - -- Create account factory - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory $ - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - [senderAccount, receiverAccount] <- mapA (Account.createAccount "Cash Account" [] - accountFactoryCid holdingFactory [] Account.Owner bank) [sender, receiver] - - -- Distribute asset - now <- getTime - cashInstrument <- Instrument.originate cb cb "USD" Transferable "United States Dollar" [] now - holdingCid1 <- Account.credit [] cashInstrument 100_000.0 senderAccount - holdingCid2 <- Account.credit [] cashInstrument 200_000.0 senderAccount - holdingCid3 <- Account.credit [] cashInstrument 300_000.0 senderAccount - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> - submit bank do createCmd Settlement.Factory with provider = bank; observers = mempty - - -- Settlement steps (to be settled independently) - let - id1 = Id "transfer 1" - id2 = Id "transfer 2" - id3 = Id "transfer 3" - first = - SettlementTypes.Step with - sender = sender - receiver = receiver - quantity = SettlementTypes.Quantity - with unit = fromInstrumentKey cashInstrument; amount = 100_000.0 - second = - SettlementTypes.Step with - sender = sender - receiver = receiver - quantity = SettlementTypes.Quantity - with unit = fromInstrumentKey cashInstrument; amount = 200_000.0 - third = - SettlementTypes.Step with - sender = sender - receiver = receiver - quantity = SettlementTypes.Quantity - with unit = fromInstrumentKey cashInstrument; amount = 300_000.0 - -- Discover settlement routes - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do - createCmd SingleCustodian with provider = bank; observers = mempty; custodian = bank - routedSteps1 <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank; contextId = None; steps = [first] - routedSteps2 <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank; contextId = None; steps = [second] - routedSteps3 <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank; contextId = None; steps = [third] - - -- Instruct settlement for transfer 1 - (batchCid1, [cashInstructionCid1]) <- submit bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.singleton bank - id = id1 - description = "transfer of USD 100000.0 payment" - contextId = None - routedSteps = routedSteps1 - settlementTime = None - -- the id of the batch must be unique - submitMustFail bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.singleton bank - id = id1 - description = "transfer of USD 200000.0 payment" - contextId = None - routedSteps = routedSteps1 - settlementTime = None - - -- Instruct settlement for transfer 2 - (batchCid2, [cashInstructionCid2]) <- submit bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.singleton bank - id = id2 - description = "transfer of USD 200000.0 payment" - contextId = None - routedSteps = routedSteps2 - settlementTime = None - - -- Instruct settlement for transfer 3 - (batchCid3, [cashInstructionCid3]) <- submit bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.singleton bank - id = id3 - description = "transfer of USD 300000.0 payment" - contextId = None - routedSteps = routedSteps3 - settlementTime = None - - let - verifyAccountDisclosureContexts : AccountKey -> [ContractId Instruction.I] -> Script () - verifyAccountDisclosureContexts account instructionCids = do - current <- (.observers) . snd . head <$> queryFilter @Account.T account.owner - (\a -> Account.getKey (toInterface @Account.I a) == account) - expected <- Map.fromList <$> mapA - (\instructionCid -> do - Some instruction <- queryContractId account.owner - (fromInterfaceContractId @Instruction.T instructionCid) - pure (show $ key instruction, Set.singleton bank) - ) - instructionCids - current === expected - - -- check account observers - verifyAccountDisclosureContexts senderAccount [] - verifyAccountDisclosureContexts receiverAccount [] - - -- Allocate instruction (in any order) - -- first - (cashInstructionCid1, _) <- submit sender do - exerciseCmd cashInstructionCid1 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid1 - verifyAccountDisclosureContexts senderAccount [cashInstructionCid1] - - (cashInstructionCid1, mAlloc) <- submit sender do - exerciseCmd cashInstructionCid1 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Unallocated - - let - releasedHoldingCid = - case mAlloc of - Some cid -> cid - None -> error "Expected released holding" - - verifyAccountDisclosureContexts senderAccount [] - (cashInstructionCid1, _) <- submit sender do - exerciseCmd cashInstructionCid1 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge releasedHoldingCid - - verifyAccountDisclosureContexts senderAccount [cashInstructionCid1] - -- second - (cashInstructionCid2, _) <- submit sender do - exerciseCmd cashInstructionCid2 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid2 - - verifyAccountDisclosureContexts senderAccount [cashInstructionCid1, cashInstructionCid2] - -- third - (cashInstructionCid3, _) <- submit sender do - exerciseCmd cashInstructionCid3 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid3 - - verifyAccountDisclosureContexts senderAccount [cashInstructionCid1, cashInstructionCid2, - cashInstructionCid3] - - -- Approve instruction (in any order) - -- third - cashInstructionCid3 <- submit receiver do - exerciseCmd cashInstructionCid3 Instruction.Approve with - actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount - verifyAccountDisclosureContexts receiverAccount [cashInstructionCid3] - -- first - cashInstructionCid1 <- submit receiver do - exerciseCmd cashInstructionCid1 Instruction.Approve with - actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount - verifyAccountDisclosureContexts receiverAccount [cashInstructionCid1, cashInstructionCid3] - -- second - cashInstructionCid2 <- submit receiver do - exerciseCmd cashInstructionCid2 Instruction.Approve with - actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount - verifyAccountDisclosureContexts receiverAccount [cashInstructionCid1, cashInstructionCid2, - cashInstructionCid3] - - -- Settle transfers (in any order) - -- second - [cashHoldingCid2] <- submit (actAs bank <> readAs publicParty) do - exerciseCmd batchCid2 Batch.Settle with actors = Set.singleton bank - verifyAccountDisclosureContexts receiverAccount [cashInstructionCid1, cashInstructionCid3] - verifyAccountDisclosureContexts receiverAccount [cashInstructionCid1, cashInstructionCid3] - -- first - [cashHoldingCid1] <- submit (actAs bank <> readAs publicParty) do - exerciseCmd batchCid1 Batch.Settle with actors = Set.singleton bank - verifyAccountDisclosureContexts senderAccount [cashInstructionCid3] - verifyAccountDisclosureContexts receiverAccount [cashInstructionCid3] - -- third - [cashHoldingCid3] <- submit (actAs bank <> readAs publicParty) do - exerciseCmd batchCid3 Batch.Settle with actors = Set.singleton bank - verifyAccountDisclosureContexts senderAccount [] - verifyAccountDisclosureContexts receiverAccount [] - - -- Assert state - let ts = [(receiver, cashHoldingCid1), (receiver, cashHoldingCid2), (receiver, cashHoldingCid3)] - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - --- Transfer of cash between two parties (sender -> receiver) which can be executed by either party. --- +------------------------------------------+ --- | Accounts | --- +------------------+-----------------------+ --- | structure: | used for: | --- +------------------+-----------------------+ --- | Bank | | --- | / \ | commercial bank money | --- | Sender Receiver | | --- +------------------+-----------------------+ -run3 : Script () -run3 = script do - TestParties{..} <- setupParties - - -- Create account factory - let pp = [("PublicParty", Set.singleton publicParty)] - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory $ - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - [senderAccount, receiverAccount] <- mapA (Account.createAccount "Cash Account" [] - accountFactoryCid holdingFactory [] Account.Owner bank) [sender, receiver] - - -- Distribute asset - now <- getTime - cashInstrument <- Instrument.originate cb cb "USD" Transferable "United States Dollar" [] now - holdingCid <- Account.credit [] cashInstrument 200_000.0 senderAccount - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> submit bank do - createCmd Settlement.Factory with provider = bank; observers = Set.singleton publicParty - - -- Discover settlement - let - step = - SettlementTypes.Step with - sender = sender - receiver = receiver - quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 - - - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do - createCmd SingleCustodian with provider = bank; observers = mempty; custodian = bank - routedSteps <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank; contextId = None; steps = [step] - - -- Instruct transfer - (batchCid, [cashInstructionCid]) <- submit bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.fromList [sender, receiver] - id = Id "transfer 1" - description = "transfer of USD 200000.0 payment" - contextId = None - routedSteps - settlementTime = None - - -- Allocate instruction - (cashInstructionCid, _) <- submit sender do - exerciseCmd cashInstructionCid Instruction.Allocate with - actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid - - -- Approve instruction - cashInstructionCid <- submit receiver do - exerciseCmd cashInstructionCid Instruction.Approve with - actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount - - -- Settle batch - -- either sender, receiver or both can settle - [cashHoldingCid] <- submit (actAs sender <> readAs publicParty) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton sender - - -- Assert state - let ts = [(receiver, cashHoldingCid)] - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - --- Transfer of 2 cash holdings in a batch between the same parties and accounts. --- +------------------------------------------+ --- | Accounts | --- +------------------+-----------------------+ --- | structure: | used for: | --- +------------------+-----------------------+ --- | Bank | | --- | / \ | commercial bank money | --- | Sender Receiver | | --- +------------------+-----------------------+ -run4 : Script () -run4 = script do - TestParties{..} <- setupParties - - -- Create account factory - let pp = [("PublicParty", Set.singleton publicParty)] - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory $ - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - [senderAccount, receiverAccount] <- mapA (Account.createAccount "Cash Account" [] - accountFactoryCid holdingFactory [] Account.Owner bank) [sender, receiver] - - -- Distribute asset - now <- getTime - cashInstrument1 <- Instrument.originate cb cb "USD" Transferable "United States Dollar" [] now - holdingCid1 <- Account.credit [] cashInstrument1 200_000.0 senderAccount - holdingCid2 <- Account.credit [] cashInstrument1 100_000.0 senderAccount - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> submit bank do - createCmd Settlement.Factory with provider = bank; observers = Set.singleton publicParty - - -- Settlement steps - let - step1 = - SettlementTypes.Step with - sender = sender - receiver = receiver - quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument1 - amount = 200_000.0 - step2 = - SettlementTypes.Step with - sender = sender - receiver = receiver - quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument1 - amount = 100_000.0 - - -- Discover settlement routes - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do - createCmd SingleCustodian with provider = bank; observers = mempty; custodian = bank - routedSteps <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank; contextId = None; steps = [step1, step2] - - -- Instruct transfer - (batchCid, [cashInstructionCid1, cashInstructionCid2]) <- submit bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.fromList [sender, receiver] - id = Id "transfer 1" - description = "transfer of USD 200000.0 and CHF 100000.0 payment" - contextId = None - routedSteps - settlementTime = None - - -- Allocate instruction - (cashInstructionCid1, _) <- submit sender do - exerciseCmd cashInstructionCid1 Instruction.Allocate with - actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid1 - (cashInstructionCid2, _) <- submit sender do - exerciseCmd cashInstructionCid2 Instruction.Allocate with - actors = Set.singleton sender; allocation = SettlementTypes.Pledge holdingCid2 - - -- Approve instruction - cashInstructionCid1 <- submit receiver do - exerciseCmd cashInstructionCid1 Instruction.Approve with - actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount - cashInstructionCid2 <- submit receiver do - exerciseCmd cashInstructionCid2 Instruction.Approve with - actors = Set.singleton receiver; approval = SettlementTypes.TakeDelivery receiverAccount - - -- Settle batch - -- either sender, receiver or both can settle - [cashHoldingCid1, cashHoldingCid2] <- submit (actAs sender <> readAs publicParty) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton sender - - -- Assert state - let ts = [(receiver, cashHoldingCid1), (receiver, cashHoldingCid2)] - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - --- Transfer using passthrough (of commercial bank money from Sender to Receiver via CCP). --- +---------------------------------------------------+ --- | Accounts | --- +---------------------------+-----------------------+ --- | structure: | used for: | --- +---------------------------+-----------------------+ --- | Bank | | --- | / | \ | commercial bank money | --- | Sender -> CCP -> Receiver | | --- +---------------------------+-----------------------+ -run5 : Script () -run5 = script do - TestParties{..} <- setupParties - - -- Create account factory - let pp = [("PublicParty", Set.singleton publicParty)] - accountFactoryCid <- toInterfaceContractId <$> Account.createFactory bank pp - - -- Create holding factory - holdingFactory <- createHoldingFactory $ - Holding.Factory with provider = bank; id = Id "Holding Factory"; observers = Map.fromList pp - - -- Create accounts - [senderAccount, ccpAccount, receiverAccount] <- mapA (Account.createAccount "Cash Account" [] - accountFactoryCid holdingFactory [] Account.Owner bank) [sender, ccp, receiver] - - -- Distribute asset - now <- getTime - cashInstrument <- Instrument.originate cb cb "USD" Transferable "United States Dollar" [] now - holdingCid <- Account.credit [] cashInstrument 200_000.0 senderAccount - - -- Create settlement factory - settlementFactoryCid <- toInterfaceContractId @SettlementFactory.I <$> - submit bank do createCmd Settlement.Factory with provider = bank; observers = mempty - - -- Settlement steps - let - step1 = - SettlementTypes.Step with - sender = sender - receiver = ccp - quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 - step2 = - SettlementTypes.Step with - sender = ccp - receiver = receiver - quantity = SettlementTypes.Quantity - with - unit = fromInstrumentKey cashInstrument - amount = 200_000.0 - - -- Discover settlement routes - routeProviderCid <- toInterfaceContractId @RouteProvider.I <$> submit bank do - createCmd SingleCustodian with provider = bank; observers = mempty; custodian = bank - routedSteps <- submit bank do - exerciseCmd routeProviderCid RouteProvider.Discover with - discoverors = Set.singleton bank - contextId = None - steps = [step2, step1] -- order does not matter - - -- Instruct transfer - (batchCid, [instructionCid2, instructionCid1]) <- submit bank do - exerciseCmd settlementFactoryCid SettlementFactory.Instruct with - instructor = bank - consenters = mempty - settlers = Set.singleton settler - id = Id "transfer 1" - description = "transfer of USD 200000.0 payment" - contextId = None - routedSteps - settlementTime = None - - -- Approve instruction - instructionCid2 <- submit receiver do - exerciseCmd instructionCid2 Instruction.Approve with - actors = Set.singleton receiver - approval = SettlementTypes.TakeDelivery receiverAccount - - -- Approve with passthrough - instructionCid1 <- submit ccp do - exerciseCmd instructionCid1 Instruction.Approve with - actors = Set.singleton ccp - approval = SettlementTypes.PassThroughTo - (ccpAccount - , SettlementTypes.InstructionKey - with - instructor = bank - batchId = Id "transfer 1" - id = Id "0" - ) - - -- Allocate with passthrough - instructionCid2 <- submit ccp do - exerciseCmd instructionCid2 Instruction.Allocate with - actors = Set.singleton ccp - allocation = SettlementTypes.PassThroughFrom - (ccpAccount - , SettlementTypes.InstructionKey - with - instructor = bank - batchId = Id "transfer 1" - id = Id "1" - ) - - -- Allocate instruction - (instructionCid1, _) <- submit sender do - exerciseCmd instructionCid1 Instruction.Allocate with - actors = Set.singleton sender - allocation = SettlementTypes.Pledge holdingCid - - -- Settle batch - [cashHoldingCid] <- submit (actAs settler <> readAs publicParty) do - exerciseCmd batchCid Batch.Settle with actors = Set.singleton settler - - -- Assert state - let ts = [(receiver, cashHoldingCid)] - Holding.verifyOwnerOfHolding ts - Holding.verifyNoObservers ts - - pure () - -setupParties : Script TestParties -setupParties = do - [cb, bank, sender, receiver, ccp, settler, publicParty] <- - createParties ["CentralBank", "Bank", "Sender", "Receiver", "CCP", "Settler", "PublicParty"] - pure TestParties with cb; bank; sender; receiver; ccp; settler; publicParty diff --git a/src/test/daml/Daml/Finance/Test/Util/Account.daml b/src/test/daml/Daml/Finance/Test/Util/Account.daml deleted file mode 100644 index 86a3b6175..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/Account.daml +++ /dev/null @@ -1,135 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Test.Util.Account where - -import DA.Assert () -import DA.List (head) -import DA.Map qualified as Map (fromList) -import DA.Set qualified as Set (fromList, singleton) -import DA.TextMap qualified as TextMap -import DA.Optional(fromSome, fromOptional) -import Daml.Finance.Account.V4.Account qualified as Account (Factory(..)) -import Daml.Finance.Interface.Account.V4.Account qualified as Account (Controllers(..), Credit(..), Debit(..), GetCid(..), I, R) -import Daml.Finance.Interface.Account.V4.Factory qualified as AccountFactory (Create(..), I) -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), HoldingFactoryKey, Id(..), InstrumentKey, Parties) -import Daml.Finance.Interface.Util.V3.Common (qty) -import Daml.Finance.Test.Util.Common (submitExerciseInterfaceByKeyCmdHelper, submitMustFailExerciseInterfaceByKeyCmdHelper) -import Daml.Script (Script, queryInterfaceContractId, submit,createCmd, actAs, readAs, exerciseCmd) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 - --- | Reconstruct an AccountKey from a Splice HoldingView. -getAccountFromSplice : Api.HoldingV1.HoldingView -> AccountKey -getAccountFromSplice v = - let - metaVals = getField @"values" (getField @"meta" v) - custodianTxt = fromOptional "" (TextMap.lookup "custodian" metaVals) - accountIdTxt = fromOptional "" (TextMap.lookup "accountId" metaVals) - in - AccountKey with - custodian = fromSome (partyFromText custodianTxt) - owner = v.owner - id = Id accountIdTxt - - --- | Options for transfer controllers. -data ControlledBy - = Owner - -- ^ Owner controls inbound and outbound transfers. - | Custodian - -- ^ Custodian controls inbound and outbound transfers. - | OwnerAndCustodian - -- ^ Owner and custodian jointly control inbound and outbound transfers. - | OwnerWithAutoApproval - -- ^ Owner controls outbound transfers, and inbound transfers are auto-approved. - deriving (Eq, Show) - --- | Get account controllers depending on controlledBy. -toControllers : Party -> Party -> ControlledBy -> Account.Controllers -toControllers custodian owner controlledBy = - case controlledBy of - Owner -> Account.Controllers with - outgoing = Set.singleton owner; incoming = Set.singleton owner - Custodian -> Account.Controllers with - outgoing = Set.singleton custodian; incoming = Set.singleton custodian - OwnerAndCustodian -> Account.Controllers with - outgoing = Set.fromList [owner, custodian]; incoming = Set.fromList [owner, custodian] - OwnerWithAutoApproval -> Account.Controllers with - outgoing = Set.singleton owner; incoming = mempty - --- | Create factory for `Account`. -createFactory : Party -> [(Text, Parties)] -> Script (ContractId Account.Factory) -createFactory provider observers = submit provider do - createCmd Account.Factory with provider; observers = Map.fromList observers - --- | Create `Account`. -createAccount : Text -> [Party] -> ContractId AccountFactory.I -> HoldingFactoryKey -> - [(Text, Parties)] -> ControlledBy -> Party -> Party -> Script AccountKey -createAccount description readers accpountFactoryCid holdingFactory observers controlledBy custodian - owner = do - let - account = AccountKey with - custodian; owner; id = Id $ show owner <> "@" <> show custodian <> "/" <> description - submit (actAs [custodian, owner] <> readAs readers) do - exerciseCmd accpountFactoryCid AccountFactory.Create with - account; holdingFactory; controllers = toControllers custodian owner controlledBy - observers = Map.fromList observers; description - pure account - --- | Credit an `Account`. -credit : [Party] -> InstrumentKey -> Decimal -> AccountKey -> Script (ContractId Api.HoldingV1.Holding) -credit readAs instrument amount account = - submitExerciseInterfaceByKeyCmdHelper @Account.R @Account.I [account.custodian, account.owner] - readAs account - (Account.GetCid with viewer = account.owner) - (Account.Credit with quantity = qty amount instrument) - --- | Debit an `Account`. -debit : [Party] -> Party -> ContractId Api.HoldingV1.Holding -> Script () -debit readAs holder holdingCid = do - opt <- queryInterfaceContractId holder holdingCid - hv <- case opt of - Some hv -> pure hv -- iv :: Api.HoldingV1.Holding -> view :: HoldingView - None -> abort "Holding not found" - assertMsg "Owner mismatch" (getField @"owner" hv == holder) - submitExerciseInterfaceByKeyCmdHelper @Account.R @Account.I - [ fromSome (partyFromText (fromSome (TextMap.lookup "custodian" - (getField @"values" (getField @"meta" hv))))), - holder - ] - readAs - (getAccountFromSplice hv) - (Account.GetCid with viewer = holder) - (Account.Debit with holdingCid) - --- | Utilty function for exercising an interface by key. -submitExerciseInterfaceByKeyCmd : forall t2 c2 b. - ( HasInterfaceTypeRep t2 - , HasTemplateTypeRep t2 - , HasToAnyTemplate t2 - , HasFromAnyTemplate t2 - , HasFromAnyChoice t2 c2 b - , HasToAnyChoice t2 c2 b - , HasExercise t2 c2 b - ) - => [Party] -> [Party] -> AccountKey -> c2 -> Script b -submitExerciseInterfaceByKeyCmd actAs readAs k arg = - submitExerciseInterfaceByKeyCmdHelper @Account.R @t2 actAs readAs k - (Account.GetCid with viewer = head actAs) arg - --- | Utilty function for exercising an interface by key. -submitMustFailExerciseInterfaceByKeyCmd : forall t2 c2 b. - ( HasInterfaceTypeRep t2 - , HasTemplateTypeRep t2 - , HasToAnyTemplate t2 - , HasFromAnyTemplate t2 - , HasFromAnyChoice t2 c2 b - , HasToAnyChoice t2 c2 b - , HasExercise t2 c2 b - ) - => [Party] -> [Party] -> AccountKey -> c2 -> Script () -submitMustFailExerciseInterfaceByKeyCmd actAs readAs k arg = - submitMustFailExerciseInterfaceByKeyCmdHelper @Account.R @t2 actAs readAs k - (Account.GetCid with viewer = head actAs) arg diff --git a/src/test/daml/Daml/Finance/Test/Util/Common.daml b/src/test/daml/Daml/Finance/Test/Util/Common.daml deleted file mode 100644 index 4a9a47c05..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/Common.daml +++ /dev/null @@ -1,98 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Test.Util.Common where - -import Daml.Script -import DA.Text (replace) - --- | Replace invalid PartyIdHint characters with underscores. -makeSafePartyHint : Text -> Text -makeSafePartyHint - = replace "." "_" - . replace ":" "_" - . replace "-" "_" - - --- | Create parties with a given suffix. -createPartiesWithSuffix : Text -> [Text] -> Script [Party] -createPartiesWithSuffix suffix names = - mapA - (\name -> - allocatePartyByHint - (PartyIdHint (makeSafePartyHint (name <> "_" <> suffix)))) names - --- | Create parties with a unique, safe suffix based on the current time-stamp. -createParties : [Text] -> Script [Party] -createParties names = do - now <- getTime - let suffix = makeSafePartyHint (show now) - createPartiesWithSuffix suffix names - --- | Takes a 'Script a' that is expected to fail with an 'AssertionFailed'. --- If the failure message does not match, or the script succeeds, the test fails. -validateAssertionFailure : Script a -> Text -> Script () -validateAssertionFailure assertion expectedFailureMessage = do - result <- tryFailureStatus assertion - case result of - Left status -> - if status.message == expectedFailureMessage - then pure () - else abort - ("Failure message mismatch.\nExpected: " <> expectedFailureMessage - <> "\nBut got: " <> status.message) - Right _ -> - abort ("Expected failure, but succeeded: " <> expectedFailureMessage) - - --- | Utility for exercising interface by key (submitMulti composed with exerciseInterfaceByKey --- helper) -submitExerciseInterfaceByKeyCmdHelper : forall t1 t2 t c1 k c2 b. - ( HasInterfaceTypeRep t2 - , HasInterfaceTypeRep t - , Template t1 - , Choice t1 c1 (ContractId t) - , HasKey t1 k - , HasLookupByKey t1 k - , HasFetchByKey t1 k - , HasMaintainer t1 k - , HasToAnyContractKey t1 k - , HasFromAnyContractKey t1 k - , HasTemplateTypeRep t2 - , HasToAnyTemplate t2 - , HasFromAnyTemplate t2 - , HasToAnyChoice t2 c2 b - , HasFromAnyChoice t2 c2 b - , HasExercise t2 c2 b - ) - => [Party] -> [Party] -> k -> c1 -> c2 -> Script b -submitExerciseInterfaceByKeyCmdHelper actors readers k arg1 arg2 = do - cid <- submit (actAs actors <> readAs readers) do exerciseByKeyCmd @t1 k arg1 - submit (actAs actors <> readAs readers) do exerciseCmd (coerceInterfaceContractId @t2 cid) arg2 - --- | Utility for exercising interface by key (submitMulti composed with exerciseInterfaceByKey --- helper) -submitMustFailExerciseInterfaceByKeyCmdHelper : forall t1 t2 t c1 k c2 b. - ( HasInterfaceTypeRep t2 - , HasInterfaceTypeRep t - , Template t1 - , Choice t1 c1 (ContractId t) - , HasKey t1 k - , HasLookupByKey t1 k - , HasFetchByKey t1 k - , HasMaintainer t1 k - , HasToAnyContractKey t1 k - , HasFromAnyContractKey t1 k - , HasTemplateTypeRep t2 - , HasToAnyTemplate t2 - , HasFromAnyTemplate t2 - , HasToAnyChoice t2 c2 b - , HasFromAnyChoice t2 c2 b - , HasExercise t2 c2 b - ) - => [Party] -> [Party] -> k -> c1 -> c2 -> Script () -submitMustFailExerciseInterfaceByKeyCmdHelper actors readers k arg1 arg2 = do - cid <- submit (actAs actors <> readAs readers) do exerciseByKeyCmd @t1 k arg1 - submitMustFail (actAs actors <> readAs readers) do exerciseCmd (coerceInterfaceContractId @t2 cid) arg2 diff --git a/src/test/daml/Daml/Finance/Test/Util/Holding.daml b/src/test/daml/Daml/Finance/Test/Util/Holding.daml deleted file mode 100644 index 76f7dc5da..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/Holding.daml +++ /dev/null @@ -1,50 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Test.Util.Holding where - -import DA.Assert ((===)) -import Splice.Api.Token.HoldingV1 qualified as Api.HoldingV1 -import Daml.Script - --- | Verify that a party is the owner of a Splice holding. -verifyOwnerOfHolding : [(Party, ContractId Api.HoldingV1.Holding)] -> Script [()] -verifyOwnerOfHolding pairs = forA pairs \(expectedOwner, holdingCid) -> do - viewOpt <- queryInterfaceContractId @Api.HoldingV1.Holding expectedOwner holdingCid - Some view <- queryInterfaceContractId @Api.HoldingV1.Holding expectedOwner holdingCid - view.owner === expectedOwner - --- | Verify that a party is the owner of a Splice holding and that it has the expected amount. -verifyOwnerAndAmountOfHolding : [(Party, Decimal, ContractId Api.HoldingV1.Holding)] -> Script [()] -verifyOwnerAndAmountOfHolding triples = forA triples \(expectedOwner, expectedAmount, holdingCid) -> do - Some view <- queryInterfaceContractId @Api.HoldingV1.Holding expectedOwner holdingCid - view.owner === expectedOwner - view.amount === expectedAmount - --- | Verify that a holding has no observers (Disclosure removed for Splice). -verifyNoObservers : [(Party, ContractId Api.HoldingV1.Holding)] -> Script [()] -verifyNoObservers pairs = forA pairs \(expectedOwner, holdingCid) -> do - Some view <- queryInterfaceContractId @Api.HoldingV1.Holding expectedOwner holdingCid - -- Splice holdings do not have observers, so we just ensure ownership consistency. - view.owner === expectedOwner - --- Helper: find exactly one holding owned by expectedOwner for (admin,instrId) -findOwnedHolding - : Text -- description (for error message) - -> Party -- expected owner - -> Party -- instrument admin - -> Text -- instrument id - -> [(ContractId Api.HoldingV1.Holding, Optional Api.HoldingV1.HoldingView)] - -> ContractId Api.HoldingV1.Holding -findOwnedHolding desc expectedOwner admin instrId holdings = - case [ cid - | (cid, Some v) <- holdings - , v.owner == expectedOwner - , v.instrumentId.admin == admin - , v.instrumentId.id == instrId - ] of - [cid] -> cid - [] -> error ("Could not find " <> desc <> " for " - <> instrId <> " owned by " <> show expectedOwner) - _ -> error ("More than one " <> desc <> " for " - <> instrId <> " owned by " <> show expectedOwner) diff --git a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml b/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml deleted file mode 100644 index f787780ab..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/BaseHolding.daml +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Test.Util.HoldingDuplicates.BaseHolding where - --- | Test Implementation. --- This module contains a copy of the code from the Daml.Finance.Holding package. It is used --- specifically for testing purposes, allowing the instantiation of an alternate implementation of --- holdings. - -import DA.Set (fromList, singleton) -import DA.TextMap qualified as TextMap -import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey(..), InstrumentKey(..), PartiesMap, Id(..)) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Interface.Util.V3.Lockable qualified as Lockable (I, Lock(..), View(..), getLockers) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Finance.Util.V4.Lockable (acquireImpl, isValidLock, releaseImpl) -import Splice.Api.Token.HoldingV1 qualified as SpliceHolding -import Splice.Api.Token.MetadataV1 qualified as SpliceMetadata - --- | Type synonym for `BaseHolding`. -type T = BaseHolding - --- | Implementation of a `BaseHolding`. --- `BaseHolding` implements the interface `Holding.I` (which requires `Lockable.I` and --- `Disclosure.I` to be implemented), but neither `Fungible.I` nor `Transferable.I`. -template BaseHolding - with - instrument : InstrumentKey - -- ^ The instrument of which units are held. - account : AccountKey - -- ^ The account at which the holding is held. Defines the holding's owner and custodian. - amount : Decimal - -- ^ Number of units. - lock : Optional Lockable.Lock - -- ^ An optional lock for the holding. - observers : PartiesMap - -- ^ Observers. - where - signatory account.custodian, account.owner, Lockable.getLockers this - observer Disclosure.flattenObservers observers - - ensure - amount > 0.0 && isValidLock lock && instrument.holdingStandard == HoldingStandard.BaseHolding - - interface instance Disclosure.I for BaseHolding where - view = Disclosure.View with - disclosureControllers = fromList [account.owner, account.custodian]; observers - setObservers = setObserversImpl @_ @Disclosure.I this None - addObservers = addObserversImpl @_ @Disclosure.I this None - removeObservers = removeObserversImpl @_ @Disclosure.I this None - - interface instance Lockable.I for BaseHolding where - view = Lockable.View with lock; controllers = singleton account.owner - acquire = acquireImpl this.lock (\lock -> this with lock) - release = releaseImpl this.lock (\lock -> this with lock) - - interface instance SpliceHolding.Holding for BaseHolding where - view = SpliceHolding.HoldingView - with - owner = account.owner - instrumentId = SpliceHolding.InstrumentId with - admin = instrument.issuer - id = case instrument.id of Id t -> t - amount = amount - lock = None - meta = SpliceMetadata.Metadata with values = TextMap.empty \ No newline at end of file diff --git a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Factory.daml b/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Factory.daml deleted file mode 100644 index 897f8ebe8..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/HoldingDuplicates/Factory.daml +++ /dev/null @@ -1,70 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Test.Util.HoldingDuplicates.Factory where - --- | Test Implementation. --- This module contains a copy of the code from the Daml.Finance.Holding package. It is used --- specifically for testing purposes, allowing the instantiation of an alternate implementation of --- holdings. - -import DA.Set (singleton) -import Daml.Finance.Interface.Holding.V4.Factory qualified as HoldingFactory (Create(..), I, View(..), holdingFactoryKey) -import Daml.Finance.Interface.Types.Common.V3.Types (Id, PartiesMap) -import Daml.Finance.Interface.Types.Common.V3.Types qualified as HoldingStandard (HoldingStandard(..)) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I, View(..), flattenObservers) -import Daml.Finance.Test.Util.HoldingDuplicates.BaseHolding (BaseHolding(..)) -import Daml.Finance.Test.Util.HoldingDuplicates.Fungible (Fungible(..)) -import Daml.Finance.Test.Util.HoldingDuplicates.Transferable (Transferable(..)) -import Daml.Finance.Test.Util.HoldingDuplicates.TransferableFungible (TransferableFungible(..)) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) - --- | Type synonym for `Factory`. -type T = Factory - --- | Implementation of a factory template for holdings. -template Factory - with - provider : Party - -- ^ The factory's provider. - id : Id - -- ^ Identifier for the factory. - observers : PartiesMap - -- ^ The factory's observers. - where - signatory provider - observer Disclosure.flattenObservers observers - - interface instance HoldingFactory.I for Factory - where - view = HoldingFactory.View with provider; id - getKey = HoldingFactory.holdingFactoryKey this - create' HoldingFactory.Create{instrument; account; amount; observers} = do - assertMsg "amount must be positive" $ amount > 0.0 - - case instrument.holdingStandard of - HoldingStandard.TransferableFungible -> do - cid <- create TransferableFungible with - instrument; account; amount; observers; lock = None - pure (toInterfaceContractId cid) - - HoldingStandard.Transferable -> do - cid <- create Transferable with - instrument; account; amount; observers; lock = None - pure (toInterfaceContractId cid) - - HoldingStandard.Fungible -> do - cid <- create Fungible with - instrument; account; amount; observers; lock = None - pure (toInterfaceContractId cid) - - HoldingStandard.BaseHolding -> do - cid <- create BaseHolding with - instrument; account; amount; observers; lock = None - pure (toInterfaceContractId cid) - - interface instance Disclosure.I for Factory where - view = Disclosure.View with disclosureControllers = singleton provider; observers - setObservers = setObserversImpl @Factory @Disclosure.I this None - addObservers = addObserversImpl @Factory @Disclosure.I this None - removeObservers = removeObserversImpl @Factory @Disclosure.I this None diff --git a/src/test/daml/Daml/Finance/Test/Util/HoldingFactory.daml b/src/test/daml/Daml/Finance/Test/Util/HoldingFactory.daml deleted file mode 100644 index 3b739b79c..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/HoldingFactory.daml +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Test.Util.HoldingFactory where - -import DA.List (head) -import Daml.Finance.Interface.Holding.V4.Factory qualified as HoldingFactory (GetCid(..), I, R, Reference(..), toKey) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingFactoryKey) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (I) -import Daml.Finance.Test.Util.Common (submitExerciseInterfaceByKeyCmdHelper, submitMustFailExerciseInterfaceByKeyCmdHelper) -import Daml.Script - --- | Create a holding factory with reference. -createHoldingFactory : - forall t. - ( HasEnsure t - , HasTemplateTypeRep t - , HasToAnyTemplate t - , HasFromAnyTemplate t - , HasToInterface t HoldingFactory.I - ) - => t -> Script HoldingFactoryKey -createHoldingFactory holdingFactory = do - let - factory = toInterface @HoldingFactory.I holdingFactory - factoryView = view factory - cid <- toInterfaceContractId @HoldingFactory.I <$> submit factoryView.provider do - createCmd holdingFactory - submit factoryView.provider do - createCmd HoldingFactory.Reference with - factoryView; cid; observers = (view $ toInterface @Disclosure.I factory).observers - pure $ HoldingFactory.toKey factoryView - --- | Utilty function for exercising an interface by key. -submitExerciseInterfaceByKeyCmd : forall t2 c2 b. - ( HasInterfaceTypeRep t2 - , HasTemplateTypeRep t2 - , HasToAnyTemplate t2 - , HasFromAnyTemplate t2 - , HasFromAnyChoice t2 c2 b - , HasToAnyChoice t2 c2 b - , HasExercise t2 c2 b - ) - => [Party] -> [Party] -> HoldingFactoryKey -> c2 -> Script b -submitExerciseInterfaceByKeyCmd actAs readAs k arg = - submitExerciseInterfaceByKeyCmdHelper @HoldingFactory.R @t2 actAs readAs k - (HoldingFactory.GetCid with viewer = head actAs) arg - --- | Utilty function for exercising an interface by key. -submitMustFailExerciseInterfaceByKeyCmd : forall t2 c2 b. - ( HasInterfaceTypeRep t2 - , HasTemplateTypeRep t2 - , HasToAnyTemplate t2 - , HasFromAnyTemplate t2 - , HasFromAnyChoice t2 c2 b - , HasToAnyChoice t2 c2 b - , HasExercise t2 c2 b - ) - => [Party] -> [Party] -> HoldingFactoryKey -> c2 -> Script () -submitMustFailExerciseInterfaceByKeyCmd actAs readAs k arg = - submitMustFailExerciseInterfaceByKeyCmdHelper @HoldingFactory.R @t2 actAs readAs k - (HoldingFactory.GetCid with viewer = head actAs) arg diff --git a/src/test/daml/Daml/Finance/Test/Util/Instrument.daml b/src/test/daml/Daml/Finance/Test/Util/Instrument.daml deleted file mode 100644 index 1f53af6cc..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/Instrument.daml +++ /dev/null @@ -1,61 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -{-# LANGUAGE AllowAmbiguousTypes #-} - -module Daml.Finance.Test.Util.Instrument where - -import DA.List (head) -import DA.Map (fromList) -import Daml.Finance.Instrument.Token.V4.Factory qualified as Token (Factory(..)) -import Daml.Finance.Interface.Instrument.Base.V4.Instrument qualified as Instrument (GetCid(..), R) -import Daml.Finance.Interface.Instrument.Token.V4.Factory qualified as TokenFactory (Create(..), I) -import Daml.Finance.Interface.Instrument.Token.V4.Types (Token(..)) -import Daml.Finance.Interface.Types.Common.V3.Types (HoldingStandard(..), Id(..), InstrumentKey(..), Parties) -import Daml.Finance.Test.Util.Common (submitExerciseInterfaceByKeyCmdHelper, createParties) -import Daml.Script - --- | Originate a `Token` Instrument. -originate : Party -> Party -> Text -> HoldingStandard -> Text-> [(Text, Parties)] -> Time - -> Script InstrumentKey -originate depository issuer label holdingStandard description observers timestamp = do - tokenFactoryCid <- toInterfaceContractId @TokenFactory.I <$> submit issuer do - createCmd Token.Factory with provider = issuer; observers = mempty - let - instrumentKey = InstrumentKey with - depository - issuer - id = Id label - version = "0" - holdingStandard - token = Token with - instrument = instrumentKey - validAsOf = timestamp - description - submit [depository, issuer] do - exerciseCmd tokenFactoryCid TokenFactory.Create with - token - observers = fromList observers - submit [depository, issuer] do archiveCmd tokenFactoryCid - pure instrumentKey - --- | Utility for exercising an interface by key. -submitExerciseInterfaceByKeyCmd : forall t2 c2 b. - ( HasInterfaceTypeRep t2 - , HasTemplateTypeRep t2 - , HasToAnyTemplate t2 - , HasFromAnyTemplate t2 - , HasFromAnyChoice t2 c2 b - , HasToAnyChoice t2 c2 b - , HasExercise t2 c2 b - ) - => [Party] -> [Party] -> InstrumentKey -> c2 -> Script b -submitExerciseInterfaceByKeyCmd actAs readAs k arg = submitExerciseInterfaceByKeyCmdHelper - @Instrument.R @t2 actAs readAs k (Instrument.GetCid with viewer = head actAs) arg - -testOriginate : Script () -testOriginate = script do - [depository, issuer] <- createParties ["Depository", "Issuer"] - now <- getTime - _ <- originate depository issuer "MyToken" TransferableFungible "Example Token" [] now - pure () diff --git a/src/test/daml/Daml/Finance/Test/Util/Time.daml b/src/test/daml/Daml/Finance/Test/Util/Time.daml deleted file mode 100644 index fc8c5131b..000000000 --- a/src/test/daml/Daml/Finance/Test/Util/Time.daml +++ /dev/null @@ -1,100 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Test.Util.Time where - -import DA.Date (toGregorian) -import DA.Set () -import Daml.Finance.Data.V4.Time.DateClock (DateClock(..)) -import Daml.Finance.Data.V4.Time.DateClock.Types (Unit(..)) -import Daml.Finance.Data.V4.Time.DateClockUpdate (DateClockUpdateEvent(..)) -import Daml.Finance.Interface.Lifecycle.V4.Event qualified as Event (I) -import Daml.Finance.Interface.Lifecycle.V4.Observable.TimeObservable qualified as TimeObservable (I) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..), Parties) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayAdjustment(..), BusinessDayConventionEnum) -import Daml.Finance.Interface.Types.Date.V3.Classes (HasUTCTimeConversion(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period(..), PeriodEnum, RollConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.Schedule (Frequency(..), PeriodicSchedule(..), ScheduleFrequency(..)) -import Daml.Script - --- | Given a `Date`, it creates a `DateClockUpdateEvent`. -createClockUpdateEvent : Parties -> Date -> Parties - -> Script (ContractId Event.I) -createClockUpdateEvent providers today observers = do - let - description = show today - id = Id description - date = Unit today - eventCid <- toInterfaceContractId <$> submit providers do - createCmd DateClockUpdateEvent with - providers; id; description; date = today; observers; eventTime = toUTCTime date - pure eventCid - --- | Given a `Date`, it creates a `DateClock` and returns it as a `TimeObservable`. -createDateClock : Parties -> Date -> Parties - -> Script (ContractId TimeObservable.I) -createDateClock providers today observers = do - let - description = show today - id = Id description - date = Unit today - toInterfaceContractId <$> submit providers do - createCmd DateClock with - providers; date; id; description; observers - --- | Create a schedule for periodic payments. -createPaymentPeriodicSchedule : Date -> [Text] -> BusinessDayConventionEnum -> PeriodEnum -> - Int -> Date -> Date -> PeriodicSchedule -createPaymentPeriodicSchedule firstCouponDate holidayCalendarIds businessDayConvention couponPeriod - couponPeriodMultiplier issueDate maturityDate = do - -- CREATE_PERIODIC_SCHEDULE_BEGIN - let - (y, m, d) = toGregorian firstCouponDate - periodicSchedule = PeriodicSchedule with - businessDayAdjustment = - BusinessDayAdjustment with - calendarIds = holidayCalendarIds - convention = businessDayConvention - effectiveDateBusinessDayAdjustment = None - terminationDateBusinessDayAdjustment = None - frequency = - Periodic Frequency with - rollConvention = DOM d - period = Period with - period = couponPeriod - periodMultiplier = couponPeriodMultiplier - effectiveDate = issueDate - firstRegularPeriodStartDate = Some firstCouponDate - lastRegularPeriodEndDate = Some maturityDate - stubPeriodType = None - terminationDate = maturityDate - -- CREATE_PERIODIC_SCHEDULE_END - periodicSchedule - --- | Create a schedule for periodic events. -createPeriodicSchedule : Optional Date -> [Text] -> BusinessDayConventionEnum -> - PeriodEnum -> Int -> Date -> Date -> Int -> PeriodicSchedule -createPeriodicSchedule firstRegularPeriodStartDate holidayCalendarIds businessDayConvention - couponPeriod couponPeriodMultiplier issueDate maturityDate rollDay = do - -- CREATE_GENERAL_PERIODIC_SCHEDULE_BEGIN - let - periodicSchedule = PeriodicSchedule with - businessDayAdjustment = - BusinessDayAdjustment with - calendarIds = holidayCalendarIds - convention = businessDayConvention - effectiveDateBusinessDayAdjustment = None - terminationDateBusinessDayAdjustment = None - frequency = - Periodic Frequency with - rollConvention = DOM rollDay - period = Period with - period = couponPeriod - periodMultiplier = couponPeriodMultiplier - effectiveDate = issueDate - firstRegularPeriodStartDate - lastRegularPeriodEndDate = Some maturityDate - stubPeriodType = None - terminationDate = maturityDate - -- CREATE_GENERAL_PERIODIC_SCHEDULE_END - periodicSchedule diff --git a/src/test/daml/Daml/Finance/Util/Test/Common.daml b/src/test/daml/Daml/Finance/Util/Test/Common.daml deleted file mode 100644 index 88b35b8d0..000000000 --- a/src/test/daml/Daml/Finance/Util/Test/Common.daml +++ /dev/null @@ -1,38 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.Test.Common where - -import DA.Assert ((===)) -import DA.List (group, groupBy, groupOn, sort) -import DA.Map qualified as Map (fromList, lookup) -import DA.Optional (fromSome) -import Daml.Finance.Interface.Types.Common.V3.Types (Id(..)) -import Daml.Finance.Util.V4.Common (sortAndGroupOn) -import Daml.Script - -testSortAndGroupOn : Script () -testSortAndGroupOn = script do - let - listToGroup = [1, 2, 3, 3, 2, 1]; - groupedConsequtive = [[1], [2], [3, 3], [2], [1]] - groupedAll = [[1, 1], [2, 2], [3, 3]] - - group listToGroup === groupedConsequtive - group (sort listToGroup) === groupedAll - - groupBy (\a b -> a == b) listToGroup === groupedConsequtive - groupBy (\a b -> a == b) (sort listToGroup) === groupedAll - - groupOn identity listToGroup === groupedConsequtive - groupOn identity (sort listToGroup) === groupedAll - - sortAndGroupOn identity listToGroup === groupedAll - - let - keys = [Id "1", Id "3", Id "222", Id "0"]; - map = Map.fromList [(Id "222", "a"), (Id "0", "b"), (Id "1", "c"), (Id "3", "d")] - lookupAll keys map = fromSome . (`Map.lookup` map) <$> keys - lookupAll keys map === ["c", "d", "a", "b"] - - pure () diff --git a/src/test/daml/Daml/Finance/Util/Test/Date/Calendar.daml b/src/test/daml/Daml/Finance/Util/Test/Date/Calendar.daml deleted file mode 100644 index 5ffd9577e..000000000 --- a/src/test/daml/Daml/Finance/Util/Test/Date/Calendar.daml +++ /dev/null @@ -1,72 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.Test.Date.Calendar where - -import DA.Assert ((===)) -import DA.Date (DayOfWeek(..), Month(..), date) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Util.V4.Date.Calendar (addBusinessDays, adjustDate, isBusinessDay, isHoliday, nextBusinessDay, nextOrSameBusinessDay, nextSameOrLastInMonthBusinessDay, previousBusinessDay, previousOrSameBusinessDay) -import Daml.Script - -calendar : HolidayCalendarData --- CREATE_HOLIDAY_CALENDAR_DATA_BEGIN -calendar = HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [date 2018 Jan 02, date 2018 Jan 31, date 2018 Feb 1] --- CREATE_HOLIDAY_CALENDAR_DATA_END - -test_isHoliday : Script () -test_isHoliday = script do - isHoliday calendar (date 2018 Jan 02) === True - -test_isBusinessDay : Script () -test_isBusinessDay = script do --- TEST_IS_BUSINESS_DAY_BEGIN - isBusinessDay calendar (date 2018 Jan 02) === False - isBusinessDay calendar (date 2018 Jan 03) === True --- TEST_IS_BUSINESS_DAY_END - -test_nextBusinessDay : Script () -test_nextBusinessDay = script do --- TEST_NEXT_BUSINESS_DAY_BEGIN - nextBusinessDay calendar (date 2018 Jan 01) === date 2018 Jan 03 --- TEST_NEXT_BUSINESS_DAY_END - -test_previousBusinessDay : Script () -test_previousBusinessDay = script do --- TEST_PREVIOUS_BUSINESS_DAY_BEGIN - previousBusinessDay calendar (date 2018 Jan 03) === date 2018 Jan 01 --- TEST_PREVIOUS_BUSINESS_DAY_END - -test_nextOrSameBusinessDay : Script () -test_nextOrSameBusinessDay = script do - nextOrSameBusinessDay calendar (date 2018 Jan 01) === date 2018 Jan 01 - -test_previousOrSameBusinessDay : Script () -test_previousOrSameBusinessDay = script do - previousOrSameBusinessDay calendar (date 2018 Jan 03) === date 2018 Jan 03 - -test_nextSameOrLastInMonthBusinessDay : Script () -test_nextSameOrLastInMonthBusinessDay = script do - nextSameOrLastInMonthBusinessDay calendar (date 2018 Jan 31) === date 2018 Jan 30 - -test_addBusinessDays : Script () -test_addBusinessDays = script do --- TEST_ADD_BUSINESS_DAYS_BEGIN - addBusinessDays calendar 5 (date 2018 Jan 01) === date 2018 Jan 09 --- TEST_ADD_BUSINESS_DAYS_END --- TEST_ADD_BUSINESS_DAYS_NEGATIVE_OFFSET_BEGIN - addBusinessDays calendar (-5) (date 2018 Feb 05) === date 2018 Jan 25 --- TEST_ADD_BUSINESS_DAYS_NEGATIVE_OFFSET_END - -test_adjustDate : Script () -test_adjustDate = script do --- TEST_ADJUST_DATE_BEGIN - adjustDate calendar NoAdjustment (date 2018 Mar 31) === (date 2018 Mar 31) - adjustDate calendar Following (date 2018 Mar 31) === (date 2018 Apr 02) - adjustDate calendar ModifiedFollowing (date 2018 Mar 31) === (date 2018 Mar 30) - adjustDate calendar Preceding (date 2018 Apr 01) === (date 2018 Mar 30) - adjustDate calendar ModifiedPreceding (date 2018 Apr 01) === (date 2018 Apr 02) --- TEST_ADJUST_DATE_END diff --git a/src/test/daml/Daml/Finance/Util/Test/Date/DayCount.daml b/src/test/daml/Daml/Finance/Util/Test/Date/DayCount.daml deleted file mode 100644 index 77c4fa454..000000000 --- a/src/test/daml/Daml/Finance/Util/Test/Date/DayCount.daml +++ /dev/null @@ -1,361 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.Test.Date.DayCount where - -import DA.Assert ((===)) -import DA.Date as D -import Daml.Finance.Interface.Types.Date.V3.DayCount (DayCountConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period(..), PeriodEnum(..), RollConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.Schedule (Frequency(..), ScheduleFrequency(..), SchedulePeriod(..), StubPeriodTypeEnum(..)) -import Daml.Finance.Util.V4.Date.DayCount (calcDcf, calcDcf30E360, calcPeriodDcf) -import Daml.Script - -testDcfCalculation : Script () -testDcfCalculation = do - - -- yearly periods - let - d1 = date 2022 Feb 23 - d2 = date 2023 Feb 23 - d3 = date 2026 Feb 23 - - calcDcf Act360 d1 d2 === 1.0138888889 - calcDcf Act365Fixed d1 d2 === 1.0 - calcDcf Act365NL d1 d2 === 1.0 - calcDcf Act365L d1 d2 === 1.0 - calcDcf Basis1 d1 d2 === 1.0 - calcDcf Basis30360 d1 d2 === 1.0 - calcDcf Basis30365 d1 d2 === 1.0 - calcDcf Basis30360ICMA d1 d2 === 1.0 - calcDcf Basis30E3360 d1 d2 === 1.0 - - calcDcf Act365Fixed d1 d3 === 4.002739726 - calcDcf Act365NL d1 d3 === 4.0 - calcDcf Act365L d1 d3 === 4.002739726 - calcDcf Basis30360 d1 d3 === 4.0 - calcDcf Basis30365 d1 d3 === 4.0 - calcDcf Basis30E3360 d1 d3 === 4.0 - - -- from the 30th to the 31st - let - d4 = date 2022 Apr 30 - d5 = date 2022 Jul 31 - - calcDcf Act365Fixed d4 d5 === 0.2520547945 - calcDcf Act365NL d4 d5 === 0.2520547945 - calcDcf Act365L d4 d5 === 0.2520547945 - calcDcf Basis1 d4 d5 === 1.0 - calcDcf Basis30360 d4 d5 === 0.25 - calcDcf Basis30365 d4 d5 === 0.2465753425 - calcDcf Basis30360ICMA d4 d5 === 0.25 - calcDcf Basis30E3360 d4 d5 === 0.25 - - -- from the 31st to the 31st - let - d6 = date 2022 May 31 - d7 = date 2022 Aug 31 - - calcDcf Basis30360 d6 d7 === 0.25 - calcDcf Basis30365 d6 d7 === 0.2465753425 - calcDcf Basis30360ICMA d6 d7 === 0.25 - calcDcf Basis30E3360 d6 d7 === 0.25 - - -- from the 30th to the 30th - let - d8 = date 2022 Apr 30 - d9 = date 2022 Jul 30 - - calcDcf Basis30360 d8 d9 === 0.25 - calcDcf Basis30365 d8 d9 === 0.2465753425 - calcDcf Basis30360ICMA d8 d9 === 0.25 - calcDcf Basis30E3360 d8 d9 === 0.25 - - -- from the 31st to the 30th - let - d10 = date 2022 Mar 31 - d11 = date 2022 Sep 30 - - calcDcf Basis30360 d10 d11 === 0.5 - calcDcf Basis30365 d10 d11 === 0.4931506849 - calcDcf Basis30360ICMA d10 d11 === 0.5 - calcDcf Basis30E3360 d10 d11 === 0.5 - - -- from the 31st to Feb 28th - let - d12 = date 2022 Aug 31 - d13 = date 2023 Feb 28 - - calcDcf Basis30360 d12 d13 === 0.4944444444 - calcDcf Basis30365 d12 d13 === 0.501369863 - calcDcf Basis30360ICMA d12 d13 === 0.4944444444 - calcDcf Basis30E3360 d12 d13 === 0.5 - - calcDcf30E360 True d12 d13 === 0.4944444444 - -- ^ test for 30E360 for a product maturing on Feb 28th - - -- from the 30th to Feb 28th - let - d14 = date 2022 Aug 30 - d15 = date 2023 Feb 28 - - calcDcf Basis30360 d14 d15 === 0.4944444444 - calcDcf Basis30365 d14 d15 === 0.501369863 - calcDcf Basis30360ICMA d14 d15 === 0.4944444444 - calcDcf Basis30E3360 d14 d15 === 0.5 - - -- from Feb 28th to the 30th - let - d16 = date 2022 Feb 28 - d17 = date 2022 Aug 30 - - calcDcf Basis30360 d16 d17 === 0.5055555556 - calcDcf Basis30365 d16 d17 === 0.498630137 - calcDcf Basis30360ICMA d16 d17 === 0.5055555556 - calcDcf Basis30E3360 d16 d17 === 0.5 - - -- from Feb 28th to the 31st - let - d18 = date 2022 Feb 28 - d19 = date 2022 Aug 31 - - calcDcf Basis30360 d18 d19 === 0.5083333333 - calcDcf Basis30365 d18 d19 === 0.501369863 - calcDcf Basis30360ICMA d18 d19 === 0.5055555556 - calcDcf Basis30E3360 d18 d19 === 0.5 - - -- from the 31st to Feb 28th of a leap year - let - d20 = date 2019 Aug 31 - d21 = date 2020 Feb 28 - - calcDcf Act365Fixed d20 d21 === 0.495890411 - calcDcf Act365NL d20 d21 === 0.495890411 - calcDcf Act365L d20 d21 === 0.4945355191 - calcDcf Basis30360 d20 d21 === 0.4944444444 - calcDcf Basis30365 d20 d21 === 0.501369863 - calcDcf Basis30360ICMA d20 d21 === 0.4944444444 - calcDcf Basis30E3360 d20 d21 === 0.4944444444 - - -- from the 30th to Feb 28th of a leap year - let - d22 = date 2019 Aug 30 - d23 = date 2020 Feb 28 - - calcDcf Basis30360 d22 d23 === 0.4944444444 - calcDcf Basis30365 d22 d23 === 0.501369863 - calcDcf Basis30360ICMA d22 d23 === 0.4944444444 - calcDcf Basis30E3360 d22 d23 === 0.4944444444 - - -- from Feb 28th to the 30th of a leap year - let - d24 = date 2020 Feb 28 - d25 = date 2020 Aug 30 - - calcDcf Basis30360 d24 d25 === 0.5055555556 - calcDcf Basis30365 d24 d25 === 0.498630137 - calcDcf Basis30360ICMA d24 d25 === 0.5055555556 - calcDcf Basis30E3360 d24 d25 === 0.5055555556 - - -- from Feb 28th to the 31st of a leap year - let - d26 = date 2020 Feb 28 - d27 = date 2020 Aug 31 - - calcDcf Basis30360 d26 d27 === 0.5083333333 - calcDcf Basis30365 d26 d27 === 0.501369863 - calcDcf Basis30360ICMA d26 d27 === 0.5055555556 - calcDcf Basis30E3360 d26 d27 === 0.5055555556 - - -- from the 31st to Feb 29th of a leap year - let - d28 = date 2019 Aug 31 - d29 = date 2020 Feb 29 - - calcDcf Basis30360 d28 d29 === 0.4972222222 - calcDcf Basis30365 d28 d29 === 0.504109589 - calcDcf Basis30360ICMA d28 d29 === 0.4972222222 - calcDcf Basis30E3360 d28 d29 === 0.5 - - -- from the 30th to Feb 29th of a leap year - let - d30 = date 2019 Aug 31 - d31 = date 2020 Feb 29 - - calcDcf Basis30360 d30 d31 === 0.4972222222 - calcDcf Basis30365 d30 d31 === 0.504109589 - calcDcf Basis30360ICMA d30 d31 === 0.4972222222 - calcDcf Basis30E3360 d30 d31 === 0.5 - - -- from Feb 29th to the 30th of a leap year - let - d32 = date 2020 Feb 29 - d33 = date 2020 Aug 30 - - calcDcf Basis30360 d32 d33 === 0.5027777778 - calcDcf Basis30365 d32 d33 === 0.495890411 - calcDcf Basis30360ICMA d32 d33 === 0.5027777778 - calcDcf Basis30E3360 d32 d33 === 0.5 - - -- from Feb 29th to the 31st of a leap year - let - d34 = date 2020 Feb 29 - d35 = date 2020 Aug 31 - - calcDcf Basis30360 d34 d35 === 0.5055555556 - calcDcf Basis30365 d34 d35 === 0.498630137 - calcDcf Basis30360ICMA d34 d35 === 0.5027777778 - calcDcf Basis30E3360 d34 d35 === 0.5 - - -- Test Act365NL over 1Y for no leap day, one leap day in the middle / at start / at end - calcDcf Act365NL (date 2023 Jan 05) (date 2024 Jan 05) === 1.0 -- no leap day - calcDcf Act365NL (date 2024 Jan 05) (date 2025 Jan 05) === 1.0 -- one leap day in the middle - calcDcf Act365NL (date 2024 Feb 29) (date 2025 Feb 28) === 1.0 -- leap day at start - calcDcf Act365NL (date 2024 Feb 29) (date 2025 Mar 01) === 1.002739726 -- leap day at start - calcDcf Act365NL (date 2023 Feb 28) (date 2024 Feb 28) === 1.0 - calcDcf Act365NL (date 2023 Feb 28) (date 2024 Feb 29) === 1.0 -- leap day at end - - pure () - --- | Test DCF calculation for a regular period. -testPeriodDcfCalculation_regularPeriod : Script () -testPeriodDcfCalculation_regularPeriod = do - let - period = SchedulePeriod with - unadjustedStartDate = D.date 2003 Nov 1 - unadjustedEndDate = D.date 2004 May 1 - adjustedStartDate = D.date 2003 Nov 1 - adjustedEndDate = D.date 2004 May 1 - stubType = None - maturityDate = D.date 2004 May 1 - useAdjustedDatesForDcf = True - frequency = Periodic Frequency with - rollConvention = DOM 1; period = Period with period = M; periodMultiplier = 6 - - calcPeriodDcf ActActAFB period useAdjustedDatesForDcf maturityDate frequency === 0.4972677596 - calcPeriodDcf ActActISDA period useAdjustedDatesForDcf maturityDate frequency === 0.4977243806 - calcPeriodDcf ActActICMA period useAdjustedDatesForDcf maturityDate frequency === 0.5 - calcPeriodDcf Basis30E2360 period useAdjustedDatesForDcf maturityDate frequency === 0.5 - --- | Test DCF calculation when there is a short initial stub period. -testPeriodDcfCalculation_shortInitial: Script () -testPeriodDcfCalculation_shortInitial = do - let - p1 = SchedulePeriod with - unadjustedStartDate = D.date 1999 Feb 1 - unadjustedEndDate = D.date 1999 Jul 1 - adjustedStartDate = D.date 1999 Feb 1 - adjustedEndDate = D.date 1999 Jul 1 - stubType = Some ShortInitial - p2 = SchedulePeriod with - unadjustedStartDate = D.date 1999 Jul 1 - unadjustedEndDate = D.date 2000 Jul 1 - adjustedStartDate = D.date 1999 Jul 1 - adjustedEndDate = D.date 2000 Jul 1 - stubType = None - - maturityDate = D.date 2000 Jul 1 - useAdjustedDatesForDcf = True - frequency = Periodic Frequency with - rollConvention = DOM 1; period = Period with period = M; periodMultiplier = 12 - calcPeriodDcf ActActAFB p1 useAdjustedDatesForDcf maturityDate frequency === 0.4109589041 - calcPeriodDcf ActActAFB p2 useAdjustedDatesForDcf maturityDate frequency === 1.0 - calcPeriodDcf ActActISDA p1 useAdjustedDatesForDcf maturityDate frequency === 0.4109589041 - calcPeriodDcf ActActISDA p2 useAdjustedDatesForDcf maturityDate frequency === 1.0013773486 - calcPeriodDcf ActActICMA p1 useAdjustedDatesForDcf maturityDate frequency === 0.4109589041 - calcPeriodDcf ActActICMA p2 useAdjustedDatesForDcf maturityDate frequency === 1.0 - calcPeriodDcf Basis30E2360 p1 useAdjustedDatesForDcf maturityDate frequency === 0.4166666667 - calcPeriodDcf Basis30E2360 p2 useAdjustedDatesForDcf maturityDate frequency === 1.0 - --- | Test DCF calculation when there is a long initial stub period. -testPeriodDcfCalculation_longInitial: Script () -testPeriodDcfCalculation_longInitial = do - let - p1 = SchedulePeriod with - unadjustedStartDate = D.date 2002 Aug 15 - unadjustedEndDate = D.date 2003 Jul 15 - adjustedStartDate = D.date 2002 Aug 15 - adjustedEndDate = D.date 2003 Jul 15 - stubType = Some LongInitial - p2 = SchedulePeriod with - unadjustedStartDate = D.date 2003 Jul 15 - unadjustedEndDate = D.date 2004 Jan 15 - adjustedStartDate = D.date 2003 Jul 15 - adjustedEndDate = D.date 2004 Jan 15 - stubType = None - maturityDate = D.date 2004 Jan 15 - useAdjustedDatesForDcf = True - frequency = Periodic Frequency with - rollConvention = DOM 15; period = Period with period = M; periodMultiplier = 6 - calcPeriodDcf ActActAFB p1 useAdjustedDatesForDcf maturityDate frequency === 0.9150684932 - calcPeriodDcf ActActAFB p2 useAdjustedDatesForDcf maturityDate frequency === 0.504109589 - calcPeriodDcf ActActISDA p1 useAdjustedDatesForDcf maturityDate frequency === 0.9150684931 - calcPeriodDcf ActActISDA p2 useAdjustedDatesForDcf maturityDate frequency === 0.5040047908 - -- Corrected in updated version of the paper: - -- https://www.isda.org/a/pIJEE/The-Actual-Actual-Day-Count-Fraction-1999.pdf - calcPeriodDcf ActActICMA p1 useAdjustedDatesForDcf maturityDate frequency === 0.9157608696 - calcPeriodDcf ActActICMA p2 useAdjustedDatesForDcf maturityDate frequency === 0.5 - calcPeriodDcf Basis30E2360 p1 useAdjustedDatesForDcf maturityDate frequency === 0.9166666667 - calcPeriodDcf Basis30E2360 p2 useAdjustedDatesForDcf maturityDate frequency === 0.5 - --- | Test DCF calculation when there is a short final stub period. -testPeriodDcfCalculation_shortFinal: Script () -testPeriodDcfCalculation_shortFinal = do - let - p1 = SchedulePeriod with - unadjustedStartDate = D.date 1999 Jul 30 - unadjustedEndDate = D.date 2000 Jan 30 - adjustedStartDate = D.date 1999 Jul 30 - adjustedEndDate = D.date 2000 Jan 30 - stubType = None - p2 = SchedulePeriod with - unadjustedStartDate = D.date 2000 Jan 30 - unadjustedEndDate = D.date 2000 Jun 30 - adjustedStartDate = D.date 2000 Jan 30 - adjustedEndDate = D.date 2000 Jun 30 - stubType = Some ShortFinal - maturityDate = D.date 2000 Jun 30 - useAdjustedDatesForDcf = True - frequency = Periodic Frequency with - rollConvention = DOM 30; period = Period with period = M; periodMultiplier = 6 - calcPeriodDcf ActActAFB p1 useAdjustedDatesForDcf maturityDate frequency === 0.504109589 - calcPeriodDcf ActActAFB p2 useAdjustedDatesForDcf maturityDate frequency === 0.4153005464 - calcPeriodDcf ActActISDA p1 useAdjustedDatesForDcf maturityDate frequency === 0.5038925069 - calcPeriodDcf ActActISDA p2 useAdjustedDatesForDcf maturityDate frequency === 0.4153005464 - calcPeriodDcf ActActICMA p1 useAdjustedDatesForDcf maturityDate frequency === 0.5 - calcPeriodDcf ActActICMA p2 useAdjustedDatesForDcf maturityDate frequency === 0.4175824176 - calcPeriodDcf Basis30E2360 p1 useAdjustedDatesForDcf maturityDate frequency === 0.5 - calcPeriodDcf Basis30E2360 p2 useAdjustedDatesForDcf maturityDate frequency === 0.4166666667 - --- | Test DCF calculation when there is a long final stub period. -testPeriodDcfCalculation_longFinal: Script () -testPeriodDcfCalculation_longFinal = do - let --- CALCULATE_ACTACTISDA_DCF_SCHEDULE_PERIOD_BEGIN - period = SchedulePeriod with - unadjustedStartDate = D.date 1999 Nov 30 - unadjustedEndDate = D.date 2000 Apr 30 - adjustedStartDate = D.date 1999 Nov 30 - adjustedEndDate = D.date 2000 Apr 30 - stubType = Some LongFinal - maturityDate = D.date 2000 Apr 30 - useAdjustedDatesForDcf = True - frequency = Periodic Frequency with - rollConvention = EOM; period = Period with period = M; periodMultiplier = 3 - - calcPeriodDcf ActActISDA period useAdjustedDatesForDcf maturityDate frequency === 0.4155400854 --- CALCULATE_ACTACTISDA_DCF_SCHEDULE_PERIOD_END - calcPeriodDcf ActActAFB period useAdjustedDatesForDcf maturityDate frequency === 0.4153005464 - calcPeriodDcf ActActICMA period useAdjustedDatesForDcf maturityDate frequency === 0.4157608696 - calcPeriodDcf Basis30E2360 period useAdjustedDatesForDcf maturityDate frequency === 0.4166666667 - calcPeriodDcf Basis1 period useAdjustedDatesForDcf maturityDate frequency === 1.0 - -testSimplifiedForTutorial: Script () -testSimplifiedForTutorial = do --- CALCULATE_ACT360_DCF_PERIOD1_BEGIN - calcDcf Act360 (D.date 2018 Dec 31) (D.date 2019 Feb 28) === 0.1638888889 --- CALCULATE_ACT360_DCF_PERIOD1_END --- CALCULATE_ACT360_DCF_PERIOD2AND3_BEGIN - calcDcf Act360 (D.date 2019 Feb 28) (D.date 2019 May 30) === 0.2527777778 - calcDcf Act360 (D.date 2019 May 30) (D.date 2019 Aug 30) === 0.2555555556 --- CALCULATE_ACT360_DCF_PERIOD2AND3_END diff --git a/src/test/daml/Daml/Finance/Util/Test/Date/RollConvention.daml b/src/test/daml/Daml/Finance/Util/Test/Date/RollConvention.daml deleted file mode 100644 index 547620f87..000000000 --- a/src/test/daml/Daml/Finance/Util/Test/Date/RollConvention.daml +++ /dev/null @@ -1,114 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.Test.Date.RollConvention where - -import DA.Assert ((===)) -import DA.Date as D -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period(..), PeriodEnum(..), RollConventionEnum(..)) -import Daml.Finance.Util.V4.Date.RollConvention (addPeriod, next, previous) -import Daml.Script - -test_addPeriod : Script () -test_addPeriod = script do --- TEST_ADD_PERIOD_DAY_WEEK_MONTH_YEAR_BEGIN - addPeriod (D.date 2018 Oct 01) (Period with periodMultiplier = 1; period = D) === - D.date 2018 Oct 02 - addPeriod (D.date 2018 Oct 01) (Period with periodMultiplier = 1; period = W) === - D.date 2018 Oct 08 - addPeriod (D.date 2018 Oct 01) (Period with periodMultiplier = 1; period = M) === - D.date 2018 Nov 01 - addPeriod (D.date 2018 Oct 01) (Period with periodMultiplier = 1; period = Y) === - D.date 2019 Oct 01 --- TEST_ADD_PERIOD_DAY_WEEK_MONTH_YEAR_END --- TEST_ADD_PERIOD_MONTH_END_EDGE_CASE_BEGIN - addPeriod (D.date 2018 Oct 31) (Period with periodMultiplier = 1; period = M) === - D.date 2018 Nov 30 --- TEST_ADD_PERIOD_MONTH_END_EDGE_CASE_END --- TEST_ADD_PERIOD_NEGATIVE_OFFSET_BEGIN - addPeriod (D.date 2018 Nov 30) (Period with periodMultiplier = -1; period = M) === - D.date 2018 Oct 30 - addPeriod (D.date 2018 Jan 30) (Period with periodMultiplier = -1; period = M) === - D.date 2017 Dec 30 --- TEST_ADD_PERIOD_NEGATIVE_OFFSET_END - -test_next : Script () -test_next = script do --- TEST_NEXT_EOM_BEGIN - next (D.date 2018 Oct 31) (Period with periodMultiplier = 1; period = M) EOM === - D.date 2018 Nov 30 --- TEST_NEXT_EOM_END --- TEST_NEXT_DOM1_BEGIN - next (D.date 2018 Oct 01) (Period with periodMultiplier = 1; period = M) (DOM 1) === - D.date 2018 Nov 01 --- TEST_NEXT_DOM1_END --- TEST_NEXT_DOM_PAST_EOM_BEGIN - next (D.date 2018 Oct 31) (Period with periodMultiplier = 1; period = M) (DOM 31) === - D.date 2018 Nov 30 --- TEST_NEXT_DOM_PAST_EOM_END - next (D.date 2018 Nov 30) (Period with periodMultiplier = 1; period = M) (DOM 30) === - D.date 2018 Dec 30 - next (D.date 2018 Nov 30) (Period with periodMultiplier = 1; period = M) (DOM 31) === - D.date 2018 Dec 31 - - -- from end of February - next (D.date 2018 Feb 28) (Period with periodMultiplier = 3; period = M) (DOM 30) === - D.date 2018 May 30 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 3; period = M) (DOM 31) === - D.date 2018 May 31 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 9; period = M) (DOM 30) === - D.date 2018 Nov 30 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 9; period = M) (DOM 31) === - D.date 2018 Nov 30 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 3; period = M) EOM === - D.date 2018 May 31 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 2; period = M) EOM === - D.date 2018 Apr 30 - next (D.date 2018 Nov 30) (Period with periodMultiplier = 3; period = M) (DOM 30) === - D.date 2019 Feb 28 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 2; period = Y) (DOM 28) === - D.date 2020 Feb 28 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 2; period = Y) (DOM 29) === - D.date 2020 Feb 29 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 2; period = Y) (DOM 30) === - D.date 2020 Feb 29 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 2; period = Y) (DOM 31) === - D.date 2020 Feb 29 - next (D.date 2018 Feb 28) (Period with periodMultiplier = 2; period = Y) EOM === - D.date 2020 Feb 29 - next (D.date 2020 Feb 28) (Period with periodMultiplier = 1; period = Y) (DOM 28) === - D.date 2021 Feb 28 - next (D.date 2020 Feb 29) (Period with periodMultiplier = 1; period = Y) (DOM 29) === - D.date 2021 Feb 28 - next (D.date 2020 Feb 29) (Period with periodMultiplier = 3; period = M) (DOM 29) === - D.date 2020 May 29 - next (D.date 2020 Feb 29) (Period with periodMultiplier = 3; period = M) (DOM 30) === - D.date 2020 May 30 - next (D.date 2020 Feb 29) (Period with periodMultiplier = 3; period = M) (DOM 31) === - D.date 2020 May 31 - next (D.date 2020 Feb 29) (Period with periodMultiplier = 3; period = M) EOM === - D.date 2020 May 31 - - -- to end of February - next (D.date 2018 Nov 30) (Period with periodMultiplier = 3; period = M) (DOM 30) === - D.date 2019 Feb 28 - next (D.date 2018 Nov 30) (Period with periodMultiplier = 3; period = M) (DOM 31) === - D.date 2019 Feb 28 - next (D.date 2018 Aug 31) (Period with periodMultiplier = 6; period = M) (DOM 31) === - D.date 2019 Feb 28 - next (D.date 2019 Nov 30) (Period with periodMultiplier = 3; period = M) (DOM 30) === - D.date 2020 Feb 29 - next (D.date 2019 Nov 30) (Period with periodMultiplier = 3; period = M) (DOM 31) === - D.date 2020 Feb 29 --- TEST_NEXT_DOM_PAST_EOFEB_BEGIN - next (D.date 2019 Aug 31) (Period with periodMultiplier = 6; period = M) (DOM 31) === - D.date 2020 Feb 29 --- TEST_NEXT_DOM_PAST_EOFEB_END - -test_previous : Script () -test_previous = script do --- TEST_PREVIOUS_DOM_FROM_EOFEB_BEGIN - previous (D.date 2020 Feb 29) (Period with periodMultiplier = 6; period = M) (DOM 31) === - D.date 2019 Aug 31 --- TEST_PREVIOUS_DOM_FROM_EOFEB_END - diff --git a/src/test/daml/Daml/Finance/Util/Test/Date/Schedule.daml b/src/test/daml/Daml/Finance/Util/Test/Date/Schedule.daml deleted file mode 100644 index db2511fce..000000000 --- a/src/test/daml/Daml/Finance/Util/Test/Date/Schedule.daml +++ /dev/null @@ -1,426 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.Test.Date.Schedule where - -import DA.Assert ((===)) -import DA.Date as D -import DA.List (head, init, tail) -import Daml.Finance.Interface.Types.Date.V3.Calendar (BusinessDayAdjustment(..), BusinessDayConventionEnum(..), HolidayCalendarData(..)) -import Daml.Finance.Interface.Types.Date.V3.RollConvention (Period(..), PeriodEnum(..), RollConventionEnum(..)) -import Daml.Finance.Interface.Types.Date.V3.Schedule (Frequency(..), PeriodicSchedule(..), Schedule(..), ScheduleFrequency(..), SchedulePeriod(..), StubPeriodTypeEnum(..)) -import Daml.Finance.Util.V4.Date.Schedule (createSchedule) -import Daml.Script - -cals : [HolidayCalendarData] -cals = [ HolidayCalendarData with - id = "USNY" - weekend = [Saturday, Sunday] - holidays = [D.date 2019 Dec 19] - ] - -example : PeriodicSchedule -example = PeriodicSchedule with - businessDayAdjustment = - BusinessDayAdjustment with calendarIds = ["USNY"]; convention = ModifiedFollowing - effectiveDateBusinessDayAdjustment = None - terminationDateBusinessDayAdjustment = None - frequency = Periodic Frequency with - rollConvention = DOM 30; period = Period with period = M; periodMultiplier = 3 - effectiveDate = D.date 2018 Nov 15 - firstRegularPeriodStartDate = Some $ D.date 2018 Nov 30 - lastRegularPeriodEndDate = Some $ D.date 2019 Nov 30 - stubPeriodType = None - terminationDate = D.date 2019 Dec 15 - -expectedResultBothStub : Schedule -expectedResultBothStub = - [ SchedulePeriod with - unadjustedStartDate = D.date 2018 Nov 15 - unadjustedEndDate = D.date 2018 Nov 30 - adjustedStartDate = D.date 2018 Nov 15 - adjustedEndDate = D.date 2018 Nov 30 - stubType = Some ShortInitial - , SchedulePeriod with - unadjustedStartDate = D.date 2018 Nov 30 - unadjustedEndDate = D.date 2019 Feb 28 - adjustedStartDate = D.date 2018 Nov 30 - adjustedEndDate = D.date 2019 Feb 28 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Feb 28 - unadjustedEndDate = D.date 2019 May 30 - adjustedStartDate = D.date 2019 Feb 28 - adjustedEndDate = D.date 2019 May 30 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 May 30 - unadjustedEndDate = D.date 2019 Aug 30 - adjustedStartDate = D.date 2019 May 30 - adjustedEndDate = D.date 2019 Aug 30 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Aug 30 - unadjustedEndDate = D.date 2019 Nov 30 - adjustedStartDate = D.date 2019 Aug 30 - adjustedEndDate = D.date 2019 Nov 29 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Nov 30 - unadjustedEndDate = D.date 2019 Dec 15 - adjustedStartDate = D.date 2019 Nov 29 - adjustedEndDate = D.date 2019 Dec 16 - stubType = Some ShortFinal - ] - -setDates : Date -> Optional Date -> Optional Date -> Date -> PeriodicSchedule -> PeriodicSchedule -setDates effective firstRegularStart lastRegularEnd termination schedule = - schedule with - effectiveDate = effective - firstRegularPeriodStartDate = firstRegularStart - lastRegularPeriodEndDate = lastRegularEnd - terminationDate = termination - -setStubType : StubPeriodTypeEnum -> PeriodicSchedule -> PeriodicSchedule -setStubType stubType schedule = schedule with stubPeriodType = Some stubType - -test_base : Script () -test_base = script do - createSchedule cals example === expectedResultBothStub - -test_reg_periods_only : Script () -test_reg_periods_only = script do - -- Regular periods only - let - testCase = setDates (D.date 2018 Nov 30) None None (D.date 2019 Nov 30) example - expectedResult = (tail . init) expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_regStart_equal_effective_smaller_termination : Script () -test_regStart_equal_effective_smaller_termination = script do - -- RegStart == Effective < Termination - let - testCase = - setDates (D.date 2018 Nov 30) (Some $ D.date 2018 Nov 30) None (D.date 2019 Nov 30) example - expectedResult = (tail . init) expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_regStart_smaller_effective_smaller_termination : Script () -test_regStart_smaller_effective_smaller_termination = script do - -- RegStart < Effective < Termination - let - testCase = - setDates (D.date 2018 Nov 15) (Some $ D.date 2018 Nov 30) None (D.date 2019 Nov 30) example - expectedResult = init expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_effective_smaller_regStart_equal_termination : Script () -test_effective_smaller_regStart_equal_termination = script do - -- Effective < RegStart == Termination - let - testCase = - setDates (D.date 2018 Nov 15) (Some $ D.date 2019 Nov 30) None (D.date 2019 Nov 30) example - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2018 Nov 15 - unadjustedEndDate = D.date 2019 Nov 30 - adjustedStartDate = D.date 2018 Nov 15 - adjustedEndDate = D.date 2019 Nov 29 - stubType = Some LongInitial - ] - createSchedule cals testCase === expectedResult - -test_regEnd_equal_effective_smaller_termination : Script () -test_regEnd_equal_effective_smaller_termination = script do - -- RegEnd == Effective < Termination - let - testCase = - setDates (D.date 2018 Nov 30) None (Some $ D.date 2018 Nov 30) (D.date 2019 Nov 30) example - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2018 Nov 30 - unadjustedEndDate = D.date 2019 Nov 30 - adjustedStartDate = D.date 2018 Nov 30 - adjustedEndDate = D.date 2019 Nov 29 - stubType = Some LongFinal - ] - createSchedule cals testCase === expectedResult - -test_effective_smaller_regEnd_smaller_termination : Script () -test_effective_smaller_regEnd_smaller_termination = script do - -- Effective < RegEnd < Termination - let - testCase = - setDates (D.date 2018 Nov 30) None (Some $ D.date 2019 Nov 30) (D.date 2019 Dec 15) example - createSchedule cals testCase === tail expectedResultBothStub - -test_effective_smaller_termination_equal_regEnd : Script () -test_effective_smaller_termination_equal_regEnd = script do - -- Effective < Termination == RegEnd - let - testCase = - setDates (D.date 2018 Nov 30) None (Some $ D.date 2019 Nov 30) (D.date 2019 Nov 30) example - expectedResult = (tail . init) expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_effective_smaller_firstReg_equal_lastReg_smaller_termination : Script () -test_effective_smaller_firstReg_equal_lastReg_smaller_termination = script do - -- Effective < FirstRegular == LastRegular < Termination - let - testCase = - setDates (D.date 2018 Oct 15) (Some $ D.date 2019 Jan 30) (Some $ D.date 2019 Jan 30) - (D.date 2019 Dec 15) example - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2018 Oct 15 - unadjustedEndDate = D.date 2019 Jan 30 - adjustedStartDate = D.date 2018 Oct 15 - adjustedEndDate = D.date 2019 Jan 30 - stubType = Some LongInitial - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Jan 30 - unadjustedEndDate = D.date 2019 Dec 15 - adjustedStartDate = D.date 2019 Jan 30 - adjustedEndDate = D.date 2019 Dec 16 - stubType = Some LongFinal - ] - createSchedule cals testCase === expectedResult - -test_shortInitial : Script () -test_shortInitial = script do - -- Implicit Stubs - -- exact match - let - testCase = - setDates (D.date 2018 Nov 30) None None (D.date 2019 Nov 30) - $ setStubType ShortInitial - $ example - expectedResult = (tail . init) expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_longFinal : Script () -test_longFinal = script do - let - testCase = - setDates (D.date 2018 Nov 30) None None (D.date 2019 Nov 30) - $ setStubType LongFinal - $ example - expectedResult = (tail . init) expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_twoPeriods_shortInitial : Script () -test_twoPeriods_shortInitial = script do - -- Two Periods ShortInitial - let - testCase = - setDates (D.date 2018 Nov 15) None None (D.date 2019 Feb 28) - $ setStubType ShortInitial - $ example - expectedResult = take 2 expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_twoPeriods_longInitial : Script () -test_twoPeriods_longInitial = script do - -- Two Periods LongInitial - let - testCase = - setDates (D.date 2018 Nov 15) None None (D.date 2019 Feb 28) - $ setStubType LongInitial - $ example - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2018 Nov 15 - unadjustedEndDate = D.date 2019 Feb 28 - adjustedStartDate = D.date 2018 Nov 15 - adjustedEndDate = D.date 2019 Feb 28 - stubType = Some LongInitial - ] - createSchedule cals testCase === expectedResult - -test_singlePeriod_shortInitial : Script () -test_singlePeriod_shortInitial = script do - -- Single Period ShortInitial - let - testCase = - setDates (D.date 2018 Nov 15) None None (D.date 2018 Nov 30) - $ setStubType ShortInitial - $ example - expectedResult = take 1 expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_singlePeriod_longInitial : Script () -test_singlePeriod_longInitial = script do - -- Single Period LongInitial - let - testCase = - setDates (D.date 2018 Nov 15) None None (D.date 2018 Nov 30) - $ setStubType LongInitial - $ example - expectedResultExceptStubInfo = head expectedResultBothStub - expectedResult = [expectedResultExceptStubInfo with stubType = Some LongInitial] - createSchedule cals testCase === expectedResult - -test_twoPeriods_shortFinal : Script () -test_twoPeriods_shortFinal = script do - -- Two Periods ShortFinal - let - testCase = - setDates (D.date 2019 Aug 30) None None (D.date 2019 Dec 15) - $ setStubType ShortFinal - $ example - expectedResult = drop 4 expectedResultBothStub - createSchedule cals testCase === expectedResult - -test_twoPeriods_longFinal : Script () -test_twoPeriods_longFinal = script do - -- Two Periods LongFinal - let - testCase = - setDates (D.date 2019 Aug 30) None None (D.date 2019 Dec 15) - $ setStubType LongFinal - $ example - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2019 Aug 30 - unadjustedEndDate = D.date 2019 Dec 15 - adjustedStartDate = D.date 2019 Aug 30 - adjustedEndDate = D.date 2019 Dec 16 - stubType = Some LongFinal - ] - createSchedule cals testCase === expectedResult - -test_singlePeriod_shortFinal : Script () -test_singlePeriod_shortFinal = script do - -- Single Period ShortFinal - let - testCase = - setDates (D.date 2019 Nov 30) None None (D.date 2019 Dec 15) - $ setStubType ShortFinal - $ example - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2019 Nov 30 - unadjustedEndDate = D.date 2019 Dec 15 - adjustedStartDate = D.date 2019 Nov 29 - adjustedEndDate = D.date 2019 Dec 16 - stubType = Some ShortFinal - ] - createSchedule cals testCase === expectedResult - -test_singlePeriod_longFinal : Script () -test_singlePeriod_longFinal = script do - -- Single Period LongFinal - let - testCase = - setDates (D.date 2019 Nov 30) None None (D.date 2019 Dec 15) - $ setStubType LongFinal - $ example - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2019 Nov 30 - unadjustedEndDate = D.date 2019 Dec 15 - adjustedStartDate = D.date 2019 Nov 29 - adjustedEndDate = D.date 2019 Dec 16 - stubType = Some LongFinal - ] - createSchedule cals testCase === expectedResult - -testSimplifiedForTutorial : Script () -testSimplifiedForTutorial = script do - let --- CREATE_PERIODIC_SCHEDULE_BEGIN - periodicSchedule = PeriodicSchedule with - businessDayAdjustment = - BusinessDayAdjustment with calendarIds = ["USNY"]; convention = ModifiedFollowing - effectiveDateBusinessDayAdjustment = None - terminationDateBusinessDayAdjustment = None - frequency = Periodic Frequency with - rollConvention = DOM 30; period = Period with period = M; periodMultiplier = 3 - effectiveDate = D.date 2018 Nov 30 - firstRegularPeriodStartDate = None - lastRegularPeriodEndDate = None - stubPeriodType = None - terminationDate = D.date 2019 Nov 30 --- CREATE_PERIODIC_SCHEDULE_END - --- CREATE_EXPECTED_SCHEDULE_RESULT_BEGIN - expectedResult = - [ SchedulePeriod with - unadjustedStartDate = D.date 2018 Nov 30 - unadjustedEndDate = D.date 2019 Feb 28 - adjustedStartDate = D.date 2018 Nov 30 - adjustedEndDate = D.date 2019 Feb 28 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Feb 28 - unadjustedEndDate = D.date 2019 May 30 - adjustedStartDate = D.date 2019 Feb 28 - adjustedEndDate = D.date 2019 May 30 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 May 30 - unadjustedEndDate = D.date 2019 Aug 30 - adjustedStartDate = D.date 2019 May 30 - adjustedEndDate = D.date 2019 Aug 30 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Aug 30 - unadjustedEndDate = D.date 2019 Nov 30 - adjustedStartDate = D.date 2019 Aug 30 - adjustedEndDate = D.date 2019 Nov 29 - stubType = None - ] --- CREATE_EXPECTED_SCHEDULE_RESULT_END - --- CREATE_SCHEDULE_BEGIN - createSchedule cals periodicSchedule === expectedResult --- CREATE_SCHEDULE_END - - let --- CREATE_PERIODIC_SCHEDULE_WITH_STUB_BEGIN - periodicScheduleWithStub = PeriodicSchedule with - businessDayAdjustment = - BusinessDayAdjustment with calendarIds = ["USNY"]; convention = ModifiedFollowing - effectiveDateBusinessDayAdjustment = None - terminationDateBusinessDayAdjustment = None - frequency = Periodic Frequency with - rollConvention = DOM 30; period = Period with period = M; periodMultiplier = 3 - effectiveDate = D.date 2018 Dec 30 - firstRegularPeriodStartDate = Some $ D.date 2019 Feb 28 - lastRegularPeriodEndDate = None - stubPeriodType = None - terminationDate = D.date 2019 Nov 30 --- CREATE_PERIODIC_SCHEDULE_WITH_STUB_END - --- CREATE_EXPECTED_SCHEDULE_RESULT_WITH_STUB_BEGIN - expectedResultWithStub = - [ SchedulePeriod with - unadjustedStartDate = D.date 2018 Dec 30 - unadjustedEndDate = D.date 2019 Feb 28 - adjustedStartDate = D.date 2018 Dec 31 - adjustedEndDate = D.date 2019 Feb 28 - stubType = Some ShortInitial - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Feb 28 - unadjustedEndDate = D.date 2019 May 30 - adjustedStartDate = D.date 2019 Feb 28 - adjustedEndDate = D.date 2019 May 30 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 May 30 - unadjustedEndDate = D.date 2019 Aug 30 - adjustedStartDate = D.date 2019 May 30 - adjustedEndDate = D.date 2019 Aug 30 - stubType = None - , SchedulePeriod with - unadjustedStartDate = D.date 2019 Aug 30 - unadjustedEndDate = D.date 2019 Nov 30 - adjustedStartDate = D.date 2019 Aug 30 - adjustedEndDate = D.date 2019 Nov 29 - stubType = None - ] --- CREATE_EXPECTED_SCHEDULE_RESULT_WITH_STUB_END - --- CREATE_SCHEDULE_WITH_STUB_BEGIN - createSchedule cals periodicScheduleWithStub === expectedResultWithStub --- CREATE_SCHEDULE_WITH_STUB_END diff --git a/src/test/daml/Daml/Finance/Util/Test/Disclosure.daml b/src/test/daml/Daml/Finance/Util/Test/Disclosure.daml deleted file mode 100644 index 745e872d5..000000000 --- a/src/test/daml/Daml/Finance/Util/Test/Disclosure.daml +++ /dev/null @@ -1,160 +0,0 @@ --- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. --- SPDX-License-Identifier: Apache-2.0 - -module Daml.Finance.Util.Test.Disclosure where - -import DA.Assert ((===)) -import DA.Map qualified as Map (fromList, lookup, member) -import DA.Optional (fromSome) -import DA.Set qualified as Set (fromList, singleton) -import Daml.Finance.Interface.Types.Common.V3.Types (PartiesMap) -import Daml.Finance.Interface.Util.V3.Disclosure qualified as Disclosure (AddObservers(..), I, RemoveObservers(..), SetObservers(..), View(..), flattenObservers) -import Daml.Finance.Test.Util.Common (createParties) -import Daml.Finance.Util.V4.Disclosure (addObserversImpl, removeObserversImpl, setObserversImpl) -import Daml.Script - -template TestDisclosure - with - p1 : Party - p2 : Party - observers : PartiesMap - where - signatory p1, p2 - observer Disclosure.flattenObservers observers - - interface instance Disclosure.I for TestDisclosure where - view = Disclosure.View with disclosureControllers = Set.fromList [p1, p2]; observers - setObservers = setObserversImpl @TestDisclosure @Disclosure.I this None - addObservers = addObserversImpl @TestDisclosure @Disclosure.I this None - removeObservers = removeObserversImpl @TestDisclosure @Disclosure.I this None - -run : Script () -run = script do - -- Create parties - [custodian, issuer, alice, bob, charlie] <- - createParties ["Custodian", "Issuer", "Alice", "Bob", "Charlie"] - - -- Create test contract to disclose - cid <- toInterfaceContractId @Disclosure.I <$> submit [custodian, issuer] do - createCmd TestDisclosure with p1 = custodian; p2 = issuer; observers = mempty - - -- Set observers - -- only disclosure controllers, i.e., custodian or issuer, can `SetObservers`. - cid <- submit custodian do - exerciseCmd cid Disclosure.SetObservers with - disclosers = Set.singleton custodian - newObservers = Map.fromList [("context 1", Set.fromList [alice, bob])] - submitMustFail alice do - exerciseCmd cid Disclosure.SetObservers with - disclosers = Set.singleton alice - newObservers = Map.fromList [("context 2", Set.fromList [alice, bob])] - cid <- submit issuer do - exerciseCmd cid Disclosure.SetObservers with - disclosers = Set.singleton issuer - newObservers = Map.fromList - [("context 1", Set.fromList [alice, bob]), ("context 2", Set.fromList [alice, bob])] - - -- Add observers - -- any disclosure controller can `AddObservers`, but no others - -- add observers (for context 3) - cid <- submit custodian do - exerciseCmd cid Disclosure.AddObservers with - disclosers = Set.singleton custodian - observersToAdd = ("context 3", Set.fromList [alice, bob, charlie]) - -- add observers (for context 4) - cid <- submit issuer do - exerciseCmd cid Disclosure.AddObservers with - disclosers = Set.singleton issuer - observersToAdd = ("context 4", Set.fromList [alice, bob]) - -- a non-disclosure controller can't add observers - submitMustFail alice do - exerciseCmd cid Disclosure.AddObservers with - disclosers = Set.singleton alice; observersToAdd = ("context 4", Set.singleton charlie) - -- add obsevers (for context 4) - cid <- submit issuer do - exerciseCmd cid Disclosure.AddObservers with - disclosers = Set.singleton issuer - observersToAdd = ("context 4", Set.singleton charlie) - - -- Remove observers - -- any disclosure controller can remove observers (from any context) - -- remove observer party (for context 3) - Some cid <- submit custodian do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton custodian - observersToRemove = ("context 3", Set.singleton charlie) - -- remove observer party (no update necessary) - None <- submit issuer do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton issuer - observersToRemove = ("context 3", Set.singleton charlie) - -- remove observer party (for context 3) - Some cid <- submit issuer do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton issuer - observersToRemove = ("context 3", Set.fromList [alice, bob]) - -- assert no context 3 - Some testDisclosure <- queryContractId issuer $ fromInterfaceContractId @TestDisclosure cid - Map.member "context 3" testDisclosure.observers === False - -- any party of a context can remove any other party in the same context - Some cid <- submit alice do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton alice - observersToRemove = ("context 4", Set.singleton charlie) - -- unauthorized party can't remove observer party - submitMustFail charlie do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton charlie - observersToRemove = ("context 4", Set.singleton alice) - Some cid <- submit bob do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton bob - observersToRemove = ("context 4", Set.fromList [alice, bob]) - -- assert no context 4 - Some testDisclosure <- queryContractId issuer $ fromInterfaceContractId @TestDisclosure cid - Map.member "context 4" testDisclosure.observers === False - -- can't remove a party for a non-existent context - None <- submit issuer do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton issuer - observersToRemove = ("non-existing context", Set.fromList [alice, bob]) - -- a disclosure controller can remove all parties - Some cid <- submit custodian do - exerciseCmd cid - Disclosure.RemoveObservers with - disclosers = Set.singleton custodian - observersToRemove = ("context 1", Set.fromList [alice, bob, custodian]) - -- assert no context 1 - Some testDisclosure <- queryContractId issuer $ fromInterfaceContractId @TestDisclosure cid - Map.member "context 1" testDisclosure.observers === False - - -- Any authorized party can remove observers together with an unauthorized party - Some cid <- submit [alice, charlie] do - exerciseCmd cid Disclosure.RemoveObservers with - disclosers = Set.fromList [alice, charlie] - observersToRemove = ("context 2", Set.fromList [alice, bob]) - -- assert no context 2 - Some testDisclosure <- queryContractId custodian $ fromInterfaceContractId @TestDisclosure cid - Map.member "context 2" testDisclosure.observers === False - -- Any authorized party can set observers together with an unauthorized party - cid <- submit [custodian, charlie] do - exerciseCmd cid Disclosure.SetObservers with - disclosers = Set.fromList [custodian, charlie] - newObservers = Map.fromList [("context 2", Set.singleton alice)] - -- Any authorized party can add observers together with an unauthorized party - cid <- submit [custodian, charlie] do - exerciseCmd cid Disclosure.AddObservers with - disclosers = Set.fromList [custodian, charlie] - observersToAdd = ("context 2", Set.singleton bob) - -- assert context 2 is set properly - Some testDisclosure <- queryContractId custodian $ fromInterfaceContractId @TestDisclosure cid - fromSome (Map.lookup "context 2" testDisclosure.observers) === Set.fromList [alice, bob] - - pure () diff --git a/tools/packell/README.MD b/tools/packell/README.MD index d37d64dc3..04cf1d895 100644 --- a/tools/packell/README.MD +++ b/tools/packell/README.MD @@ -67,4 +67,4 @@ To cross compile in the opposite direction, change the system variable in the co Compilation of the Linux `x86_64` Packell executable is done via the `CI` by the job `packell_linux_x86_64` and will be made available as an `artifact` upon successful completion of -the `CI`. To run this job, simply create a branch beginning with `packell-release`. +the `CI`. To run this job, simply create a branch beginning with `packell-build`. diff --git a/tools/packell/packell.cabal b/tools/packell/packell.cabal index 3f5a07efa..ef6c369c7 100644 --- a/tools/packell/packell.cabal +++ b/tools/packell/packell.cabal @@ -21,6 +21,7 @@ executable packell shelly, text, time, + containers, utf8-string, vector, yaml diff --git a/tools/packell/src/main/haskell/Daml/DataDependencies.hs b/tools/packell/src/main/haskell/Daml/DataDependencies.hs index afae56f28..35cd7703a 100644 --- a/tools/packell/src/main/haskell/Daml/DataDependencies.hs +++ b/tools/packell/src/main/haskell/Daml/DataDependencies.hs @@ -21,18 +21,26 @@ import qualified Daml.Version as Version (increment, updateVersion) import qualified Daml.Yaml as Daml (Config(..), damlConfigFile, source, version, writeDamlConfig) import Data.Foldable (foldlM) import Data.Functor ((<&>)) -import Data.List (sort, group, nub, isPrefixOf, find, delete, (\\)) +import Data.List (sort, group, nub, isPrefixOf, find, delete, (\\), isInfixOf) import Data.Maybe (catMaybes, maybeToList) import qualified Data.Text as T (pack) import qualified GHC.List as L (concat) import qualified Package.Yaml as Package (Config(..), Remote(..), Local(..), local, getLocalBaseModule, getLocalName, getLocalRepoName, getRemoteBaseModule, getRemotePackages, getRemoteRepoName, path) import System.Directory (listDirectory, makeAbsolute, doesFileExist, doesDirectoryExist) -import System.FilePath ((), isExtensionOf) +import System.FilePath ((), isExtensionOf, splitDirectories, joinPath) import System.FilePattern.Directory (getDirectoryFiles, FilePattern) -- | The dar file extension. darExtension :: String = ".dar" +-- | Determines whether a given file path refers to a Splice API dependency. +-- These dependencies are special-cased and should be excluded from processing. +isSpliceDep :: FilePath -> Bool +isSpliceDep p = + "splice-api-token-holding-v1" `isInfixOf` p || + "splice-api-token-metadata-v1" `isInfixOf` p + + -- | Updates data-dependencies of a list of packages matches the usage in their sources. update :: FilePath -> Package.Config -> [Daml.Package] -> IO () update root config localPackages = @@ -117,9 +125,17 @@ processDataDependency' root config allPackages package = pure $ case (currentDataDependenciesMaybe, newDataDependencies damlModules) of (Nothing, []) -> Nothing (Nothing, xs) -> justUpdatePackage xs - (Just cur, xs) - | cur == xs -> Nothing - | otherwise -> justUpdatePackage xs + (Just cur, xs) -> + let + spliceCur = filter isSpliceDep cur + merged = sort . nub $ xs ++ spliceCur + + norm :: [FilePath] -> [FilePath] + norm = sort . nub + in + if norm cur == norm merged + then Nothing + else justUpdatePackage merged -- | Updates a package version, if required. validateVersion :: UpdatedConfig -> IO (Maybe UpdatedConfig) @@ -134,42 +150,78 @@ validateVersion UpdatedConfig{package, updatedConfig} = Just version -> pure . Just . UpdatedConfig package $ Version.updateVersion updatedConfig version _ -> pure Nothing +-- | Computes the relative path from the current package directory to the +-- target dependency DAR file. +computeRelativeDataDep :: FilePath -> FilePath -> FilePath +computeRelativeDataDep pkgDir depDar = + let + pkgParts = splitDirectories pkgDir + darParts = splitDirectories depDar + + -- Drop the shared prefix of both paths + dropCommonPrefix (x:xs) (y:ys) + | x == y = dropCommonPrefix xs ys + dropCommonPrefix xs ys = (xs, ys) + + (pkgRest, darRest) = dropCommonPrefix pkgParts darParts + + ups = replicate (length pkgRest) ".." + final = ups ++ darRest + in + joinPath final + + -- | Creates the data dependencies for a package based of the sourced daml modules. generateDataDependencies :: Package.Config -> [Daml.Package] -> Daml.Package -> [String] -> [FilePath] generateDataDependencies config allPackages package damlModules = let + -- Directory of this package (e.g. main/daml/Daml.Finance.Data.V4) + pkgDir = "package" Package.path (Daml.packageConfig package) + remotePackages = Package.getRemotePackages config - localPackages = package `delete` allPackages + localPackages = package `delete` allPackages + getDataDependencies getBaseModule packages = nub $ foldl (\acc m -> acc ++ filter (flip isPrefixOf m . getBaseModule) packages) [] damlModules + remoteDataDependencies = getDataDependencies Package.getRemoteBaseModule remotePackages localDataDependencies = getDataDependencies (Package.getLocalBaseModule . Daml.packageConfig) localPackages in - sort $ map (generateRemoteDependency config) remoteDataDependencies ++ map (generateLocalDependency config) localDataDependencies + sort $ map (generateRemoteDependency config pkgDir) remoteDataDependencies ++ map (generateLocalDependency config pkgDir) localDataDependencies -- | Generate a data-dependency for remote packages. -- Format is /// -generateRemoteDependency :: Package.Config -> Package.Remote -> FilePath -generateRemoteDependency config remote = - Package.installDir config - Package.getRemoteRepoName remote - Package.tag remote - Package.darName remote +generateRemoteDependency :: Package.Config -> FilePath -> Package.Remote -> FilePath +generateRemoteDependency config pkgDir remote = + computeRelativeDataDep pkgDir fullDarPath + where + fullDarPath = + Package.installDir config + Package.getRemoteRepoName remote + Package.tag remote + Package.darName remote -- | Generate a data-dependency for local packages. --- Format is //// -generateLocalDependency :: Package.Config -> Daml.Package -> String -generateLocalDependency config package = - Package.installDir config - Package.getLocalRepoName (Package.local config) - (Package.getLocalName . Daml.packageConfig) package - (Daml.version . Daml.damlConfig) package - generateDarName (Daml.name . Daml.damlConfig $ package) (Daml.version . Daml.damlConfig $ package) +-- //// +generateLocalDependency :: Package.Config -> FilePath -> Daml.Package -> FilePath +generateLocalDependency config pkgDir pkg = + computeRelativeDataDep pkgDir fullDarPath + where + pkgConfig = Daml.damlConfig pkg + pkgName = Daml.name pkgConfig + pkgVersion = Daml.version pkgConfig + + fullDarPath = + "package" + Package.path (Daml.packageConfig pkg) + ".daml/dist" + generateDarName pkgName pkgVersion + -- | Generate a daml dar file name. -generateDarName :: String -> String -> String +generateDarName :: String -> String -> FilePath generateDarName name version = name <> "-" <> version <> darExtension -- | Update the data-dependencies of a daml config file. updateDamlDataDependencies :: Daml.Config -> [FilePath] -> Daml.Config updateDamlDataDependencies config [] = config { Daml.dataDependencies = Nothing } -updateDamlDataDependencies config xs = config { Daml.dataDependencies = Just xs } +updateDamlDataDependencies config xs = config { Daml.dataDependencies = Just xs } \ No newline at end of file