|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Script to setup a stake pool from scratch. Please modify the parameters to |
| 4 | +# create a stake pool to your liking! |
| 5 | + |
| 6 | +cd "$(dirname "$0")" || exit |
| 7 | +command_args=() |
| 8 | +sol_amount=$1 |
| 9 | + |
| 10 | +################################################### |
| 11 | +### MODIFY PARAMETERS BELOW THIS LINE FOR YOUR POOL |
| 12 | +################################################### |
| 13 | + |
| 14 | +# Epoch fee, assessed as a percentage of rewards earned by the pool every epoch, |
| 15 | +# represented as `numerator / denominator` |
| 16 | +command_args+=( --epoch-fee-numerator 1 ) |
| 17 | +command_args+=( --epoch-fee-denominator 100 ) |
| 18 | + |
| 19 | +# Withdrawal fee for SOL and stake accounts, represented as `numerator / denominator` |
| 20 | +command_args+=( --withdrawal-fee-numerator 2 ) |
| 21 | +command_args+=( --withdrawal-fee-denominator 100 ) |
| 22 | + |
| 23 | +# Deposit fee for SOL and stake accounts, represented as `numerator / denominator` |
| 24 | +command_args+=( --deposit-fee-numerator 3 ) |
| 25 | +command_args+=( --deposit-fee-denominator 100 ) |
| 26 | + |
| 27 | +command_args+=( --referral-fee 0 ) # Percentage of deposit fee that goes towards the referrer (a number between 0 and 100, inclusive) |
| 28 | + |
| 29 | +command_args+=( --max-validators 2350 ) # Maximum number of validators in the stake pool, 2350 is the current maximum possible |
| 30 | + |
| 31 | +# (Optional) Deposit authority, required to sign all deposits into the pool. |
| 32 | +# Setting this variable makes the pool "private" or "restricted". |
| 33 | +# Uncomment and set to a valid keypair if you want the pool to be restricted. |
| 34 | +#command_args+=( --deposit-authority keys/authority.json ) |
| 35 | + |
| 36 | +################################################### |
| 37 | +### MODIFY PARAMETERS ABOVE THIS LINE FOR YOUR POOL |
| 38 | +################################################### |
| 39 | + |
| 40 | +keys_dir=keys |
| 41 | +spl_stake_pool=spl-stake-pool |
| 42 | +# Uncomment to use a local build |
| 43 | +spl_stake_pool=../../../target/debug/spl-stake-pool |
| 44 | + |
| 45 | +mkdir -p $keys_dir |
| 46 | + |
| 47 | +create_keypair () { |
| 48 | + if test ! -f "$1" |
| 49 | + then |
| 50 | + solana-keygen new --no-passphrase -s -o "$1" |
| 51 | + fi |
| 52 | +} |
| 53 | + |
| 54 | +echo "Creating pool" |
| 55 | +stake_pool_keyfile=$keys_dir/stake-pool.json |
| 56 | +validator_list_keyfile=$keys_dir/validator-list.json |
| 57 | +mint_keyfile=$keys_dir/mint.json |
| 58 | +reserve_keyfile=$keys_dir/reserve.json |
| 59 | +create_keypair $stake_pool_keyfile |
| 60 | +create_keypair $validator_list_keyfile |
| 61 | +create_keypair $mint_keyfile |
| 62 | +create_keypair $reserve_keyfile |
| 63 | + |
| 64 | +spl-token create-token --program-2022 "$mint_keyfile" |
| 65 | + |
| 66 | +set -ex |
| 67 | +$spl_stake_pool \ |
| 68 | + create-pool \ |
| 69 | + "${command_args[@]}" \ |
| 70 | + --pool-keypair "$stake_pool_keyfile" \ |
| 71 | + --validator-list-keypair "$validator_list_keyfile" \ |
| 72 | + --mint-keypair "$mint_keyfile" \ |
| 73 | + --reserve-keypair "$reserve_keyfile" |
| 74 | + |
| 75 | +set +ex |
| 76 | +stake_pool_pubkey=$(solana-keygen pubkey "$stake_pool_keyfile") |
| 77 | +set -ex |
| 78 | + |
| 79 | +echo "Depositing SOL into stake pool" |
| 80 | +$spl_stake_pool deposit-sol "$stake_pool_pubkey" "$sol_amount" |
0 commit comments