Created
April 1, 2021 09:59
-
-
Save simonjohnthompson/3c486fc7aa587572d2eb6ce9090f087b to your computer and use it in GitHub Desktop.
Contract for difference - SJT revised (NB difference singular).
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
{"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."]]} |
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
When | |
[Case | |
(Deposit | |
(Role "Party") | |
(Role "Party") | |
(Token "" "") | |
(Constant 100000000) | |
) | |
(When | |
[Case | |
(Deposit | |
(Role "Counterparty") | |
(Role "Counterparty") | |
(Token "" "") | |
(Constant 100000000) | |
) | |
(When | |
[Case | |
(Choice | |
(ChoiceId | |
"Price at beginning" | |
(Role "Oracle") | |
) | |
[Bound 0 1000000000] | |
) | |
(When | |
[] | |
150 | |
(When | |
[Case | |
(Choice | |
(ChoiceId | |
"Price at end" | |
(Role "Oracle") | |
) | |
[Bound 0 1000000000] | |
) | |
(If | |
(ValueGT | |
(ChoiceValue | |
(ChoiceId | |
"Price at beginning" | |
(Role "Oracle") | |
)) | |
(ChoiceValue | |
(ChoiceId | |
"Price at end" | |
(Role "Oracle") | |
)) | |
) | |
(Let | |
"Decrease in price" | |
(SubValue | |
(ChoiceValue | |
(ChoiceId | |
"Price at beginning" | |
(Role "Oracle") | |
)) | |
(ChoiceValue | |
(ChoiceId | |
"Price at end" | |
(Role "Oracle") | |
)) | |
) | |
(Pay | |
(Role "Counterparty") | |
(Account (Role "Party")) | |
(Token "" "") | |
(Cond | |
(ValueLT | |
(UseValue "Decrease in price") | |
(Constant 100000000) | |
) | |
(UseValue "Decrease in price") | |
(Constant 100000000) | |
) | |
Close | |
) | |
) | |
(If | |
(ValueLT | |
(ChoiceValue | |
(ChoiceId | |
"Price at beginning" | |
(Role "Oracle") | |
)) | |
(ChoiceValue | |
(ChoiceId | |
"Price at end" | |
(Role "Oracle") | |
)) | |
) | |
(Let | |
"Increase in price" | |
(SubValue | |
(ChoiceValue | |
(ChoiceId | |
"Price at end" | |
(Role "Oracle") | |
)) | |
(ChoiceValue | |
(ChoiceId | |
"Price at beginning" | |
(Role "Oracle") | |
)) | |
) | |
(Pay | |
(Role "Party") | |
(Account (Role "Counterparty")) | |
(Token "" "") | |
(Cond | |
(ValueLT | |
(UseValue "Increase in price") | |
(Constant 100000000) | |
) | |
(UseValue "Increase in price") | |
(Constant 100000000) | |
) | |
Close | |
) | |
) | |
Close | |
) | |
)] | |
180 Close | |
) | |
)] | |
90 Close | |
)] | |
60 Close | |
)] | |
30 Close |
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
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment