1 contract FixedLimitProfit(assetBill: Asset,
2 totalAmountBill: Amount,
3 totalAmountCapital: Amount,
4 expireBlockHeight: Integer,
5 additionalBlockHeight: Integer,
7 bankerKey: PublicKey) locks capitalAmount of capitalAsset {
8 clause profit(amountBill: Amount, saver: Program) {
9 verify above(expireBlockHeight)
10 define sAmountBill: Integer = amountBill/100000000
11 define sTotalAmountBill: Integer = totalAmountBill/100000000
12 verify sAmountBill > 0 && sTotalAmountBill > 0 && amountBill < totalAmountBill
13 define gain: Integer = totalAmountCapital*sAmountBill/sTotalAmountBill
15 if gain < capitalAmount {
16 lock amountBill of assetBill with banker
17 lock gain of capitalAsset with saver
18 lock capitalAmount - gain of capitalAsset with FixedLimitProfit(assetBill, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
20 lock amountBill of assetBill with banker
21 lock capitalAmount of capitalAsset with saver
24 clause cancel(bankerSig: Signature) {
25 verify above(additionalBlockHeight)
26 verify checkTxSig(bankerKey, bankerSig)
27 unlock capitalAmount of capitalAsset