Created
February 21, 2022 19:48
-
-
Save sclearion/b21dc40efc1c33c8fb6127c06dd85e52 to your computer and use it in GitHub Desktop.
ZeroCoupon
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
{"valueParameterInfo":[["Interest",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"The interest paid by the _**borrower**_."}],["Amount",{"valueParameterFormat":{"contents":[6,"₳"],"tag":"DecimalFormat"},"valueParameterDescription":"The amount borrowed by the _**borrower**_."}]],"slotParameterDescriptions":[["Loan deadline","The _**lender**_ needs to deposit the _amount_ by this time."],["Payback deadline","The _**borrower**_ needs to deposit the repayment (_amount_ plus _interest_) by this time."]],"roleDescriptions":[["Borrower","The party that borrows the _amount_."],["Lender","The party that lends the _amount_."]],"contractType":"ZeroCouponBond","contractShortDescription":"A simple loan: the _**borrower**_ borrows the _amount_ from the _**lender**_, and at the _payback deadline_ pays back the _amount_ plus _interest_.","contractName":"Loan","contractLongDescription":"This is a high risk/high reward contract. There is no guarantee that the _**borrower**_ will pay back the loan. However there is an opportunity for the _**lender**_ to set a high _interest_ rate at the cost of taking on this risk.","choiceInfo":[]} |
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
const discountedPrice: Value = ConstantParam("Amount"); | |
const notionalPrice: Value = AddValue(ConstantParam("Interest"), discountedPrice); | |
const investor: Party = Role("Lender"); | |
const issuer: Party = Role("Borrower"); | |
const initialExchange: Timeout = SlotParam("Loan deadline"); | |
const maturityExchangeTimeout: Timeout = SlotParam("Payback deadline"); | |
function transfer(timeout: Timeout, from: Party, to: Party, amount: Value, continuation: Contract): Contract { | |
return When([Case(Deposit(from, from, ada, amount), | |
Pay(from, Party(to), ada, amount, continuation))], | |
timeout, | |
Close); | |
} | |
const contract: Contract = | |
transfer(initialExchange, investor, issuer, discountedPrice, | |
transfer(maturityExchangeTimeout, issuer, investor, notionalPrice, | |
Close)) | |
return 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
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment