Skip to content

Instantly share code, notes, and snippets.

View palas's full-sized avatar

Pablo Lamela palas

View GitHub Profile
@palas
palas / Main.hs
Created May 9, 2023 20:36
Raffle
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Trustworthy #-}
module Main (
-- * Entry point
main
-- * Contracts
, makeContract
) where
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]}
@palas
palas / metadata.json
Last active November 18, 2022 02:05
Token swap
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[["Counterparty","The second one to deposit the token"],["Party","The first one to deposit the token"]],"contractType":"Swap","contractShortDescription":"In this contract a _**pary**_ wants to exchange tokens with a _**counterparty**_ .","contractName":"Token swap","contractLongDescription":"In this contract a _**pary**_ wants to exchange tokens with a _**counterparty**_ .","choiceInfo":[]}
@palas
palas / metadata.json
Created October 29, 2021 13:51
Purchase
{"valueParameterInfo":[["Price",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"The price of the item."}]],"slotParameterDescriptions":[["Payment deadline","The _**buyer**_ must pay the _price_ of the item by this time, otherwise the contract is cancelled."],["Complaint deadline","The _**buyer**_ can only complain until this deadline, otherwise the contract will assume the transaction went smoothly and pay the _**seller**_."],["Complaint response deadline","If the _**buyer**_ complained, the _**seller**_ must respond before this deadline, otherwise the contract will assume there was a problem with the transaction and refund the _**buyer**_."],["Mediation deadline","If the _**buyer**_ and the _**seller**_ disagree, the _**mediator**_ must weigh in before this deadline, otherwise the contract will assume there was a problem with the transaction and refund the _**buyer**_."]],"roleDescriptions":[["Buyer","The buyer of the item."],["Mediator","The mediator decides w
@palas
palas / Main.hs
Last active July 26, 2021 13:43
CFD Haskell no oracle updated
{-# 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
@palas
palas / metadata.json
Created July 26, 2021 13:23
CFD no Oracle updated
{"valueParameterInfo":[],"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.","choiceInfo":[["dir-adausd",{"choiceFormat":{"contents":[8,"ADA/USD"],"tag":"DecimalFormat"},"choiceDescription":"Exchange rate ADA/USD at the beginning of the contract."}],["inv-adausd",{"choiceFormat":{"contents":[8,"USD/ADA"],"tag":"DecimalFormat"},"choiceDescription":"Exchang
@palas
palas / Main.hs
Created July 22, 2021 19:28
Updated contract for differences (Haskell)
{-# 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
@palas
palas / metadata.json
Last active July 22, 2021 19:16
Updated Contract For Differences With Oracle
{"valueParameterInfo":[],"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.","choiceInfo":[["dir-adausd",{"choiceFormat":{"contents":[8,"ADA/USD"],"tag":"DecimalFormat"},"choiceDescription":"Exchange rate ADA/USD at the beginning of the contract."}],["inv-adausd",{"choiceFormat":{"contents":[8,"USD/ADA"],"tag":"DecimalFormat"},"choiceDescription":"Exchang
@palas
palas / Main.hs
Last active April 1, 2021 09:53
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
@palas
palas / Main.hs
Last active April 1, 2021 09:54
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