Skip to content

Instantly share code, notes, and snippets.

@simonjohnthompson
simonjohnthompson / metadata.json
Created April 16, 2021 10:17
Contract for differences with oracle - SJT.
{"valueParameterDescriptions":[],"slotParameterDescriptions":[],"roleDescriptions":[["Counterparty","Party that gets the difference in trade price if it increases."],["Party","Party that gets the difference in trade price if it decreases."],["kraken","Oracle party that provides the exchange rate for ADA/USD."]],"contractType":"CD","contractName":"Contract for Differences with Oracle","contractDescription":"\"Party\" and \"Counterparty\" deposit 100 Ada and after 60 slots these assets are redistributed depending on the change in price of 100 Ada worth of dollars between the start and the end of the contract. If the price increases, the difference goes to \"Counterparty\"; if it decreases, the difference goes to \"Party\", up to a maximum of 100 Ada.","choiceDescriptions":[["dir-adausd","Exchange rate ADA/USD at the beginning of the contract."],["inv-adausd","Exchange rate USD/ADA at the end of the contract."]]}
@simonjohnthompson
simonjohnthompson / Main.hs
Created April 16, 2021 10:13
Contract for differences with oracle
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
module ContractForDifferencesWithOracle where
import Language.Marlowe.Extended
main :: IO ()
main = print . pretty $ contract
-- We can set explicitRefunds True to run Close refund analysis
@simonjohnthompson
simonjohnthompson / metadata.json
Created April 1, 2021 09:59
Contract for difference - SJT revised (NB difference singular).
{"valueParameterDescriptions":[],"slotParameterDescriptions":[],"roleDescriptions":[["Counterparty","Party that gets the difference in trade price if it increases."],["Oracle","Party that provides the trade price in real time."],["Party","Party that gets the difference in trade price if it decreases."]],"contractType":"CD","contractName":"Contract for Difference","contractDescription":"\"Party\" and \"Counterparty\" deposit 100 Ada and after 60 slots is redistributed depending on the change in a given trade price reported by \"Oracle\". If the price increases, the difference goes to \"Counterparty\"; if it decreases, the difference goes to \"Party\", up to a maximum of 100 Ada.","choiceDescriptions":[["Price at beginning","Trade price at the beginning of the contract."],["Price at end","Trade price at the end of the contract."]]}
@simonjohnthompson
simonjohnthompson / metadata.json
Created April 1, 2021 09:55
Coupon bond guaranteed - SJT revised
{"valueParameterDescriptions":[["Interest instalment","Amount of Lovelace that will be paid by the \"Issuer\" every 30 slots for 3 iterations."],["Principal","Amount of Lovelace that will be borrowed by the \"Issuer\"."]],"slotParameterDescriptions":[],"roleDescriptions":[["Guarantor","Provides a collateral in case the \"Issuer\" defaults."],["Investor","Provides the money that the \"Issuer\" borrows."],["Issuer","Borrows the money provided by the \"Investor\" and returns it together with three \"Interest instalment\"s."]],"contractType":"CB","contractName":"Coupon Bond Guaranteed","contractDescription":"Debt agreement between an \"Investor\" and an \"Issuer\". \"Investor\" will advance the \"Principal\" amount at the beginning of the contract, and the \"Issuer\" will pay back \"Interest instalment\" every 30 slots and the \"Principal\" amount by the end of 3 instalments. The debt is backed by a collateral provided by the \"Guarantor\" which will be refunded as long as the \"Issuer\" pays back on time.","choi
@simonjohnthompson
simonjohnthompson / Main.hs
Created April 1, 2021 09:54 — forked from palas/Main.hs
Coupon Bond Guaranteed
{-# LANGUAGE OverloadedStrings #-}
module CouponBondGuaranteed where
import Language.Marlowe.Extended
main :: IO ()
main = print . pretty $ contract
-- We can set explicitRefunds True to run Close refund analysis
-- but we get a shorter contract if we set it to False
@simonjohnthompson
simonjohnthompson / Main.hs
Created April 1, 2021 09:53 — forked from palas/Main.hs
Contract for differences
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
module ContractForDifferences where
import Language.Marlowe.Extended
main :: IO ()
main = print . pretty $ contract
-- We can set explicitRefunds True to run Close refund analysis
@simonjohnthompson
simonjohnthompson / metadata.json
Created March 23, 2021 17:55
Swap - SJT revised.
{"valueParameterDescriptions":[["Amount of ada","Amount of Ada to be exchanged for dollars."],["Amount of dollars","Amount of dollars to be exchange for Ada."]],"slotParameterDescriptions":[["Timeout for ada deposit","Deadline by which Ada must be deposited."],["Timeout for dollar deposit","Deadline by which dollars must be deposited (must be after the deadline for Ada deposit)."]],"roleDescriptions":[["Ada provider","The party that provides the Ada."],["Dollar provider","The party that provides the dollars."]],"contractType":"S","contractName":"Swap of Ada and dollar tokens","contractDescription":"Takes Ada from one party and dollar tokens from another party, and it swaps them atomically.","choiceDescriptions":[]}
@simonjohnthompson
simonjohnthompson / metadata.json
Created March 23, 2021 17:52
Zero Coupon Bond - SJT revised.
{"valueParameterDescriptions":[["Discounted price","The price of the Zero Coupon Bond at the start date."],["Notional","The full price of the Zero Coupon Bond."]],"slotParameterDescriptions":[["Initial exchange deadline","The \"Investor\" must deposit the discounted price of the bond before this deadline or the offer will expire."],["Maturity exchange deadline","The \"Issuer\" must deposit the full price of the bond before this deadline or it will default."]],"roleDescriptions":[["Investor","The party that buys the bond at a discounted price, i.e. makes the loan."],["Issuer","The party that issues the bond, i.e. receives the loan."]],"contractType":"ZC","contractName":"Zero Coupon Bond","contractDescription":"A simple loan. The investor pays the issuer the discounted price at the start, and is repaid the full (notional) price at the end.","choiceDescriptions":[]}
@simonjohnthompson
simonjohnthompson / metadata.json
Created March 23, 2021 17:48
Escrow with collateral - SJT revised.
{"valueParameterDescriptions":[["Collateral amount","The amount to be deposited by both parties at the start of the contract to serve as an incentive for collaboration."],["Price","The amount to be paid by the \"Buyer\" as part of the exchange."]],"slotParameterDescriptions":[["Collateral deposit by seller timeout","The deadline by which the \"Seller\" must deposit the \"Collateral amount\" in the contract."],["Deposit of collateral by buyer timeout","The deadline by which the \"Buyer\" must deposit the \"Collateral amount\" in the contract."],["Deposit of price by buyer timeout","The deadline by which the \"Buyer\" must deposit the \"Price\" in the contract."],["Dispute by buyer timeout","The deadline by which, if the \"Buyer\" has not opened a dispute, the \"Seller\" will be paid."],["Seller's response timeout","The deadline by which, if the \"Seller\" has not responded to the dispute, the \"Buyer\" will be refunded."]],"roleDescriptions":[["Buyer","The party that pays for the item on sale."],["Seller","The
@simonjohnthompson
simonjohnthompson / metadata.json
Created March 23, 2021 17:29
Simple escrow - SJT revised.
{"valueParameterDescriptions":[["Price","Amount to be paid by the \"Buyer\" for the item."]],"slotParameterDescriptions":[["Buyer's deposit timeout","Deadline by which the \"Buyer\" must deposit the selling \"Price\" in the contract."],["Buyer's dispute timeout","Deadline by which, if the \"Buyer\" has not opened a dispute, the \"Seller\" will be paid."],["Seller's response timeout","Deadline by which, if the \"Seller\" has not responded to the dispute, the \"Buyer\" will be refunded."],["Timeout for arbitrage","Deadline by which, if the \"Arbiter\" has not resolved the dispute, the \"Buyer\" will be refunded."]],"roleDescriptions":[["Arbiter","The party that will choose who gets the money in the event of a disagreement between the \"Buyer\" and the \"Seller\" about the outcome."],["Buyer","The party that wants to buy the item. Payment is made to the seller if they acknowledge receiving the item. "],["Seller","The party that wants to sell the item. They receive the payment if the exchange is uneventful."]],"