Skip to content

Commit

Permalink
chore: updates NatSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
PacificYield committed Jan 6, 2025
1 parent 710f76f commit de71bf8
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 127 deletions.
4 changes: 1 addition & 3 deletions contracts/finance/ConfidentialVestingWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";

import { IConfidentialERC20 } from "../token/ERC20/IConfidentialERC20.sol";

/**
* @title ConfidentialVestingWallet
* @title ConfidentialVestingWallet.
* @notice This contract offers a simple vesting wallet for ConfidentialERC20 tokens.
* This is based on the VestingWallet.sol contract written by OpenZeppelin.
* see: openzeppelin/openzeppelin-contracts/blob/master/contracts/finance/VestingWallet.sol
Expand All @@ -32,7 +31,6 @@ abstract contract ConfidentialVestingWallet {

/// @notice Constant for zero using TFHE.
/// @dev Since it is expensive to compute 0, it is stored instead.
/* solhint-disable var-name-mixedcase*/
euint64 internal immutable _EUINT64_ZERO;

/// @notice Total encrypted amount released (to the beneficiary).
Expand Down
3 changes: 1 addition & 2 deletions contracts/finance/ConfidentialVestingWalletCliff.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";

import { ConfidentialVestingWallet } from "./ConfidentialVestingWallet.sol";

/**
* @title ConfidentialVestingWalletCliff
* @title ConfidentialVestingWalletCliff.
* @notice This contract offers a simple vesting wallet with a cliff for ConfidentialERC20 tokens.
* This is based on the VestingWalletCliff.sol contract written by OpenZeppelin.
* see: openzeppelin/openzeppelin-contracts/blob/master/contracts/finance/VestingWalletCliff.sol
Expand Down
11 changes: 5 additions & 6 deletions contracts/governance/CompoundTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ pragma solidity ^0.8.24;
import { ICompoundTimelock } from "./ICompoundTimelock.sol";

/**
* @title CompoundTimelock
* @notice This contract allows the admin to set a delay period before executing transactions.
* Transactions must be queued before execution. No transaction can be executed during this period,
* which offers time to verify the validity of pending transactions.
* It also has a grace period to allow for transactions
* not to be executed after a specific period following the queuing.
* @title CompoundTimelock.
* @notice This contract allows the admin to set a delay period before executing transactions.
* Transactions must be queued before execution. No transaction can be executed during this period,
* which offers time to verify the validity of pending transactions. It also has a grace period to allow
* for transactions not to be executed after a specific period following the queuing.
*/
contract CompoundTimelock is ICompoundTimelock {
/**
Expand Down
17 changes: 8 additions & 9 deletions contracts/governance/ConfidentialERC20Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import { ConfidentialERC20 } from "../token/ERC20/ConfidentialERC20.sol";
import { IConfidentialERC20Votes } from "./IConfidentialERC20Votes.sol";

/**
* @title ConfidentialERC20Votes
* @notice This contract inherits ConfidentialERC20, EIP712, and Ownable2Step.
* This is based on the Comp.sol contract written by Compound Labs.
* see: compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
* It is a governance token used to delegate votes, which can be used by contracts such as
* ConfidentialGovernorAlpha.sol.
* It uses encrypted votes to delegate the voting power associated
* with an account's balance.
* @dev The delegation of votes leaks information about the account's encrypted balance to the `delegatee`.
* @title ConfidentialERC20Votes.
* @notice This contract inherits ConfidentialERC20, EIP712, and Ownable2Step.
* This is based on the Comp.sol contract written by Compound Labs.
* see: compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
* It is a governance token used to delegate votes, which can be used by contracts such as
* ConfidentialGovernorAlpha.
* It uses encrypted votes to delegate the voting power associated with an account's balance.
* @dev The delegation of votes leaks information about the account's encrypted balance to the `delegatee`.
*/
abstract contract ConfidentialERC20Votes is IConfidentialERC20Votes, ConfidentialERC20, EIP712, Ownable2Step {
/// @notice Returned if the `blockNumber` is higher or equal to the (current) `block.number`.
Expand Down
19 changes: 9 additions & 10 deletions contracts/governance/ConfidentialGovernorAlpha.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";
import "fhevm/gateway/GatewayCaller.sol";

import { Ownable2Step, Ownable } from "@openzeppelin/contracts/access/Ownable2Step.sol";
import { IConfidentialERC20Votes } from "./IConfidentialERC20Votes.sol";
import { ICompoundTimelock } from "./ICompoundTimelock.sol";

/**
* @title ConfidentialGovernorAlpha
* @notice This is based on the GovernorAlpha.sol contract written by Compound Labs.
* see: compound-finance/compound-protocol/blob/master/contracts/Governance/GovernorAlpha.sol
* This decentralized governance system allows users to propose and vote on changes to the protocol.
* The contract is responsible for:
* - Proposal: A new proposal is made to introduce a change.
* - Voting: Users can vote on the proposal, either in favor or against it.
* - Quorum: A minimum number of votes (quorum) must be reached for the proposal to pass.
* - Execution: Once a proposal passes, it is executed and takes effect on the protocol.
* @title ConfidentialGovernorAlpha.
* @notice This is based on the GovernorAlpha.sol contract written by Compound Labs.
* see: compound-finance/compound-protocol/blob/master/contracts/Governance/GovernorAlpha.sol
* This decentralized governance system allows users to propose and vote on changes to the protocol.
* The contract is responsible for:
* - Proposal: A new proposal is made to introduce a change.
* - Voting: Users can vote on the proposal, either in favor or against it.
* - Quorum: A minimum number of votes (quorum) must be reached for the proposal to pass.
* - Execution: Once a proposal passes, it is executed and takes effect on the protocol.
*/
abstract contract ConfidentialGovernorAlpha is Ownable2Step, GatewayCaller {
/// @notice Returned if proposal contains too many changes.
Expand Down
3 changes: 2 additions & 1 deletion contracts/governance/ICompoundTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
pragma solidity ^0.8.24;

/**
* @title ICompoundTimelock
* @title ICompoundTimelock.
* @dev The CompoundTimelock inherits this interface.
*/
interface ICompoundTimelock {
/// @notice Returned if the delay is below the minimum delay.
Expand Down
4 changes: 2 additions & 2 deletions contracts/governance/IConfidentialERC20Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pragma solidity ^0.8.24;
import "fhevm/lib/TFHE.sol";

/**
* @title IConfidentialERC20Votes
* @dev The ConfidentialGovernorAlpha relies on this interface.
* @title IConfidentialERC20Votes.
* @dev Governor contracts use this interface to build a logic using votes.
*/
interface IConfidentialERC20Votes {
/**
Expand Down
13 changes: 6 additions & 7 deletions contracts/token/ERC20/ConfidentialERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";

import { IERC20Errors } from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import { IConfidentialERC20 } from "./IConfidentialERC20.sol";
import { TFHEErrors } from "../../utils/TFHEErrors.sol";

/**
* @title ConfidentialERC20
* @notice This contract implements an encrypted ERC20-like token with confidential balances using
* Zama's FHE (Fully Homomorphic Encryption) library.
* @dev It supports standard ERC20 functions such as transferring tokens, minting,
* and setting allowances, but uses encrypted data types.
* The total supply is not encrypted.
* @title ConfidentialERC20.
* @notice This contract implements an encrypted ERC20-like token with confidential balances using
* Zama's FHE (Fully Homomorphic Encryption) library.
* @dev It supports standard ERC20 functions such as transferring tokens, minting,
* and setting allowances, but uses encrypted data types.
* The total supply is not encrypted.
*/
abstract contract ConfidentialERC20 is IConfidentialERC20, IERC20Errors, TFHEErrors {
/// @notice Used as a placeholder in `Approval` & `Transfer` events to comply with the official EIP20.
Expand Down
17 changes: 6 additions & 11 deletions contracts/token/ERC20/ConfidentialERC20Wrapped.sol
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";
import "fhevm/gateway/GatewayCaller.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";

import "fhevm/lib/TFHE.sol";
import "fhevm/gateway/GatewayCaller.sol";

import { IConfidentialERC20Wrapped } from "./IConfidentialERC20Wrapped.sol";
import { ConfidentialERC20 } from "./ConfidentialERC20.sol";

/**
* @title ConfidentialERC20Wrapped
* @notice This contract allows users to wrap/unwrap trustlessly
* ERC20 tokens to ConfidentialERC20 tokens.
* @dev This implementation does not support tokens with rebase functions or
* tokens with a fee on transfer. All ERC20 tokens must have decimals
* inferior or equal to 18 decimals but superior or equal to 6 decimals.
* @title ConfidentialERC20Wrapped.
* @notice This contract allows users to wrap/unwrap trustlessly ERC20 tokens to ConfidentialERC20 tokens.
* @dev This implementation does not support tokens with rebase functions or tokens with a fee on transfer.
* All ERC20 tokens must have decimals superior or equal to 6 decimals.
*/
abstract contract ConfidentialERC20Wrapped is
ConfidentialERC20,
Expand All @@ -40,7 +36,6 @@ abstract contract ConfidentialERC20Wrapped is
mapping(uint256 requestId => UnwrapRequest unwrapRequest) public unwrapRequests;

/**
* @notice Deposit/withdraw ERC20 tokens using confidential ERC20 tokens.
* @param erc20_ Address of the ERC20 token to wrap/unwrap.
* @dev The name/symbol are autogenerated.
* For instance,
Expand Down
20 changes: 9 additions & 11 deletions contracts/token/ERC20/ConfidentialWETH.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import { ConfidentialERC20 } from "./ConfidentialERC20.sol";
import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";

import "fhevm/lib/TFHE.sol";
import "fhevm/gateway/GatewayCaller.sol";

import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
import { ConfidentialERC20 } from "./ConfidentialERC20.sol";
import { IConfidentialERC20Wrapped } from "./IConfidentialERC20Wrapped.sol";

/**
* @title ConfidentialWETH
* @notice This contract allows users to wrap/unwrap trustlessly
* ETH (or other native tokens) to ConfidentialERC20 tokens.
* @title ConfidentialWETH.
* @notice This contract allows users to wrap/unwrap trustlessly
* ETH (or other native tokens) to ConfidentialERC20 tokens.
*/
abstract contract ConfidentialWETH is
ConfidentialERC20,
Expand All @@ -33,7 +31,7 @@ abstract contract ConfidentialWETH is
mapping(uint256 requestId => UnwrapRequest unwrapRequest) public unwrapRequests;

/**
* @notice Deposit/withdraw ethers (or native tokens).
* @notice Deposit/withdraw ethers (or other native tokens).
* @dev The name/symbol are autogenerated.
* @param maxDecryptionDelay_ Maximum delay for the Gateway to decrypt.
* @dev Do not use a small value in production to avoid security issues if the response
Expand All @@ -51,14 +49,14 @@ abstract contract ConfidentialWETH is
}

/**
* @notice Receive function calls wrap().
* @notice Receive function calls wrap().
*/
receive() external payable {
wrap();
}

/**
* @notice Unwrap ConfidentialERC20 tokens to ether.
* @notice Unwrap ConfidentialERC20 tokens to ether (or other native tokens).
* @param amount Amount to unwrap.
*/
function unwrap(uint64 amount) public virtual {
Expand All @@ -83,7 +81,7 @@ abstract contract ConfidentialWETH is
}

/**
* @notice Wrap ether to an encrypted format.
* @notice Wrap ether (or other native token) to an encrypted format.
*/
function wrap() public payable virtual {
uint256 amountAdjusted = (msg.value) / (10 ** (18 - decimals()));
Expand Down
Loading

0 comments on commit de71bf8

Please sign in to comment.