#### Alert: Unverified Work in Progress.

Much of the information here is compiled from the Reddcoin Source Code, the Reddcoin White Paper, and the original PoS White Paper.

That said, other bits may be things I've heard from places I can't remember. Essentially internet rumors. We will attempt to note these cases but there are no guarantees. Nothing written in this guide should be considered gospel until it's verified by a developer.

Contributions and corrections are welcomed with open arms. You can contribute at the repository.

# Understanding PoSV

In its most basic form, we can think of PoSV simply as compounding interest. It was designed to offer 5-6% interest, compounding every time you stake (produce new coins). For a rough approximation of returns under near optimal conditions, we will calculate the returns for 5% interest compounded daily.

## Reddcoin Stake Calculator

Enter your total Reddcoin above to see your stake returns.

I'm not positive this is accurate. If it's wrong please fix it and/or blame hoppi.

## Isn't it a bit more complicated than that?

It is of course. Under PoSV, your returns are greatly influenced by how often you successfully stake. This is due to the mathematical formula of PoSV, and not a product of how often your interest is compounded.

Not very important. While compounding your interest more times does result in more coins, this is not a relevant incentive of PoSV.

To demonstrate, we can use the calculator above to calculate interest on 1 million coins compounded one time versus 365 times. The difference is about 1,267 coins, or 0.13%. This example uses two very extreme cases and the difference is still relatively insignificant. In practice, the difference will be even less.

To begin understanding PoSV, we need to first understand when, or how often, you stake.

It's easiest to think about this in terms of a lottery. Everyone with reddcoins has many "lottery tickets." Approximately every minute, one lottery ticket is chosen, and whoever wins gets awarded newly created coins.

If you have reddcoins in your wallet, you have some lottery tickets. Whoever has the most lottery tickets has
the best chance of winning. To enter the lottery just make sure your wallet is *staking*, and it will enter
the drawing for you every minute.

Before we can understand how many tickets each person gets, we'll need to review a few important concepts.

###
What is *staking* ?

Staking is the process your wallet uses to validate transactions and award you with coins. When your wallet is staking, it is checking transactions to make sure everyone who sends coins actually owned those coins and had the right to transfer them. If most of the wallets online agree that a transaction is valid, then it gets accepted by the network. This concept of consensus is essential to all digital currencies, and is what keeps Reddcoin secure.

In order to stake, ensure that your wallet is encrypted and unlocked. By keeping your wallet open, it will stake automatically.

When you encrypt your wallet, make sure to use a strong password that you will never forget. You cannot recover your password or coins if you forget your password.

As a reward for keeping the network secure, every minute one person is chosen to receive some interest on the coins they own. Whoever has the most "lottery tickets" has the best chance of winning the award.

In Reddcoin terms, your lottery tickets are referred to as your "Weighted Coin Age" or simply *weight*, and
your weight is a non-linear product of *coin age*.

###
What is *coin age* ?

Quite simply, *coin age* is the age of your coins. Imagine you get a new wallet and start out with zero coins.
On Monday, your friend sends you 5,000 coins. On Wednesday, you decide to buy 10,000 more coins and withdraw them
to your wallet.

Assuming it's Thursday, you'll have two groups of coins. The first group of 5,000 has 3 days of coin age, and the second group of 10,000 coins has 1 day of coin age.

When coins are sent to another address or successfully stake (generate interest), their coin age is reset.

It's important to recognize that staking happens in groups. So, following our example above, if your first group of 5,000 coins stakes, you'll get an interest payed on those 5,000 coins, not your entire balance of 15,000 coins.

Additionally, coin age will be reset on your group of 5,000, but coinage on your second group of 10,000 will continue to grow until they stake or are used in a transaction.

##
What is the *network weight*, *total weight*, and *expected time* until next reward ?

In your reddcoin wallet, you can view weight information at the bottom right of your wallet if you let your mouse hover over the green arrow which indicates that your wallet is currently staking.

According to the reddcoin protocol, every minute there's a lottery going on, which will result in a single block being discovered.

A block is essentially a group of Reddcoin transactions. When you stake, your wallet attempts to "Solve" the current block by making a guess about an unknown password which unlocks the block. It takes a lot of guesses to find the password, but once you find it, you inform all the other wallets that you found the block and tell them the password you discovered.

The other wallets will check that password to make sure it actually unlocks the block. When enough of them report back that your password was correct, you have solved the block and as a reward you get paid interest.

In PoSV, the more coin weight you have, the easier it is for you to guess the password. Each block has many "passwords" and it's possible that two people solve the same block. When this happens, Reddcoin will give the award to the person who has the most coin weight.

The *network weight* can be understood as the number of tickets available for this lottery.
In practice the network weight is the sum of "weighted coin age" of all the coins which are staking at this
moment accross the entire network. Let's call this number NW (for "network weight").

Now your *total weight* is the number of tickets *you* own which allow you to participate in this lottery.
It is calculated by summing up all the coinage of the coins which are staking in your wallet.
Let's call this number TW (for "total weight").

A visual representation of your "Tickets" compared to total tickets.

Now you need to know that this lottery is *fair* in the sense that each "ticket" is equally likely to win
on the next round. The details by which the winner is found is internal to the protocol implementation, but a
simplified explanation can be found in the
"What's a Block?" info section.

That being said, since different participants own different number of
those tickets, the more of them you own, the quicker you can expect to be a winner, this is the *expected time*
until your next reward. Of course the lottery is random so nothing is 100% certain. It could effectively take less time
(if you're lucky) or more time (if you're less lucky :P) than the expected time for you to actually win. But in the long
run, those differences average out and you would see that the expected time is pretty accurate (as long as you keep your
wallet online 24/7).

To be more mathematically specific, on each minute round you have a chance NW/TW to be the lucky winner. It is a simple result that as a consequence the expected time to be a winner is NW/TW minutes.

## Expected Time Until Reward

To access these numbers in your wallet, you can go to Help -> Debug Window and type "getstakinginfo". It will show you staking numbers that can be easily copied and pasted.

Let's now see how these things work in practice. Let's assume that right now the network weight is about 13B (13,000,000,000) and that your total weight is 100m (100,000,000). According to what we explained above the expected time will be

13B/100m = 130minutes

so in expectation to get a reward, it would take you about 2hrs in that case. Check it with your wallet and see if the formula works!

Just to put things back in the context of posv, winning here means discovering a block which will not only award you those precious RDD but will also validate the most recent transactions for the network. That's how you get rewarded for providing a useful service to the community!

##
What is the *average weight* ?

We mentionned before that in the wallet, coins stake in *groups* of coins which arrived in your wallet during a single transaction.

In your reddcoin wallet, you can have access to a very detailed description of the content of your wallet. In order to unlock it you need to go to
Preferences->Display and check *"Display coin control features (experts only!)"*.

Although we are not experts yet we can have a look. Now let's go to the *"Send"* tab. A new zone apppears on top of the regular gui used to send reddcoins.
It is called *"Coin Control Features"*. If you now click on *"Inputs"* you will raise a new window which will display *all* the groups of coins
which your wallet is made of.

Click on *"List mode"*. You will see a series of lines. Each line corresponds to a group of coins sharing the same coinage since they arrived in your wallet
during the same transaction. The "Date" column indicates the time this group of coins landed in your wallet and "Address" is the actual address where those coins
were received (we remind you that your wallet can contain multiple receiving addresses!).

If you take a look at the *Coin Control* menu you will discover how many groups your wallet is made of. Now each such group has a corresponding coin weight.
As we said in the previous section the total weight is the sum of all those group's coin weights. Now the *average weight* is simply the average of the coin weights
of each group!

## So how is weight calculated?

The calculation of coin weight is the core of PoSV. Like traditional PoS, the weight is a product of total coins (stake) and the average age of those coins. In contrast to traditional PoS, which calculates weight as a linear product of age, PoSV uses an algorithm where new coins gain weight quickly, and old coins gain weight increasingly slowly. This is how PoSV offers a big incentive to be active.

To see the PoSV algorithm in action, we can look at a graph of coin weight over age.

For the first week, you can see that coin weight is a linear function of coin age that grows faster than POS. On the other hand even though coins continue to accrue weight with time, they do a slower and slower pace compared to POS.

In order to better visualise the relative speed at which POSV and POS accrue weight for their coin,
the next graph shows the *ratio* of POSV to POS weights. The peak of 1.2 means that at
1 week, the coins which stake in the POSV wallet accrue weight 20% *faster* than their POS counterpart.

On the other hand after 2 weeks the POSV coins start to accrue weight *slower* than POS. This is why it is
said that POSV encourages staking over a relatively short period of time compared to POS.

Chart rendered with an adapted version of the weight algorithm from reddcoin's source.

## How much do I earn when I mint?

Every time you successfully stake coins, you get paid interest on the weighted age of those coins. To make this more clear, we'll use some examples and compare weighted age (PoSV) to calendar age (Traditional PoS).

With traditional PoS, coins are not age-weighted. One calendar day corresponds to one coin age day. What this means is that you could gather 10,000 coins and close your wallet for a year. When you open it back up, your coins would have gained a year's worth of age. Since they're so old, they'll have a high probability of staking immediately. When they do stake, they'll pay the entire year's worth of interest. So those 10,000 coins will pay 5% interest (500 coins) on 365 days worth of age. Similarly, if they were to stake with an age of one month, they would earn one month worth of interest at 5% (~42 coins)

With PoSV, interest is paid on the weighted age instead of the actual age. So if you have 10,000 Reddcoins which stake with a calendar age of one year (365 days) you'll only get paid interest on 41 days. This means you would only get a return of 57 coins, instead of the 500 they would have got in traditional PoS. This is a great incentive to keep your wallet open and secure the network.

TODO: Figure out how this actually works. This stuff could very well be made up, I don't remember where I heard it.

In order to ensure you're getting the best returns possible, Reddcoin will move your coins around to reset their age after they get to a point where the return is not high. Additionally, when you spend coins, Reddcoin will spend your oldest coins first, since they will yield the worst interest rate if they were to stake instead of being spent.

In contrast to the example of staking with old coins, Reddcoin offers an extra reward for coins that stake with a low age. According to the PoSV algorithm, a coin which stakes with a calendar age of 7 days will receive 5% interest on 8 days. This means that under optimal conditions, you can receive more than 5% interest.

To understand a bit better, let's look at a graph of annual interest depending on the average coin age when staking occurs.

TODO: Create the graph :P

## Putting it all together

To see how all of this fits together we've created a staking simulator. What we'll do here is define the total network weight and assume it remains constant for the entire simulated year. For simplicity, we'll also assume that all of your coins are in one group and that they will stay in that group the entire year. Your coins will start with a coinage of zero.

We will simulate every minute of the year by calculating your current weighted age and generating a random number to determine if you successfully stake that minute. If you do, you'll receive interest and your coinage will be reset. If you don't, we'll increase your coinage by one minute and then try to stake again.

## Simulate A Year of Staking

Current RDD: RDD

Total Times Staked: time(s)

Average Age at Stake: Days

RDD Gained: RDD

Effective Interest: %