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

Reserve Withdrawals #239

Merged
merged 19 commits into from
Jul 30, 2021
Merged

Reserve Withdrawals #239

merged 19 commits into from
Jul 30, 2021

Conversation

migueldingli1997
Copy link
Collaborator

@migueldingli1997 migueldingli1997 commented Jul 30, 2021

New messages:

  • MsgWithdrawReserve: withdraws tokens from the reserve (available both from CLI and REST). Only allowed if the withdrawer is the bond's controller DID, and if the bond is in the OPEN state and has enough available reserve.

New fields in bond type:

  • ReserveWithdrawalAddress: destination address of any reserve tokens withdrawn via the MsgWithdrawReserve message. This is specified during bond creation and is not optional.
  • AvailableReserve: coins value specifying the remaining reserve out of the current (virtual) reserve. This will only ever not match with the current reserve if the MsgWithdrawReserve message is used. This defaults to nil (empty coins) and is not specified during bond creation.
  • AllowReserveWithdrawals: bool specifying whether reserve withdrawals by the controller DID are allowed. This is specified during bond creation and is not optional (however if excluded from the CLI, it is assumed to be False).

New queries:

  • QueryAvailableReserve: gets the bond's available reserve (available both from CLI and REST)

New invariants:

  • AvailableReserveInvariant: ensures that the sum of all the 'available reserve' values being reported by the bonds matches the balance in the global reserve pool.

Other changes:

  • Updated documentation and scripts/demos
  • Renamed WithdrawReserve function to WithdrawFromReserve to avoid clash with new message
  • Renamed DepositReserve function to DepositIntoReserve to match above change

Interesting points:

  • Wherever we use setReserveBalances, we now also update the available reserve via setAvailableReserve
  • Sells are not allowed when reserve withdrawals are enabled (so the two bools cannot be True in the bond)

Copy link

@dferendo dferendo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@migueldingli1997 migueldingli1997 merged commit 2e285c2 into master Jul 30, 2021
@migueldingli1997 migueldingli1997 deleted the feature/reserve-withdrawals branch July 30, 2021 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants