plutus-use-cases-1.2.0.0: Collection of smart contracts to develop the plutus/wallet interface
Safe HaskellNone
LanguageHaskell2010

Plutus.Contracts.Swap

Contents

Synopsis

Documentation

data Swap Source #

A swap is an agreement to exchange cashflows at future dates. To keep things simple, this is an interest rate swap (meaning that the cashflows are interest payments on the same principal amount but with two different interest rates, of which one is fixed and one is floating (varying with time)) with only a single payment date.

At the beginning of the contract, the fixed rate is set to the expected future value of the floating rate (so if the floating rate behaves as expected, the two payments will be exactly equal).

Constructors

Swap 

Fields

  • swapNotionalAmt :: !Ada
     
  • swapObservationTime :: !POSIXTime
     
  • swapFixedRate :: !Rational

    Interest rate fixed at the beginning of the contract

  • swapFloatingRate :: !Rational

    Interest rate whose value will be observed (by an oracle) on the day of the payment

  • swapMargin :: !Ada

    Margin deposited at the beginning of the contract to protect against default (one party failing to pay)

  • swapOracle :: PaymentPubKey

    Public key of the oracle (see note [Oracles] in [[Plutus.Contracts]]). Unsure why, but this field needs to be non-strict, otherwise GHC will try to unbox the datatype, which will result in a compilation error such as "GHC Core to PLC plugin: E042:Error: Unsupported feature: Type constructor: GHC.Prim.Addr#"

Instances

Instances details
Lift DefaultUni Swap Source # 
Instance details

Defined in Plutus.Contracts.Swap

Methods

lift :: Swap -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ())

Typeable DefaultUni Swap Source # 
Instance details

Defined in Plutus.Contracts.Swap

Methods

typeRep :: Proxy Swap -> RTCompile DefaultUni fun (Type TyName DefaultUni ())

Script

swapValidator :: Swap -> Validator Source #

Validator script for the two transactions that initialise the swap. See note [Swap Transactions] See note [Contracts and Validator Scripts] in Language.Plutus.Coordination.Contracts