Packages & Modules
Last updated
Last updated
The package functionality is distributed between several modules. Key modules are described below:
The module is rather an interface which allows interaction with the protocol. It provides main entry points for the protocol users. One may use the following functionality:
Request stake: User provides SUI coin to the protocol and instantly receives corresponding amount of AFSUI as per current epoch SUI <-> AFSUI exchange rate.
Request unstake: User provides AFSUI and receives corresponding amount of SUI. There are two possibilities. Regular unstaking, when the user receives his SUI at the beginning of the next epoch. Atomic unstaking, when the user receives his SUI immediately. It is also possible to restake a StakedSui object.
Epoch changing treatment: Sui staking framework workflow is strongly coupled with epoch changing processing. There are a few activities which the Sui framework performs between every two epochs. The most important ones are rewards collecting and stakes activation. To reflect this in the protocol a crank function has to be triggered. Due to Sui framework restrictions it is highly possible that the function has to be triggered several times. Before epoch changing is processed protocol considered to be in undefined state and does not operate. Once one triggers the crank function one receives incentive payment. To make epoch changing processing smooth Aftermath ran a bot which monitors Sui chain state and initiates epoch processing in time.
Update validator fee: If the protocol is aware about a validator, the validator receives Operation Capability Object which allows change of validator fee for a particular validator. Validator fee is taken from each minted AFSUI and sent to the validator address directly.
The module implements the protocol’s business logic which is previously discussed in the staked_sui_vault module description.
The module provides actual implementation of the staked sui vault. It is authorized to mint and burn AFSUI. It is also responsible for the protocol configuration. The main purpose is to keep all StakedSui objects and SUI balances. To organize StakedSuis a Storage entity is used.
A storage is an abstraction which allows us to keep StakedSui objects and implements unstaking logic. Unstaking by itself is a crucial part of the LSD protocol because, in some sense, it defines the protocol performance. To provide this the storage has an unstaking queue which is sorted by validators performance in ascend order, so stakes from inactive and low performance validators will be unstaked firstly. To avoid instant validators draining, each unstake is distributed between several validators.
The module implements Operation Capability Object logic. The object allows one to change the validator fee value for a particular validator.
Aftermath LSD protocol uses several additional packages.
The package provides one module which is called Safe. This entity allows to store an object of any type and provides mutable reference to this object to an authorized module. Only one module may be authorized. LSD protocol uses this entity to store AFSUI Treasury and provide authorized access from the staked sui vault state module.
Aftermath LSD protocol users may utilize the referral system. The module is providing logic for managing referrer - referee relationship and royalties collecting.
The protocol is collecting several types of fees. A Treasury entity allows us to collect a specific part of the fee and use it for different purposes later.
Aftermath collection of high performant math primitives and functions.
LinkedSet is based on the Sui framework LinkedTable implementation. This entity is used to implement the unstaking queue.
Collection of methods for interaction with Sui System.