Smart contract setup
Parameters:
unlocked_interest_rate
locked_interest_rate
interest_tax_rate - global parameter for all products (also in main account)
Flags:
locked
Addresses:
default
- customer's moneyinterest
unlocked pocket: interests accumulated on daily basis
locked pocket: used to simulate unlocked pocket's interests
monthly_interests
unlocked pocket: interests accumulated on monthly basis
locked pocket: used to simulate monthly transfer of interests of unlocked pocket in its simulation
locked_unlocked_diff
- locked pocket interests lowered by simulated interests of unlocked pocket
Daily scheduled interests accumulation
Compute unlocked_daily_interest = (
default
address +monthly_interests
address) * unlocked_interest_rate.Transfer unlocked_daily_interest pesos from internal account to
interest
address.If pocket is locked, transfer (
default
* locked_interest_rate -unlocked_daily_interest
) pesos from internal account tolocked_unlocked_diff
address.If it is end of month, transfer all money from
interest
address todefault
address if pocket is unlockedmonthly_interests
if pocket is locked
If the pocket is locked and it is target day, transfer all money from
non-default
addresses todefault
address
Operations with the pocket
Transform locked to unlocked
Transfer all money from
locked_unlocked_diff
address back to internal accountTransfer all money from
monthly_interests
address tointerests
addressTransfer all money from
interests
address todefault
address
Transform unlocked to locked
Transfer all money from
interests
address todefault
address
Taxation
General rule is if any interest is moved to default account, the tax should be paid. Specifically:
In case of unlocked pocket, in the end of month when money is transferred from
interest
addressIn case of locked pocket, on target day when money is transferred from all
non-default
addresses. Should be single transactionWhen locked account is transformed to unlocked and money is transferred from
monthly_interests
address (TBD case ofinterests
address)(TBD) When unlocked account is transformed to locked and money is transferred from
interests
address.
Displayed balances
Money on the pocket =
default
addressAcquired unpaid interests =
interests
address +monthly_interests
address +locked_unlocked_diff
addressMoney lost when transforming from locked to unlocked =
locked_unlocked_diff
address
Example of unlocked pocket
initial deposit: 100
days in month : 5 (just to shorten example)
unlocked_interest_rate = 0.02
day | default address | interests address |
---|---|---|
0 | 100 | 0 |
1 | 100 | 2 (+2) |
2 | 100 | 4 (+2) |
3 | 100 | 6 (+2) |
4 | 100 | 8 (+2) |
5 | 110 | 0 (+2, 10 moved to default) |
6 | 110 | 2.2 (+2.2) |
7 | 110 | 4.4 (+2.2) |
8 | 110 | 6.6 (+2.2) |
9 | 110 | 8.8 (+2.2) |
10 | 121 | 0 (+2.2, 11 moved to default) |
Note: other addresses are 0 all the time
Example of locked pocket
initial deposit: 100
days in month : 5 (just to shorten example)
unlocked_interest_rate = 0.02
locked_interest_rate = 0.05
locked until day 12
day | default address | interests address | monthly_interests address | locked_unlocked_diff address | Amount if transformed to unlocked (sum of first three columns) | Total amount in account |
---|---|---|---|---|---|---|
0 | 100 | 0 | 0 | 0 | 100 | 100 |
1 | 100 | 2 (+2 + 0) | 0 | 3 (+5 - 2) | 102 | 105 |
2 | 100 | 4 (+2 + 0) | 0 | 6 (+5 - 2) | 104 | 110 |
3 | 100 | 6 (+2 + 0) | 0 | 9 (+5 - 2) | 106 | 115 |
4 | 100 | 8 (+2 + 0) | 0 | 12 (+5 - 2) | 108 | 120 |
5 | 100 | 0 (+2, 10 moved ->) | 10 | 15 (+5 - 2) | 110 | 125 |
6 | 100 | 2.2 (+2 + 0.2) | 10 | 17.8 (+5 -2.2) | 112.2 | 130 |
7 | 100 | 4.4 (+2 + 0.2) | 10 | 20.6 (+5 -2.2) | 114.4 | 135 |
8 | 100 | 6.6 (+2 + 0.2) | 10 | 23.4 (+5 -2.2) | 116.6 | 140 |
9 | 100 | 8.8 (+2 + 0.2) | 10 | 26.2 (+5 -2.2) | 118.8 | 145 |
10 | 100 | 0 (+2 + 0.2, 11 moved ->) | 21 | 29 (+5 -2.2) | 121 | 150 |
11 | 100 | 2.42 (+2 +0.42) | 21 | 31.58 (+5 -2.42) | 123.42 | 155 |
12 | 160 | 0 (+2 +0.42, 4.84 moved to default) | 0 (21 moved to default) | 0 (+5 -2.42, 34.16 moved to default) | - | 160 |
Comments
No “virtual” money
You can easily answer how many would customer lose in case of unlocking
In case of locked pocket, you can get money from two separate internal accounts, so you can also see the range of interest that has to be paid (first account contains money of interest that has to be paid for sure, second only if everybody will keep their pocket locked)
Unlocking can even be made so everything will be exactly as if you had unlocked pocket from the beginning, including interest that has to be paid at the end of the month