mirror of https://github.com/nucypher/nucypher.git
Merge pull request #1892 from derekpierre/worklock-doc-update
Documentation to incorporate WorkLock v4 updatespull/1925/head
commit
14fe3d0232
|
@ -0,0 +1,299 @@
|
|||
.. _worklock-architecture:
|
||||
|
||||
========
|
||||
WorkLock
|
||||
========
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
`WorkLock` is a novel, permissionless token distribution mechanism, developed at NuCypher, which requires participants
|
||||
to stake ETH and maintain NuCypher nodes in order to receive NU tokens.
|
||||
|
||||
WorkLock offers specific advantages over ICO or airdrop as a distribution mechanism, chiefly: it selects for participants
|
||||
who are most likely to strengthen the network because they commit to staking and running nodes.
|
||||
|
||||
The WorkLock begins with an open bidding or `contribution` period, during which anyone seeking to participate can send
|
||||
ETH to the WorkLock contract to be escrowed on-chain.
|
||||
At any time during the contribution period, WorkLock participants can cancel their bid to forgo NU and recoup their escrowed ETH immediately.
|
||||
Once the contribution period closes, the WorkLock contract does not accept more bids, but it will still accept
|
||||
cancellations during an additional time window. At the end of this cancellation period, the claiming window opens and
|
||||
stake-locked NU token allocations can be claimed by participants. Stake-locked NU will be distributed according to
|
||||
the following principles:
|
||||
|
||||
- All of the tokens held by WorkLock will be distributed.
|
||||
- All bids must be greater than or equal to the minimum allowed bid.
|
||||
- For each bid, the surplus above the minimum allowed bid is called the `bonus`; all bids are composed of a `base` bid (fixed minimum bid) and a `bonus` bid (variable amount).
|
||||
- Each bidder will receive at least the minimum amount of NU needed to stake.
|
||||
- Once all bidders have been assigned the minimum amount of NU, each bidder with a `bonus` will receive a portion of the remaining NU, distributed pro rata across all participants, taking into consideration only their bonus ETH amounts.
|
||||
- If the resulting NU distributed to a bidder is above the maximum allowed NU to stake, then such a bidder has their bid partially refunded until the corresponding amount of NU is within the allowed limits.
|
||||
|
||||
Finally, if WorkLock participants use that stake-locked NU to run a node, the NU will eventually unlock and their escrowed ETH will be returned in full.
|
||||
|
||||
|
||||
Hypothetical Bidding Scenarios
|
||||
------------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
To reduce complexity, calculations are performed in a step-wise manner which may lead to minor rounding differences
|
||||
in the determined values.
|
||||
|
||||
For each scenario, assume the following hypothetical WorkLock properties:
|
||||
|
||||
#. WorkLock holds 280,000,000 NU tokens and the minimum bid is 15 ETH.
|
||||
#. The minimum amount of NU required to stake is 15,000 NU and the maximum stake size is 4,000,000 NU.
|
||||
#. The total number of bidders is 1000 bidders (including you) with a total of 50,000 ETH committed (including your bid).
|
||||
#. For our purposes, a `whale` bid is a bid that causes the calculated stake size to be larger than the maximum stake size (4,000,000 NU).
|
||||
|
||||
|
||||
Scenario 1: Resulting stake size does not exceed maximum stake size (no whale bids)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**You submit a bid of 22 ETH i.e. 15 ETH minimum bid + 7 bonus ETH.**
|
||||
|
||||
*How many NU tokens would you receive?*
|
||||
|
||||
- Each of the 1000 bidders (including you) would receive at least the minimum NU to stake = 15,000 NU
|
||||
- Remaining NU in WorkLock after minimum distribution is
|
||||
|
||||
.. math::
|
||||
|
||||
280,000,000 NU - (15,000 NU \times 1000 \,bidders) = 265,000,000 NU
|
||||
|
||||
- Bonus ETH supply (i.e. total ETH not including minimum bids) is
|
||||
|
||||
.. math::
|
||||
|
||||
50,000 ETH - (15 ETH \times 1000 \,bidders) = 35,000 ETH
|
||||
|
||||
- Your bonus portion of the bonus ETH supply is
|
||||
|
||||
.. math::
|
||||
|
||||
\frac{7 ETH}{35,000 ETH} = 0.02\%
|
||||
|
||||
- Your portion of the remaining NU is
|
||||
|
||||
.. math::
|
||||
|
||||
0.02\% \times 265,000,000 NU= 53,000 NU
|
||||
|
||||
|
||||
**Total NU tokens received = 15,000 NU + 53,000 NU = 68,000 NU**
|
||||
|
||||
Scenario 2: Resulting stake size exceeds maximum stake size (1 whale bid)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**You submit a bid of 715 ETH i.e. 15 ETH minimum bid + 700 bonus ETH.**
|
||||
|
||||
*How many NU tokens would you receive?*
|
||||
|
||||
- Each of the 1000 bidders (including you) would receive at least the minimum NU to stake = 15,000 NU
|
||||
- Remaining NU in WorkLock after minimum distribution is
|
||||
|
||||
.. math::
|
||||
|
||||
280,000,000 NU - (15,000 NU \times 1000 \,bidders) = 265,000,000 NU
|
||||
|
||||
- Bonus ETH supply (i.e. total ETH not including minimum bids) is
|
||||
|
||||
.. math::
|
||||
|
||||
50,000 ETH - (15 ETH \times 1000 \,bidders) = 35,000 ETH
|
||||
|
||||
- Your bonus portion of the bonus ETH supply is
|
||||
|
||||
.. math::
|
||||
|
||||
\frac{700 ETH}{35,000 ETH} = 2\%
|
||||
|
||||
- Your portion of the remaining NU is
|
||||
|
||||
.. math::
|
||||
|
||||
2\% \times 265,000,000 NU= 5,300,000 NU
|
||||
|
||||
|
||||
However, the total amount of NU tokens to receive is 15,000 NU + 5,300,000 NU = 5,315,000 NU which is greater than
|
||||
the maximum stake amount (4,000,000 NU). Therefore, the amount of NU tokens distributed to you needs to be reduced,
|
||||
and some of your bonus ETH refunded.
|
||||
|
||||
- Typically the calculation for the NU received from the bonus portion is
|
||||
|
||||
.. math::
|
||||
|
||||
\frac{\text{your bonus ETH}}{\text{bonus ETH supply}} \times \text{remaining NU tokens}
|
||||
|
||||
- The additional complication here is that refunding bonus ETH reduces your bonus ETH **AND** the bonus ETH supply since the
|
||||
bonus ETH supply includes the bonus ETH portion of your bid.
|
||||
- A more complicated equation arises for the bonus part of the calculation, where `x` is the refunded ETH:
|
||||
|
||||
.. math::
|
||||
|
||||
\text{stake size} = \frac{\text{(your bonus ETH - x)}}{\text{(bonus ETH supply - x)}} \times \text{remaining NU tokens}
|
||||
|
||||
- Since you will receive a 15,000 NU minimum, and the maximum stake size is 4,000,000 NU, the most you can receive from the remaining NU is
|
||||
|
||||
.. math::
|
||||
|
||||
4,000,000 NU - 15,000 NU = 3,985,000 NU
|
||||
|
||||
- Therefore using values in the equation above yields
|
||||
|
||||
.. math::
|
||||
|
||||
3,985,000 NU = \frac{700 ETH - x ETH}{35,000 ETH - x ETH} \times 265,000,000 NU
|
||||
|
||||
- Reorganizing the equation
|
||||
|
||||
.. math::
|
||||
|
||||
x &= \frac{700 ETH \times 265,000,000 NU - 35,000 ETH \times 3,985,000 NU}{265,000,000 NU - 3,985,000 NU} \\
|
||||
&\approx 176.33 ETH
|
||||
|
||||
- Therefore, your final bonus bid is
|
||||
|
||||
.. math::
|
||||
|
||||
700 ETH - 176.33 ETH \approx 523.67 ETH
|
||||
|
||||
- Your portion of the bonus ETH supply is
|
||||
|
||||
.. math::
|
||||
|
||||
\frac{523.67}{(35,000 ETH - 176.33 ETH)} \approx 1.504\%
|
||||
|
||||
- Your portion of the remaining NU is
|
||||
|
||||
.. math::
|
||||
|
||||
1.504\% \times 265,000,000 NU \approx 3,985,006.46 NU
|
||||
|
||||
**Total NU tokens received ~ 15,000 NU + 3,985,006.46 NU (rounding) ~ 4,000,000 NU, and refunded ETH ~ 176.33 ETH**
|
||||
|
||||
|
||||
Scenario 3: Resulting stake size exceeds maximum stake size (2 whale bids)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**Someone else submitted a bid of 715 ETH (15 ETH + 700 bonus ETH); we'll call them `whale_1`.**
|
||||
|
||||
**You submit a bid of 785 ETH i.e. 15 ETH minimum bid + 770 bonus ETH; you are `whale_2`.**
|
||||
|
||||
*How many NU tokens would you receive?*
|
||||
|
||||
- Each of the 1000 bidders (including you) would receive at least the minimum NU to stake = 15,000 NU
|
||||
- Remaining NU in WorkLock after minimum distribution is
|
||||
|
||||
.. math::
|
||||
|
||||
280,000,000 NU - (15,000 NU \times 1000 \,bidders) = 265,000,000 NU
|
||||
|
||||
- Bonus ETH supply (i.e. total ETH not including minimum bids) is
|
||||
|
||||
.. math::
|
||||
|
||||
50,000 ETH - (15 ETH \times 1000 \,bidders) = 35,000 ETH
|
||||
|
||||
- Your portion of the bonus ETH supply is
|
||||
|
||||
.. math::
|
||||
|
||||
\frac{770 ETH}{35,000 ETH} = 2.2\%
|
||||
|
||||
- Your portion of the remaining NU is
|
||||
|
||||
.. math::
|
||||
|
||||
2.2\% \times 265,000,000 NU= 5,830,000 NU
|
||||
|
||||
However, the total amount of NU tokens to receive is 15,000 NU + 5,830,000 NU = 5,845,000 NU which is greater than
|
||||
the maximum stake amount (4,000,000 NU).
|
||||
|
||||
- From the previous scenario, the equation for the bonus part of the calculation is as follows, where `x` is the refunded ETH
|
||||
|
||||
.. math::
|
||||
|
||||
\text{stake size} = \frac{\text{(your bonus ETH - x)}}{\text{(bonus ETH supply - x)}} \times \text{remaining NU tokens}
|
||||
|
||||
- Additionally, there is more than one whale bid, which would also cause the bonus ETH supply to reduce as well
|
||||
- Instead the following `whale resolution` algorithm is employed:
|
||||
|
||||
#. Select the smallest whale bonus ETH bid; in this case 700 ETH from `whale_1` < 770 ETH from `whale_2`
|
||||
#. Equalize the bonus ETH whale bids for all other whales (in this case, just `whale_2` i.e. just you) to be the smallest whale bonus bid i.e. 700 ETH in this case
|
||||
#. Since your bonus ETH bid is > 700 ETH, you will be refunded
|
||||
|
||||
.. math::
|
||||
|
||||
770 ETH - 700 ETH = 70 ETH
|
||||
|
||||
#. This reduces the resulting bonus ETH supply which will now be
|
||||
|
||||
.. math::
|
||||
|
||||
35,000 ETH - 70 ETH = 34,930 ETH
|
||||
|
||||
#. We now need to calculate the bonus ETH refunds based on the updated bonus ETH supply, and the maximum stake size.
|
||||
#. Remember that everyone receives a 15,000 NU minimum, and the maximum stake size is 4,000,000 NU, so the most you can receive from the remaining NU is
|
||||
|
||||
.. math::
|
||||
|
||||
4,000,000 NU - 15,000 NU = 3,985,000 NU
|
||||
|
||||
#. Since we have multiple bidders, our equation is the following , where `n` is the number of whale bidders
|
||||
|
||||
.. math::
|
||||
|
||||
x = \frac{\text{(min whale bid} \times \text{token supply - eth_supply} \times \text{max stake)}}{\text{(token supply - n} \times \text{max stake)}}
|
||||
|
||||
#. Plugging in values
|
||||
|
||||
.. math::
|
||||
|
||||
x &= \frac{(700 ETH \times 265,000,000 NU - 34,930 ETH \times 3,985,000 NU)}{(265,000,000 NU - 2 \times 3,985,000 NU)} \\
|
||||
&\approx 180.15 ETH
|
||||
|
||||
- hence each whale gets refunded ~ 180.15 ETH
|
||||
|
||||
#. Therefore,
|
||||
|
||||
- `whale_1` is refunded ~ 180.15 ETH
|
||||
- `whale_2` (i.e. you) is refunded ~ 180.15 ETH + 70 ETH (from Step 3) = 250.15 ETH
|
||||
|
||||
#. Based on the refunds
|
||||
|
||||
- The bonus bids for the whales will now be equalized:
|
||||
|
||||
- `whale_1` bonus bid = 700 ETH - 180.15 ETH = 519.85 ETH
|
||||
- `whale_2` bonus bid = 770 ETH - 250.15 ETH = 519.85 ETH
|
||||
|
||||
- The updated bonus ETH supply will be
|
||||
|
||||
.. math::
|
||||
|
||||
35,000 ETH - (180.15 ETH + 250.15 ETH) = 34,569.70 ETH
|
||||
|
||||
#. Each whale's portion of the bonus ETH supply is therefore
|
||||
|
||||
.. math::
|
||||
|
||||
\frac{519.85 ETH}{34,569.70 ETH} \approx 1.504\%
|
||||
|
||||
#. And each whale's portion of the remaining NU is
|
||||
|
||||
.. math::
|
||||
|
||||
1.504\% \times 265,000,000 NU = 3,985,600 NU
|
||||
|
||||
**Total NU tokens received ~ 15,000 NU + 3,985,600 NU (rounding) ~ 4,000,000 NU, and refunded ETH ~ 176.33 ETH**
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
In Scenarios 2 and 3, you will notice that the bonus ETH supply was reduced. This produces a very subtle situation -
|
||||
for previous non-whale bids (bids in the original bonus ETH supply that did not produce a stake larger than the
|
||||
maximum stake) their bids remained unchanged, but the bonus ETH supply was reduced. This means that some bids that
|
||||
were not originally whales, may become whales once the bonus ETH supply is reduced since their proportion of the
|
||||
bonus pool increased. Therefore, the `whale resolution` algorithm described in Scenario 3 may be repeated for
|
||||
multiple rounds until there are no longer any whales. To keep the explanation simple, both Scenarios 2 and 3 ignore
|
||||
such a situation since the calculations become even more complex.
|
|
@ -7,39 +7,25 @@ WorkLock Guide
|
|||
Overview
|
||||
--------
|
||||
|
||||
`WorkLock` is a novel, permissionless token distribution mechanism, developed at NuCypher, which requires participants to stake ETH and maintain NuCypher nodes in order to receive NU tokens.
|
||||
:ref:`worklock-architecture` is the distribution mechanism for the NuCypher token.
|
||||
|
||||
WorkLock offers specific advantages over ICO or airdrop as a distribution mechanism, chiefly: it selects for participants who are most likely to strengthen the network because they commit to staking and running nodes.
|
||||
|
||||
The WorkLock begins with an open bidding period, during which anyone seeking to participate can send ETH to the WorkLock contract to be escrowed on-chain.
|
||||
At any time, WorkLock participants can cancel their bid to forgo NU and recoup their escrowed ETH immediately.
|
||||
Once the bidding period closes, the WorkLock contract doesn't accept more bids, although it still accepts cancellations during an additional time window.
|
||||
At the end of this cancellation period, stake-locked NU will be distributed according to the following principles:
|
||||
|
||||
- Each bidder receives, at least, the minimum amount of NU needed to stake.
|
||||
- All bids will be greater or equal to the minimum allowed bid.
|
||||
- In addition to the minimum amount of NU, each bidder receives a portion of the remaining NU, distributed pro rata across all participants, taking into consideration their bid surplus with respect to the minimum bid.
|
||||
- If the resulting NU amount is above the maximum allowed NU to stake, then such a bidder has their bid partially refunded until the corresponding amount of NU is within the allowed limits.
|
||||
|
||||
Finally, if WorkLock participants use that stake-locked NU to run a node, the NU will eventually unlock and their escrowed ETH will be returned in full.
|
||||
|
||||
WorkLock CLI
|
||||
------------
|
||||
|
||||
The ``nucypher worklock`` CLI command provides the ability to participate in WorkLock. To better understand the
|
||||
commands and their options, use the ``--help`` option.
|
||||
|
||||
Common CLI flags
|
||||
----------------
|
||||
|
||||
All ``nucypher worklock`` commands share a similar structure:
|
||||
|
||||
.. code::
|
||||
|
||||
(nucypher)$ nucypher worklock <ACTION> [OPTIONS] --network <NETWORK> --provider <YOUR PROVIDER URI>
|
||||
(nucypher)$ nucypher worklock <COMMAND> [OPTIONS] --network <NETWORK> --provider <YOUR PROVIDER URI>
|
||||
|
||||
|
||||
Replace ``<YOUR PROVIDER URI>`` with a valid node web3 node provider string, for example:
|
||||
|
||||
- ``ipc:///home/ubuntu/.ethereum/goerli/geth.ipc`` - Geth Node on Görli testnet running under user ``ubuntu`` (most probably that's what you need).
|
||||
- ``ipc:///home/ubuntu/.ethereum/goerli/geth.ipc`` - Geth Node on Görli testnet running under user ``ubuntu``.
|
||||
|
||||
|
||||
Show current WorkLock information
|
||||
|
@ -52,12 +38,155 @@ You can obtain information about the current state of WorkLock by running:
|
|||
(nucypher)$ nucypher worklock status --network <NETWORK> --provider <YOUR PROVIDER URI>
|
||||
|
||||
|
||||
If you want to see detailed information about your current bid, you can specify your bidder address with the ``--bidder-address`` flag:
|
||||
The following is an example output of the ``status`` command (hypothetical values):
|
||||
|
||||
.. code::
|
||||
|
||||
_ _ _ _ _
|
||||
| | | | | | | | | |
|
||||
| | | | ___ _ __ | | __| | ___ ___ | | __
|
||||
| |/\| | / _ \ | '__|| |/ /| | / _ \ / __|| |/ /
|
||||
\ /\ /| (_) || | | < | |____| (_) || (__ | <
|
||||
\/ \/ \___/ |_| |_|\_\\_____/ \___/ \___||_|\_\
|
||||
|
||||
══ <NETWORK> ══
|
||||
|
||||
Reading Latest Chaindata...
|
||||
|
||||
Time
|
||||
══════════════════════════════════════════════════════
|
||||
|
||||
Contribution (Closed)
|
||||
------------------------------------------------------
|
||||
Claims Available ...... Yes
|
||||
Start Date ............ 2020-03-25 00:00:00+00:00
|
||||
End Date .............. 2020-03-31 23:59:59+00:00
|
||||
Duration .............. 6 days, 23:59:59
|
||||
Time Remaining ........ Closed
|
||||
|
||||
Cancellation (Open)
|
||||
------------------------------------------------------
|
||||
End Date .............. 2020-04-01 23:59:59+00:00
|
||||
Duration .............. 7 days, 23:59:59
|
||||
Time Remaining ........ 1 day, 2:47:32
|
||||
|
||||
|
||||
Economics
|
||||
══════════════════════════════════════════════════════
|
||||
|
||||
Participation
|
||||
------------------------------------------------------
|
||||
Lot Size .............. 280000000 NU
|
||||
Min. Allowed Bid ...... 15 ETH
|
||||
Participants .......... 1000
|
||||
ETH Supply ............ 50000 ETH
|
||||
ETH Pool .............. 50000 ETH
|
||||
|
||||
Base (minimum bid)
|
||||
------------------------------------------------------
|
||||
Base Deposit Rate ..... 1000 NU per base ETH
|
||||
|
||||
Bonus (surplus over minimum bid)
|
||||
------------------------------------------------------
|
||||
Bonus ETH Supply ...... 35000 ETH
|
||||
Bonus Lot Size ........ 265000000 NU
|
||||
Bonus Deposit Rate .... 7571.43 NU per bonus ETH
|
||||
|
||||
Refunds
|
||||
------------------------------------------------------
|
||||
Refund Rate Multiple .. 4.00
|
||||
Bonus Refund Rate ..... 1892.86 units of work to unlock 1 bonus ETH
|
||||
Base Refund Rate ...... 250.0 units of work to unlock 1 base ETH
|
||||
|
||||
* NOTE: bonus ETH is refunded before base ETH
|
||||
|
||||
|
||||
For the less obvious values in the output, here are some definitions:
|
||||
|
||||
- Lot Size
|
||||
NU tokens to be distributed by WorkLock
|
||||
- ETH Supply
|
||||
Sum of all ETH bids that have been placed
|
||||
- ETH Pool
|
||||
Current ETH balance of WorkLock that accounts for refunded ETH for work performed i.e. `ETH Supply` - `Refunds for Work`
|
||||
- Refund Rate Multiple
|
||||
Indicates how quickly your ETH is unlocked relative to the deposit rate e.g. a value of ``4`` means that you get your ETH refunded 4x faster than the rate used when you received NU
|
||||
- Base Deposit Rate
|
||||
Amount of NU to be received per base ETH in WorkLock
|
||||
- Bonus ETH Supply
|
||||
Sum of all bonus ETH bids that have been placed i.e. sum of all ETH above minimum bid
|
||||
- Bonus Lot Size
|
||||
Amount of NU tokens tokens that are available to be distributed based on the bonus part of bids
|
||||
- Bonus Deposit Rate
|
||||
Amount of NU to be received per bonus ETH in WorkLock
|
||||
- Bonus Refund Rate
|
||||
Units of work to unlock 1 bonus ETH
|
||||
- Base Refund Rate
|
||||
Units of work to unlock 1 base ETH
|
||||
|
||||
|
||||
If you want to see specific information about your current bid, you can specify your bidder address with the ``--bidder-address`` flag:
|
||||
|
||||
.. code::
|
||||
|
||||
(nucypher)$ nucypher worklock status --bidder-address <YOUR BIDDER ADDRESS> --network <NETWORK> --provider <YOUR PROVIDER URI>
|
||||
|
||||
The following output is an example of what is included when ``--bidder-address`` is used
|
||||
|
||||
.. code::
|
||||
|
||||
WorkLock Participant <BIDDER ADDRESS>
|
||||
=====================================================
|
||||
Tokens Claimed? ...... No
|
||||
Total Bid ............ 22 ETH
|
||||
Base ETH ......... 15 ETH
|
||||
Bonus ETH ........ 7 ETH
|
||||
Tokens Allocated ..... 68000 NU
|
||||
|
||||
Completed Work ....... 0
|
||||
Available Refund ..... 0 ETH
|
||||
|
||||
Refunded Work ........ 0
|
||||
Remaining Work ....... <REMAINING WORK>
|
||||
|
||||
Alternatively, when the allocated tokens have been claimed, the following is an example of the output
|
||||
|
||||
.. code::
|
||||
|
||||
WorkLock Participant <BIDDER ADDRESS>
|
||||
=====================================================
|
||||
Tokens Claimed? ...... Yes
|
||||
Locked ETH ........... 22 ETH
|
||||
|
||||
Completed Work ....... 0
|
||||
Available Refund ..... 0 ETH
|
||||
|
||||
Refunded Work ........ 0
|
||||
Remaining Work ....... <REMAINING WORK>
|
||||
|
||||
where,
|
||||
|
||||
- Total Bid
|
||||
WorkLock Bid
|
||||
- Base ETH
|
||||
Minimum required bid
|
||||
- Bonus ETH
|
||||
Surplus over minimum bid
|
||||
- Tokens Allocated
|
||||
Allocation of NU tokens
|
||||
- Locked ETH
|
||||
Remaining ETH to be unlocked via completion of work
|
||||
- Tokens Claimed
|
||||
Whether the allocation of NU tokens have been claimed or not
|
||||
- Completed Work
|
||||
Work already completed by the bidder
|
||||
- Available Refund
|
||||
ETH portion available to be refunded due to completed work
|
||||
- Refunded Work
|
||||
Work that has been completed and already refunded
|
||||
- Remaining Work
|
||||
Pending amount of work required before all of the participant's ETH locked will be refunded
|
||||
|
||||
|
||||
Place a bid
|
||||
-----------
|
||||
|
|
|
@ -147,6 +147,7 @@ Whitepapers
|
|||
:caption: Architecture
|
||||
|
||||
architecture/character
|
||||
architecture/worklock
|
||||
architecture/contracts
|
||||
architecture/upgradeable_proxy_contracts
|
||||
architecture/sub_stakes
|
||||
|
|
|
@ -1158,6 +1158,19 @@ class WorkLockAgent(EthereumContractAgent):
|
|||
refund_rate = self.get_bonus_deposit_rate() * slowing_refund / boosting_refund
|
||||
return refund_rate
|
||||
|
||||
def get_base_refund_rate(self) -> int:
|
||||
f = self.contract.functions
|
||||
slowing_refund = f.SLOWING_REFUND().call()
|
||||
boosting_refund = f.boostingRefund().call()
|
||||
refund_rate = self.get_base_deposit_rate() * slowing_refund / boosting_refund
|
||||
return refund_rate
|
||||
|
||||
def get_base_deposit_rate(self) -> int:
|
||||
f = self.contract.functions
|
||||
min_allowed_locked_tokens = f.minAllowableLockedTokens().call()
|
||||
deposit_rate = min_allowed_locked_tokens // self.minimum_allowed_bid # should never divide by 0
|
||||
return deposit_rate
|
||||
|
||||
def get_bonus_deposit_rate(self) -> int:
|
||||
try:
|
||||
deposit_rate = self.get_bonus_lot_value() // self.get_bonus_eth_supply()
|
||||
|
|
|
@ -891,11 +891,15 @@ def paint_worklock_status(emitter, registry: BaseContractRegistry):
|
|||
cancellation_open = bidding_start <= now <= cancellation_end
|
||||
bidding_open = bidding_start <= now <= bidding_end
|
||||
|
||||
# Refund
|
||||
refund_multiple = worklock_agent.contract.functions.boostingRefund().call() \
|
||||
/ worklock_agent.contract.functions.SLOWING_REFUND().call()
|
||||
|
||||
payload = f"""
|
||||
Time
|
||||
══════════════════════════════════════════════════════
|
||||
|
||||
Contribution ({'Open' if bidding_open else 'Closed'})
|
||||
Contribution Period ({'Open' if bidding_open else 'Closed'})
|
||||
------------------------------------------------------
|
||||
Claims Available ...... {'Yes' if worklock_agent.is_claiming_available() else 'No'}
|
||||
Start Date ............ {bidding_start}
|
||||
|
@ -903,7 +907,7 @@ End Date .............. {bidding_end}
|
|||
Duration .............. {bidding_duration}
|
||||
Time Remaining ........ {bidding_remaining}
|
||||
|
||||
Cancellation ({'Open' if cancellation_open else 'Closed'})
|
||||
Cancellation Period ({'Open' if cancellation_open else 'Closed'})
|
||||
------------------------------------------------------
|
||||
End Date .............. {cancellation_end}
|
||||
Duration .............. {cancellation_duration}
|
||||
|
@ -918,20 +922,26 @@ Participation
|
|||
Lot Size .............. {NU.from_nunits(worklock_agent.lot_value)}
|
||||
Min. Allowed Bid ...... {prettify_eth_amount(worklock_agent.minimum_allowed_bid)}
|
||||
Participants .......... {worklock_agent.get_bidders_population()}
|
||||
ETH Pool .............. {prettify_eth_amount(blockchain.client.get_balance(worklock_agent.contract_address))}
|
||||
ETH Supply ............ {prettify_eth_amount(worklock_agent.get_eth_supply())}
|
||||
ETH Pool .............. {prettify_eth_amount(blockchain.client.get_balance(worklock_agent.contract_address))}
|
||||
|
||||
Refunds
|
||||
Base (minimum bid)
|
||||
------------------------------------------------------
|
||||
Boosting Refund ....... {worklock_agent.contract.functions.boostingRefund().call()}
|
||||
Slowing Refund ........ {worklock_agent.contract.functions.SLOWING_REFUND().call()}
|
||||
Base Deposit Rate ..... {worklock_agent.get_base_deposit_rate()} NU per base ETH
|
||||
|
||||
Bonus
|
||||
Bonus (surplus over minimum bid)
|
||||
------------------------------------------------------
|
||||
Bonus ETH Supply ...... {prettify_eth_amount(worklock_agent.get_bonus_eth_supply())}
|
||||
Bonus Lot Size ........ {NU.from_nunits(worklock_agent.get_bonus_lot_value())}
|
||||
Bonus Refund Rate ..... {worklock_agent.get_bonus_refund_rate()}
|
||||
Bonus Deposit Rate .... {worklock_agent.get_bonus_deposit_rate()}
|
||||
Bonus Deposit Rate .... {worklock_agent.get_bonus_deposit_rate()} NU per bonus ETH
|
||||
|
||||
Refunds
|
||||
------------------------------------------------------
|
||||
Refund Rate Multiple .. {refund_multiple:.2f}
|
||||
Bonus Refund Rate ..... {worklock_agent.get_bonus_refund_rate()} units of work to unlock 1 bonus ETH
|
||||
Base Refund Rate ...... {worklock_agent.get_base_refund_rate()} units of work to unlock 1 base ETH
|
||||
|
||||
* NOTE: bonus ETH is refunded before base ETH
|
||||
"""
|
||||
emitter.echo(payload)
|
||||
return
|
||||
|
@ -942,12 +952,24 @@ def paint_bidder_status(emitter, bidder):
|
|||
if claim > bidder.economics.maximum_allowed_locked:
|
||||
claim = f"{claim} (Above the allowed max. The bid will be partially refunded)"
|
||||
|
||||
deposited_eth = bidder.get_deposited_eth
|
||||
bonus_eth = deposited_eth - bidder.economics.worklock_min_allowed_bid
|
||||
|
||||
message = f"""
|
||||
WorkLock Participant {bidder.checksum_address}
|
||||
=====================================================
|
||||
Total Bid ............ {prettify_eth_amount(bidder.get_deposited_eth)}
|
||||
Tokens Allocated ..... {claim}
|
||||
Tokens Claimed? ...... {"Yes" if bidder._has_claimed else "No"}"""
|
||||
====================================================="""
|
||||
|
||||
if bidder._has_claimed:
|
||||
message += f"""
|
||||
Tokens Claimed? ...... Yes
|
||||
Locked ETH ........... {prettify_eth_amount(bidder.get_deposited_eth)}"""
|
||||
else:
|
||||
message += f"""
|
||||
Tokens Claimed? ...... No
|
||||
Total Bid ............ {prettify_eth_amount(deposited_eth)}
|
||||
Base ETH ......... {prettify_eth_amount(bidder.economics.worklock_min_allowed_bid)}
|
||||
Bonus ETH ........ {prettify_eth_amount(bonus_eth)}
|
||||
Tokens Allocated ..... {claim}"""
|
||||
|
||||
compensation = bidder.available_compensation
|
||||
if compensation:
|
||||
|
|
|
@ -42,6 +42,21 @@ def test_get_deposited_eth(testerchain, agency, token_economics, test_registry):
|
|||
assert bid == small_bid
|
||||
|
||||
|
||||
def test_get_base_deposit_rate(agency, token_economics, test_registry):
|
||||
agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)
|
||||
base_deposit_rate = agent.get_base_deposit_rate()
|
||||
assert base_deposit_rate == token_economics.minimum_allowed_locked / token_economics.worklock_min_allowed_bid
|
||||
|
||||
|
||||
def test_get_base_refund_rate(testerchain, agency, token_economics, test_registry):
|
||||
agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)
|
||||
base_refund_rate = agent.get_base_refund_rate()
|
||||
|
||||
slowing_refund = agent.contract.functions.SLOWING_REFUND().call()
|
||||
assert base_refund_rate == (token_economics.minimum_allowed_locked / token_economics.worklock_min_allowed_bid) * \
|
||||
(slowing_refund / token_economics.worklock_boosting_refund_rate)
|
||||
|
||||
|
||||
def test_cancel_bid(testerchain, agency, token_economics, test_registry):
|
||||
bidder = testerchain.client.accounts[1]
|
||||
agent = ContractAgency.get_agent(WorkLockAgent, registry=test_registry)
|
||||
|
|
Loading…
Reference in New Issue