cic-docs/spec/007_eMoney_integration.md

57 lines
3.6 KiB
Markdown
Raw Normal View History

2020-05-18 15:41:40 +02:00
## Incoming Sarafu ##
2020-06-30 07:59:31 +02:00
When users exchange CIC <> National Currency we have to manually send them Mpesa or CIC.
2020-05-18 15:41:40 +02:00
We would like to automate this.
## Solution ##
Configure - using our own system AfricasTalking API to automatically send Sarafu / Mpesa based on rules:
2020-06-30 07:59:31 +02:00
### Incoming Sarafu Rules - MPESA out###
- *white list* The chama (group accounts only but eventually anyone) must only be able to cash out - using the exchange option to an Agent account
2020-05-18 15:41:40 +02:00
- *amount* The max cash out is the minimum of (30,000 Sarafu, half their balance, their total amount of outward trade volume to other users (standard transactions)
- *time* They can only cash out once per month
2020-06-30 07:55:23 +02:00
- *rate* The Sarafu (and their community) to Mpesa rate should be calculated as follows:
- CIC_supply_b: Get the total CIC supply off **blockchain** - the amount of **CIC_burn**
- total_reserve_b: Get the total reserve off **blockchain** - the amount of **cash_out** we've gotten (in USD)
- CIC_burn_amount = whatever they have sent to exhange
The Reserve (xDAI) pulled out
> const reserveOut_xDAI = total_reserve_b * (Math.pow(1 + (-1 * CIC_burn) / CIC_supply_b, 1 / trr) - 1);
- Mpesa_out = reserveOut_xDAI **USD => KSH** rate
2020-06-30 07:59:31 +02:00
- reserve_given = reserve_out - CIC_created*fee (0.02) (this is given to the user)
2020-06-30 07:55:23 +02:00
- Simulate as if done on blockchain .... new_cic_supply_b = cic_supply_b - CIC_burn
- Simulate as if done on blockchain .... new_total_reserve_b = total_reserve_b - reserveOut_xDAI
2020-05-18 15:41:40 +02:00
2020-06-30 07:59:31 +02:00
### Outgoing Sarafu Rules - MPESA In###
2020-06-30 07:55:23 +02:00
- *white list* Only users sending via paybill receive Sarafu. Non users receive a invitation to join Sarafu sms (alert to admins there was a donation).
- *amount* The max sarafu out is 20,000 Sarafu per user, KYC_limit max, supply_max
2020-05-18 15:41:40 +02:00
- *time* No limit
2020-06-30 07:55:23 +02:00
- *rate* The Mpesa to Sarafu (and their community) rate should be calculated as follows:
- CIC_supply_b: Get the total CIC supply off **blockchain** + the amount of **CIC_given**
- total_reserve_b: Get the total reserve off **blockchain** + the amount of **cash_in** we've gotten (in USD)
- cash_in_amount = Mpesa_in **KSH -> USD** rate (what is the current USD <> KSH rate)
The amount cashed in = cash_in_amount
> const CIC_Created = cic_supply_b * (Math.pow(1 + cash_in_amount / total_reserve_b, trr) - 1);
- **CIC_given = CIC_Created - CIC_created*fee (0.02)**
- Simulate as if done on blockchain .... new_cic_supply_b = cic_supply_b + CIC_given
- Simulate as if done on blockchain .... new_total_reserve_b = total_reserve_b + cash_in_amount
2020-05-18 15:41:40 +02:00
### Security ###
2020-06-30 07:55:23 +02:00
- Balance alerts: On both Mpesa and CIC balances: The paybill from which Sarafu is sent needs to send a sms and email alert when low
2020-05-18 15:41:40 +02:00
- Failure alerts: If the API session fails an sms and email alert should be sent
- Reject on not enough Mpesa balance: If there is not enough Mpesa (on incoming Sarafu) the transaction should be rejected and an email sent to admin along with a SMS to admin and user (Sarafu should not be taken from user). (message should be visible also on mgmt platform txn view and user view and admin view).
- Reject on not enough Sarafu balance: If there is not enough Sarafu (on incoming Mpesa) the transaction should be rejected and an email sent to admin along with a SMS to admin and user (Mpesa should not be taken from user). (message should be visible also on mgmt platform txn view and user view and admin view).
### Variables ###
- The account from which Sarafu is sent should be a Agent account
- The cash-out rules for a chama (minimum and time limit)
- Alert balance levels
2020-06-30 07:55:23 +02:00
- Fees: Mpesa to Sarafu
- Fees: Sarafu to Mpesa