Given the limitation of smart contracts, they are not self-executing, and require an external force to trigger their functions. Relay is a service to drive LSD network to properly process its own internal states, such as dealing with delegating, undelegating, distributing rewards and calculating the rate between LST and Sol. We introduce era concept to define how often in epochs the smart contract should be called.

Security is the our first priority when developing Stack, We are thrilled to say that the new era process is permissionless, showcasing the decentralized nature of the StaFi Sol LSD Stack, allowing anyone to trigger the new era process.

Install

Install build tools

Install makegcc and git

sudo apt update
sudo apt install -y make gcc git build-essential

Install go by following the official docs. Remember to set your $PATH environment variable, for example:

cd $HOME
wget -O go1.22.6.linux-amd64.tar.gz https://go.dev/dl/go1.22.6.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.6.linux-amd64.tar.gz && rm go1.22.6.linux-amd64.tar.gz
echo 'export GOROOT=/usr/local/go' >> $HOME/.bashrc
echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
echo 'export GO111MODULE=on' >> $HOME/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bashrc && . $HOME/.bashrc
go version

Install relay service

git clone https://github.com/stafiprotocol/solana-lsd-relay.git
cd solana-lsd-relay
make install

Account

Add account

$ solana-lsd-relay keys gen --keys 1 
 
You will be asked to provide a passphrase to secure your newly created vault.
Make sure you make it long and strong.
 
Enter passphrase to encrypt your solana vault: 
Confirm passphrase: 
 
Wallet file "./keys/solana_keys.json" written to disk.
Here are the keys that were ADDED during this operation (use `list` to see them all):
- B5gfiMdYkcerAPD5depiTb4JpJ1F9CfYG5UukFrUhhiW
Total keys stored: 1

Or import existing account

$ solana-lsd-relay keys import 
 
PLEASE READ:
We are now going to ask you to paste your private keys, one at a time.
They will not be shown on screen.
Please verify that the public keys printed on screen correspond to what you have noted
 
Paste your first private key: 
- Scanned private key corresponding to Gi2ommjX7QKTHPsyr96XSPoBDzzNnS4rtjMp4B4eEXas
Paste your next private key or hit ENTER if you are done: 
 
You will be asked to provide a passphrase to secure your newly created vault.
Make sure you make it long and strong.
 
Enter passphrase to encrypt your solana vault: 
Confirm passphrase: 
 
Wallet file "./keys/solana_keys.json" written to disk.
Here are the keys that were ADDED during this operation (use `list` to see them all):
- Gi2ommjX7QKTHPsyr96XSPoBDzzNnS4rtjMp4B4eEXas
Total keys stored: 1

Create and update config

$ cp config_start.example.toml config.toml
$ vim config.toml
 
Endpoint = "https://api.devnet.solana.com"
KeystorePath = "./keys/solana_keys.json"
 
LsdProgramID = "795MBfkwwtAX4fWiFqZcJK8D91P9tqqtiSRrSNhBvGzq"
 
StackAddress = "EpgquacesXp8h7nk9j5KcnzDVATFKLE995cuhj1hRbpR"
StakeManagerAddress = "6g8ziuefcXnmP1kmCXd7CGxdQrL59CkdnH9C6vQnQYkp" # entrusted mode if empty
 
## signers
FeePayerAccount = "ErCsmTQhM9qt17ce8XDTasKo76FEdg2scP2UX4VLxKDb"

Commands

Start relay service

$ solana-lsd-relay start --config config.toml --log_level info

Config

configdescriptionexample value
endpointrpc endpoint
keystorePathkeystore file path
lsdProgramIDlsd program id provided by 61Lab
stackAddressstack address provided by 61Lab
stakeManagerAddressstake manager address
created through 61Lab stack app
feePayerAccountimported or generated account
must have enough funds to sign transactions

Update Stake Manager Configs

config_set_stakemanager.example.toml will be used as a template file for updating settings.

$ cp config_set_stakemanager.example.toml config_set_stakemanager.toml
$ cat config_set_stakemanager.toml
Endpoint = "https://api.devnet.solana.com"
KeystorePath = "./keys/solana_keys.json"
# keystore will be omitted if ExportTx is enabled
ExportTx = false

LsdProgramID = "795MBfkwwtAX4fWiFqZcJK8D91P9tqqtiSRrSNhBvGzq"
StakeManagerAddress = "JAAGMA3nXSFq3QhSMC9Trkf5hneMGoGRLaGtEkmL1Nmj"

## signers
FeePayerAccount = "ErCsmTQhM9qt17ce8XDTasKo76FEdg2scP2UX4VLxKDb"
AdminAccount = "GgAy6GnqaPJUdGfCQGMgW2fGMMvmxc3E7a2oizFuCbhF"

# RateChangeLimit = 0
# UnbondingDuration = 8
# AddValidatorAddress   = ""
# RemoveValidatorAddress = ""
# MinStakeAmount = 0
# PlatformFeeCommission = 0
# NewBalancerAddress = ""
# NewAdminAddress = ""
⚠️

Make sure ExportTx is set to true when working with multisig

Let’s say we want to update min stake amount to 2000000, we update config MinStakeAmount = 2000000. Then execute bash command:

$ solana-lsd-relay stake-manager set-min-stake-amount 
load config success
stakeManager: JAAGMA3nXSFq3QhSMC9Trkf5hneMGoGRLaGtEkmL1Nmj
admin: GgAy6GnqaPJUdGfCQGMgW2fGMMvmxc3E7a2oizFuCbhF
feePayer: ErCsmTQhM9qt17ce8XDTasKo76FEdg2scP2UX4VLxKDb
minStakeAmount(lamports): 2000000
exportTx: true
 
check config info, then press (y/n) to continue:
y
set min stake amount tx(base58):
UhNyKks3vkbHAFx8Swc5vB21vHhCCZ57RLhXYQC73vE136ya72LyqQcGP5z25eqzfKRfD7EekXwDboaBLkbp2RaCnrg5wBLsjaomRyPAzX9tamcz3WronGF5idFuXhcfjCag14DUZgy4JRL9oaBt1CPj1yv6PhiEWnVCpdZMf2JX11DgjjU8oPnNHC5wPNzemyt8CWGRDHcH86djRuMfgFHfv5yFGZZBJXLvR5WSKvkzrmGi8K4tjb97FRv1m
Exiting.

You are able to update other configs in a same way. Available Commands:

  • Add validator
  • Remove validator
  • Set min stake amount
  • Set platform fee commission
  • Set rate change limit
  • Set unbonding duration
  • Transfer admin
  • Transfer balancer