> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# Splice.Testing.Apps.TradingApp

> Documentation for Splice.Testing.Apps.TradingApp

An example of how to build an OTC trading app for multi-leg standard token trades.

Used as part of the testing infrastructure to test the DvP workflows based on the token standard.

## Templates

**template** OTCTrade

> Signatory: venue, tradingParties transferLegs
>
> | Field | Type | Description |
> | - | - | - |
> | venue | [Party](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-party-57932) | |
> | transferLegs | [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) TransferLeg | |
> | tradeCid | [ContractId](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-contractid-95282) OTCTradeProposal | |
> | createdAt | [Time](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-time-63886) | |
> | prepareUntil | [Time](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-time-63886) | |
> | settleBefore | [Time](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-time-63886) | |
>
> * **Choice** Archive
>
>   Controller: venue, tradingParties transferLegs
>
>   Returns: ()
>
>   (no fields)
>
> * **Choice** OTCTrade\_Cancel
>
>   Controller: venue
>
>   Returns: [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) ([Optional](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-prelude-optional-37153) Allocation\_CancelResult)
>
>   | Field | Type | Description |
>   | - | - | - |
>   | allocationsWithContext | [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) ([ContractId](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-contractid-95282) Allocation, ExtraArgs) | |
>
> * **Choice** OTCTrade\_Settle
>
>   Controller: venue
>
>   Returns: [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) Allocation\_ExecuteTransferResult
>
>   | Field | Type | Description |
>   | - | - | - |
>   | allocationsWithContext | [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) ([ContractId](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-contractid-95282) Allocation, ExtraArgs) | |
>
> * **interface instance** AllocationRequest **for** OTCTrade

**template** OTCTradeProposal

> Signatory: approvers
>
> | Field | Type | Description |
> | - | - | - |
> | venue | [Party](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-party-57932) | |
> | tradeCid | [Optional](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-prelude-optional-37153) ([ContractId](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-contractid-95282) OTCTradeProposal) | |
> | transferLegs | [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) TransferLeg | |
> | approvers | \[[Party](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-party-57932)] | Parties that have approved the proposal |
>
> * **Choice** Archive
>
>   Controller: approvers
>
>   Returns: ()
>
>   (no fields)
>
> * **Choice** OTCTradeProposal\_Accept
>
>   Controller: approver
>
>   Returns: [ContractId](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-contractid-95282) OTCTradeProposal
>
>   | Field | Type | Description |
>   | - | - | - |
>   | approver | [Party](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-party-57932) | |
>
> * **Choice** OTCTradeProposal\_InitiateSettlement
>
>   Controller: venue
>
>   Returns: [ContractId](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-contractid-95282) OTCTrade
>
>   | Field | Type | Description |
>   | - | - | - |
>   | prepareUntil | [Time](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-time-63886) | |
>   | settleBefore | [Time](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-time-63886) | |
>
> * **Choice** OTCTradeProposal\_Reject
>
>   Controller: trader
>
>   Returns: ()
>
>   | Field | Type | Description |
>   | - | - | - |
>   | trader | [Party](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-party-57932) | |

## Functions

tradeAllocations
: SettlementInfo -> [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) TransferLeg -> [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) AllocationSpecification

tradingParties
: [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) TransferLeg -> Set [Party](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-party-57932)

require
: [CanAssert](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-da-internal-assert-canassert-67323) m => [Text](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-text-51952) -> [Bool](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-bool-66265) -> m ()

Check whether a required condition is true. If it's not, abort the transaction with a message saying that the requirement was not met.

makeTradeRef
: [ContractId](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-contractid-95282) OTCTradeProposal -> Reference

zipTextMaps
: [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) a -> [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) b -> [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) ([Optional](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-prelude-optional-37153) a, [Optional](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-prelude-optional-37153) b)

forTextMapWithKey
: [Applicative](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-da-internal-prelude-applicative-9257) f => [TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) a -> ([Text](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-text-51952) -> a -> f b) -> f ([TextMap](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-da-internal-lf-textmap-11691) b)
