👩‍💻
Builder Portal
  • Sovryn Builder Portal
    • Contribution
  • Design System
    • Design principles
    • Structure
    • Usage by Sovryn
  • UI Library
    • Overview
    • Getting Started
    • Atoms
      • Accordion
      • Badge
      • HealthBar
      • Button
      • DynamicValue
      • Heading
      • ErrorBadge
      • Icon
      • Input
      • Lottie
      • Paragraph
      • Toggle
      • Link
      • Checkbox
    • Molecules
      • AmountInput
      • ContextLink
      • Dialog
      • Dropdown
      • ErrorList
      • Footer
      • FormGroup
      • Header
      • HelperButton
      • Menu
      • NavMenuItem
      • Notification
      • Overlay
      • Pagination
      • RadioButton
      • RadioButtonGroup
      • Select
      • SimpleTable
      • StatusItem
      • Table
      • TableBase
      • Tabs
      • Tooltip
      • TransactionId
      • VerticalTabs
      • VerticalTabsMobile
      • WalletContainer
      • WalletIdentity
    • Working with Components
    • Links
    • Contribution
  • Sovryn SDK
    • Smart Router
      • Creating a New Swap Route
      • Available routes
        • AMM
        • MoC integration
        • MYNT bAsset
        • MYNT fixed rate
    • Sovryn Onboard
      • Installation
      • Usage
      • Custom Connectors
      • Custom UI
      • Contribution
    • The Graph
      • Overview
      • Usage
      • Sovryn Subgraphs
      • Advanced Usage
  • sovryn.app
    • Overview
    • Sovryn UI Library Usage
    • The Graph Usage
    • Links
    • Contribution
    • Dapp specific components
      • MaxButton
  • Smart Contracts
    • Overview
    • AMM
      • Liquidity
        • V1 Converters
        • V2 Converters
      • Conversion
      • Wrapper
        • V1 liquidity
        • V2 liquidity
        • Swaps
    • Sovryn Protocol
      • Lending
        • Mint
        • Burn
      • Borrowing
        • Borrow
        • Repay
      • Margin Trading
        • Open
        • Close
      • Collateral Management
    • Liquidity Mining
      • Deposit
      • Withdraw
      • Rewards
    • FastBTC
      • RSK->BTC
    • Bitocracy
      • Staking
      • Governor
      • Fee Sharing
      • Vesting
    • Zero
      • Borrower operations
      • Trove Manager
      • Satability Pool
      • Rewards
    • Mynt & DLLR
      • Basset to Masset Conversion
      • Masset to Basset Conversion
      • MOC Integration Conversion
Powered by GitBook
On this page
  • STAKING CONTRACT STRUCTURE
  • STAKING ASSETS
  • UNSTAKING ASSETS
  1. Smart Contracts
  2. Bitocracy

Staking

Staking contract allows SOV owners to put their assets in a locked position, commiTted until a given date.

PreviousBitocracyNextGovernor

Last updated 9 months ago

Staking contract allows SOV owners to put their assets in a locked position, commiTted until a given date. In exchange the user receives rights in the voting system (the GovernorAlpha contract) and in the fee sharing contract rewarding them with a cut of the fees collected by the Sovryn protocol. This whole system - staking, governance and fee sharing - is known as "Bitocracy".

STAKING CONTRACT STRUCTURE

Staking contract is an upgradeable contract deployed with a specific strategy to save the most amount of bytecode per module. As shown in the figure, the logics of the Staking contract is distributed in seven modules as described below:

  • Admin Module: Is the access and control layer. It allows to set logics and parameters for the protocol. Its functions are accessible only by the Timelock itself or other designated administrators by the protocol.

  • Governance Module: Is a calculator for voting power of users and delegates.

  • Stake Module: The logics that governs the managing of staking positions.

  • Storage Module: The logics that manages the way the proxy's storage is used.

  • Vesting Module: The logics governing the way the staking positions for vesting contracts are created and tracked.

  • Withdraw Module: Special logics ruling the way assets are withdrawn from staking.

  • Weighted Staking Module: Is a complementary calculator for the weights of a staking position, required for the voting power and to determine the amount of profits claimable for the user.

STAKING ASSETS

In order to open a staking position, the user must own a balance of valid assets:SOV so far.

The user must first execute the proper approve function to the ERC20 contract of SOV.

After such transaction the user can address the execution of stake to the Staking contract. The stake function implies the internal execution of several delegatecalls to the StakingModuleProxy and several of logic modules.

function stake(
        uint96 amount,
        uint256 until,
        address stakeFor,
        address delegatee
    ) external whenNotPaused whenNotFrozen 

Arguments

Name
Type
Description

amount

uint96

The number of SOV tokens to stake

until

uint256

Timestamp in seconds -blockchain format- indicating the date until which to stake

stakeFor

address

The address to stake the tokens for or zero address if staking for oneself

delegatee

address

The address of the delegatee or zero address if there is none.

UNSTAKING ASSETS

If a user had or still have a staking position can perform call the function withdraw to the Staking contract. Early unstaking will be punished. The current destin of punished SOV is the zero address (they are burned).

function withdraw(
  uint96 amount, 
  uint256 until, 
  address receiver) external whenNotFrozen 

Arguments

Name
Type
Description

amount

uint96

The number of SOV tokens to stake

until

uint256

Timestamp in seconds -blockchain format- indicating the date until which to stake If until is not a valid "unlock" date, the next lock date after until is used.

receiver

address

The receiver of the tokens. If not specified, send to the msg.sender

Smart Contract Structure for Staking Contract