Skip to content

Commit

Permalink
Fix init single pool rent amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
jgur-psyops committed Jan 3, 2025
1 parent 96360c6 commit d4f2d74
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/scripts-ts/accounts_ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ TODO list of common banks and groups...
## MINTS
* UXD - 7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT
* USDT - Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB


## VALIDATORS
* Cavey Cool - CooLbbZy5Xmdt7DiHPQ3ss2uRXawnTXXVgpMS8E8jDzr
* Cavey Cool Single Pool - AvS4oXtxWdrJGCJwDbcZ7DqpSqNQtKjyXnbkDbrSk6Fq
41 changes: 35 additions & 6 deletions packages/scripts-ts/init_single_pool.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// NOTE: you will need to change package resolution or overrides to use `"@solana/web3.js":
// "^1.91.6"`, unless Solana foundation updates this...
import { Connection, PublicKey, sendAndConfirmTransaction } from "@solana/web3.js";
import {
Connection,
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
sendAndConfirmTransaction,
SystemProgram,
Transaction,
} from "@solana/web3.js";
import { AnchorProvider } from "@coral-xyz/anchor";
import { loadKeypairFromFile, SINGLE_POOL_PROGRAM_ID } from "./utils";
import { findPoolAddress, SinglePoolProgram } from "@solana/spl-single-pool-classic";
import { findPoolAddress, findPoolStakeAddress, SinglePoolProgram } from "@solana/spl-single-pool-classic";

type Config = {
VALIDATOR_VOTE_ACC: PublicKey;
Expand All @@ -14,22 +22,43 @@ const config: Config = {

async function main() {
const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
const wallet = loadKeypairFromFile(process.env.HOME + "/.config/solana/id.json");
const wallet = loadKeypairFromFile(process.env.HOME + "/keys/staging-deploy.json");
console.log("payer: " + wallet.publicKey);

const poolKey = await findPoolAddress(SINGLE_POOL_PROGRAM_ID, config.VALIDATOR_VOTE_ACC);
const poolStake = await findPoolStakeAddress(SINGLE_POOL_PROGRAM_ID, poolKey);

// @ts-ignore
const provider = new AnchorProvider(connection, wallet, {
preflightCommitment: "confirmed",
});
let tx = await SinglePoolProgram.initialize(provider.connection, config.VALIDATOR_VOTE_ACC, wallet.publicKey, true);
let tx = new Transaction();
tx.add(
SystemProgram.transfer({
fromPubkey: wallet.publicKey,
toPubkey: poolStake,
// TODO
/*
NO IDEA HOW MUCH IS ACTUALLY NEEDED HERE, SOLANA'S REFERENCE IMPLEMENTATION DOESN'T
SEND ENOUGH, BUT THIS IS LIKELY TOO MUCH
*/
lamports: LAMPORTS_PER_SOL * 1.1,
})
);

tx.add(
...(await SinglePoolProgram.initialize(provider.connection, config.VALIDATOR_VOTE_ACC, wallet.publicKey, true))
.instructions
);

try {
const signature = await sendAndConfirmTransaction(connection, tx, [wallet]);
console.log("Transaction signature:", signature);
const poolKey = await findPoolAddress(SINGLE_POOL_PROGRAM_ID, config.VALIDATOR_VOTE_ACC);
console.log("Pool key: " + poolKey);
} catch (error) {
console.error("Transaction failed:", error);
}

console.log("pool key: " + poolKey);
}

main().catch((err) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts-ts/init_validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
VoteProgram,
} from "@solana/web3.js";
import { AnchorProvider } from "@coral-xyz/anchor";
import { loadKeypairFromFile, SINGLE_POOL_PROGRAM_ID } from "./utils";
import { loadKeypairFromFile } from "./utils";

type Config = {
/**
Expand Down

0 comments on commit d4f2d74

Please sign in to comment.