That's a test function that helps making sure the stake2vote()
works as intended.
The stake2vote()
function fromcontracts/eosio.system/voting.cpp
is as follows:
double stake2vote( int64_t staked ) {
double weight = int64_t( (now() - (block_timestamp::block_timestamp_epoch / 1000)) / (seconds_per_day * 7) ) / double( 52 );
return double(staked) * std::pow( 2, weight );
}
In the code above, weight
is the time elapsed (in years) from block_timestamp::block_timestamp_epoch
, which is year 2000. The weight
variable in the code, therefore, increases linearly with time.
However, the return value multiplies the amount staked by 2^w
, making the value of a vote increase exponentially as time passes. In other words, the later you vote, the more weight your vote has. Note that weight
increases every week as the number of weeks is casted to a uint64_t
before dividing by number of weeks in a year.
Thus, the formula is as shown below:

where v
is the "value" of your vote, t
is the time elapsed since year 2000 and is measured in years and updated every week, and s
is the amount of EOS you staked with. While old votes will keep their values, new votes will weigh more, implicitly decaying the relative weight of old votes.
The function you quoted is a helper function used in unit testing to verify that the stake2vote()
function works as intended.