Technical Overview
This document provides a technical overview of the Kernel smart contract system, which facilitates token deposits and withdrawals to BEP20 asset-specific vaults.
The system is designed to manage user balances securely and efficiently via a StakerGateway acting as a mediator between the users and the Vaults.
This architecture supports a wide range of assets and ensures flexibility and security for all interactions.
Table of Contents
Actors
User: Can stake and unstake suported assets
StakerGateway: User's entrypoint, permits staking and unstaking
KernelVault: Manages users' deposits for each asset handled by the protocol
Contracts
1. StakerGateway.sol
The StakerGateway
is the contract that interfaces directly with users, enabling them to stake and unstake tokens to and from the protocol. It acts as the intermediary that ensures proper authorization and routing of transactions between users and vaults.
Key Features
Stake: User can stake an asset by depositing tokens into the related Vault
Unstake: Facilitates the unstaking of an asset by withdrawing tokens from the vault, ensures user eligibility and transfers tokens back to the user
Flows
Staking
User calls
stake()
function to stake an assetThe
StakerGateway
transfers the tokens fromUser
to theKernelVault
responsible for the specific assetKernelVault
increasesUser
's balance
Untaking
User calls
unstake()
function to stake an assetThe
StakerGateway
transfers the tokens from theKernelVault
responsible for the specific asset toUser
KernelVault
decreasesUser
's balance
2. KernelVault.sol
The KernelVault
is responsible for tracking the token balance of users within the system. It offers functionality for deposits and withdrawals and ensures that only StakerGateway
can interact with the vaults.
One KernelVault is deployed for each asset. Vaults are deployed using the Beacon proxy pattern.
Key Features
Deposit: User can deposit tokens until the vault reaches a pre-defined limit, increasing his balance
Withdraw: User can withdraw tokens from the Vault, decreasing his balance
Security Considerations
Only
StakerGateway
can callKernelVault.sol
's functions, ensuring secure and controlled accessUser balances are securely stored within the vault, preventing unauthorized access or manipulation
3. AssetRegistry.sol
AssetRegistry
manages the mapping of assets to their respective vaults. It stores information on supported assets and ensures that the system only processes transactions for valid asset-vault pairs.
Key Features
Asset-to-Vault Mapping: Keeps track of the vault associated with each supported asset
Asset Validation: Ensures that only supported assets are processed in the system
4. KernelConfig.sol
KernelConfig
handles the overall configuration of the protocol, including role-based access control and functionalities pausing.
The contract allows pausing of Deposits to all Vaults
or Withdrawals from all Vaults
independently, or pausing all users' functions at the same time at protocol level
.
Key Roles
Admin: Manages roles and perform critical tasks
Manager: Responsible for managing system configurations, such as adding vaults and assets
Pauser: Has the ability to pause the entire protocol or some specific features like deposit and withdrawa in case of emergency
Last updated