Staking

Staking is the consensus algorithm in delegated proof of stake coins, which is essentially a process of pooling (delegating) the validation stakes with one wallet, called a staking pool. Proof of stake validation doesn’t require large processing power to be allocated for hashing, and requires only large amounts of coins (stakes) to be held on the validator’s wallet. The stake balance is combined from amounts of coins, delegated by a user to the staking balance of a pool. These coins physically remain on the delegator’s wallet, but can’t be sent until they get unstaked. Stake balance is used by the consensus algorithm to select top nodes that will be allowed to stake in the next period.

In FreeTON, here is DePool, which is a specialized smart contract that collects stakes from various participants to be pooled together and forwarded as one stake to the Elector on behalf of a validator node. The validator node owner supports the DePool providing a guaranteed minimal stake, and allowing smaller token holders to participate in and benefit from validation. The owner's benefit, in turn, is the increased stake for their node.
Stake collection is continuous. Stakes can be made at any time, and will be distributed to whichever round is currently in the pooling stage. Every time an election begins on the blockchain, the accumulated pool is locked and staked in this election, and the pooling stage of the next round begins.

TONOS-CLI allows to manage several types of stakes. All you need are some tokens and a DePool address.

## Risks

All participants of a DePool bear the same risks as any validator participating in elections through their own wallet and with only their own funds directly – in case of malfunction or misbehavior of their node during validation, part of the total stake or all of it may be lost. However, in DePool there are usually other participants, who have no control over the node. To protect their interests, the DePool is programmed to preserve as much of their funds as possible – the losses are deducted from the validator’s investment first, and only then from other participants. The Validator Assurance DePool parameter exists for this purpose. It defines how much the validator stands to lose, in case their node malfunctions.

## How to choose DePools

To make a stake in a DePool you need to choose a DePool you are willing to trust with your funds.
The list of available DePools is located on ton.live.
It lists their most relevant settings, and, if you click on any of them, the additional information, such as participant/stake list and round status.
Analyze the provided parameters, choose a DePool that suits you and save its address.

The parameters are the following:

* Validator assurance

Validator assurance is the minimum amount of tokens the DePool owner is obliged to invest each validation round. Without it, DePool will not participate in elections. DePool owner's funds will be the first lost, in case of any validator node malfunction or misbehavior. Only if they are not enough to cover the losses of the total stake, will the funds of other pool participants be affected.
So the higher the validator assurance, the more the validator owner is motivated to ensure proper operation of their node and the safer the stakes of all other participants are.
This parameter of the DePool cannot be changed after the DePool is deployed, not even by its owner.

* DePool fee

DePool fee is the fraction of the total DePool reward, that goes directly to the validator's wallet each time rewards are received. Validator needs it to cover current operational expenses of the node and the DePool.
The rest of the rewards are distributed among all DePool participants, proportionally to their stakes.
So the lower the DePool fee, the more profitable the DePool is for participants.

* Minimal stake

This parameter sets the minimal amount of tokens necessary to make a stake.
It is available on each DePool's page on ton.live.

## Staking fees

All staking commands are subject to an additional fee (by default 0.5 tons), that is partially spent to pay for DePool executing the command. The change is then returned to the sender. This value can be adjusted in TONOS-CLI config.
Additionally, when DePool receives the stake and rewards back from elector and processes the funds of participants, it uses the rewards to top up its balance proportionally to the number of participants. These funds cover the costs of processing stakes at the end of each round.

### Configure TONOS-CLI for DePool operations

TONOS-CLI installation instructions can be found here.
For all commands listed below, the DePool address, the wallet making the stake, the amount of fee to pay for DePool's services and the path to the keyfile/seed phrase may be specified in the TONOS-CLI config file in advance:

`tonos-cli config --addr <address> --wallet <address> --keys <path_to_keys or seed_phrase> --depool_fee <depool_fee>`

Where:

* `--addr <address>` - the address of the DePool
* `--wallet <address>` - the address of the wallet making the stake
* `<path_to_keys or seed_phrase>` - either the keyfile for the wallet making the stake, or the seed phrase in quotes
* `--depool_fee <depool_fee>` - value in tons, that is additionally attached to the message sent to the DePool to cover its fees. Change is returned to the sender. The default value, used if this option isn't configured, is 0.5 tons. It should be increased only if it proves insufficient and DePool begins to run out of gas on execution.

Example:

`tonos-cli config --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e --keys "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel" --depool_fee 0.8`

In this case all commands allow to omit `--addr`, `--wallet` and `--sign` options.

## Deposit stakes

### Ordinary stake

Ordinary stake is the most basic type of stake. It and the rewards from it belong to the wallet that made it. It is invested completely in the current pooling round, and can be reinvested every second round (as odd and even rounds are handled by DePool separately). Thus to participate in every DePool round, an ordinary stake should be invested in two consecutive rounds, so it can later be reinvested in odd and even rounds both.

Ordinary stake must exceed DePool minimum stake. Check DePool's page on ton.live to find out the minimum stake.

`tonos-cli depool [--addr <depool_address>] stake ordinary [--wallet <msig_address>] `--value` <number> [--sign <key_file or seed_phrase>]`

Where:

* `<depool_address>` - address of the DePool contract.
* `<msig_address>` - address of the wallet making a stake.

All `--value` parameters must be defined in tons, like this: `--value` 10.5, which means the value is 10,5 tons.

* `<key_file or seed_phrase>` - either the keyfile for the wallet making the stake, or the seed phrase in quotes.

Example:

`tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace stake ordinary --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e `--value` 100.5 --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"`

### Vesting stake

A wallet can make a vesting stake and define a target participant address (beneficiary) who will own this stake, provided the beneficiary has previously indicated the donor as its vesting donor address. This condition prevents unauthorized vestings from blocking the beneficiary from receiving an expected vesting stake from a known address.
**To receive a vesting stake beneficiary must:**

* already have an ordinary stake of any amount in the DePool
* set the donor address with the following command: `tonos-cli depool [--addr <depool_address>] donor vesting [--wallet <beneficiary_address>] --donor <donor_address> [--sign <key_file or seed_phrase>]`

Where

* `<depool_address>` - address of the DePool contract.
* `<beneficiary_address>` - address of the beneficiary wallet .
* `<donor_address>` - address of the donor wallet.
* `<key_file or seed_phrase>` - either the keyfile for the beneficiary wallet, or the seed phrase in quotes.

Example:

`tonos-cli depool --addr 0:3187b4d738d69776948ca8543cb7d250c042d7aad1e0aa244d247531590b9147 donor vesting --wallet 0:255a3ad9dfa8aa4f3481856aafc7d79f47d50205190bd56147138740e9b177f3 --donor 0:279afdbd7b2cbf9e65a5d204635a8630aec2baec60916ffdc9c79a09d2d2893d --sign "deal hazard oak major glory meat robust teach crush plastic point edge"`

Not the whole stake is available to the beneficiary at once. Instead it is split into parts and the next part of stake becomes available to the beneficiary (is transformed into beneficiary's ordinary stake) at the end of the round that coincides with the end of the next withdrawal period. Rewards from vesting stake are always added to the beneficiary's ordinary stake. To withdraw these funds, beneficiary should use use one of the withdrawal functions.
Please note, that the vesting stake is split into two equal parts by the DePool, to be used in both odd and even rounds, so to ensure DePool can participate in elections with just one vesting stake where validator wallet is beneficiary, the stake should exceed validatorAssurance \*2. Similarly, to ensure any vesting stake is accepted, make sure it exceeds minStake \*2.

**Donor uses the following command to make a vesting stake:**

`tonos-cli depool [--addr <depool_address>] stake vesting [--wallet <msig_address>] `--value` <number> --total <days> --withdrawal <days> --beneficiary <address> [--sign <key_file or seed_phrase>]`

Where

<depool\_address> - address of the DePool contract.
<msig\_address> - address of the donor wallet making a stake.
all `--value` parameters must be defined in tons, like this: `--value` 10.5, which means the value is 10,5 tons.
total <days> - total period, for which the stake is made.
withdrawal <days> - withdrawal period (each time a withdrawal period ends, a portion of the stake is released to the beneficiary).

There are limitations for period settings: withdrawalPeriod should be <= totalPeriod, totalPeriod cannot exceed 18 years or be <=0, totalPeriod should be exactly divisible by withdrawalPeriod.

beneficiary <address> - address of the beneficiary (wallet that will receive rewards from the stake and, in parts over time, the vesting stake itself). Cannot be the same as the wallet making the stake.

<key\_file or seed\_phrase> - either the keyfile for the donor wallet making the stake, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace stake vesting --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e `--value` 1000 --total 360 --withdrawal 30 --beneficiary 0:f22e02a1240dd4b5201f8740c38f2baf5afac3cedf8f97f3bd7cbaf23c7261e3 --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"
Note: Each participant can concurrently be the beneficiary of only one vesting stake. Once the current vesting stake expires, another can be made for the participant.
3) Lock stake

A wallet can make a lock stake, in which it locks its funds in DePool for a defined period, but rewards from this stake will be payed to another target participant (beneficiary). As with vesting, the beneficiary has to indicate the donor as its lock donor address before receiving a lock stake. This condition prevents unauthorized lock stakes from blocking the beneficiary from receiving an expected lock stake from a known address.

To receive a lock stake beneficiary must:

already have an ordinary stake of any amount in the DePool
set the donor address with the following command:
tonos-cli depool [--addr <depool\_address>] donor lock [--wallet <beneficiary\_address>] --donor <donor\_address> [--sign <key\_file or seed\_phrase>]

Where

<depool\_address> - address of the DePool contract.

<beneficiary\_address> - address of the beneficiary wallet .

<donor\_address> - address of the donor wallet.

<key\_file or seed\_phrase> - either the keyfile for the beneficiary wallet, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:3187b4d738d69776948ca8543cb7d250c042d7aad1e0aa244d247531590b9147 donor lock --wallet 0:255a3ad9dfa8aa4f3481856aafc7d79f47d50205190bd56147138740e9b177f3 --donor 0:279afdbd7b2cbf9e65a5d204635a8630aec2baec60916ffdc9c79a09d2d2893d --sign "deal hazard oak major glory meat robust teach crush plastic point edge"

Like vesting stake, lock stake can be configured to be unlocked in parts at the end of each round that coincides with the end of the next withdrawal period. At the end of each period the Lock Stake is returned to the wallet which locked it. The rewards of a lock stake are always added to the ordinary stake of the beneficiary. To withdraw these funds, beneficiary should use use one of the withdrawal functions.

Please note that the lock stake is split into two equal parts by the DePool, to be used in both odd and even rounds, so to ensure DePool can participate in elections with just one lock stake where validator wallet is beneficiary, the stake should equal validatorAssurance \*2. Similarly, to ensure any vesting stake is accepted, make sure it exceeds minStake \*2.

Donor uses the following command to make a lock stake:

tonos-cli depool [--addr <depool\_address>] stake lock [--wallet <msig\_address>] `--value` <number> --total <days> --withdrawal <days> --beneficiary <address> [--sign <key\_file or seed\_phrase>]

Where

<depool\_address> - address of the DePool contract.

<msig\_address> - address of the donor wallet making a stake.

all `--value` parameters must be defined in tons, like this: `--value` 10.5, which means the value is 10,5 tons.

total <days> - total period, for which the stake is made.

withdrawal <days> - withdrawal period (each time a withdrawal period ends, a portion of the stake is returned to the wallet that made the stake).

There are limitations for period settings: withdrawalPeriod should be <= totalPeriod, totalPeriod cannot exceed 18 years or be <=0, totalPeriod should be exactly divisible by withdrawalPeriod.

beneficiary <address>address of the beneficiary (wallet that will receive rewards from the stake). Cannot be the same as the wallet making the stake.

key\_file or seed\_phrase - either the keyfile for the donor wallet making the stake, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace stake lock --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e `--value` 1000 --total 360 --withdrawal 30 --beneficiary 0:f22e02a1240dd4b5201f8740c38f2baf5afac3cedf8f97f3bd7cbaf23c7261e3 --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"
Note: Each participant can concurrently be the beneficiary of only one lock stake. Once the current lock stake expires, another can be made for the participant.
Remove stakes

This command removes an ordinary stake from a pooling round (while it has not been staked in the Elector yet):

tonos-cli depool [--addr <depool\_address>] stake remove [--wallet <msig\_address>] `--value` <number> [--sign <key\_file or seed\_phrase>]

Where

<depool\_address> - address of the DePool contract.

<msig\_address> - address of the wallet that made the stake.

all `--value` parameters must be defined in tons, like this: `--value` 10.5, which means the value is 10,5 tons.

<key\_file or seed\_phrase> - either the keyfile for the wallet making the stake, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace stake remove --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e `--value` 100 --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"
Transfer stakes

The following command assigns an existing ordinary stake or its part to another participant wallet. If the entirety of the stake is transferred, the transferring wallet is removed from the list of participants in the DePool. If the receiving wallet isn't listed among the participants, it will become a participant as the result of the command.

tonos-cli depool [--addr <depool\_address>] stake transfer [--wallet <msig\_address>] `--value` <number> --dest <address> [--sign <key\_file or seed\_phrase>]

Where

<depool\_address> - address of the DePool contract.

<msig\_address> - address of the wallet that made the stake.

all `--value` parameters must be defined in tons, like this: `--value` 10.5, which means the value is 10,5 tons.

dest <address> - address of the new owner of the stake.

<key\_file or seed\_phrase> - either the keyfile for the wallet making the stake, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace stake transfer --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e `--value` 1000 --dest 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"
Note: Stakes cannot be transferred from or to DePool's validator wallet, and between any wallets during round completion step.
Withdraw Stakes
1) Withdraw entire stake

The following command allows to withdraw an ordinary stake to the wallet that owns it, as soon as the stake becomes available. Use withdraw on to receive the stake, once it's unlocked. If you then make another stake, and want to keep reinvesting it every round, run the command with withdraw off.

tonos-cli depool [--addr <depool\_address>] withdraw on | off [--wallet <msig\_address>] [--sign <key\_file or seed\_phrase>]

Where

<depool\_address> - address of the DePool contract.

<msig\_address> - address of the wallet that made the stake.

<key\_file or seed\_phrase> - either the keyfile for the wallet that made the stake, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace withdraw on --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"
2) Withdraw part of the stake

The following command allows to withdraw part of an ordinary stake to the wallet that owns it, as soon as the stake becomes available. If, as result of this withdrawal, participant's ordinary stake becomes less than minStake, then participant's whole stake is sent to participant.

tonos-cli depool [--addr <depool\_address>] stake withdrawPart [--wallet <msig\_address>] `--value` <number> [--sign <key\_file or seed\_phrase>]

Where

<depool\_address> - address of the DePool contract.

<msig\_address> - address of the wallet that made the stake.

all `--value` parameters must be defined in tons, like this: `--value` 10.5, which means the value is 10,5 tons.

<key\_file or seed\_phrase> - either the keyfile for the wallet that made the stake, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace stake withdrawPart --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e `--value` 1000 --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"
Reinvest Stakes

Ordinary stake reinvestment is controlled by the DePool reinvest flag. By default this flag is set to yes, and the the participant's available ordinary stake will be reinvested every round, no additional action required. It gets set to no when withdrawing the entire stake. After stake withdrawal it remains set to no. To re-enable ordinary stake reinvesting after withdrawing a stake, run the withdraw command with option off:

tonos-cli depool [--addr <depool\_address>] withdraw off [--wallet <msig\_address>] [--sign <key\_file or seed\_phrase>]

Where

<depool\_address> - address of the DePool contract.

<msig\_address> - address of the wallet that made the stake.

<key\_file or seed\_phrase> - either the keyfile for the wallet that made the stake, or the seed phrase in quotes.

Example:

tonos-cli depool --addr 0:37fbcb6e3279cbf5f783d61c213ed20fee16e0b1b94a48372d20a2596b700ace withdraw off --wallet 0:1b91c010f35b1f5b42a05ad98eb2df80c302c37df69651e1f5ac9c69b7e90d4e --sign "dizzy modify exotic daring gloom rival pipe disagree again film neck fuel"

Note:

Withdrawing a part of the stake does not affect the reinvest flag.

Lock and vesting stakes are reinvested according to their initial settings for the full duration of the staking period. There is no way to change these settings once lock and vesting stakes are made.

Monitor your stake in the DePool

Your stakes, their parameters (such as reinvest flag), and accumulated rewards will be listed on the DePool's page on ton.live.

Stakes are assigned to your address. You can check them anytime.