Portfolio
Registry public immutable registry;
uint256 public cap;
uint256 public depositFee;
uint256 public redemptionFee;
address public immutable asset;
bool public didShutdown;
constructor(
Registry _registry,
address _asset,
string memory _name,
string memory _symbol,
uint256 _cap,
uint256 _depositFee,
uint256 _redemptionFee
) ERC20(_name, _symbol, ERC20(_asset).decimals());
Parameters
Name | Type | Description |
---|---|---|
_registry | Registry | Endaoment registry. |
_asset | address | |
_name | string | Name of the ERC20 Portfolio share tokens. |
_symbol | string | Symbol of the ERC20 Portfolio share tokens. |
_cap | uint256 | Amount in baseToken that value of totalAssets should not exceed. |
_depositFee | uint256 | Percentage fee as ZOC that will go to treasury on asset deposit. |
_redemptionFee | uint256 | Percentage fee as ZOC that will go to treasury on share redemption. |
Function used to determine whether an Entity is active on the registry.
function _isEntity(Entity _entity) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_entity | Entity | The Entity. |
Set the Portfolio cap.
function setCap(uint256 _amount) external virtual requiresAuth;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | Amount, denominated in baseToken. |
Set deposit fee.
function setDepositFee(uint256 _pct) external virtual requiresAuth;
Parameters
Name | Type | Description |
---|---|---|
_pct | uint256 | Percentage as ZOC (e.g. 1000 = 10%). |
Set redemption fee.
function setRedemptionFee(uint256 _pct) external virtual requiresAuth;
Parameters
Name | Type | Description |
---|---|---|
_pct | uint256 | Percentage as ZOC (e.g. 1000 = 10%). |
Total amount of the underlying asset that is managed by the Portfolio.
function totalAssets() external view virtual returns (uint256);
Takes some amount of assets from this portfolio as assets under management fee.
function takeFees(uint256 _amountAssets) external virtual;
Parameters
Name | Type | Description |
---|---|---|
_amountAssets | uint256 | Amount of assets to take. |
Exchange
_amountBaseToken
for some amount of Portfolio shares.function deposit(uint256 _amountBaseToken, bytes calldata _data) external virtual returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
_amountBaseToken | uint256 | The amount of the Entity's baseToken to deposit. |
_data | bytes | Data that the portfolio needs to make the deposit. In some cases, this will be swap parameters. |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares that this deposit yields to the Entity. |
Exchange
_amountShares
for some amount of baseToken.function redeem(uint256 _amountShares, bytes calldata _data) external virtual returns (uint256 baseTokenOut);
Parameters
Name | Type | Description |
---|---|---|
_amountShares | uint256 | The amount of the Entity's portfolio shares to exchange. |
_data | bytes | Data that the portfolio needs to make the redemption. In some cases, this will be swap parameters. |
Returns
Name | Type | Description |
---|---|---|
baseTokenOut | uint256 | The amount of baseToken that this redemption yields to the Entity. |
Calculates the amount of shares that the Portfolio should exchange for the amount of assets provided.
function convertToShares(uint256 _amountAssets) public view virtual returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_amountAssets | uint256 | Amount of assets. |
Calculates the amount of assets that the Portfolio should exchange for the amount of shares provided.
function convertToAssets(uint256 _amountShares) public view virtual returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_amountShares | uint256 | Amount of shares. |
Exit out all assets of portfolio for baseToken. Must persist a mechanism for entities to redeem their shares for baseToken.
function shutdown(bytes calldata _data) external virtual returns (uint256 baseTokenOut);
Parameters
Name | Type | Description |
---|---|---|
_data | bytes | Data that the portfolio needs to exit from asset. In some cases, this will be swap parameters. |
Returns
Name | Type | Description |
---|---|---|
baseTokenOut | uint256 | The amount of baseToken that this exit yielded. |
transfer
disabled on Portfolio tokens.function transfer(address, uint256) public pure override returns (bool);
transferFrom
disabled on Portfolio tokens.function transferFrom(address, address, uint256) public pure override returns (bool);
approve
disabled on Portfolio tokens.function approve(address, uint256) public pure override returns (bool);
permit
disabled on Portfolio tokens.function permit(address, address, uint256, uint256, uint8, bytes32, bytes32) public pure override;
Permissioned method that allows Endaoment admin to make arbitrary calls acting as this Portfolio.
function callAsPortfolio(address _target, uint256 _value, bytes memory _data)
external
payable
requiresAuth
returns (bytes memory);
Parameters
Name | Type | Description |
---|---|---|
_target | address | The address to which the call will be made. |
_value | uint256 | The ETH value that should be forwarded with the call. |
_data | bytes | The calldata that will be sent with the call. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | _return The data returned by the call. |
Internal helper method to calculate the fee on a base token amount for a given fee multiplier.
function _calculateFee(uint256 _amount, uint256 _feeMultiplier)
internal
pure
returns (uint256 _netAmount, uint256 _fee);
sender
has exchanged assets
(after fees) for shares
, and transferred those shares
to receiver
. The sender paid a total of depositAmount
and was charged fee
for the transaction.event Deposit(
address indexed sender, address indexed receiver, uint256 assets, uint256 shares, uint256 depositAmount, uint256 fee
);
sender
has exchanged shares
for assets
, and transferred those assets
to receiver
. The sender received a net of redeemedAmount
after the conversion of assets
into base tokens and was charged fee
for the transaction.event Redeem(
address indexed sender,
address indexed receiver,
uint256 assets,
uint256 shares,
uint256 redeemedAmount,
uint256 fee
);
Event emitted when
cap
is set.event CapSet(uint256 cap);
Event emitted when
depositFee
is set.event DepositFeeSet(uint256 fee);
Event emitted when
redemptionFee
is set.event RedemptionFeeSet(uint256 fee);
Event emitted when management takes fees.
event FeesTaken(uint256 amount);
Event emitted when admin forcefully swaps portfolio asset balance for baseToken.
event Shutdown(uint256 assetAmount, uint256 baseTokenOut);
error InvalidSwapper();
error TransferDisallowed();
error DepositAfterShutdown();
error DidShutdown();
error NotEntity();
error ExceedsCap();
error PercentageOver100();
error RoundsToZero();
error CallFailed(bytes response);
Last modified 2mo ago