xDAI vs MPESA floats

This commit is contained in:
Will Ruddick 2020-06-30 07:11:05 +00:00
parent 533b09b4b5
commit 7af458a616

View File

@ -4,6 +4,17 @@ 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:
- CIC - > Mpesa
- CICs are converted to reserve on-chain and the xDAI is held in a GE account (xDAI Float)
- We send back an equivalent amount of Mpesa to the user from out MPESA float account
- Mpesa -> CIC
- Mpesa are added to our float Mpesa account.
- xDAI from our xDAI float account is added to the reserve of the CIC (Home CIC of the user) and new CICs are minted
- We send back the user an equivalent amount of CIC
## Un -speced - todo ##
- Define the credit clearing process
### Variables ### ### Variables ###
- blockchain_CIC_Supply = the total supply of the CIC on the blockchain - blockchain_CIC_Supply = the total supply of the CIC on the blockchain
@ -27,54 +38,45 @@ Configure - using our own system AfricasTalking API to automatically send Sarafu
- Fees: Sarafu to Mpesa FeeCC2M = 2% - Fees: Sarafu to Mpesa FeeCC2M = 2%
- Fees: Sarafu to Mpesa FeeM2CC = 2% - Fees: Sarafu to Mpesa FeeM2CC = 2%
### Incoming Sarafu Rules - MPESA out ### ### Incoming CIC 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
- *mpesa given* The amount of Mpesa given should be calculated as follows: - *mpesa given* The amount of Mpesa given should be calculated as follows:
- CIC_excahnge_amount = the amount of CIC the user wants to excahnge
The Reserve (xDAI) pulled out The Reserve (xDAI) pulled out
> reserveOut_xDAI = CIC_reserve_b * (Math.pow(1 + (-1 * CIC_excahnge_amount) / CIC_supply_b, 1 / trr) - 1) --> this should be calculated as it is done on contract > reserveOut_xDAI = the amount of xDAI pulled from the reserve on-chain
- Mpesa_out = reserveOut_xDAI **USD => KSH** rate (this is from our MPESA float account)
- Mpesa_out = reserveOut_xDAI **USD => KSH** rate
- **Mpesa_given = Mpesa_out - Mpesa_out*S22M (fee) this is the amount of Mpesa sent to the user** - **Mpesa_given = Mpesa_out - Mpesa_out*S22M (fee) this is the amount of Mpesa sent to the user**
- Update CIC variables on database:
- 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
- *Mpesa_excahnge_amount* The amount of CIC given should be calculated as follows: - *Mpesa_excahnge_amount* The amount of CIC given should be calculated as follows:
- reserveIn_xDAI = Mpesa_excahnge_amount **KSH => USD** rate - reserveIn_xDAI = Mpesa_excahnge_amount **KSH => USD** rate (this will come out of the xDAI float account)
The amount cashed in = cash_in_amount The amount cashed in = cash_in_amount
> CIC_Created = CIC_supply_b * (Math.pow(1 + reserveIn_xDAI / CIC_reserve_b, trr) - 1) --> this should be calculated as it is done on contract > CIC_Created = the amount of CIC created on chain by adding the reserveIn_xDAI
- **CIC_given = CIC_Created - CIC_created*FeeM2CC ()** - **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_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
### Exchange Rate ### ### Exchange Rate ###
When dislaying the SPOT price or excahnge rate to a user we should use the following formula: When dislaying the SPOT price or excahnge rate to a user we should use the following formula:
> Exchange Price = CIC_reserve_b / (CIC_supply_b * trr) > Exchange Price = CIC_reserve / (CIC_supply * trr)
### User Interface ### ### User Interface ###
- When a user chooses to ``Redeem```: - When a user chooses to ``Redeem```:
- They should enter the amount (limited to the max in their balance) - They should enter the amount (limited to the max in their balance)
- They should get a confirmation Based on the above equations: - They should get a confirmation Based on a quote from the blockchain in a SMS:
- The user should be asked you will revice **Mpesa_given** for **CIC_excahnge_amount**: Please type your PIN to confirm - The user should be asked you will recieve **Mpesa_given** for **CIC_excahnge_amount** (note this is from blockchain and will change second by second)
- Please type your PIN to confirm
- The user should get a Mpesa responce for recieving the Mpesa - The user should get a Mpesa responce for recieving the Mpesa
- When a user chooses to ``Contribute```: - When a user chooses to ``Contribute```:
@ -85,6 +87,8 @@ When dislaying the SPOT price or excahnge rate to a user we should use the follo
- They will then get instructions on USSD as well as a SMS on how to send Mpesa or Bonga boints to our Lipa na Mpesa - They will then get instructions on USSD as well as a SMS on how to send Mpesa or Bonga boints to our Lipa na Mpesa
### Credit Clearing ###
### Security ### ### Security ###
- 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 - 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