Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
QYuQianchen committed Jan 10, 2024
1 parent ecce042 commit 78c77c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
38 changes: 23 additions & 15 deletions src/strategies/hopr-stake-and-balance-qv/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
# HOPR Stake and Balance QV

This `hopr-stake-and-balance-qv` strategy calculates voting power with:
`(B1 + B2 + B3 + S1 + S2)^0.5`
`(B1 + B2 + sum((B_i + S_i) * F_i)) ^ exponent`

where:
- B1: balance of HOPR token on mainnet
- B2: balance of HOPR token on Gnosis chain (xHOPR)
- B3: balance of wrapped HOPR token on Gnosis chain (wxHOPR)
- S1: amount of xHOPR token staked into the latest staking season
- S2: amount of wxHOPR token unclaimed from the latest staking season
- B1: HOPR token balance in the voting account on the mainnet
- B2: xHOPR token & wxHOPR token balance in the voting account on the Gnosis chain
- B_i: xHOPR token & wxHOPR token balance in the "Staking Safe", where the voting account is an owner, on the Gnosis chain
- S_i: wxHOPR token staked in outgoing HOPR Channels by HOPR nodes that are managed by the "Staking Safe", where the voting account is an owner, on the Gnosis chain
- F_i: Share of the voting account in the "Staking Safe", where the voting account is an owner, on the Gnosis chain
- exponent: Quadratic Voting-like exponent value. E.g., for quadratic-voting, the exponent is 0.5. This value can be set by the community to any value between 0 and 1, inclusive. Currently it is set at 0.75.


## Parameters
- "tokenAddress": Contract address of HOPR token on mainnet. Value should be `"0xf5581dfefd8fb0e4aec526be659cfab1f8c781da"`
- "symbol": Token Symbol. Value should be `"HOPR"`.
- "season": Number of the ongoing season. E.g. `7`.
- "fallbackGnosisBlock": Fallback block number on Gnosis chain, in case Gnosis block number cannot be translated from Ethereum mainnet due to subgraph issues. E.g. `27852687`,
- "subgraphStudioProdQueryApiKey": Production decentralized subgraph studio query API key. If no key can be provided, use `null`.
- "subgraphStudioDevAccountId": Development subgraph studio account ID. Note that this ID should not be exposed normally. If unknown, use `null`.
- "subgraphHostedAccountName": Legacy hosted subgraph account name. Value is `"hoprnet"`.
- "useStake": If the staking program should be considered. If `false`, `S1 + S2 === 0`. Value should be set to `true`.
- "useHoprOnGnosis": If tokens on Gnosis chain should be considered. If `false`, `B2 + B3 === 0`. Value should be set to `true`.
- "useHoprOnMainnet": If tokens on Ethereum mainnet should be considered. If `false`, `B1 === 0`. Value should be set to `true`.
- "subgraphStudioProdAllSeasonQueryId": Production stake all season subgraph ID. Value is `"DrkbaCvNGVcNH1RghepLRy6NSHFi8Dmwp4T2LN3LqcjY"`.
- "subgraphStudioDevAllSeasonVersion": Latest development version of the stake all season subgraph. E.g. `"v0.0.9"`
- "subgraphStudioDevAllSeasonSubgraphName": Name of the staking subgraph in Graph Studio. Value should be `"hopr-stake-all-seasons"`.
- "subgraphHostedAllSeasonSubgraphName": Name of the staking subgraph in Graph Hosted service. Value should be `"hopr-stake-all-seasons"`.
- "subgraphStudioProdHoprOnGnosisQueryId": Latest development version of the HOPR token balances on Gnosis subgraph. Value should be `"njToE7kpetd3P9sJdYQPSq6yQjBs7w9DahQpBj6WAoD"`.
- "useSafeStake": If "Safe Staking" should be considered. If `false`, `S_i === 0` and `F_i === 0`. This value should be set to `true`,
- "useChannelStake": If tokens staked in outgoing channels should be considered. If `false`, `S_i === 0`. This value should be set to `true`,
- "useHoprOnGnosis": If tokens on Gnosis chain should be considered. If `false`, `B2 === 0` and `B_i === 0`. This value should be set to `true`.
- "useHoprOnMainnet": If tokens on Ethereum mainnet should be considered. If `false`, `B1 === 0`. This value should be set to `true`.

- "subgraphStudioProdSafeStakeQueryId": ID of the "safe stake" subgraph in production. E.g. "DrkbaCvNGVcNH1RghepLRy6NSHFi8Dmwp4T2LN3LqcjY".
- "subgraphStudioDevSafeStakeSubgraphName": Name of the safe stake subgraph in Graph Studio. E.g. "hopr-nodes-dufour".
- "subgraphStudioDevSafeStakeVersion": Latest development version of the safe stake subgraph. E.g. "latest".
- "subgraphHostedSafeStakeSubgraphName": Name of the safe stake subgraph in Graph Hosted service. This servie does not exist, so the value should be `null`.
- "subgraphStudioProdChannelsQueryId": ID of the "channels" subgraph in production. E.g. "Feg6Jero3aQzesVYuqk253NNLyNAZZppbDPKFYEGJ1Hj".
- "subgraphStudioDevChannelsSubgraphName": Name of the channels subgraph in Graph Studio. E.g. "hopr-channels".
- "subgraphStudioDevChannelsVersion": Latest development version of the channels subgraph. E.g. "latest".
- "subgraphHostedChannelsSubgraphName": Name of the channels subgraph in Graph Hosted service. This servie does not exist, so the value should be `null`.
- "subgraphStudioProdHoprOnGnosisQueryId": ID of the HOPR token balances on Gnosis subgraph in production. Value should be `"njToE7kpetd3P9sJdYQPSq6yQjBs7w9DahQpBj6WAoD"`.
- "subgraphStudioDevHoprOnGnosisSubgraphName": Name of the HOPR token balances on Gnosis subgraph in Graph Studio. Value should be "hopr-on-gnosis"`
- "subgraphStudioDevHoprOnGnosisVersion": Latest development version of the HOPR token balances on Gnosis subgraph. E.g. "v0.0.2"`
- "subgraphHostedHoprOnGnosisSubgraphName": Name of the HOPR token balances on Gnosis in Graph Hosted service. Value should be `"hopr-on-xdai"`
- "exponent": Quadratic Voting-like exponent value. E.g., for quadratic-voting, the exponent is 0.5. This value can be set by the community to any value between 0 and 1, inclusive. Currently it is set at `"0.75"`.
4 changes: 2 additions & 2 deletions src/strategies/hopr-stake-and-balance-qv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const XDAI_BLOCK_HOSTED_SUBGRAPH_URL =
'https://api.thegraph.com/subgraphs/name/1hive/xdai-blocks'; // convert mainnet block to its corresponding block on Gnosis chain
const tokenAbi = ['function balanceOf(address) view returns (uint256)']; // get mainnet HOPR token balance
const DEFAULT_HOPR_HOSTED_ACCOUNT_NAME = 'hoprnet';
const DEFAULT_FACTOR = 0.5; // Quadratic-voting-like factor
const DEFAULT_FACTOR = 0.75; // Quadratic-voting-like factor

/*
********************************************
Expand All @@ -48,7 +48,7 @@ const DEFAULT_FACTOR = 0.5; // Quadratic-voting-like factor
* @param mainnetBalance HOPR token balance of the voting account, if the mainnet token balance should be taken into account. Otherwise, zero
* @param gnosisBalance xHOPR and wxHOPR token balance of the voting account, if the gnosis token balance should be taken into account. Otherwise, zero
* @param safeStakingBalance Voting account's summed share of all its owned safes, on the xHOPR/wxHOPR token balance and all the stakes in channels by their managed nodes.
* @param exponent QV-like exponent value. E.g., for quadratic-voting, the exponent is 0.5
* @param exponent QV-like exponent value. E.g., for quadratic-voting, the exponent is 0.5. This value can be set by the community to any value between 0 and 1, inclusive. Currently it is set at 0.75.
* @returns calculated score
*/
function calculateScore(
Expand Down

0 comments on commit 78c77c3

Please sign in to comment.