Giter VIP home page Giter VIP logo

sargo-smart-contracts's People

Contributors

allen-muhani avatar alphonce-mutebi avatar mutinda-kioko avatar

Stargazers

 avatar

sargo-smart-contracts's Issues

[BUG] Intermittent failing tests

After setting up my local environment, I ran npx hardhut test the first time and the tests failed and upon running the tests the second time they both ran. See the logs below
Screenshot 2022-03-15 at 16 34 13
Screenshot 2022-03-15 at 16 33 49

[ Bug ] [ Fees ] Agent fees is paid by agent and not the user.

What is happening:

  • Agent accepts the request
  • Amount stated PLUS the agent fee (5 cents) is withdrawn from agents wallet and sent to escrow (5 cents too many).
  • After both, user and agent, confirm the M-PESA Payment, the 0.05 cUSD agent fee is sent back from the Wakala escrow contract to the agent wallet.
  • Meaning: The agent first pays too much, then gets it back. And he does not earn anything.

What should happen:

  • Agent accepts request
  • Amount stated (not plus the agent fee) is withdrawn from agents wallet and sent to the escrow contract.
  • both, agent and user, confirm M-PESA payment.
  • amount from escrow is sent to users wallet.
  • there is no explicit payment of 0.05 cUSD

Scenario 1: User Request cUSD Top up.

  • User posts request of 500 KSH

  • Fee for user = 0.05 cUSD (agent fee) + 0.04 cUSD (Wakala fee) = 0.09 cUSD

  • Amount the user will receive = (500 / 115) cUSD - 0.09 cUSD = 4.35 cUSD - 0.09 cUSD = 4.26 cUSD

  • Agent accepts request

  • money withdrawn from agent wallet to escrow = 4.26 cUSD (separate transaction: wallet to escrow contract)

  • money withdrawn from agent wallet to Kukuza treasury = 0.04 cUSD (separate transaction: wallet to kukuza treasury

  • Total withdrawn: 4.30 cUSD

  • 4.30 cUSD is 5 cents less than 4.35 cUSD (500 / 115), because the agent retains the 5 cent agent fee

Scenario 2: User Requests cUSD Withdrawal

  • Agent accepts request

  • Agent receives: (500 / 115)- Wakala fee = 4.35 - 0.04 = 4.31 cUSD

  • Agent sends via M-PESA: 4.35 cUSD - wakala fee - agent fee = 500 KSH - 0.09 cUSD = 500 KSH - 10.35 KSH = 489.65 KSH

  • User post request to withdraw 500 KSH

  • Fee for user = 0.05 cUSD (agent fee) + 0.04 cUSD (Wakala fee) = 0.09 cUSD

  • amount withdrawn from user wallet to escrow: (500/115) - wakala fee = 4.35 - 0.04 = 4.31 cUSD

  • amount withdrawn from user wallet to treasury: 0.04 cUSD Wakala fee

  • Check: total withdrawn: 4.35 cUSD

  • M-PESA amount the user will receive: (500 / 115) cUSD - 0.09 cUSD = 4.35 cUSD - 0.09 cUSD = 4.26 cUSD

4.26 * 115 = 489.9

Add properties for currency and country to P2P transactions/requests

In the (near) future we want to be able to filter transactions in the feed.
Based on:

  1. currency
  2. country

We don't know yet, how exactly we will filter.
But what we do know is that

  1. The user sets his/her display currency in the front end.
  2. The user specifies what country he/she is from.

Does it make sense to add bother properties to the smart contract?

What we haven't figured out yet:
What if a user sets his display currency to KSH, but chooses the country "Nigeria" when posting a request?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.