Skip to content

Commit

Permalink
Merge pull request #121 from manumonti/legacy-nu-miscalculation
Browse files Browse the repository at this point in the history
Fix legacy Nu stakes miscalculation
  • Loading branch information
manumonti authored Jan 9, 2024
2 parents 963ad8e + bfc95b5 commit 04e26f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/scripts/gen_rewards_dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function main() {

// We need the legacy stakes to delete the Keep legacy stakes
const blockNumber = 18624792 // Block height in which legacy stakes were deac
const legacyStakes = await Subgraph.getLegacyStakes(
const legacyStakes = await Subgraph.getLegacyKeepStakes(
graphqlApi,
blockNumber - 1
)
Expand Down
14 changes: 6 additions & 8 deletions src/scripts/pre-rewards/subgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,15 +921,13 @@ exports.getLegacyNuRewards = async function (gqlUrl) {
* @param {number} blockNumber Block at which legacy stakes were deactivated
* @returns {Object[]} Stakes info
*/
exports.getLegacyStakes = async function (gqlUrl, blockNumber) {
const legacyStakersQuery = gql`
query legacyStakersQuery($blockNumber: Int) {
exports.getLegacyKeepStakes = async function (gqlUrl, blockNumber) {
const legacyKeepStakersQuery = gql`
query legacyKeepStakersQuery($blockNumber: Int) {
accounts(
first: 1000
block: { number: $blockNumber }
where: {
stakes_: { or: [{ keepInTStake_gt: "0" }, { nuInTStake_gt: "0" }] }
}
where: { stakes_: { keepInTStake_gt: "0" } }
) {
id
stakes {
Expand All @@ -946,11 +944,11 @@ exports.getLegacyStakes = async function (gqlUrl, blockNumber) {
const gqlClient = createClient({ url: gqlUrl, maskTypename: true })

const response = await gqlClient
.query(legacyStakersQuery, { blockNumber: blockNumber })
.query(legacyKeepStakersQuery, { blockNumber: blockNumber })
.toPromise()

if (response.error) {
console.error(`Error in getLegacyStakes: ${response.error.message}`)
console.error(`Error in getLegacyKeepStakes: ${response.error.message}`)
return null
}

Expand Down

0 comments on commit 04e26f3

Please sign in to comment.