Skip to content
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

Update governance script #263

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions staking/app/deploy/3_create_governance.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,66 @@
import {
PROGRAM_VERSION_V2,
withCreateGovernance,
GovernanceConfig,
VoteTipping,
VoteThreshold,
VoteThresholdType,
withCreateProgramGovernance,
PROGRAM_VERSION,
} from "@solana/spl-governance";
import { Transaction, Connection, PublicKey } from "@solana/web3.js";
import { BN } from "bn.js";
import { Constants } from "@pythnetwork/staking-wasm";
import { AUTHORITY_KEYPAIR, RPC_NODE } from "./devnet";

import { GOVERNANCE_ADDRESS, REALM_ID, EPOCH_DURATION } from "../constants";
import {
GOVERNANCE_ADDRESS,
REALM_ID,
EPOCH_DURATION,
STAKING_ADDRESS,
} from "../constants";
// Actual transaction hash :
// mainnet-beta : vjUE28suh1yt42aRtsj8mwYpz4zM17WQo4ujfXCDGQ5WK1z5G2JATYvEduh1vdMt2pT9auVLJnoCQMtiyEP3aYC
// devnet : 3gKKKPGAfV15yV1Ce6Tn9vmwbeRnMHcyrvDxDpPhHAEr6L8VAe4N3rkNizhLGa7cM19xQaJykt6rxjx651fFRqXM
// devnet (12/11/23): 2N1w4WGrLGsbcTre7yfpNw6FbD2X3uDpmCd3DVPyNv95jLwjt1vDFqdpcEGM9PMXj7RQgW7fJovWd7RHaouFYbmL

async function main() {
const tx = new Transaction();

let governanceConfig = new GovernanceConfig({
communityVoteThreshold: new VoteThreshold({
type: VoteThresholdType.YesVotePercentage,
value: 50,
}), // 50% of the locked supply
value: 10, // 10%
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wrong?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change this back if you changed it for devnet to prevent accidents

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to start it with 10% and adjust it later

}),
minCommunityTokensToCreateProposal: new BN(
Constants.MAX_VOTER_WEIGHT().toString()
).div(new BN(100)), // 1% of the locked supply
minInstructionHoldUpTime: 0, // 0 seconds
maxVotingTime: EPOCH_DURATION, // Is equal to 1 Pyth epoch
baseVotingTime: EPOCH_DURATION, // Is equal to 1 Pyth epoch
communityVoteTipping: VoteTipping.Strict,
minCouncilTokensToCreateProposal: new BN(1), // Not used since we don't have a council

// V3
councilVoteThreshold: new VoteThreshold({
type: VoteThresholdType.YesVotePercentage,
value: 0,
}), // Maps into `proposal_cool_off_time`, needs to be 0 in PROGRAM_VERSION_V2
type: VoteThresholdType.Disabled,
}),
councilVetoVoteThreshold: new VoteThreshold({
type: VoteThresholdType.YesVotePercentage,
value: 0,
}), // Maps into `proposal_cool_off_time`, needs to be 0 in PROGRAM_VERSION_V2
minCouncilTokensToCreateProposal: new BN(1), // Should never be used because we don't have a council mint
type: VoteThresholdType.Disabled,
}),
communityVetoVoteThreshold: new VoteThreshold({
type: VoteThresholdType.YesVotePercentage,
value: 0,
}), // Not used in PROGRAM_VERSION_V2
councilVoteTipping: VoteTipping.Strict, // Not used in PROGRAM_VERSION_V2
type: VoteThresholdType.Disabled,
}),
councilVoteTipping: VoteTipping.Strict, // Not used since we don't have a council
votingCoolOffTime: 0,
depositExemptProposalCount: 100,
});

await withCreateGovernance(
await withCreateProgramGovernance(
tx.instructions,
GOVERNANCE_ADDRESS(), // Address of our instance of the governance program
PROGRAM_VERSION_V2, // Version of the onchain program
REALM_ID, // Address of the Pyth realms
undefined, // This is a generic governance so no initial governed account
governanceConfig,
PROGRAM_VERSION, // Version of the on-chain program
REALM_ID, // Address of the Pyth realm
STAKING_ADDRESS, // Address of the staking program
governanceConfig, // Governance config
false, // Transfer upgrade authority
AUTHORITY_KEYPAIR.publicKey, // Program authority
new PublicKey(0), // The realm authority is creating it, so this doesn't need to be defined
AUTHORITY_KEYPAIR.publicKey, // Payer address
AUTHORITY_KEYPAIR.publicKey // Realm authority
Expand Down