Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: natspec #89

Merged
merged 1 commit into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contracts/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,17 @@ contract Hub is IHub, Ownable, Initializable {
}

/// @inheritdoc IHub
function getWarmup() external view override returns (uint256) {
function warmup() external view override returns (uint256) {
return _warmup;
}

/// @inheritdoc IHub
function getDuration() external view override returns (uint256) {
function duration() external view override returns (uint256) {
return _duration;
}

/// @inheritdoc IHub
function getCooldown() external view override returns (uint256) {
function cooldown() external view override returns (uint256) {
return _cooldown;
}

Expand Down
47 changes: 38 additions & 9 deletions contracts/interfaces/ICurve.sol
Original file line number Diff line number Diff line change
@@ -1,58 +1,87 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

/// @title Curve Interface
/// @title Generic Curve interface
/// @author Carl Farterson (@carlfarterson)
/// @dev Required for all Curves
interface ICurve {
event Updated(uint256 indexed hubId);
/// @notice Event when curveDetails are updated from target values to actual values
event Updated(uint256 indexed _hubId);

/// @notice Given a hub, baseX, baseY and connector weight, add the configuration to the
/// BancorZero Curve registry
/// @dev Curve need to be encoded as the Hub may register Curves for different curves
/// that may contain different Curve arguments
/// @param _hubId unique hub identifier
/// @param _encodedDetails encoded Curve arguments
/// @param _hubId unique hub identifier
/// @param _encodedDetails encoded Curve arguments
function register(uint256 _hubId, bytes calldata _encodedDetails) external;

/// @notice TODO
/// @param _hubId unique hub identifier
/// @param _encodedDetails encoded target Curve arguments
/// @notice Initialize reconfiguring curveDetails for a hub
/// @param _hubId unique hub identifier
/// @param _encodedDetails encoded target Curve arguments
function initReconfigure(uint256 _hubId, bytes calldata _encodedDetails)
external;

/// @notice Finish reconfiguring curveDetails for a hub
/// @param _hubId uinque hub identifier
function finishReconfigure(uint256 _hubId) external;

/// @notice Get curveDetails for a hub
/// @return curveDetails (TODO: curve w/ more than 4 curveDetails)
function getDetails(uint256 _hubId)
external
view
returns (uint256[4] memory);

/// @notice Calculate meTokens minted based on a curve's active details
/// @param _assetsDeposited Amount of assets deposited to the hub
/// @param _hubId unique hub identifier
/// @param _supply current meToken supply
/// @param _balancePooled area under curve
/// @return meTokensMinted amount of MeTokens minted
function viewMeTokensMinted(
uint256 _assetsDeposited,
uint256 _hubId,
uint256 _supply,
uint256 _balancePooled
) external view returns (uint256 meTokensMinted);

/// @notice Calculate assets returned based on a curve's active details
/// @param _meTokensBurned Amount of assets deposited to the hub
/// @param _hubId unique hub identifier
/// @param _supply current meToken supply
/// @param _balancePooled area under curve
/// @return assetsReturned amount of assets returned
function viewAssetsReturned(
uint256 _meTokensBurned,
uint256 _hubId,
uint256 _supply,
uint256 _balancePooled
) external view returns (uint256 assetsReturned);

/// @notice Calculate meTokens minted based on a curve's target details
/// @param _assetsDeposited Amount of assets deposited to the hub
/// @param _hubId unique hub identifier
/// @param _supply current meToken supply
/// @param _balancePooled area under curve
/// @return meTokensMinted amount of MeTokens minted
function viewTargetMeTokensMinted(
uint256 _assetsDeposited,
uint256 _hubId,
uint256 _supply,
uint256 _balancePooled
) external view returns (uint256 meTokensMinted);

/// @notice Calculate assets returned based on a curve's target details
/// @param _meTokensBurned Amount of assets deposited to the hub
/// @param _hubId unique hub identifier
/// @param _supply current meToken supply
/// @param _balancePooled area under curve
/// @return assetsReturned amount of assets returned
function viewTargetAssetsReturned(
uint256 _meTokensBurned,
uint256 _hubId,
uint256 _supply,
uint256 _balancePooled
) external view returns (uint256 assetsReturned);

function finishReconfigure(uint256 id) external;
}
36 changes: 29 additions & 7 deletions contracts/interfaces/IFees.sol
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

/// @title MeTokens protocol fee interface
/// @author Carl Farterson (@carlfarterson)
interface IFees {
function setBurnBuyerFee(uint256 amount) external;
/// @notice Set meToken protocol BurnBuyer fee
/// @param _fee new fee
function setBurnBuyerFee(uint256 _fee) external;

function setBurnOwnerFee(uint256 amount) external;
/// @notice Set meToken protocol BurnOwner fee
/// @param _fee new fee
function setBurnOwnerFee(uint256 _fee) external;

function setTransferFee(uint256 amount) external;
/// @notice Set meToken protocol Transfer fee
/// @param _fee new fee
function setTransferFee(uint256 _fee) external;

function setInterestFee(uint256 amount) external;
/// @notice Set meToken protocol Interest fee
/// @param _fee new fee
function setInterestFee(uint256 _fee) external;

function setYieldFee(uint256 amount) external;

function setOwner(address _owner) external;
/// @notice Set meToken protocol Yield fee
/// @param _fee new fee
function setYieldFee(uint256 _fee) external;

/// @notice Get mint fee
/// @return uint256 _mintFee
function mintFee() external view returns (uint256);

/// @notice Get burnBuyer fee
/// @return uint256 _burnBuyerFee
function burnBuyerFee() external view returns (uint256);

/// @notice Get burnOwner fee
/// @return uint256 _burnOwnerFee
function burnOwnerFee() external view returns (uint256);

/// @notice Get transfer fee
/// @return uint256 _transferFee
function transferFee() external view returns (uint256);

/// @notice Get interest fee
/// @return uint256 _interestFee
function interestFee() external view returns (uint256);

/// @notice Get yield fee
/// @return uint256 _yieldFee
function yieldFee() external view returns (uint256);
}
48 changes: 36 additions & 12 deletions contracts/interfaces/IFoundry.sol
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

/// @title MeTokens foundry interface
/// @author Carl Farterson (@carlfarterson)
interface IFoundry {
/// @notice Event of minting a meToken
/// @param _meToken address of meToken minted
/// @param _asset address of asset deposited
/// @param _depositor address to deposit asset
/// @param _recipient address to receive minted meTokens
/// @param _assetsDeposited amount of assets deposited
/// @param _meTokensMinted amount of meTokens minted
event Mint(
address meToken,
address token,
address depositor,
address recipient,
uint256 assetsDeposited,
uint256 meTokensMinted
address _meToken,
address _asset,
address _depositor,
address _recipient,
uint256 _assetsDeposited,
uint256 _meTokensMinted
);

/// @notice Event of burning a meToken
/// @param _meToken address of meToken burned
/// @param _asset address of asset returned
/// @param _burner address to burn meTokens
/// @param _recipient address to receive underlying asset
/// @param _meTokensBurned amount of meTokens to burn
/// @param _assetsReturned amount of assets
event Burn(
address meToken,
address token,
address burner,
address recipient,
uint256 meTokensBurned,
uint256 assetsReturned
address _meToken,
address _asset,
address _burner,
address _recipient,
uint256 _meTokensBurned,
uint256 _assetsReturned
);

/// @notice Mint a meToken by depositing the underlying asset
/// @param _meToken address of meToken to mint
/// @param _assetsDeposited amount of assets to deposit
/// @param _recipient address to receive minted meTokens
function mint(
address _meToken,
uint256 _assetsDeposited,
address _recipient
) external;

/// @notice Burn a meToken to receive the underlying asset
/// @param _meToken address of meToken to burn
/// @param _meTokensBurned amount of meTokens to burn
/// @param _recipient address to receive the underlying assets
function burn(
address _meToken,
uint256 _meTokensBurned,
Expand Down
89 changes: 66 additions & 23 deletions contracts/interfaces/IHub.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

import "../libs/Details.sol";
import "./IVault.sol";
import "./ICurve.sol";
import "../libs/Details.sol";

/// @title MeTokens hub interface
/// @author Carl Farterson (@carlfarterson)
interface IHub {
/// @notice Event of registering a hub
/// @param _owner address to own hub
/// @param _asset address of underlying asset
/// @param _vault address of vault
/// @param _curve address of curve
/// @param _refundRatio rate to refund burners
/// @param _encodedCurveDetails additional encoded curve details
/// @param _encodedVaultArgs additional encoded vault arguments
event Register(
address _owner,
address _asset,
Expand All @@ -15,21 +25,49 @@ interface IHub {
bytes _encodedCurveDetails,
bytes _encodedVaultArgs
);

/// @notice Event of initializing a hub update
/// @notice _id unique hub identifier
/// @notice _targetCurve address of target curve
/// @notice _targetRefundRatio target rate to refund burners
/// @notice _encodedCurveDetails additional encoded curve details
/// @notice _reconfigure boolean to show if we're changing the
/// curveDetails but not the curve address
/// @notice _startTime timestamp to start updating
/// @notice _endTime timestamp to end updating
/// @notice _endCooldown timestamp to allow another update
event InitUpdate(
uint256 _id,
address _targetCurve,
uint256 _targetRefundRatio,
bytes _encodedCurveDetails,
bool reconfigure,
uint256 startTime,
uint256 endTime,
uint256 endCooldown
bool _reconfigure,
uint256 _startTime,
uint256 _endTime,
uint256 _endCooldown
);

/// @notice Event of canceling a hub update
/// @param _id unique hub identifier
event CancelUpdate(uint256 _id);

/// @notice Event of transfering hub ownership
/// @param _id unique hub identifier
/// @param _newOwner address to own the hub
event TransferHubOwnership(uint256 _id, address _newOwner);

/// @notice Event of finishing a hub update
/// @param _id unique hub identifier
event FinishUpdate(uint256 _id);

/// @notice Register a new hub
/// @param _owner address to own hub
/// @param _asset address of vault asset
/// @param _vault address of vault
/// @param _curve address of curve
/// @param _refundRatio rate to refund burners
/// @param _encodedCurveDetails additional encoded curve details
/// @param _encodedVaultArgs additional encoded vault arguments
function register(
address _owner,
address _asset,
Expand All @@ -40,41 +78,46 @@ interface IHub {
bytes memory _encodedVaultArgs
) external;

/// @notice Intialize a hub update
/// @param _id unique hub identifier
/// @param _targetCurve address of target curve
/// @param _targetRefundRatio target rate to refund burners
/// @param _encodedCurveDetails additional encoded curve details
function initUpdate(
uint256 _id,
address _targetCurve,
uint256 _targetRefundRatio,
bytes memory _encodedCurveDetails
) external;

/// @notice Cancel a hub update
/// @dev Can only be called before _startTime
/// @param _id unique hub identifier
function cancelUpdate(uint256 _id) external;

/// @notice Function to end the update, setting the target values of the hub,
/// as well as modifying a hubs' status to ACTIVE
/// @param id Unique hub identifier
function finishUpdate(uint256 id) external returns (Details.Hub memory);

/// @notice TODO
/// @param id Unique hub identifier
/// @return hub_ Details of hub
function getDetails(uint256 id)
external
view
returns (Details.Hub memory hub_);

/// @notice TODO
/// @return count of hubs created
/// @notice Finish updating a hub
/// @param _id unique hub identifier
/// @return details of hub
function finishUpdate(uint256 _id) external returns (Details.Hub memory);

/// @notice Get the details of a hub
/// @param _id unique hub identifier
/// @return details of hub
function getDetails(uint256 _id) external view returns (Details.Hub memory);

/// @notice Counter of hubs registered
/// @return uint256
function count() external view returns (uint256);

function getWarmup() external view returns (uint256);
function warmup() external view returns (uint256);

function setWarmup(uint256 warmup_) external;

function getDuration() external view returns (uint256);
function duration() external view returns (uint256);

function setDuration(uint256 duration_) external;

function getCooldown() external view returns (uint256);
function cooldown() external view returns (uint256);

function setCooldown(uint256 cooldown_) external;
}
Loading