OSDN Git Service

optimise equity commandline (#36)
[bytom/equity.git] / compiler / equitytest / FixedLimitCollect
1 import "./FixedLimitProfit"
2
3 contract FixedLimitCollect(assetDeposited: Asset,
4                            totalAmountBill: Amount,
5                            totalAmountCapital: Amount,
6                            dueBlockHeight: Integer,
7                            expireBlockHeight: Integer,
8                            additionalBlockHeight: Integer,
9                            banker: Program,
10                            bankerKey: PublicKey) locks billAmount of billAsset {
11   clause collect(amountDeposited: Amount, saver: Program) {
12     verify below(dueBlockHeight)
13     verify amountDeposited <= billAmount && totalAmountBill <= totalAmountCapital
14     define sAmountDeposited: Integer = amountDeposited/100000000
15     define sTotalAmountBill: Integer = totalAmountBill/100000000
16     verify sAmountDeposited > 0 && sTotalAmountBill > 0
17     if amountDeposited < billAmount {
18       lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
19       lock amountDeposited of billAsset with saver
20       lock billAmount-amountDeposited of billAsset with FixedLimitCollect(assetDeposited, totalAmountBill, totalAmountCapital, dueBlockHeight, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
21     } else {
22       lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
23       lock billAmount of billAsset with saver
24     }
25   }
26   clause cancel(bankerSig: Signature) {
27     verify above(dueBlockHeight)
28     verify checkTxSig(bankerKey, bankerSig)
29     unlock billAmount of billAsset
30   }
31 }