Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenable staging in client fund #24

Closed
jijordre opened this issue Apr 24, 2018 · 0 comments
Closed

Reenable staging in client fund #24

jijordre opened this issue Apr 24, 2018 · 0 comments
Assignees
Labels
Milestone

Comments

@jijordre
Copy link
Contributor

jijordre commented Apr 24, 2018

Description

The client fund does not allow funds to be explicitly staged. Thus at present the only way that a wallet can withdraw funds from the client fund is if its active balance is for deals and settlements increment the wallet's staged balance.

The new concepts for the client fund was exemplified in Slack message from @jijordre to @markbkk.

--

First, let’s rename client fund 1 balance and introduce 1 more balance. The active balance in the current spec we rename to deposited balance. The concept of staged balance is unchanged. We then introduce the concept of settled balance. (In name this matches what L&B suggested, although semantically it may be different.:smile:). This means that a wallet will have 3 balances (i.e. balance values) per currency.

Also we (re)introduce function Stage() in the client fund. Details about its implementation are below.

Then, we look at some actions.

  1. Wallet a makes an initial deposit of 10 ETH. This increments his deposited balance of ETH.

  2. Wallet a places a payment of 2 ETH to wallet b.

  3. Wallet a then wants to withdraw its ETH. It is successful in running the deal settlement challenge for the payment deal.

  4. Wallet a settles the payment deal on-chain by calling exchange contract’s SettleDeal() (Let’s assume immediate settlement is requested and/or discarding the reserve fund for now.) According to the net transfer of the payment it increments wallet b’s settled balance of ETH by an amount of 2 and decrements wallet a’s settled balance of ETH by the same amount of 2.

  5. Wallet a continues towards withdrawal by calling client fund contract’s Stage(). The increment to its staged balance of ETH is the sum of deposited balance (10) and settled balance (-2) of ETH, with the total value of 8 ETH. This action also zeros out the deposited balance and settled balance of wallet a.

  6. Wallet b then wants to withdraw its ETH and starts off by calling client fund’s Stage(). The increment to its staged balance of ETH is the sum of deposited balance (0) and settled balance (+2) of ETH, with the total value of 2 ETH. This action also zeros out the deposited balance and settled balance of wallet b.

  7. Wallet a choses to not withdraw after all but rather wants to reengage with orders and payments. It calls Unstage() which increments the deposited balance of ETH to 8 and zeros out the staged balance of ETH.

  8. Wallet b choses to withdraw by calling Withdraw() and zeros the staged balance of ETH.

I believe this scenario can be easily extended to trades as well. In addition we should bake into it the possibility of partial withdrawal and partial unstage. Partial stage may or may not make sense. I can’t quite decide yet.

Definition of done

  • Active balance has been renamed to deposited balance in client fund.
  • Settled balance has been implemented in client fund.
  • Function Stage() has been implemented in client fund.
  • Client fund function TransferFromActiveToStagedBalance() has been renamed to TransferFromDepositedToSettledBalance() and implementation updated to deal with updated balances.
  • Client fund function WithdrawFromActiveBalance() has been renamed to WithdrawFromDepositedBalance() and implementation updated to deal with deposited balance instead of active balance.
  • Client fund function DepositEtherToStagedBalance() has been renamed to DepositEtherToSettledBalance() and implementation updated to deal with settled balance instead of staged balance.
  • Client fund function DepositTokenToStagedBalance() has been renamed to DepositTokenToSettledBalance() and implementation updated to deal with settled balance instead of staged balance.
  • Unit tests are implemented/updated.

Details & Questions

This implementation is not included in the Omphalos specification.

Depends on

@jijordre jijordre added the bug label Apr 24, 2018
@jijordre jijordre added this to To do in nahmii contracts via automation Apr 24, 2018
@jijordre jijordre added this to the Priority 4 milestone Apr 24, 2018
mxmauro added a commit that referenced this issue Apr 26, 2018
* Whole code of ClientFund SC

* Some unit tests for ClientFund SC

* Added Unit test Helper SC

* Added more tests for ClientFunds

* Lots of unit tests added.

* More tests and added methods of issue #23

* Completed code before issue #24 major change.
@mxmauro mxmauro moved this from To do to In progress in nahmii contracts Apr 26, 2018
@jijordre jijordre modified the milestones: Priority 4, v1 Apr 30, 2018
mxmauro added a commit that referenced this issue May 7, 2018
Implemented setted balance.
Completed unit tests for ClientFund with settled balance.
@jijordre jijordre moved this from In progress to In Review in nahmii contracts May 8, 2018
@jijordre jijordre moved this from In Review to Done in nahmii contracts May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants