Skip to content

Commit

Permalink
merge: main
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsahu committed Aug 22, 2024
2 parents 4730fa7 + 30934d2 commit 75ed38f
Show file tree
Hide file tree
Showing 81 changed files with 834 additions and 140 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Parameters
Licensor: Liquid Foundation

Licensed Work: Liquid Collective Protocol.
The Licensed Work is (c) 2022 Liquid Foundation
The Licensed Work is (c) 2024 Liquid Foundation

Additional Use Grant: If specified, any use grant listed at
v1-license-use-grants.liquidcollective.eth

Change Date: The earlier of 2026-10-04 or, if specified, the date at
Change Date: The earlier of 2028-08-19 or, if specified, the date at
v1-license-date.liquidcollective.eth

Change License: GNU Affero General Public License v3.0 or later or, if specified, the license at
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/Administrable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./libraries/LibAdministrable.sol";
import "./libraries/LibSanitize.sol";

/// @title Administrable
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the administration of the contracts
abstract contract Administrable is IAdministrable {
/// @notice Prevents unauthorized calls
Expand Down
10 changes: 7 additions & 3 deletions contracts/src/Allowlist.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.20;

import "./interfaces/IAllowlist.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";

import "./libraries/LibAllowlistMasks.sol";
import "./Initializable.sol";
Expand All @@ -13,13 +13,13 @@ import "./state/allowlist/DenierAddress.sol";
import "./state/allowlist/Allowlist.sol";

/// @title Allowlist (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the list of allowed recipients.
/// @notice All accounts have an uint256 value associated with their addresses where
/// @notice each bit represents a right in the system. The DENY_MASK defined the mask
/// @notice used to identify if the denied bit is on, preventing users from interacting
/// @notice with the system
contract AllowlistV1 is IAllowlistV1, Initializable, Administrable, ProtocolVersion {
contract AllowlistV1 is IAllowlistV1, Initializable, Administrable, IProtocolVersion {
/// @inheritdoc IAllowlistV1
function initAllowlistV1(address _admin, address _allower) external init(0) {
_setAdmin(_admin);
Expand Down Expand Up @@ -159,4 +159,8 @@ contract AllowlistV1 is IAllowlistV1, Initializable, Administrable, ProtocolVers

emit SetAllowlistPermissions(_accounts, _permissions);
}

function version() external pure returns (string memory) {
return "1.2.0";
}
}
10 changes: 7 additions & 3 deletions contracts/src/CoverageFund.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.20;
import "./interfaces/IRiver.1.sol";
import "./interfaces/IAllowlist.1.sol";
import "./interfaces/ICoverageFund.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";

import "./libraries/LibUint256.sol";
import "./libraries/LibAllowlistMasks.sol";
Expand All @@ -15,7 +15,7 @@ import "./state/shared/RiverAddress.sol";
import "./state/slashingCoverage/BalanceForCoverage.sol";

/// @title Coverage Fund (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract receive donations for the slashing coverage fund and pull the funds into river
/// @notice This contract acts as a temporary buffer for funds that should be pulled in case of a loss of money on the consensus layer due to slashing events.
/// @notice There is no fee taken on these funds, they are entirely distributed to the LsETH holders, and no shares will get minted.
Expand All @@ -29,7 +29,7 @@ import "./state/slashingCoverage/BalanceForCoverage.sol";
/// @notice the coverage fund will be pulled after the revenue stream, and there won't be any commission on the eth pulled.
/// @notice Once a Slashing event occurs, the team will do its best to inject the recovery funds in at maximum 365 days
/// @notice The entities allowed to donate are selected by the team. It will mainly be treasury entities or insurance protocols able to fill this coverage fund properly.
contract CoverageFundV1 is Initializable, ICoverageFundV1, ProtocolVersion {
contract CoverageFundV1 is Initializable, ICoverageFundV1, IProtocolVersion {
/// @inheritdoc ICoverageFundV1
function initCoverageFundV1(address _riverAddress) external init(0) {
RiverAddress.set(_riverAddress);
Expand Down Expand Up @@ -72,4 +72,8 @@ contract CoverageFundV1 is Initializable, ICoverageFundV1, ProtocolVersion {
fallback() external payable {
revert InvalidCall();
}

function version() external pure returns (string memory) {
return "1.2.0";
}
}
10 changes: 7 additions & 3 deletions contracts/src/ELFeeRecipient.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.20;

import "./interfaces/IRiver.1.sol";
import "./interfaces/IELFeeRecipient.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";

import "./libraries/LibUint256.sol";

Expand All @@ -12,9 +12,9 @@ import "./Initializable.sol";
import "./state/shared/RiverAddress.sol";

/// @title Execution Layer Fee Recipient (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract receives all the execution layer fees from the proposed blocks + bribes
contract ELFeeRecipientV1 is Initializable, IELFeeRecipientV1, ProtocolVersion {
contract ELFeeRecipientV1 is Initializable, IELFeeRecipientV1, IProtocolVersion {
/// @inheritdoc IELFeeRecipientV1
function initELFeeRecipientV1(address _riverAddress) external init(0) {
RiverAddress.set(_riverAddress);
Expand Down Expand Up @@ -43,4 +43,8 @@ contract ELFeeRecipientV1 is Initializable, IELFeeRecipientV1, ProtocolVersion {
fallback() external payable {
revert InvalidCall();
}

function version() external pure returns (string memory) {
return "1.2.0";
}
}
2 changes: 1 addition & 1 deletion contracts/src/Initializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.20;
import "./state/shared/Version.sol";

/// @title Initializable
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract ensures that initializers are called only once per version
contract Initializable {
/// @notice Disable initialization on implementations
Expand Down
10 changes: 7 additions & 3 deletions contracts/src/OperatorsRegistry.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.20;

import "./interfaces/IOperatorRegistry.1.sol";
import "./interfaces/IRiver.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";

import "./libraries/LibUint256.sol";

Expand All @@ -21,9 +21,9 @@ import "./state/migration/OperatorsRegistry_FundedKeyEventRebroadcasting_KeyInde
import "./state/migration/OperatorsRegistry_FundedKeyEventRebroadcasting_OperatorIndex.sol";

/// @title Operators Registry (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the list of operators and their keys
contract OperatorsRegistryV1 is IOperatorsRegistryV1, Initializable, Administrable, ProtocolVersion {
contract OperatorsRegistryV1 is IOperatorsRegistryV1, Initializable, Administrable, IProtocolVersion {
/// @notice Maximum validators given to an operator per selection loop round
uint256 internal constant MAX_VALIDATOR_ATTRIBUTION_PER_ROUND = 5;

Expand Down Expand Up @@ -898,4 +898,8 @@ contract OperatorsRegistryV1 is IOperatorsRegistryV1, Initializable, Administrab
TotalValidatorExitsRequested.set(_newValue);
emit SetTotalValidatorExitsRequested(_currentValue, _newValue);
}

function version() external pure returns (string memory) {
return "1.2.0";
}
}
10 changes: 7 additions & 3 deletions contracts/src/Oracle.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.20;

import "./interfaces/IRiver.1.sol";
import "./interfaces/IOracle.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";

import "./Administrable.sol";
import "./Initializable.sol";
Expand All @@ -16,9 +16,9 @@ import "./state/oracle/Quorum.sol";
import "./state/oracle/ReportsPositions.sol";

/// @title Oracle (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the input from the allowed oracle members. Highly inspired by Lido's implementation.
contract OracleV1 is IOracleV1, Initializable, Administrable, ProtocolVersion {
contract OracleV1 is IOracleV1, Initializable, Administrable, IProtocolVersion {
modifier onlyAdminOrMember(address _oracleMember) {
if (msg.sender != _getAdmin() && msg.sender != _oracleMember) {
revert LibErrors.Unauthorized(msg.sender);
Expand Down Expand Up @@ -281,4 +281,8 @@ contract OracleV1 is IOracleV1, Initializable, Administrable, ProtocolVersion {
function _river() internal view returns (IRiverV1) {
return IRiverV1(payable(RiverAddress.get()));
}

function version() external pure returns (string memory) {
return "1.2.0";
}
}
10 changes: 0 additions & 10 deletions contracts/src/ProtocolVersion.sol

This file was deleted.

10 changes: 7 additions & 3 deletions contracts/src/RedeemManager.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.20;
import "./interfaces/IAllowlist.1.sol";
import "./interfaces/IRiver.1.sol";
import "./interfaces/IRedeemManager.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";
import "./libraries/LibAllowlistMasks.sol";
import "./libraries/LibUint256.sol";
import "./Initializable.sol";
Expand All @@ -16,9 +16,9 @@ import "./state/redeemManager/BufferedExceedingEth.sol";
import "./state/redeemManager/RedeemDemand.sol";

/// @title Redeem Manager (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the redeem requests of all users
contract RedeemManagerV1 is Initializable, IRedeemManagerV1, ProtocolVersion {
contract RedeemManagerV1 is Initializable, IRedeemManagerV1, IProtocolVersion {
/// @notice Value returned when resolving a redeem request that is unsatisfied
int64 internal constant RESOLVE_UNSATISFIED = -1;
/// @notice Value returned when resolving a redeem request that is out of bounds
Expand Down Expand Up @@ -553,4 +553,8 @@ contract RedeemManagerV1 is Initializable, IRedeemManagerV1, ProtocolVersion {
emit SetRedeemDemand(RedeemDemand.get(), _newValue);
RedeemDemand.set(_newValue);
}

function version() external pure returns (string memory) {
return "1.2.0";
}
}
10 changes: 7 additions & 3 deletions contracts/src/River.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./interfaces/IRiver.1.sol";
import "./interfaces/IWithdraw.1.sol";
import "./interfaces/IELFeeRecipient.1.sol";
import "./interfaces/ICoverageFund.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";

import "./components/ConsensusLayerDepositManager.1.sol";
import "./components/UserDepositManager.1.sol";
Expand All @@ -30,7 +30,7 @@ import "./state/river/MetadataURI.sol";
import "./state/river/LastConsensusLayerReport.sol";

/// @title River (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract merges all the manager contracts and implements all the virtual methods stitching all components together
contract RiverV1 is
ConsensusLayerDepositManagerV1,
Expand All @@ -39,7 +39,7 @@ contract RiverV1 is
OracleManagerV1,
Initializable,
Administrable,
ProtocolVersion,
IProtocolVersion,
IRiverV1
{
/// @inheritdoc IRiverV1
Expand Down Expand Up @@ -611,4 +611,8 @@ contract RiverV1 is
_setBalanceToDeposit(currentBalanceToDeposit - currentMaxCommittableAmount);
}
}

function version() external pure returns (string memory) {
return "1.2.0";
}
}
2 changes: 1 addition & 1 deletion contracts/src/TLC.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "./components/ERC20VestableVotesUpgradeable.1.sol";
import "./interfaces/ITLC.1.sol";

/// @title TLC (v1)
/// @author Alluvial
/// @author Alluvial Finance Inc.
/// @notice The TLC token has a max supply of 1,000,000,000 and 18 decimal places.
/// @notice Upon deployment, all minted tokens are send to account provided at construction, in charge of creating the vesting schedules
/// @notice The contract is based on ERC20Votes by OpenZeppelin. Users need to delegate their voting power to someone or themselves to be able to vote.
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/TUPProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.20;
import "openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

/// @title TUPProxy (Transparent Upgradeable Pausable Proxy)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract extends the Transparent Upgradeable proxy and adds a system wide pause feature.
/// When the system is paused, the fallback will fail no matter what calls are made.
/// Address Zero is allowed to perform calls even if paused to allow view calls made
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/WLSETH.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "./state/shared/ApprovalsPerOwner.sol";
import "./state/wlseth/BalanceOf.sol";

/// @title Wrapped LsETH (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract wraps the LsETH token into a rebase token, more suitable for some DeFi use-cases
/// like stable swaps.
contract WLSETHV1 is IWLSETHV1, Initializable, ReentrancyGuardUpgradeable {
Expand Down
11 changes: 8 additions & 3 deletions contracts/src/Withdraw.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ pragma solidity 0.8.20;
import "./Initializable.sol";
import "./interfaces/IRiver.1.sol";
import "./interfaces/IWithdraw.1.sol";
import "./ProtocolVersion.sol";
import "./interfaces/IProtocolVersion.sol";
import "./libraries/LibErrors.sol";
import "./libraries/LibUint256.sol";

import "./state/shared/RiverAddress.sol";

/// @title Withdraw (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract is in charge of holding the exit and skimming funds and allow river to pull these funds
contract WithdrawV1 is IWithdrawV1, Initializable, ProtocolVersion {
contract WithdrawV1 is IWithdrawV1, Initializable, IProtocolVersion {
modifier onlyRiver() {
if (msg.sender != RiverAddress.get()) {
revert LibErrors.Unauthorized(msg.sender);
Expand Down Expand Up @@ -52,4 +52,9 @@ contract WithdrawV1 is IWithdrawV1, Initializable, ProtocolVersion {
RiverAddress.set(_river);
emit SetRiver(_river);
}

/// @inheritdoc IProtocolVersion
function version() external pure returns (string memory) {
return "1.2.0";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "../state/river/CommittedBalance.sol";
import "../state/river/KeeperAddress.sol";

/// @title Consensus Layer Deposit Manager (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the interactions with the official deposit contract, funding all validators
/// @notice Whenever a deposit to the consensus layer is requested, this contract computed the amount of keys
/// @notice that could be deposited depending on the amount available in the contract. It then tries to retrieve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "../libraries/LibSanitize.sol";
import "../libraries/LibUint256.sol";

/// @title ERC20VestableVotesUpgradeableV1
/// @author Alluvial
/// @author Alluvial Finance Inc.
/// @notice This is an ERC20 extension that
/// @notice - can be used as source of vote power (inherited from OpenZeppelin ERC20VotesUpgradeable)
/// @notice - can delegate vote power from an account to another account (inherited from OpenZeppelin ERC20VotesUpgradeable)
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/components/OracleManager.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "../state/river/DepositedValidatorCount.sol";
import "../state/river/LastOracleRoundId.sol";

/// @title Oracle Manager (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the inputs provided by the oracle
/// @notice The Oracle contract is plugged to this contract and is in charge of pushing
/// @notice data whenever a new report has been deemed valid. The report consists in two
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/components/SharesManager.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "../state/river/SharesPerOwner.sol";
import "../state/shared/ApprovalsPerOwner.sol";

/// @title Shares Manager (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the shares of the depositor and the ERC20 interface
abstract contract SharesManagerV1 is ISharesManagerV1 {
/// @notice Internal hook triggered on the external transfer call
Expand Down Expand Up @@ -227,13 +227,13 @@ abstract contract SharesManagerV1 is ISharesManagerV1 {
/// @return sharesToMint The amnount of minted shares
function _mintShares(address _owner, uint256 _underlyingAssetValue) internal returns (uint256 sharesToMint) {
uint256 oldTotalAssetBalance = _assetBalance() - _underlyingAssetValue;
uint256 totalSupply = _totalSupply();
uint256 tSupply = _totalSupply();

if (oldTotalAssetBalance == 0 || totalSupply == 0) {
if (oldTotalAssetBalance == 0 || tSupply == 0) {
sharesToMint = _underlyingAssetValue;
_mintRawShares(_owner, _underlyingAssetValue);
} else {
sharesToMint = (_underlyingAssetValue * totalSupply) / oldTotalAssetBalance;
sharesToMint = (_underlyingAssetValue * tSupply) / oldTotalAssetBalance;
_mintRawShares(_owner, sharesToMint);
}
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/components/UserDepositManager.1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "../libraries/LibSanitize.sol";
import "../state/river/BalanceToDeposit.sol";

/// @title User Deposit Manager (v1)
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This contract handles the inbound transfers cases or the explicit submissions
abstract contract UserDepositManagerV1 is IUserDepositManagerV1 {
/// @notice Handler called whenever a user has sent funds to the contract
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/interfaces/IAdministrable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.20;

/// @title Administrable Interface
/// @author Kiln
/// @author Alluvial Finance Inc.
/// @notice This interface exposes methods to handle the ownership of the contracts
interface IAdministrable {
/// @notice The pending admin address changed
Expand Down
Loading

0 comments on commit 75ed38f

Please sign in to comment.