contracts

## Package contracts

### Types

Cash | `class Cash : Contract` A cash transaction may split and merge money represented by a set of (issuer, depositRef) pairs, across multiple input and output states. Imagine a Bitcoin transaction but in which all UTXOs had a colour (a blend of issuer+depositRef) and you couldnt merge outputs of two colours together, but you COULD put them in the same transaction.
CommercialPaper | `class CommercialPaper : Contract`
CrowdFund | `class CrowdFund : Contract` This is a basic crowd funding contract. It allows a party to create a funding opportunity, then for others to pledge during the funding period , and then for the party to either accept the funding (if the target has been reached) return the funds to the pledge-makers (if the target has not been reached).
DealState | `interface DealState : LinearState` Interface representing an agreement that exposes various attributes that are common. Implementing it simplifies implementation of general protocols that manipulate many agreement types.
DummyContract | `class DummyContract : Contract`
Event | `open class Event` Event superclass - everything happens on a date.
FixableDealState | `interface FixableDealState : DealState` Interface adding fixing specific methods
FixedRate | `class FixedRate : Rate` A very basic subclass to represent a fixed rate.
FixedRatePaymentEvent | `class FixedRatePaymentEvent : RatePaymentEvent` Basic class for the Fixed Rate Payments on the fixed leg - see RatePaymentEvent Assumes that the rate is valid.
FloatingRate | `open class FloatingRate : Rate` The parent class of the Floating rate classes
FloatingRatePaymentEvent | `class FloatingRatePaymentEvent : RatePaymentEvent` Basic class for the Floating Rate Payments on the floating leg - see RatePaymentEvent If the rate is null returns a zero payment. // TODO: Is this the desired behaviour?

InterestRateSwap

`class InterestRateSwap : Contract`

The Interest Rate Swap class. For a quick overview of what an IRS is, see here - http://www.pimco.co.uk/EN/Education/Pages/InterestRateSwapsBasics1-08.aspx (no endorsement) This contract has 4 significant data classes within it, the "Common", "Calculation", "FixedLeg" and "FloatingLeg" It also has 4 commands, "Agree", "Fix", "Pay" and "Mature". Currently, we are not interested (excuse pun) in valuing the swap, calculating the PVs, DFs and all that good stuff (soon though). This is just a representation of a vanilla Fixed vs Floating (same currency) IRS in the R3 prototype model.

PaymentEvent | `abstract class PaymentEvent : Event` Top level PaymentEvent class - represents an obligation to pay an amount on a given date, which may be either in the past or the future.
PercentageRatioUnit | `open class PercentageRatioUnit : RatioUnit` A class to reprecent a percentage in an unambiguous way.
Rate | `open class Rate` Parent of the Rate family. Used to denote fixed rates, floating rates, reference rates etc

RatePaymentEvent

`abstract class RatePaymentEvent : PaymentEvent`

A RatePaymentEvent represents a dated obligation of payment. It is a specialisation / modification of a basic cash flow event (to be written) that has some additional assistance functions for interest rate swap legs of the fixed and floating nature. For the fixed leg, the rate is already known at creation and therefore the flows can be pre-determined. For the floating leg, the rate refers to a reference rate which is to be "fixed" at a point in the future.

RatioUnit | `open class RatioUnit` A utility class to prevent the various mixups between percentages, decimals, bips etc.
ReferenceRate | `class ReferenceRate : FloatingRate` So a reference rate is a rate that takes its value from a source at a given date e.g. LIBOR 6M as of 17 March 2016. Hence it requires a source (name) and a value date in the getAsOf(..) method.
UnknownType | `open class UnknownType`

### Exceptions

InsufficientBalanceException | `class InsufficientBalanceException : Exception`

### Extensions for External Classes

kotlin.Int |
kotlin.String |
kotlin.collections.Iterable |

### Properties

CASH_PROGRAM_ID | `val CASH_PROGRAM_ID: Cash`

CP_PROGRAM_ID

`val CP_PROGRAM_ID: CommercialPaper`

This is an ultra-trivial implementation of commercial paper, which is essentially a simpler version of a corporate bond. It can be seen as a company-specific currency. A company issues CP with a particular face value, say $100, but sells it for less, say $90. The paper can be redeemed for cash at a given date in the future. Thus this example would have a 10% interest rate with a single repayment. Commercial paper is often rolled over (the maturity date is adjusted as if the paper was redeemed and immediately repurchased, but without having to front the cash).

CROWDFUND_PROGRAM_ID | `val CROWDFUND_PROGRAM_ID: CrowdFund`
DUMMY_PROGRAM_ID | `val DUMMY_PROGRAM_ID: DummyContract`
IRS_PROGRAM_ID | `val IRS_PROGRAM_ID: InterestRateSwap`

### Functions

exportIRSToCSV | `fun State.exportIRSToCSV(): String`
times | `operator fun Amount.times(other: RatioUnit): Amount`