Skip to content

Commit

Permalink
Update constants (#244)
Browse files Browse the repository at this point in the history
* Update constants

* Prettier

* Add realm address

* Revert to 0.3.26
  • Loading branch information
guibescos authored Oct 13, 2023
1 parent 39974af commit 93269fe
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 123 deletions.
2 changes: 1 addition & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ npm run localnet
```

This command spawns a validator at `http://localhost:8899` with the staking program deployed in the genesis block at the address :
`sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d`
`pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ`

Additionally it will :

Expand Down
114 changes: 35 additions & 79 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions staking/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ seeds = true
members = ["programs/staking"]

[programs.localnet]
staking = "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d"
governance = "GovFUVGZWWwyoLq8rhnoVWknRFkhDSbQiSoREJ5LiZCV"
staking = "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ"
governance = "pytGY6tWRgGinSCvRLnSv4fHfBTMoiDGiCsesmHWM6U"
chat = "gCHAtYKrUUktTVzE4hEnZdLV4LXrdBf6Hh9qMaJALET"

[programs.devnet]
staking = "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d"
governance = "GovFUVGZWWwyoLq8rhnoVWknRFkhDSbQiSoREJ5LiZCV"
staking = "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ"
governance = "pytGY6tWRgGinSCvRLnSv4fHfBTMoiDGiCsesmHWM6U"

[programs.mainnet]
staking = "sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d"
governance = "GovFUVGZWWwyoLq8rhnoVWknRFkhDSbQiSoREJ5LiZCV"
staking = "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ"
governance = "pytGY6tWRgGinSCvRLnSv4fHfBTMoiDGiCsesmHWM6U"

[registry]
url = "https://anchor.projectserum.com"
Expand Down
14 changes: 3 additions & 11 deletions staking/app/constants.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import { PublicKey } from "@solana/web3.js";
import { wasm } from "./StakeConnection";

export const MAINNET_ENDPOINT = "https://api.mainnet-beta.solana.com";
export const DEVNET_ENDPOINT = "https://api.devnet.solana.com";

export function GOVERNANCE_ADDRESS() {
return new PublicKey(wasm.Constants.GOVERNANCE_PROGRAM());
}

export const STAKING_ADDRESS = new PublicKey(
"sta99txADjRfwHQQMNckb8vUN4jcAAhN2HBMTR2Ah6d"
"pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ"
);

export const REALM_ID = new PublicKey(
"A1f6LNEymJSSJsEVCL1FSgtS1jA9dNTC4ni8SkmbwQjG"
"4ct8XU5tKbMNRphWy4rePsS9kBqPhDdvZoGpmprPaug4"
);

export const MAINNET_PYTH_MINT = new PublicKey(
"3ho8ZM4JVqJzD56FADKdW7NTG5Tv6GiBPFUvyRXMy35Q"
);
export const DEVNET_PYTH_MINT = new PublicKey(
"7Bd6bEH4wHTMmov8D2WTXgxzLJcxJYczqE5NaDtZdhF6"
);
export const EPOCH_DURATION = 3600 * 24 * 7;
14 changes: 6 additions & 8 deletions staking/app/deploy/1_create_realm.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
import {
GoverningTokenType,
MintMaxVoteWeightSource,
PROGRAM_VERSION_V2,
PROGRAM_VERSION,
withCreateRealm,
} from "@solana/spl-governance";
import { Transaction, Connection } from "@solana/web3.js";
import { BN } from "bn.js";

import { AUTHORITY_KEYPAIR, PYTH_TOKEN, RPC_NODE } from "./mainnet_beta";

import { AUTHORITY_KEYPAIR, PYTH_TOKEN, RPC_NODE } from "./devnet";
import { STAKING_ADDRESS, GOVERNANCE_ADDRESS } from "../constants";
import { Constants } from "pyth-staking-wasm";
// Actual transaction hash :
// mainnet-beta : 3es1jwFLTwMBSSyVyRJ6kcJK9MmYgoJxBqBLVv6D8iKYJ1Jj2jQ9UA24ZDnJ1jqU3BVvLGMifgaGdhnhsturdtTF
// devnet : NjowaS5ApGYkGr19ge2ikQnggJJ4x8DyMcQu3pyzPPyJJ7orL3CY8FJToAMcupP8uCKh288fpBBEH6yPbqQDjiA
// devnet (10/12/23): ZoyuaKQbahuWcUkbvY4R5Cn8do8Ra1sjdKKHNQ3oVeorcn5xU7fz5uGKDAHAazD792LNytkeJz4cUu7eun8hrHr

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

await withCreateRealm(
tx.instructions,
GOVERNANCE_ADDRESS(), // Address of the governance program
PROGRAM_VERSION_V2, // Version of the on-chain governance program
PROGRAM_VERSION, // Version of the on-chain governance program
"Pyth Governance", // `name` of the realm
AUTHORITY_KEYPAIR.publicKey, // Address of the realm authority
PYTH_TOKEN, // Address of the Pyth token
AUTHORITY_KEYPAIR.publicKey, // Address of the payer
undefined, // No council mint
MintMaxVoteWeightSource.FULL_SUPPLY_FRACTION, // Irrelevant because we use the max voter weight plugin
new BN(
Constants.MAX_VOTER_WEIGHT().toString() // Create governance requires realm authority
"18446744073709551615" // u64::MAX
),
{
voterWeightAddin: STAKING_ADDRESS, // Voter weight plugin
maxVoterWeightAddin: STAKING_ADDRESS, // Max voter weight plugin
tokenType: GoverningTokenType.Liquid, // Liquid token
tokenType: GoverningTokenType.Dormant, // Users should never deposit tokens but instead use the staking program
},
undefined // No council mint
);
Expand Down
4 changes: 2 additions & 2 deletions staking/app/deploy/2_create_governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
import { Transaction, Connection, PublicKey } from "@solana/web3.js";
import { BN } from "bn.js";
import { Constants } from "pyth-staking-wasm";
import { EPOCH_DURATION, AUTHORITY_KEYPAIR, RPC_NODE } from "./mainnet_beta";
import { AUTHORITY_KEYPAIR, RPC_NODE } from "./mainnet_beta";

import { GOVERNANCE_ADDRESS, REALM_ID } from "../constants";
import { GOVERNANCE_ADDRESS, REALM_ID, EPOCH_DURATION } from "../constants";
// Actual transaction hash :
// mainnet-beta : vjUE28suh1yt42aRtsj8mwYpz4zM17WQo4ujfXCDGQ5WK1z5G2JATYvEduh1vdMt2pT9auVLJnoCQMtiyEP3aYC
// devnet : 3gKKKPGAfV15yV1Ce6Tn9vmwbeRnMHcyrvDxDpPhHAEr6L8VAe4N3rkNizhLGa7cM19xQaJykt6rxjx651fFRqXM
Expand Down
9 changes: 2 additions & 7 deletions staking/app/deploy/3_init_staking.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { Wallet, AnchorProvider, Program } from "@project-serum/anchor";
import { Connection } from "@solana/web3.js";
import { getTargetAccount } from "../../tests/utils/utils";
import {
AUTHORITY_KEYPAIR,
PYTH_TOKEN,
RPC_NODE,
EPOCH_DURATION,
} from "./mainnet_beta";
import { AUTHORITY_KEYPAIR, PYTH_TOKEN, RPC_NODE } from "./devnet";
import { BN } from "bn.js";
import { STAKING_ADDRESS, REALM_ID } from "../constants";
import { STAKING_ADDRESS, REALM_ID, EPOCH_DURATION } from "../constants";

// Actual transaction hash :
// mainnet-beta : KrWZD8gbH6Afg6suwHrmUi1xDo25rLDqqMAoAdunXmtUmuVk5HZgQvDqxFHC2uidL6TfXSmwKdQnkbnbZc8BZam
Expand Down
2 changes: 0 additions & 2 deletions staking/app/deploy/devnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ export const PYTH_TOKEN = new PublicKey(
);

export const RPC_NODE = "https://api.devnet.solana.com";

export const EPOCH_DURATION = 3600;
4 changes: 1 addition & 3 deletions staking/app/deploy/mainnet_beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ export const MULTISIG_AUTHORITY = new PublicKey(
);

export const PYTH_TOKEN = new PublicKey(
"3ho8ZM4JVqJzD56FADKdW7NTG5Tv6GiBPFUvyRXMy35Q"
"HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3"
);

export const RPC_NODE = "https://api.mainnet-beta.solana.com";

export const EPOCH_DURATION = 3600 * 24 * 7;
Loading

1 comment on commit 93269fe

@vercel
Copy link

@vercel vercel bot commented on 93269fe Oct 13, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

staking-devnet – ./

staking-devnet-pyth-web.vercel.app
staking-devnet-git-main-pyth-web.vercel.app
governance-nu.vercel.app

Please sign in to comment.