Skip to main content

Stake Liquidity Tokens with ZenSwap App

Overview

ZenVault allows you to stake ZenSwap liquidity pool (LP) tokens to participate in ZenChain's native staking system. When you deposit LP tokens into a ZenVault, the vault stakes those assets on your behalf, allowing you to earn rewards in the native currency (ZTC) while maintaining liquidity exposure.

This guide explains how to interact with the ZenSwap app to stake, unstake, and withdraw your LP tokens, as well as how rewards and potential slashing work.

Key Concepts

  • LP Token Staking: A ZenVault accepts and manages deposits of a specific ZenSwap-compatible LP token.
  • Native Staking Participation: The vault stakes the underlying assets represented by your deposited LP tokens into ZenChain's native staking mechanism.
  • Rewards: The vault earns native staking rewards (in ZTC) on behalf of its stakers. These rewards are periodically processed and distributed proportionally to stakers.
  • Unstaking Period: When you unstake, your tokens enter an "unlocking" period determined by ZenChain's native staking bondingDuration. You can only withdraw after this period has passed.
  • Slashing: If validators nominated by the vault misbehave, the vault may be subject to slashing penalties, which are distributed proportionally among all stakers.
  • Account State Synchronization: To ensure fairness, your pending rewards and any applicable slashes are calculated and applied to your balance whenever you stake, unstake, or withdraw your LP tokens.

Core User Actions

These are the primary functions you will use to manage your stake.

1. Staking LP Tokens

Enter the amount you want to stake and click "Stake" to deposit your LP tokens into the vault. Clicking the button will open a modal that will allow you to confirm the action, sending a transaction to your wallet that will execute the action.

  • Purpose: Adds your LP tokens to the vault's staking pool.
  • Parameters:
    • amount: The quantity of LP tokens you wish to stake.
  • Requirements:
    • You must have approved the ZenVault contract to spend your LP tokens beforehand.
  • Effect: Your LP tokens are transferred to the vault, your staked balance increases, and you begin earning rewards. Any pending ZTC rewards are claimed and any pending slashes are applied before the new amount is added.

2. Initiating Unstaking

Enter the amount you want to unstake and click "Unstake" to start the process of withdrawing your LP tokens. Clicking the button will open a modal that will allow you to confirm the action, sending a transaction to your wallet that will execute the action.

  • Purpose: Moves the specified amount of your staked tokens into the unlocking queue.
  • Parameters:
    • amount: The quantity of LP tokens you wish to unstake.
  • Requirements:
    • You must have sufficient staked balance.
    • The number of separate unlocking entries you have must be less than the maximum allowed of 10.
  • Effect: Your staked balance decreases by amount, and a new entry is added to your unlocking list, which includes the era when the funds will be available to withdraw. Any pending ZTC rewards are claimed and any pending slashes are applied before the amount is moved to unlocking.

After you click to unstake, a pending withdrawal will appear.

3. Withdrawing Unlocked Tokens

When your tokens are ready to withdraw, you can click "Withdraw" to claim LP tokens that have completed their unlocking period. Clicking the button will open a modal that will allow you to confirm the action, sending a transaction to your wallet that will execute the action.

  • Purpose: Transfers LP tokens from your unlocking queue back to your wallet.
  • Requirements:
    • You must have at least one unlocking chunk where the era is less than the current ZenChain era.
  • Effect: Tokens that have completed their unlocking period are transferred to your wallet, and the corresponding entries are removed from your unlocking list. Any pending ZTC rewards are claimed and any pending slashes are applied before the withdrawal occurs.

4. Claim Rewards

When you have pending rewards, you can click the "Claim" button to receive them. Clicking the button will open a modal that will allow you to confirm the action, sending a transaction to your wallet that will execute the action.

  • Purpose: Manually trigger the application of any pending rewards and slashes to a user's balance without performing any other action.
  • Effect: Any pending ZTC rewards are claimed and sent to the user's wallet. Any pending slashes are applied to the user's staked and unlocking balances. This is useful for realizing rewards without changing your stake.

Understanding Rewards and Slashing

How Rewards Work

  1. Earning: The ZenVault, acting as a nominator in ZenChain's native staking system, earns ZTC rewards.
  2. Accumulation: These rewards are sent to a dedicated Reward Account managed by the Vault Staking system.
  3. Distribution: Any user can call the distributeRewards function on the system-level VaultStaking precompile. This triggers the transfer of accumulated ZTC from the Reward Account into the ZenVault smart contract for accounting.
  4. Claiming: The ZTC rewards are sent directly to your wallet whenever you interact with the vault (stake, unstake, withdrawUnlocked, or updateUserState). The amount of ZTC you receive is proportional to your share of the vault's total stake.

How Slashing Works

  1. Risk: Participating in staking carries the risk of slashing if validators chosen by the vault misbehave.
  2. Application: If a slash occurs, the penalty is proportionally distributed among all stakers. The actual reduction of your staked LP tokens happens when you next interact with the contract (stake, unstake, etc.), where your share of the slash is calculated and deducted from your balance.
  3. Pending Slash (Exception): In rare cases, if the system fails to apply a slash immediately, a Pending Slash is created at the system level. The vault is then temporarily chilled (stops nominating and earning new rewards) to prevent further risk. An administrator must manually resolve the situation to resume vault operations.

How the ZenVault System Works

The ZenVault ecosystem consists of two primary components:

  1. The ZenVault Smart Contract (ZenVault.sol): This is the user-facing EVM contract you interact with to stake, unstake, and manage your LP tokens.
  2. The VaultStaking Precompile: This is a system-level contract that administrators use to manage the lifecycle of all ZenVaults (registering, deregistering, etc.). It also exposes functions that anyone can call to trigger system-wide actions.

Important Considerations

  • Unlocking Delay: Remember there is a time delay between unstaking and being able to withdraw your LP tokens.
  • Risks: Understand the risks involved, including smart contract vulnerabilities and the possibility of slashing.
  • ZTC Rewards: Rewards are paid in the native currency (ZTC). They are not automatically re-staked or compounded.