Skip to content

Commit

Permalink
Merge branch 'snapshot-labs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmark13 authored Jan 25, 2024
2 parents d7d98b7 + b79cf32 commit e6ca43d
Show file tree
Hide file tree
Showing 17 changed files with 945 additions and 317 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@ethersproject/strings": "^5.6.1",
"@ethersproject/units": "^5.6.1",
"@ethersproject/wallet": "^5.6.2",
"@snapshot-labs/snapshot.js": "^0.9.9",
"@snapshot-labs/snapshot.js": "^0.10.1",
"@spruceid/didkit-wasm-node": "^0.2.1",
"@uniswap/sdk-core": "^3.0.1",
"@uniswap/v3-sdk": "^3.9.0",
Expand Down
5 changes: 3 additions & 2 deletions src/strategies/arrow-vesting/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"0xB66f08DBd7A59B32e98033b9A1da08B5793DAb79",
"0x5b8eD2A2CfFCD474B2E688fdeA21CB5c4350E575",
"0x03b5Dc2CE78a7bEe9F66DD619b291595a2E166BB",
"0x06A61f56de8c6a2735D1Dea68340D201ddEd7348"
"0x06A61f56de8c6a2735D1Dea68340D201ddEd7348",
"0x252C855Cc3aB5f48229393Bc4DA129542a08C808"
],
"snapshot": 18879362
"snapshot": 112192500
}
]
20 changes: 10 additions & 10 deletions src/strategies/arrow-vesting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const vestingContractAbi = [
'function recipient() public view returns (address)',
'function total_locked() public view returns (uint256)',
'function start_time() public view returns (uint256)',
'function end_time() public view returns (uint256)'
'function unclaimed() public view returns (uint256)'
// don't need to check initialized?
// don't need to check admin?
// don't need to check future_admin?
];

export async function strategy(
Expand Down Expand Up @@ -82,9 +85,9 @@ export async function strategy(
[]
);
vestingContractMulti.call(
`${vestingContractAddress}.end_time`,
`${vestingContractAddress}.unclaimed`,
vestingContractAddress,
'end_time',
'unclaimed',
[]
);
});
Expand All @@ -106,15 +109,12 @@ export async function strategy(
const start = params['start_time'];

if (recipient in addressBalances && time > start) {
const locked = parseFloat(
formatUnits(params['total_locked'], options.decimals)
const unclaimedTokens = parseFloat(
formatUnits(params['unclaimed'], options.decimals)
);
const end = params['end_time'];

addressBalances[recipient] += Math.min(
(locked * (time - start)) / (end - start),
locked
);
// Vested arrow that can be claimed is all that is counted in this strategy
addressBalances[recipient] += unclaimedTokens;
}
});

Expand Down
10 changes: 10 additions & 0 deletions src/strategies/contract-call/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@ You can call methods with multiple inputs in any contract:
]
}
```

### Params

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| address | `string` | | Contract address |
| decimals | `number` | 18 | Decimals of the output |
| symbol | `string` | optional | Symbol of the output |
| methodABI | `object` | | ABI of the method to call |
| output | `string` | optional | Output type of the method to call |
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"`.
19 changes: 12 additions & 7 deletions src/strategies/hopr-stake-and-balance-qv/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@
"params": {
"tokenAddress": "0xf5581dfefd8fb0e4aec526be659cfab1f8c781da",
"symbol": "HOPR",
"season": 7,
"fallbackGnosisBlock": 27852687,
"subgraphStudioProdQueryApiKey": null,
"subgraphStudioDevAccountId": null,
"subgraphHostedAccountName": "hoprnet",
"useStake": true,
"useSafeStake": true,
"useChannelStake": true,
"useHoprOnGnosis": true,
"useHoprOnMainnet": true,
"subgraphStudioProdAllSeasonQueryId": "DrkbaCvNGVcNH1RghepLRy6NSHFi8Dmwp4T2LN3LqcjY",
"subgraphStudioDevAllSeasonVersion": "v0.0.9",
"subgraphStudioDevAllSeasonSubgraphName": "hopr-stake-all-seasons",
"subgraphHostedAllSeasonSubgraphName": "hopr-stake-all-seasons",
"subgraphStudioProdSafeStakeQueryId": "DrkbaCvNGVcNH1RghepLRy6NSHFi8Dmwp4T2LN3LqcjY",
"subgraphStudioDevSafeStakeSubgraphName": "hopr-nodes-dufour",
"subgraphStudioDevSafeStakeVersion": "latest",
"subgraphHostedSafeStakeSubgraphName": null,
"subgraphStudioProdChannelsQueryId": "Feg6Jero3aQzesVYuqk253NNLyNAZZppbDPKFYEGJ1Hj",
"subgraphStudioDevChannelsSubgraphName": "hopr-channels",
"subgraphStudioDevChannelsVersion": "latest",
"subgraphHostedChannelsSubgraphName": null,
"subgraphStudioProdHoprOnGnosisQueryId": "njToE7kpetd3P9sJdYQPSq6yQjBs7w9DahQpBj6WAoD",
"subgraphStudioDevHoprOnGnosisSubgraphName": "hopr-on-gnosis",
"subgraphStudioDevHoprOnGnosisVersion": "v0.0.2",
"subgraphHostedHoprOnGnosisSubgraphName": "hopr-on-xdai"
"subgraphHostedHoprOnGnosisSubgraphName": "hopr-on-xdai",
"exponent": "0.75"
}
},
"network": "1",
Expand Down
Loading

0 comments on commit e6ca43d

Please sign in to comment.