This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | A versioned identifier backed by a set of signatories. Can be used as | |
-- a primary key or foreign key of a contract. | |
data Id = Id | |
with | |
signatories : Set Party | |
-- ^ The parties that need to sign a contract with this id and | |
-- that are responsible to ensure primary key uniqueness. | |
label : Text | |
-- ^ A label that makes a contract unique for a given set of signatories. | |
version : Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Represents a deposit of an asset in an account. The `account.id` and `asset.id` fields | |
-- can be used to link the contract to other contracts that provide further information | |
-- such as the type of the asset or reference data for it. This allows new asset classes | |
-- to be added without having to modify business processes that operate on generic | |
-- asset deposits. | |
template AssetDeposit | |
with | |
account : Account | |
-- ^ A deposit is allocated to an account and backed by the account.id.signatories. | |
-- Depending on the desired trust model this might be (i) both the provider and the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Data describing settlement details. | |
data SettlementDetails = SettlementDetails | |
with | |
senderAccount : Account | |
-- ^ The sender account. | |
receiverAccount : Account | |
-- ^ The receiver account. | |
depositCid : Optional (ContractId AssetDeposit) | |
-- ^ The allocated asset deposit. | |
deriving (Eq, Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ensure length steps > 0 && asset.quantity > 0.0 | |
&& all (\(s1,s2) -> s1.receiverAccount.owner == s2.senderAccount.owner) (zip steps $ tail steps) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nextSender : SettlementInstruction -> Optional Party | |
nextSender SettlementInstruction{..} = (.senderAccount.owner) <$> find (\step -> isNone step.depositCid) steps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
choice SettlementInstruction_AllocateNext : ContractId SettlementInstruction | |
-- ^ Allocates an asset deposit to the next step of the settlement instruction. | |
-- In the simple case where both counterparties have an account with the same provider | |
-- a single allocation by the sender party is required. | |
with | |
depositCid : ContractId AssetDeposit | |
-- ^ Specifies the asset deposit contract to be allocated. | |
ctrl : Party | |
-- ^ The next sender. | |
controller ctrl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
controller masterAgreement.id.signatories can | |
SettlementInstruction_Process : [ContractId AssetDeposit] | |
-- ^ Processes a settlement instruction by transferring all allocated asset deposits. | |
-- This choice is often called from the trade itself to atomically settle all | |
-- assets involved. | |
do | |
mapA | |
(\x -> do | |
exerciseByKey @AssetSettlementRule x.senderAccount.id AssetSettlement_Transfer with | |
receiverAccountId = x.receiverAccount.id, depositCid = fromSome x.depositCid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data OptionType = PUT | CALL deriving (Eq, Show) | |
data ExerciseType = EUROPEAN | AMERICAN deriving (Eq, Show) | |
data SettlementType = CASH | PHYSICAL deriving (Eq, Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Reference data describing an asset that entitles the owner to receive the | |
-- underlying asset at the settlement date. Can be used to lifecycle asset | |
-- deposits, trades or dependent instruments. | |
template Entitlement | |
with | |
id : Id | |
-- ^ The asset id of the entitlement. Depending on the trust model the | |
-- signatories might be the issuer or a third party reference data provider | |
-- such as Reuters. | |
settlementDate : Date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
where | |
signatory union masterAgreement.id.signatories $ fromList sendersDone | |
observer insert masterAgreement.party1 $ insert masterAgreement.party2 | |
$ union observers $ fromList sendersPending |
OlderNewer