-
Notifications
You must be signed in to change notification settings - Fork 2
/
OpenOffer.daml
99 lines (84 loc) · 4.22 KB
/
OpenOffer.daml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
-- Copyright (c) 2024 ASX Operations Pty Ltd. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module Synfini.Interface.Settlement.OpenOffer.OpenOffer where
import DA.Set (Set)
import DA.Time (RelTime)
import Daml.Finance.Interface.Types.Common.Types
import Daml.Finance.Interface.Settlement.Batch qualified as Batch
import Daml.Finance.Interface.Settlement.Factory qualified as SettlementFactory
import Daml.Finance.Interface.Settlement.Instruction qualified as Instruction
import Daml.Finance.Interface.Settlement.RouteProvider qualified as RouteProvider
import Daml.Finance.Interface.Util.Disclosure qualified as Disclosure
-- | Data type used to resolve a party ID during exercise of the 'Take' choice.
data Entity =
PartyEntity Party | -- ^ The party is resolved to the given party.
TakerEntity -- ^ The party will be equal to the party exercising the 'Take' choice.
deriving (Show, Eq, Ord)
-- | Proposed settlement step.
data OfferStep = OfferStep
with
sender : Entity -- ^ Sender of the asset.
receiver : Entity -- ^ Receiver of the asset.
quantity : InstrumentQuantity -- ^ Instrument and amount of the asset.
deriving (Show, Eq)
-- | View of an 'OpenOffer'.
data View = View
with
offerId : Id -- ^ Unique identifier of the offer to be used as the context id of the 'Batch' if the offer is
-- accepted.
offerDescription : Text -- ^ Description of the offer.
offerers : Set Party -- ^ Signatories of the offer.
settlementInstructors : Set Entity -- ^ Parties who will act as instructors of the settlement if the offer is
-- accepted.
settlers : Set Entity -- ^ Parties who will act as settlers on the resulting 'Batch' if the offer is accepted.
permittedTakers : Optional (Set Party) -- ^ Whitelist of parties with permission to take the offer. 'None' indicates
-- any stakeholder can take the offer.
steps : [OfferStep] -- ^ Proposed settlement steps, where the quantity of each step is multiplied by the quantity
-- specified by the taker.
settlementTime : Optional (Either Time RelTime) -- ^ Optional settlement time of the 'Batch' if the offer
-- is accepted. 'RelTime' can be used to specify settlement time relative to the ledger time when the offer is
-- taken.
minQuantity : Optional Decimal -- ^ Minimum quantity that can be specified by the taker. 'None' indicates no lower
-- bound.
maxQuantity : Optional Decimal -- ^ Maximum quantity that can be specified by the taker. 'None' indicates no upper
-- bound.
increment : Optional Decimal -- ^ If provided then the quantity specified by the taker must be a multiple of the
-- increment value.
routeProviderCid : ContractId RouteProvider.I -- ^ Route provider used to determine the custodian(s) used for
-- settlement.
settlementFactoryCid : ContractId SettlementFactory.I -- ^ Settlement factory used to instruct settlement.
deriving (Show, Eq)
-- | Type synonym for 'View'.
type V = View
-- | An offer, which if accepted, generates settlement instructions. It is an "open" offer because, if the offer is
-- taken, it is not archived and can be used again.
interface OpenOffer requires Disclosure.I where
viewtype V
-- | Implementation of the 'Take' choice.
take' : Take -> Update (ContractId Batch.I, [ContractId Instruction.I])
-- | Implementation of the 'Revoke' choice.
revoke : Revoke -> Update ()
-- | Retrieves the interface view.
nonconsuming choice GetView : V
with
viewer : Party -- ^ The party fetching the view.
controller viewer
do
pure (view this)
-- | Take the offer and generate settlement instructions.
nonconsuming choice Take : (ContractId Batch.I, [ContractId Instruction.I])
with
id : Id -- ^ Settlement 'Batch' ID.
taker : Party -- ^ Party taking the offer.
quantity : Decimal -- ^ The quantity of each settlement step will be multiplied by this amount.
reference : Optional Text -- ^ Optional reference information provided by the taker of the offer.
controller taker
do
take' this arg
-- | Choice for the offerers to take away the offer.
choice Revoke : ()
controller (view this).offerers
do
revoke this arg
-- | Type synonym for 'OpenOffer'.
type I = OpenOffer