# Cardano Pool Ranking in Daedalus

**URL:** <https://forum.cardano.org/t/cardano-pool-ranking-in-daedalus/40110>\
**Category:** Operate a Stake Pool\
**Created:** [10 September 2020 06:58 UTC](https://forum.cardano.org/t/cardano-pool-ranking-in-daedalus/40110 "2020-09-10T06:58:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_ilap](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/_ilap/32/80886_2.png) [@\_ilap](https://forum.cardano.org/u/_ilap)\
**Post date:** [10 September 2020 06:58 UTC](https://forum.cardano.org/t/cardano-pool-ranking-in-daedalus/40110/1 "2020-09-10T06:58:18Z")

</div>

I wrote this gist for the pool ops (and probably for the delegators) to understand how ranking in Daedalus or in other wallets (if they use the protocol’s `non-myopic pool member rewards` for ranking) works. I assume, that there would be some errors, so happy to correct if missed or misunderstood something.  
**UPDATE: please read the updated doc in the gist instead of this, as that is updated and errors are corrected**  
The original link: [Cardano Pool Ranking in Daedalus · GitHub](https://gist.github.com/ilap/ad088d31e542f73685a3a245b3ad6c50)

# Cardano Pool Ranking in Daedalus

> **DISCLAIMER** : It seems that the ranking mechanism specified in the [Design Specification](https://hydra.iohk.io/job/Cardano/cardano-ledger-specs/delegationDesignSpec/latest-finished/download/1), and explained below, is not fully implemented and/or enabled.

## Brief explanation

The ranking in Daedalus is simply based on a sorted list of the pools, which comes from the underlying backend node that Deadalus uses.

The pool list is updated each time when Daedalus (`cardano-wallet` to be more precise) queries the node (using the `node-to-client` mini-porotocol) with the user’s specified `delegatable stake`.

The rank order is based on the pools’ calculated `non-myopic pool member rewards` that are calculated either of the user specified `delegatable stake` of the query and the pools characteristics (perfomance an pool parameters).

It can be thought as some dynamic ranking, when a user could always get different ranks based on the stake she or he wants to delegate when the protocol calculates `non-myopic member reward`, and therefore the rank, based on that value the user specified in the GUI.

When daedalus receives the `non-myopic rewards` ordered pool list (`pool id` and `non-myopic reward` pairs), it links the pools’ details (semi-static data queried earlier) to latest `non-myopic` (dynamically queried) rewards and shows it in GUI as ranked pools (highest the reward higest the rank e.g. highest reward then the pool ranked as 1st).

> Note: the slider in Daedalus is for querying the protocol for the pools’ list /w the updated `non-myopic` rewards based on the amount of ADA the users wants to delegate.

The `non-myopic pool member rewards` is caclulated by the Cardano protocol as the following:

1. First, it ranks (it is different than the wallet ranks) the pools by `desirability` which is based on the pools `apparent performance` ( **UPDATE: the `average apparent perfromance` was considered, but IO is considering to use some `hit rate estimates`** ) and on `cost`, **declared** `pledge`, and `margin` pool’s parameters ( **the pool parameters are taken from the most recent pool registration certificate** ).
2. then, the first `nOpt` ranked pools keep their total stake (`pledge` + `delegated stake`) for further calculations, while the rest can keep only their pledge, this called `non-myopic stake`.
3. After that, for the `non-myopic` reward calculations it uses the normal `pool member reward` function, but it uses the `non-myopic pool's stake` instead of the current `active stake` of the relevant pool as the `total delegated stakes` (i.e. `sigma`) parameter in the function.

As an example below querying the protocol using `cardano-wallet` listening on `localhost:8090`.

```bash
# 500 ADA delegatable stake in loveloce
STAKE=500000000

# if you left empty it will show all pools
POOL_ID=abcdef77

curl -s "http://localhost:8090/v2/stake-pools?stake=$STAKE" | jq -r '.[] | [.id, .metrics.non_myopic_member_rewards.quantity] | @csv' | grep -n "${POOL_ID}.*,"
126:"abcdef77d812a5a397fb324f1d00325e2243c476ea8ecd2030719ae5",43796301

```

## High level explanation

The pool ranking in Daedalus is based on the Cardano procotol’s game theoretic model that assumes that the procolol will inevitably reach an ideailistic (`non-myopic`) state (`Nash equilibirium`) by some time, and the rank of the pools based on their expected - `non-myopic` - reward.

And therefore in this context, `non-myopic` simply means, that Daedalus for ranking assumes the equilibirium in which a pool can be either part of only the `nOpt` number of almost fully the saturated pools (selected) or not.

It makes sense as saturation means: `stakes` delegated to pool; and if almost all `nOpt` nr. of pools would be fully saturated then, there would not be any room (i.e. no stakes left) for the rest of the pools.

Therefore, the game theoritic model assumes that the selected `nOpt` number (currently 150) of pools will have a high chance of being part of the equlibirium and the rest of them (the non-selected) would probably die out for long term.

### Desirability

This initial selection of the pools are based on their expected reward as `attractivenes` as if they would be fully saturated, which called `desirability`.

It also means, that a simplified reward function is used to calculate the pools’ reward.

![Test](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/a/d/ad7bba5ab5a674f762fe1b3374fd9cde5768622a.png)

> Note: As you can see it is not simplified, but uses `z0` as full saturation for the sigma, `σ` i.e. it assumes full saturation. ![Test](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/1/3/13eb7c50cda6a9ee5175cc11215e9792bef6e384.png), when `σ = z0`.

The pools `desirability` are calculated from the pools’ individual `apparent performance` and their monetary related pool’s parameter such as `cost`, `pledge` and `margin`.

![Test](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/5/b/5bd4132a74383dea598fbc0681232b528cbbf1dc.png)

> Note: if the caclulated `non-myopic` optimal reward is less then the `cost` then the desirability is `0`.

> The rationale of this assumption is that these parameters have some degree of impact on the pools’ rewards that will drive the delegators toward to the pools that offer the highest return of their investment (rationale behaviour).

### Non-Myopic Pool Stake

After the initial `desirability` based ranking, the system assign a `non-myopic pool stake` to each of the pools, based on the ranking selection.

![Test](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/7/8/785e9e4aec86f589d7927c86428fa385f6ed9ec9.png)

As a result, all of the pools are - virtualy - split into two distinct groups by this non-myopic pool stake assignment.

The `non-myopic stake` simply means that the first `nOpt` umber of pools (currently 150) will be considered as it would have at least a saturated level of stakes for the later `non-myopic` reward calculations, while the rest only can have their currently delegated owner’s stake (`pledge`, **keep in mind that the pledge and the pool’s stake are calculated from the current UtXO set on the time of the query and not from the active- or total stake** ).

> The rationale of this is that those who won’t be part of the equlibirium (the non-selected pools) will loose all their delegators by the time anyway, and therefore they would have stakes only from their owner(s), while the selected ones will be inevitably saturated i.e. assumes that the system will reach the Nash equilibirium.

In simple words, the system has ranked the pools by their desirability and selected the first `nOpt` number of them as the attractive ones that would be saturated  
by the time and the others wont be really counted as they would have been already died out by the time the system reaches equlibirium.

### Non-myopic Pool Member Rewards

The ranking in wallet is based on the `non-myopic pool member reward` that is calculated for each pools based on the stake of the pool member wants to delegate, for example in the Daedalus.

This `non-myopic pool member reward` is calculated by the the normal reward splitting formula of a pool, but uses the idealised `non-myopic pool stake` as the `total stake` instead of the actual `total stake` (\*\*also this non-myopic stake is based on the current UtxO set at the time of the query and not based on the actual `total stake`).

![Test](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/b/a/ba54897464877dc2f1435a06544efe7f8a94773e.png)

The meaining of this above formula is that the protocol calculates the pool member reward for each of the pools relative to the member stakes (`t` **is the stake the user is about to delegate** ) to the corresponding `non-myopic` pool stake, by using the following formula:

![Test](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/0/5/055ed648631b049a5f0cc5532c1dcbfdb8c5fd5d.png)

In simple words this means:

For each of the pools, the pool (`non-myopic`) reward is calculated based on the pool’s `pledge`, the `non-myopic pool stake` which is either of:

- at least the full saturation or more if the pool is oversaturated (for the selected ones) or
- the owner(s)’ pledge (for the rest).

and the `apparent performance`.

If the pool reward is less then the cost then it returns the `reward` as `non-myopic pool member reward`.

Otherwise, it calculates the `non-myopic pool member reward` for that pool as  
the `non-myopic pool reward` minus `cost`.

Which is multiplied by the reduced `margin` of the whole.

Then it is multiplied by `member stake` relative to the `non-myopic pool stake`.

See details below:

(`non-myopic pool reward` - `cost`) times (1 - `margin`) times `member contributing stake` relative to the `non-myopic pool stake`

![Test](https://us1.discourse-cdn.com/flex023/uploads/cardano/original/3X/9/0/90e343700eff1ee35387e7cac03d9a04b8c9b9e1.png)

## Wallet Ranking

In the wallet, the pool ranking is based on the specified wallet’s expected (`non-myopic`) rewards for its delegated- or delegatable stake, from each of the pools.

Meaning, that a wallet would have a list of all pools that contains the caclulated `non-myopic` reward that the wallet should expect. And the wallet ranking is based on this list, meaning the pool which has higher expected `non-myopic` reward, will be higher in the rank.

Though, the GUI is quite misleading, as it should behave per wallet basis, and not using some slides to fine tune to what the wallet owner wants to delegate, it should be wallet specific. For example some `drop down list` of the wallets Daedalus, have and rank the pools based on the wallets delegatable stakes.

This non-myopic rewards uses the normal reward function, but the total stakes of the pool, the `sigma` depends on the inital ranking selection, which means that the selected ones (in some degree) would be much more attractive for the users, as their all delegated stake would be considered, while the rest only can use their stake in the `non-myopic` reward caclulation.

In simple words, the wallet would sort/rank the pools based on the delegators `non-myopic pool member reward` for each of the pools.  
Meaning, the first in the rank would be the best choice for the delegator. This assumes rational behaviour from the delegators where  
they, in general, choose from the first few pools of the ranked list.

# References

- [Read the Section 4.3 and 5.6 of Latest Design Spec](https://hydra.iohk.io/job/Cardano/cardano-ledger-specs/delegationDesignSpec/latest-finished/download/1)
- [Ranking Specification](https://hydra.iohk.io/job/Cardano/cardano-ledger-specs/specs.pool-ranking/latest-finished/download/1)
- [getNonMyopicMemberRewards Function](https://github.com/input-output-hk/cardano-ledger-specs/blob/7265f655856525b0a6d44b8d79f19f6afe42e748/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/API/Wallet.hs#L70)
- [getTopRankedPools Function](https://github.com/input-output-hk/cardano-ledger-specs/blob/0caf4e6674faa9c9bf1ff1a3ca9bf5e9d143b2bf/shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/Rewards.hs#L270)
