Open d-sfounis opened 5 years ago
In contract FixedLimitCollect
Line 17, the purpose of calculating gain
is to prevent users from saving amount too little to gain the profit, because the zero profit is is unfriendly to users.
I think you made a mistake about the meaning of the contract. the contract FixedLimitCollect
is raising users funds, and the contract FixedLimitProfit
gain the reward.
@oysheng Thank you for replying!
Can you describe where you get the reward?
In FixedLimitProfit, you only get your own (initial) assets back, nothing extra.
After all, the FixedLimitProfit contract, when created, locks the same assets that you sent it.
Do you mean that a banker creates 1 FixedLimitCollect
+ 1 FixedLimitProfit
contract initially, and then because of the automatically created + 1 FixedLimitProfit contract, you end up with 2 FixedLimitProfit contracts (1 for initial assets, 1 for rewards) at the end?
Users can get the reward from the FixedLimitProfit
, the reward contains the user's initial asset and the profit asset.
define gain: Integer = totalAmountCapital*sAmountBill/sTotalAmountBill
...
lock gain of capitalAsset with saver
First, The contract FixedLimitProfit
inited by the unlock flow of the contract FixedLimitCollect
. for example, assume that the total Bill asset is 1000 and the profit is 100 BTM asset, if the user deposit 100 BTM asset by contract FixedLimitCollect
, he must be deposit 100 BTM into FixedLimitProfit
(inited by this position) to get the 100 Bill asset, at the same time, the project banker cannot use these assets. therefore, the FixedLimitProfit
contract is not inited individually.
Second, the banker needed to deposit the profit(not contain the user asset) into FixedLimitProfit
, besides, there are multiple users, so the contract FixedLimitProfit
contain multiple UTXOs. If the one of these UTXOs not satisfied with the user,he can use multiple UTXOs to unlock FixedLimitProfit.
Finally, the total capital and total bill is calculated from the beginning, if the banker deposit the profit into the FixedLimitProfit, all users can believe that the project side is reliable.
Alright, I think I get it!
At first, I thought that the bank only creates 1 FixedLimitCollect
contract (nothing else), and all FixedLimitProfit
contracts are created dynamically through FixedLimitCollect
only. That's why I thought the only assets locked by FixedLimitProfit
are the initial collected assets and no gain.
If I understand what you told me, the bank creates 1 FixedLimitCollect
(all the bill certificates) and 1 FixedLimitProfit
(all the reward capital) at first, and then FixedLimitProfit
dynamically gets multiple instances and UTXOs (user assets back) as people start using FixedLimitCollect
.
Correct me if I'm wrong.
This picture is the flow chart.
200 depositedAsset
is the profit which is deposited by the banker. the total reward is 1200 depositedAsset
which composed by the users (total is 1000 depositedAsset
) and the banker (200 depositedAsset
). Then the contract FixedLimitProfit
dynamically gets multiple instances and UTXOs, and the users can get the reward by FixedLimitProfit
.
Thank you for the flowchart. It cleared everything up.
Updating my documentation based on your explanation.
Hi again,
I think there might be a logical error in FixedLimitCollect and, as a result, FixedLimitProfit: https://github.com/Bytom/equity/blob/master/compiler/equitytest/FixedLimitCollect
Line 17: Gain is calculated as a percentage of the
billAmount
filled by the saver callingcollect
. Hoever, other thanverify gain > 0
,gain
is never used again.In lines 20 and 24,
FixedLimitProfit
locks exactly the amount deposited by the saver,amountDeposited
, without included profits. This means that when the contract expires afterexpireBlockHeight
, savers are allowed to get their money back and nothing more. Essentially they just locked their own money away without receiving any profit.What I think it should be:
define reward: Integer = amountDeposited + gain
, as gain isdefine gain: Integer = sTotalAmountCapital * (sAmountDeposited/sTotalAmountBill)
and then,FixedLimitProfit
should lockreward
Amount of assets, which would be initial assets + profits as part of the capital.Example workflow:
totalAmountBill
: 1000totalAmountCapital
: 2000I choose to lock away the full
1000
as a saver. I callcollect
withamountDeposited==1000
:gain==2000
, as expected (the full reward) However, in line 24:FixedLimitProfit
only locks 1000 of my assets and nothing more. In line 21 ofFixedLimitProfit
, I get back my 1000 assets without anything else.