Splice.Testing.Apps.TradingAppV2
An example of how to build an OTC trading app that supports V1/V2 mixed settlements with extra privacy for V2 allocations..
Used as part of the testing infrastructure to test the V2 token standard DvP workflows.
Templates
template OTCTrade
A matched trade ready to settle.
Signatory: venue
Field
Type
Description
venue
tradeLegs
[TradeLeg]
Transfers to settle.
createdAt
When the matched trade was created on-ledger.
settleAt
When the trade should be settled by.
settlementDeadline
Deadline for when the settlement should be completed.
Choice Archive
Controller: venue
Returns: ()
(no fields)
Choice OTCTrade_Cancel
Controller: venue
Returns: OTCTrade_CancelResult
Field
Type
Description
allocationsWithContextV1
V1 allocations to cancel, together with the context required to cancel them.
allocationsWithContextV2
[(ContractId Allocation, ExtraArgs)]
allocationRequestCids
Choice OTCTrade_RequestAllocations
Controller: venue
Returns: [ContractId OTCTradeAllocationRequest]
(no fields)
Choice OTCTrade_Settle
Controller: venue
Returns: OTCTrade_SettleResult
Field
Type
Description
batchesByAdmin
Allocations
allocationRequests
Allocation request to archive as part of settlement.
template OTCTradeAllocationRequest
A request to a single trading account to authorize their legs to the trade.
Signatory: (DA.Internal.Record.getField @"executors" settlement)
Field
Type
Description
settlement
SettlementInfo
requestedAt
settleAt
allocations
[AllocationSpecification]
Choice Archive
Controller: (DA.Internal.Record.getField @"executors" settlement)
Returns: ()
(no fields)
interface instance AllocationRequest for OTCTradeAllocationRequest
interface instance AllocationRequest for OTCTradeAllocationRequest
template TradeSettlementAgreement
An agreement to authorize the settlement of a trade by the venue, as an additional settlementAuthorizer. Used to settle V1 allocations, which require extra settlement authorizers to authorize the batch settlement.
Signatory: venue, trader
Field
Type
Description
venue
trader
Choice Archive
Controller: venue, trader
Returns: ()
(no fields)
Choice TradeSettlementAgreement_CancelAsReceiver
Controller: venue, sender
Returns: Allocation_CancelResult
Field
Type
Description
sender
allocationCid
ContractId Allocation
extraArgs
ExtraArgs
Choice TradeSettlementAgreement_CancelAsSender
Controller: venue
Returns: Allocation_CancelResult
Field
Type
Description
receiverAgreementCid
allocationCid
ContractId Allocation
extraArgs
ExtraArgs
Choice TradeSettlementAgreement_CreateReceiptAllocation
Controller: venue
Returns: ContractId Allocation
Field
Type
Description
factoryCid
ContractId AllocationFactory
choiceArg
AllocationFactory_Allocate
Choice TradeSettlementAgreement_ExecuteTransferAsReceiver
Controller: venue, sender
Returns: Allocation_ExecuteTransferResult
Field
Type
Description
sender
allocationCid
ContractId Allocation
extraArgs
ExtraArgs
Choice TradeSettlementAgreement_ExecuteTransferAsSender
Controller: venue
Returns: Allocation_ExecuteTransferResult
Field
Type
Description
receiverAgreementCid
allocationCid
ContractId Allocation
extraArgs
ExtraArgs
Data Types
A V1 allocation with enough context to settle or cancel it.
Field
Type
Description
allocationCid
ContractId Allocation
extraArgs
ExtraArgs
senderAgreementCid
receiverAgreementCid
instance Eq AllocationWithContextV1
instance Show AllocationWithContextV1
instance GetField "allocationCid" AllocationWithContextV1 (ContractId Allocation)
instance GetField "allocationsWithContext" SettlementBatch (TextMap AllocationWithContextV1)
instance GetField "allocationsWithContextV1" OTCTrade_Cancel [AllocationWithContextV1]
instance GetField "extraArgs" AllocationWithContextV1 ExtraArgs
instance GetField "receiverAgreementCid" AllocationWithContextV1 (ContractId TradeSettlementAgreement)
instance GetField "senderAgreementCid" AllocationWithContextV1 (ContractId TradeSettlementAgreement)
instance SetField "allocationCid" AllocationWithContextV1 (ContractId Allocation)
instance SetField "allocationsWithContext" SettlementBatch (TextMap AllocationWithContextV1)
instance SetField "allocationsWithContextV1" OTCTrade_Cancel [AllocationWithContextV1]
instance SetField "extraArgs" AllocationWithContextV1 ExtraArgs
instance SetField "receiverAgreementCid" AllocationWithContextV1 (ContractId TradeSettlementAgreement)
instance SetField "senderAgreementCid" AllocationWithContextV1 (ContractId TradeSettlementAgreement)
data MissingAllocation
Field
Type
Description
authorizerAgreementCid
None for missing allocations of the venue itself.
factoryCid
ContractId AllocationFactory
choiceArg
AllocationFactory_Allocate
instance Eq MissingAllocation
instance Show MissingAllocation
instance GetField "authorizerAgreementCid" MissingAllocation (Optional (ContractId TradeSettlementAgreement))
instance GetField "choiceArg" MissingAllocation AllocationFactory_Allocate
instance GetField "factoryCid" MissingAllocation (ContractId AllocationFactory)
instance GetField "missingAllocations" SettlementBatch [MissingAllocation]
instance SetField "authorizerAgreementCid" MissingAllocation (Optional (ContractId TradeSettlementAgreement))
instance SetField "choiceArg" MissingAllocation AllocationFactory_Allocate
instance SetField "factoryCid" MissingAllocation (ContractId AllocationFactory)
instance SetField "missingAllocations" SettlementBatch [MissingAllocation]
Field
Type
Description
resultsV1
TextMap Allocation_CancelResult
Results for V1 allocation cancellations keyed by transferLegId
resultsV2
[(Account, AllocationResult)]
instance GetField "resultsV1" OTCTrade_CancelResult (TextMap Allocation_CancelResult)
instance GetField "resultsV2" OTCTrade_CancelResult [(Account, AllocationResult)]
instance SetField "resultsV1" OTCTrade_CancelResult (TextMap Allocation_CancelResult)
instance SetField "resultsV2" OTCTrade_CancelResult [(Account, AllocationResult)]
instance HasExercise OTCTrade OTCTrade_Cancel OTCTrade_CancelResult
instance HasFromAnyChoice OTCTrade OTCTrade_Cancel OTCTrade_CancelResult
instance HasToAnyChoice OTCTrade OTCTrade_Cancel OTCTrade_CancelResult
instance GetField "resultsByAdminV1" OTCTrade_SettleResult (Map Party (TextMap Allocation_ExecuteTransferResult))
instance GetField "resultsByAdminV2" OTCTrade_SettleResult (Map Party SettlementFactory_SettleBatchResult)
instance SetField "resultsByAdminV1" OTCTrade_SettleResult (Map Party (TextMap Allocation_ExecuteTransferResult))
instance SetField "resultsByAdminV2" OTCTrade_SettleResult (Map Party SettlementFactory_SettleBatchResult)
instance HasExercise OTCTrade OTCTrade_Settle OTCTrade_SettleResult
instance HasFromAnyChoice OTCTrade OTCTrade_Settle OTCTrade_SettleResult
instance HasToAnyChoice OTCTrade OTCTrade_Settle OTCTrade_SettleResult
data SettlementBatch
A batch of allocations for the same admin together with the extra arguments required to settle them.
Batch for V1-only admins
Field
Type
Description
allocationsWithContext
Field
Type
Description
allocationCids
[ContractId Allocation]
missingAllocations
Allocations that should be created as part of settlement. These are: * the allocation(s) of the venue to receive fees * the allocations for the receipt of V2 assets for traders that use V1 wallets, which do not create receipt allocations on their own
factoryCid
ContractId SettlementFactory
extraArgs
ExtraArgs
instance Eq SettlementBatch
instance Show SettlementBatch
instance GetField "allocationCids" SettlementBatch [ContractId Allocation]
instance GetField "allocationsWithContext" SettlementBatch (TextMap AllocationWithContextV1)
instance GetField "batchesByAdmin" OTCTrade_Settle (Map Party SettlementBatch)
instance GetField "extraArgs" SettlementBatch ExtraArgs
instance GetField "factoryCid" SettlementBatch (ContractId SettlementFactory)
instance GetField "missingAllocations" SettlementBatch [MissingAllocation]
instance SetField "allocationCids" SettlementBatch [ContractId Allocation]
instance SetField "allocationsWithContext" SettlementBatch (TextMap AllocationWithContextV1)
instance SetField "batchesByAdmin" OTCTrade_Settle (Map Party SettlementBatch)
instance SetField "extraArgs" SettlementBatch ExtraArgs
instance SetField "factoryCid" SettlementBatch (ContractId SettlementFactory)
instance SetField "missingAllocations" SettlementBatch [MissingAllocation]
data TradeLeg
Leg of a trade.
Field
Type
Description
admin
Admin party of the instrument being transferred.
leg
TransferLeg
The transfer details.
instance GetField "admin" TradeLeg Party
instance GetField "leg" TradeLeg TransferLeg
instance GetField "tradeLegs" OTCTrade [TradeLeg]
instance SetField "admin" TradeLeg Party
Functions
- mkOtcTradeSettlementInfoV2
: ContractId OTCTrade -> OTCTrade -> SettlementInfo
- mkOtcTradeSettlementInfoV1
: ContractId OTCTrade -> OTCTrade -> SettlementInfo
- expectedTradeAllocationsV1
: SettlementInfo -> [TradeLeg] -> TextMap AllocationSpecification
The expected allocations for a trade that involves an asset implementing the V1 token standard only. There we expect exactly one allocation per transfer leg. That allocation is created by the sender, and settled with the authority of sender and receiver
- extractAllocationCidFromResult
: AllocationInstructionResult -> Update (ContractId Allocation)
- validateAllocationAsSender
: TradeSettlementAgreement -> ContractId TradeSettlementAgreement -> ContractId Allocation -> Update ()
- validateAllocationAsReceiver
: TradeSettlementAgreement -> Party -> ContractId Allocation -> Update ()
Comments