Update 007_eMoney_integration.md

This commit is contained in:
Will Ruddick 2021-02-01 13:48:31 +00:00
parent 8fd364bc52
commit a5c24d8f6d
1 changed files with 29 additions and 51 deletions

View File

@ -1,75 +1,53 @@
## Incoming Sarafu ## ## Notes ##
When users exchange CIC <> National Currency we have to manually send them Mpesa or CIC. Users have no way to automate the excahnge of CIC <> National Currency. Can people be encouraged to be liquidity providers and develop pools containing CIC and National Currency or other token? Creating a on-chain liquidity pool still requires on and off-boarding crypto to fiat.
We would like to automate this.
## Solution ## ## Solution ##
Configure - using our own system AfricasTalking API to automatically send CIC / Mpesa based on rules: Using AfricasTalking API to automatically send Mpesa from a business account when CIC is received (Blockchain account triggered):
Using RPC endpoints and contract calls to automatically send CIC when KSH is received (MPesa call back triggered)
A liquidity pool can be created off-chain where a liquidity provider simply monitors two (float) accounts one of CIC and another of Mpesa.
- CIC - > Mpesa - CIC - > Mpesa
- CICs are converted to reserve on-chain and the xDAI is held in a GE account (xDAI Float) - CICs are added to the float account account triggering Mpesa to be released from the mpesa (float)
- We send back an equivalent amount of Mpesa to the user from out MPESA float account - We send back an amount of Mpesa to the user from out MPESA float account (this amount can be based on a bonding curve)
- Mpesa -> CIC - Mpesa -> CIC
- Mpesa are added to our float Mpesa account. - 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 and sent to the user - CIC from our Sarafu float account is sent to the user (this amount can be based on a bonding curve)
### Variables ### ### Variables for excahnge rates ###
- blockchain_CIC_Supply = the total supply of the CIC on the blockchain - float_CIC_Supply = the total supply of the CIC on the float account
- blockchain_CIC_reserve = the total reserve (xDAI) of the CIC on the blockchain - float_CIC_reserve = the total supply of Mpesa in the float account
- trr = the connector weight on blockchain converter between supply and reserve - trr = the connector weight on blockchain converter between supply and reserve (assuming 50%)
- FLoat xDAI: THe amount of xDAI we have in our master wallet - CIC_excahnge_amount = the amount of CIC the user has sent to exhange for Mpesa
- FLoat Mpesa: THe amount of Mpesa supply we have in our PayBill account - Mpesa_excahnge_amount = the amount of MPesa the user has sent to exhange for CIC
- CIC_excahnge_amount = the amount of CIC they user has sent to exhange - Rate: CIC -> KSH
- Mpesa_excahnge_amount = the amount of MPesa the user has sent to exhange - Rate: KSH -> CIC
- Rate: USD -> KSH
- Rate: KSH -> USD
- Fees: Sarafu to Mpesa FeeCC2M = 2% - Fees: Sarafu to Mpesa FeeCC2M = 2%
- Fees: Sarafu to Mpesa FeeM2CC = 2% - Fees: Sarafu to Mpesa FeeM2CC = 2%
- The account to which CIC are sent should be a Agent account - Alert on float balance and excahnge rate levels
- The cash-out rules for a chama (minimum and time limit)
- Alert balance levels
### Incoming CIC Rules - MPESA out ### ### Incoming CIC Rules - MPESA out ###
- *white list* The chama (group accounts only but eventually anyone) can cash out - note the chama limits The amount of Mpesa given should be calculated as follows:
- *amount* See KYC_limit max, supply_max
- *mpesa given* The amount of Mpesa given should be calculated as follows:
- CIC_excahnge_amount = the amount of CIC the user wants to excahnge - CIC_excahnge_amount = the amount of CIC the user wants to excahnge
The Reserve (xDAI) to be pulled out (reported): Quotation: The Reserve (Mpesa) to be pulled out (reported):
- reserveOut_xDAI_reported = the amount of xDAI that would be pulled from the reserve on-chain (by getting a quote on-chain) Assuming a (trr=50%) connector weight: return (float_CIC_reserve x CIC_exchange_amount ) / (float_CIC_reserve + CIC_excahnge_amount)
- reserveOut_Mpesa = reserveOut_xDAI_reported **USD => KSH** rate - reserveOut_Mpesa_reported = the the above amount of Mpesa that would be pulled from the Mpesa float account minus any fees (FeeM2CC)
- reserveOut_Mpesa_reported = reserveOut_xDAI_reported **USD => KSH** rate
After the user confirms: Note that this should be the minimum amount the user will get - if they confirm (not the max)
The Reserve (xDAI) actually pulled out
- reserveOut_xDAI = the amount of xDAI actually pulled from the reserve on-chain
- **Mpesa_out** = reserveOut_Mpesa_reported (this is actually given to the user) - **and GE takes on the Mpesa risk**
- reserveOut_Mpesa = reserveOut_xDAI **USD => KSH** rate (this is from our MPESA float account)
- Mpesa_risk = Mpesa_out - reserveOut_Mpesa - this should me monitored and recorded for each transactions
After the user confirms the quotation - and executes the conversion: they should get out a minimum of reserveOut_Mpesa_reported
### 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). inverse of the above
- *amount* The max sarafu out is 20,000 Sarafu per user, KYC_limit max, supply_max
- *time* No limit
- *Mpesa_excahnge_amount* The amount of CIC given should be calculated as follows:
- reserveIn_xDAI = (Mpesa_excahnge_amount - Mpesa_excahnge_amount* fee) **KSH => USD** rate (this will come out of the xDAI float account)
The CIC to be created (reported for quote):
- CIC_Created_reported = the amount of CIC to be created on chain by adding the reserveIn_xDAI (quote from blockchain)
After the user confirms:
- CIC_Created = the actualy amount of CIC created on chain by adding the reserveIn_xDAI
- **CIC_given** = CIC_Created_reported
- CIC_risk = CIC_given - CIC_Created - this should be monitored and recorded for each transaction
### 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 / (CIC_supply * trr) -> this is pulled from blockchain and should be sent back as a SMS > Exchange Price = float_CIC_reserve / (float_CIC_supply * trr) -> this is pulled from blockchain and should be sent back as a SMS
### USSD Interface ### ### USSD Interface ###