How are users' winning possibilities calculated?

Learn more about our operations

Basic description

Users' winning possibilities are calculated based on the duration that the user has stayed in Modulus Protocol in an epoch, and the amount of tokens that they have deposited into pools. Mathematically, we use integral to calculate the number of tickets a user has in each epoch.

Calculating users' ticket amount in an Epoch

How is ticket amount calculated

The ticket amount of each user in an epoch can be calculated by the following formula

ts=startingβ€…β€Špointβ€…β€Šofβ€…β€Šanβ€…β€ŠEpocht_s= starting\;point\;of\;an\;Epoch
te=endingβ€…β€Špointβ€…β€Šofβ€…β€Šanβ€…β€ŠEpocht_e= ending\;point\; of \;an\; Epoch
tn=updatingβ€…β€Špointβ€…β€Šofβ€…β€Štheβ€…β€Šuserβ€…β€Š(eitherβ€…β€Šdepositβ€…β€Šandβ€…β€Šwithdraw)t_n= updating \;point \;of\; the\; user\; (either\; deposit\; and\; withdraw)
yn=balanceβ€…β€Šofβ€…β€Štheβ€…β€Šuserβ€…β€Šafterβ€…β€Šdepositingβ€…β€Šorβ€…β€Šwithdrawingy_n= balance \;of\; the \;user\; after\; depositing\; or\; withdrawing
yo=0y_o = 0
ticketβ€…β€Šamount=[(t1βˆ’ts)βˆ—y0]+[(t2βˆ’t1)βˆ—y1]+...+[(tnβˆ’tnβˆ’1)βˆ—ynβˆ’1]+[(teβˆ’tn)βˆ—yn]ticket\;amount = [(t_1 - t_s)*y_0] + [(t_2 - t_1)*y_1] + ... + [(t_n - t_{n-1})*y_{n-1}] + [(t_e-t_n)*y_n]

In the smart contract, every time a user deposits or withdraws, his ticket amount would be updated via the below function

function _updateAccumulatedTicket(uint256 userIDnow, uint256 beforeUpdateBalance, uint256 latestUpdatedBlock, uint256 currentEpoch) internal

The variable accumulatedTicket[Epoch ID][user] would be updated, which would be used to calculate the user's final ticket amount. In order to give the conveniences to the users making them do not have to do anything, our smart contract would automatically calculate the amount of tickets that is not accumulated (in the cases that user have no changes since the last updated time till the end of the epoch), and then sum it up with the user's accumulated ticket to get the final ticket amount of the user.

The above formula indicates that as more amount of tokens users deposit and longer time that users hold the tokens in the protocol, as higher chances of winning they would have. Deposit now

Below are the 3 examples that may help you figure out how your winning possibilities are calculated.

Case 1

On the first day of Modulus Protocol, Roberto has deposited 50 stETH, and has held it for the whole epoch duration (7 days). He is considered to be in Epoch 0.

To calculate Roberto's winning possibilities, first of all, Modulus would calculate his ticket amount. To do so, the protocol would take 50βˆ—750 * 7, which is equal to 350 tickets.

So, at Epoch 0, Roberto got 350 tickets.

Case 2

During epoch 0, Chris has deposited 100 stETH on the third day of the epoch, and has held it for the rest of the epoch, which means he has held it for a period of 4 days. Similar to Case 1, Chris would get a ticket amount of 100βˆ—4=400100 * 4 = 400 tickets.

So, at Epoch 0, Chris got 400 tickets.

Case 3

On the first day of Epoch 0, Anna has deposited 30 stETH; however, she has withdrawn half of them on the fifth day of the Epoch, and has held the rest for the last 2 days of the Epoch.

In this case, the way Anna's ticket amount calculated is a bit different. Here, we would break it down into 2 parts:

  • The first part would be from the first day to the fifth day. Anna's ticket amount would be 30βˆ—5=15030 * 5 = 150 tickets.

  • The second part for the rest of the Epoch would be 15βˆ—2=3015 * 2 = 30

At the end of the Epoch, our smart contracts would summarize all Anna's accumulated tickets, which means Anna would get 150+30=180150 + 30 = 180 tickets at the end.

So, at Epoch 0, Anna would get 180 tickets.

Technically, every time a user deposits or withdraws from the pool, our smart contracts would calculate the amount of tickets that they have accumulated for the period that they have held the tokens in the current epoch, which means even if the user withdraws all of his/her tokens during a certain epoch, the user would still be be a part of the epoch and would still have a chance of winning

With tickets given, how are the users' possibilities calculated?

At the end of each epoch, Modulus would automatically calculate how many tickets there are in total. The following formula best describes the winning possibility of a user.

Userβ€²sβ€…β€Šwinningβ€…β€Šratio=userβ€²sβ€…β€Šticketβ€…β€Šamount:totalβ€…β€Šticketβ€…β€Šamountβ€…β€Šofβ€…β€Šallβ€…β€ŠusersUser's\;winning\;ratio = user's \; ticket\; amount : total\;ticket\;amount\;of\;all\;users

For example, let say there were 650 users participated in Epoch 0, and the total amount of tickets was 125,000. To calculate one's winning chance, we would take his/her ticket amount divided by the total tickets in that epoch, which means:

  • Roberto in Case 1 would have a winning chance of 350:125,000350 : 125,000 = 1:3571 : 357

  • Chris in Case 2 would have a winning chance of 400:125,000400 : 125,000 = 1:3121 : 312

  • Anna in Case 3 would have a winning chance of 180:125,000180 : 125,000 = 1:6941 : 694

*Please note that we don't take decimals

With such a winning chance, how are the winners chosen?

To learn more about how the winners are chosen each week, please browse the next page which is embedded below:

How are lucky winners chosen?

Last updated