Staking
Treasury has native support for delegated staking on many of the supported chains like Solana, Cosmos chains, and Ethereum. Staking involves moving assets into a locked status on-chain, which typically allows them to accrue rewards. While the specific mechanics involved may depend on the chain, Treasury provides a uniform interface to interact with staking.
Treasury will also natively produce it's own staking transactions to ensure clear signing. You always know what you are signing. Many other custody solutions rely on the use of blind signing which is unsafe.
This guide is based on using CLI tooling with your Treasury instance. This all can be used with our product UI as well.
Setup staking providers
Most chains natively support delegated staking and Treasury can be used with them without any configuration.
Ethereum however does not fully support delegated staking, and Treasury requires a 3rd party provider to be configured to run Ethereum validators on your behalf. Treasury supports providers like Kiln, Figment, and Twinstake. If you are not staking Ethereum, you can skip this step.
Configure a staking provider by editting your treasury.toml
for your connector node(s).
[services]
[services.kiln]
api_token = '<YOUR_API_KEY>'
[services.figment]
api_token = '<YOUR_API_KEY>'
[services.twinstake]
username = '<YOUR_USERNAME>'
password = '<YOUR_PASSWORD>'
client_id = '<YOUR_CLIENT_ID>'
account = '<YOUR_ACCOUNT>'
Note that these services are non-custodial and you always have control over your funds.
Staking transactions
Treasury supports three types of staking transactions.
- stake: Move liquid funds into an
active
state. - unstake: Move
activating
oractive
funds into aninactive
or liquid state. - withdraw: Move funds from an
inactive
state to a liquid state.
In order to stake funds, you need to submit stake
transactions. In order to get funds back into a liquid state, you need
to submit unstake
and withdraw
transactions.
Most chains enforce delays before the state of funds will change. Funds can be in activating
state for days or weeks before becoming active
- what's known as the bonding period.
There is also an unbonding period - the delay between deactivating
and inactive
states.
Both the oracle and connector API's can be used to report on the status of staking transactions and staked balances.
Staking arguments
All staking operations require the following arguments.
- Address that owns the funds.
- Amount to move.
In most cases you may also need to input:
- Validator address associated with the stake.
- Account delegator account or logical account associated with the stake.
Example
We'll use some funds on Solana to stake, unstake, and withdraw as an example. Solana is nice as you can immediately withdraw funds
that are still in the activating
state (no need to wait to bond or unbond). There is also no minimum on the amount to stake.
Stake funds
Create a staking operation. This stakes 0.005 SOL.
treasury stakings create --chain SOL --from HrRGPQ5cqE4LLumD2RGpnxAQjeMcbaojXcVukmz7628L stake 0.005 --validator CcaHc2L43ZWjwCHART3oZoJvHLAe9hzT2DJNUpBzoTN1 --sign-with root-key
Check on the transaction
Using the connector API we can check on the transaction and also look at our balance.
curl -u $API_KEY 'https://connector.cordialapis.com/v1/chains/SOL/addresses/HrRGPQ5cqE4LLumD2RGpnxAQjeMcbaojXcVukmz7628L/staking?validator=HrRGPQ5cqE4LLumD2RGpnxAQjeMcbaojXcVukmz7628L'
[
{
"validator": "HrRGPQ5cqE4LLumD2RGpnxAQjeMcbaojXcVukmz7628L",
"account": "kYxw8yBa2ypi4Buf4sVeWLMpTLYT6Z2eiuzZ67fXbg1",
"balance": {
"activating": "5000000",
"active": "0",
"deactivating": "0",
"inactive": "0"
}
}
]
Unstake funds
Similarly, we can unstake the funds.
treasury stakings create --chain SOL --from HrRGPQ5cqE4LLumD2RGpnxAQjeMcbaojXcVukmz7628L unstake 0.005 --sign-with root-key --validator CcaHc2L43ZWjwCHART3oZoJvHLAe9hzT2DJNUpBzoTN1
Withdraw funds
Finally we can get back our 0.005 SOL.
treasury stakings create --chain SOL --from HrRGPQ5cqE4LLumD2RGpnxAQjeMcbaojXcVukmz7628L stake 0.005 --validator CcaHc2L43ZWjwCHART3oZoJvHLAe9hzT2DJNUpBzoTN1 --sign-with root-key
Review
See the full history on chain on Solscan.
Ethereum
Ethereum works using the same abstraction, assuming you have a staking provider configured. You must additionally provider the provider
argument, which
may be either kiln
, figment
, twinstake
, or native
. We may continue to support more providers.
Ethereum also only works with 32 ETH values or increments. You can stake any amount in a single transaction, as long as it's factored by 32 ETH.
You do not need to pass a value for the validator. This is because your staking provider will create "ethereum" validators on demand whenever you stake. Each ethereum-validator will have 32 ETH associated with it natively on the Ethereum Beacon chain. Only your address in Treasury that created the stake can ever receive the funds back.