Zero coupon with insurance
The issue is that the previous zero coupon bond is that the owner has zero guarantee for repay.
The solution is to use a guarantee fund to ensure pay back. This fund plays the role of trusted third party for the zero coupon bond contract.
zcb_with_insurance.arl
1
archetype zero_coupon_bond_with_insurance
2
3
variable issuer : role = @tz1bfVgcJC4ukaQSHUe1EbrUd5SekXeP9CWk (* seller 'Alice' *)
4
5
variable owner : role = @tz1Lc2qBKEWCBeDU8npG6zCeCqpmaegRi6Jg
6
(* buyer 'Bob'; receives 11 tez in one-year *)
7
8
variable zero_insur : address = @KT1TJrR7uovV5tFpsLBCKmx3x95pY6hMy775
9
10
variable price : tez = 10tz
11
12
variable payment : tez = 1.1 * price
13
14
variable maturity : date = now
15
16
states =
17
| Created initial
18
| Insured (* Guarantee Fund has accepted issuer *)
19
| Confirmed (* owner has purchased bond *)
20
| Repaid (* issuer has transferred payment to contract *)
21
| Collected (* owner has collected payment *)
22
23
transition insured () {
24
called by zero_insur
25
26
from Created
27
to Insured
28
}
29
30
transition confirm () {
31
specification {
32
s1 : balance = 0tz
33
}
34
35
from Insured
36
to Confirmed
37
when { transferred = price }
38
with effect {
39
maturity := now + 365d;
40
transfer price to issuer
41
}
42
}
43
44
transition repay () {
45
called by issuer
46
47
from Confirmed
48
to Repaid
49
when {
50
transferred = payment
51
}
52
}
53
54
transition collect () {
55
called by owner
56
57
from Repaid
58
to Collected
59
when { now > maturity }
60
with effect {
61
if balance >= payment
62
then transfer balance to owner
63
else transfer 0tz to zero_insur call pay<address * tez>((owner, payment))
64
}
65
}
66
Copied!
guarantee_fund.arl
1
archetype guarantee_fund
2
3
variable admin : role = @tz1Lc2qBKEWCBeDU8npG6zCeCqpmaegRi6Jg
4
5
asset insured_contract identified by addr {
6
addr : address;
7
max_transfer : tez;
8
}
9
10
entry credit () {
11
called by admin
12
require {
13
c1 : transferred > 0tz;
14
}
15
}
16
17
entry add_contract (ic_addr : address, ic_max_transfer : tez) {
18
called by admin
19
effect {
20
insured_contract.add({addr = ic_addr; max_transfer = ic_max_transfer})
21
}
22
}
23
24
entry pay (recipient : address, amount : tez) {
25
require {
26
c2 : insured_contract.contains(caller);
27
c3 : amount <= insured_contract[caller].max_transfer;
28
}
29
30
effect {
31
transfer amount to recipient
32
}
33
}
34
Copied!
Last modified 1yr ago
Export as PDF
Copy link