Skip to content

Commit

Permalink
feat: Basic natspec docs
Browse files Browse the repository at this point in the history
  • Loading branch information
86667 committed Dec 5, 2024
1 parent 07dcfae commit 72b3e16
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/LiquidDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface ILiquidDelegation {
function getPrice() external view returns(uint256);
}

/// Initial dummy implementation of Liquid Delegation contract
contract LiquidDelegation is BaseDelegation, ILiquidDelegation {

/// @custom:storage-location erc7201:zilliqa.storage.LiquidDelegation
Expand Down
2 changes: 2 additions & 0 deletions src/LiquidDelegationV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {ILiquidDelegation} from "src/LiquidDelegation.sol";
import {NonRebasingLST} from "src/NonRebasingLST.sol";

// the contract is supposed to be deployed with the node's signer account
/// Liquid Delegation contract V2.
/// A staking pool implementation in which users receive a Non-Rebasing Liquid Staking Token to represent their staked assets
contract LiquidDelegationV2 is BaseDelegation, ILiquidDelegation {

/// @custom:storage-location erc7201:zilliqa.storage.LiquidDelegation
Expand Down
1 change: 1 addition & 0 deletions src/NonLiquidDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface INonLiquidDelegation {
function rewards() external view returns(uint256);
}

/// Initial dummy implementation of Non-Liquid Delegation contract
contract NonLiquidDelegation is BaseDelegation, INonLiquidDelegation {

/* commented out because defining empty structs is disallowed
Expand Down
2 changes: 2 additions & 0 deletions src/NonLiquidDelegationV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {BaseDelegation} from "src/BaseDelegation.sol";
import {INonLiquidDelegation} from "src/NonLiquidDelegation.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

/// Non-Liquid Delegation contract V2.
/// A staking pool implementation in which users receive no representation for their staked assets. Assets are locked up until the staking period has ended.
contract NonLiquidDelegationV2 is BaseDelegation, INonLiquidDelegation {
using SafeCast for int256;

Expand Down
3 changes: 2 additions & 1 deletion src/NonRebasingLST.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ pragma solidity ^0.8.26;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/// A simple contract implementing ERC20 and Ownable
contract NonRebasingLST is ERC20, Ownable {
constructor(address initialOwner)
ERC20("MyToken", "MTK")
ERC20("NonRebasingLST", "NR-LST")
Ownable(initialOwner)
{}

Expand Down
7 changes: 4 additions & 3 deletions src/utils/WithdrawalQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.26;
/// Interal WithdrawalQueue error
error WithdrawalQueueError(string msg);

/// Queue implementation for withdrawals from staking contract awaiting an unbonding period
library WithdrawalQueue {

address public constant DEPOSIT_CONTRACT = address(0x5A494C4445504F53495450524F5859);
Expand All @@ -19,11 +20,11 @@ library WithdrawalQueue {
mapping(uint256 => Item) items;
}

function unbondingPeriod() view internal returns(uint256) {
function unbondingPeriod() internal view returns(uint256) {
(bool success, bytes memory data) = DEPOSIT_CONTRACT.staticcall(
abi.encodeWithSignature("withdrawalPeriod()")
);
require(success, "unbonding period unknown");
require(success, WithdrawalQueueError("unbonding period unknown"));
return abi.decode(data, (uint256));
}

Expand All @@ -33,7 +34,7 @@ library WithdrawalQueue {
}

function dequeue(Fifo storage fifo) internal returns(Item memory result) {
require(fifo.first < fifo.last, "queue empty");
require(fifo.first < fifo.last, WithdrawalQueueError("queue empty"));
result = fifo.items[fifo.first];
delete fifo.items[fifo.first];
fifo.first++;
Expand Down

0 comments on commit 72b3e16

Please sign in to comment.