-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
voters fix for able poke properly #39
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import {ethers} from "hardhat"; | ||
import {Addresses} from "../addresses/addresses"; | ||
import {ControllerV2__factory, TetuVoter__factory} from "../../typechain"; | ||
import {RunHelper} from "../utils/RunHelper"; | ||
import {deployContract, txParams} from "../deploy/DeployContract"; | ||
import {Misc} from "../utils/Misc"; | ||
import {TimeUtils} from "../../test/TimeUtils"; | ||
|
||
// tslint:disable-next-line:no-var-requires | ||
const {request, gql} = require('graphql-request') | ||
|
||
// tslint:disable-next-line:no-var-requires | ||
const hre = require("hardhat"); | ||
|
||
async function main() { | ||
const [signer] = await ethers.getSigners(); | ||
const core = Addresses.getCore(); | ||
|
||
const gov = await Misc.impersonate('0xcc16d636dD05b52FF1D8B9CE09B09BC62b11412B') | ||
const logic = await deployContract(hre, signer, 'TetuVoter'); | ||
await ControllerV2__factory.connect(core.controller, gov).announceProxyUpgrade([core.tetuVoter], [logic.address]); | ||
await TimeUtils.advanceBlocksOnTs(60 * 60 * 24 * 2); | ||
await ControllerV2__factory.connect(core.controller, gov).upgradeProxy([core.tetuVoter]); | ||
|
||
const voter = TetuVoter__factory.connect(core.tetuVoter, signer); | ||
|
||
const data = await request('https://api.thegraph.com/subgraphs/name/tetu-io/tetu-v2', gql` | ||
query tetuVoterUserVotes { | ||
tetuVoterUserVotes { | ||
date | ||
percent | ||
weight | ||
user { | ||
veNFT { | ||
veNFTId | ||
} | ||
} | ||
} | ||
} | ||
`); | ||
|
||
const votes = data.tetuVoterUserVotes; | ||
|
||
const minDate = new Map<number, number>() | ||
for (const vote of votes) { | ||
// console.log(vote) | ||
const veId = vote.user.veNFT.veNFTId; | ||
console.log(new Date(vote.date * 1000), 'percent: ', vote.percent, 'weight: ', Number(vote.weight).toFixed(), 've: ', veId); | ||
const md = minDate.get(+veId) ?? Date.now(); | ||
if (md > +vote.date && +vote.weight > 10_000) { | ||
minDate.set(+veId, +vote.date); | ||
} | ||
} | ||
|
||
console.log('total ve voted', minDate.size); | ||
|
||
const vePokes: number[] = []; | ||
for (const [veId, md] of minDate.entries()) { | ||
console.log('ve: ', veId, 'min date: ', new Date(md * 1000)); | ||
const time = Date.now() - 60 * 60 * 24 * 21 * 1000; | ||
if (md * 1000 < time) { | ||
vePokes.push(veId); | ||
} | ||
} | ||
|
||
console.log('total ve pokes', vePokes.length); | ||
|
||
const skipVe = new Set<number>([]); | ||
|
||
for (const veId of vePokes) { | ||
console.log('poke ve: ', veId); | ||
if (skipVe.has(veId)) { | ||
continue; | ||
} | ||
const params = await txParams(hre, ethers.provider); | ||
await RunHelper.runAndWait(() => voter.poke(veId, {...params})); | ||
} | ||
|
||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no restrictions to call poke. Probably it worth to make a comment why the restrictions are not required.