cleaned formatting on math and variables
This commit is contained in:
parent
dc4128ef78
commit
2476d9fc9f
@ -5,42 +5,60 @@ We would like to automate this.
|
|||||||
## Solution ##
|
## Solution ##
|
||||||
Configure - using our own system AfricasTalking API to automatically send Sarafu / Mpesa based on rules:
|
Configure - using our own system AfricasTalking API to automatically send Sarafu / Mpesa based on rules:
|
||||||
|
|
||||||
|
### Variables ###
|
||||||
|
- blockchain_CIC_Supply = the total supply of the CIC on the blockchain
|
||||||
|
- blockchain_CIC_reserve = the total reserve (xDAI) of the CIC on the blockchain
|
||||||
|
- trr = the connector weight on blockchain converter between supply and reserve
|
||||||
|
- total_CIC_sent = the total amount of CIC that has been sent to users from our Float account - this needs to be updated for each conversion and when clearing
|
||||||
|
- total_CIC_Reserve_Sent = the total amount of Reserve that has been sent to users from our Float account - this needs to be updated for each conversion and when clearing
|
||||||
|
- total_CIC_recieved = the total amount of CIC that has been sent to users from our Float account - this needs to be updated for each conversion and when clearing
|
||||||
|
- total_CIC_Reserve_recieved = the total amount of Reserve that has been sent to users from our Float account - this needs to be updated for each conversion and when clearing
|
||||||
|
- CIC_supply_b: **blockchain_CIC_Supply** - **total_CIC_sent** + **total_CIC_recieved** = this simulates/tracks the changes to the blockchain
|
||||||
|
- CIC_reserve_b: **blockchain_CIC_reserve** - **total_CIC_Reserve_Sent** + **total_CIC_Reserve_recieved** = this simulates/tracks the changes to the blockchain
|
||||||
|
- CIC_excahnge_amount = the amount of CIC they user has sent to exhange
|
||||||
|
- Mpesa_excahnge_amount = the amount of MPesa the user has sent to exhange
|
||||||
|
- Rate: USD -> KSH
|
||||||
|
- Rate: KSH -> USD
|
||||||
|
- The account to which CIC are sent should be a Agent account
|
||||||
|
- The cash-out rules for a chama (minimum and time limit)
|
||||||
|
- Alert balance levels
|
||||||
|
- Fees: Sarafu to Mpesa FeeCC2M = 2%
|
||||||
|
- Fees: Sarafu to Mpesa FeeM2CC = 2%
|
||||||
|
|
||||||
### Incoming Sarafu Rules - MPESA out ###
|
### 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
|
- *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
|
||||||
- *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)
|
- *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
|
- *time* They can only cash out once per month
|
||||||
- *rate* The Sarafu (and their community) to Mpesa rate should be calculated as follows:
|
- *mpesa given* The amount of Mpesa given 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
|
The Reserve (xDAI) pulled out
|
||||||
> const reserveOut_xDAI = total_reserve_b * (Math.pow(1 + (-1 * CIC_burn) / CIC_supply_b, 1 / trr) - 1);
|
> reserveOut_xDAI = CIC_reserve_b * (Math.pow(1 + (-1 * CIC_excahnge_amount) / CIC_supply_b, 1 / trr) - 1) --> this shoudl be calculated as it is done on contract
|
||||||
|
|
||||||
- Mpesa_out = reserveOut_xDAI **USD => KSH** rate
|
- Mpesa_out = reserveOut_xDAI **USD => KSH** rate
|
||||||
- reserve_given = reserve_out - CIC_created*fee (0.02) (this is given to the user)
|
- **Mpesa_given = Mpesa_out - Mpesa_out*S22M (fee) this is the amount of Mpesa sent to the user**
|
||||||
- Simulate as if done on blockchain .... new_cic_supply_b = cic_supply_b - CIC_burn
|
- Update CIC variables on database:
|
||||||
- Simulate as if done on blockchain .... new_total_reserve_b = total_reserve_b - reserveOut_xDAI
|
- total_CIC_recieved+= CIC_excahnge_amount
|
||||||
|
- total_CIC_Reserve_Sent+= reserveOut_xDAI
|
||||||
|
|
||||||
|
|
||||||
### Outgoing Sarafu Rules - MPESA In ###
|
### Outgoing Sarafu Rules - MPESA In ###
|
||||||
- *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).
|
- *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
|
- *amount* The max sarafu out is 20,000 Sarafu per user, KYC_limit max, supply_max
|
||||||
- *time* No limit
|
- *time* No limit
|
||||||
- *rate* The Mpesa to Sarafu (and their community) rate should be calculated as follows:
|
- *CIC given* The amount of CIC given should be calculated as follows:
|
||||||
- CIC_supply_b: Get the total CIC supply off **blockchain** + the amount of **CIC_given**
|
- reserveIn_xDAI = Mpesa_excahnge_amount **KSH => USD** rate
|
||||||
- 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
|
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)**
|
> const CIC_Created = CIC_supply_b * (Math.pow(1 + reserveIn_xDAI / CIC_reserve_b, trr) - 1);
|
||||||
|
|
||||||
|
- **CIC_given = CIC_Created - CIC_created*FeeM2CC ()**
|
||||||
- Simulate as if done on blockchain .... new_cic_supply_b = cic_supply_b + CIC_given
|
- 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
|
- Simulate as if done on blockchain .... new_total_reserve_b = total_reserve_b + cash_in_amount
|
||||||
|
- Update CIC variables on database:
|
||||||
|
- total_CIC_sent+= CIC_excahnge_amount
|
||||||
|
- total_CIC_Reserve_recieved+= reserveIn_xDAI
|
||||||
|
|
||||||
|
|
||||||
### Security ###
|
### Security ###
|
||||||
@ -49,9 +67,3 @@ The amount cashed in = cash_in_amount
|
|||||||
- 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 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).
|
- 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
|
|
||||||
- Fees: Mpesa to Sarafu
|
|
||||||
- Fees: Sarafu to Mpesa
|
|
Loading…
Reference in New Issue
Block a user