Search
K

Portfolio

Inherits: ERC20, EndaomentAuth

State Variables

registry

Registry public immutable registry;

cap

uint256 public cap;

depositFee

uint256 public depositFee;

redemptionFee

uint256 public redemptionFee;

asset

address public immutable asset;

didShutdown

bool public didShutdown;

Functions

constructor

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.

_isEntity

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.

setCap

Set the Portfolio cap.
function setCap(uint256 _amount) external virtual requiresAuth;
Parameters
Name
Type
Description
_amount
uint256
Amount, denominated in baseToken.

setDepositFee

Set deposit fee.
function setDepositFee(uint256 _pct) external virtual requiresAuth;
Parameters
Name
Type
Description
_pct
uint256
Percentage as ZOC (e.g. 1000 = 10%).

setRedemptionFee

Set redemption fee.
function setRedemptionFee(uint256 _pct) external virtual requiresAuth;
Parameters
Name
Type
Description
_pct
uint256
Percentage as ZOC (e.g. 1000 = 10%).

totalAssets

Total amount of the underlying asset that is managed by the Portfolio.
function totalAssets() external view virtual returns (uint256);

takeFees

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.

deposit

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.

redeem

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.

convertToShares

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.

convertToAssets

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.

shutdown

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

transfer disabled on Portfolio tokens.
function transfer(address, uint256) public pure override returns (bool);

transferFrom

transferFrom disabled on Portfolio tokens.
function transferFrom(address, address, uint256) public pure override returns (bool);

approve

approve disabled on Portfolio tokens.
function approve(address, uint256) public pure override returns (bool);

permit

permit disabled on Portfolio tokens.
function permit(address, address, uint256, uint256, uint8, bytes32, bytes32) public pure override;

callAsPortfolio

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.

_calculateFee

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);

Events

Deposit

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
);

Redeem

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
);

CapSet

Event emitted when cap is set.
event CapSet(uint256 cap);

DepositFeeSet

Event emitted when depositFee is set.
event DepositFeeSet(uint256 fee);

RedemptionFeeSet

Event emitted when redemptionFee is set.
event RedemptionFeeSet(uint256 fee);

FeesTaken

Event emitted when management takes fees.
event FeesTaken(uint256 amount);

Shutdown

Event emitted when admin forcefully swaps portfolio asset balance for baseToken.
event Shutdown(uint256 assetAmount, uint256 baseTokenOut);

Errors

InvalidSwapper

error InvalidSwapper();

TransferDisallowed

error TransferDisallowed();

DepositAfterShutdown

error DepositAfterShutdown();

DidShutdown

error DidShutdown();

NotEntity

error NotEntity();

ExceedsCap

error ExceedsCap();

PercentageOver100

error PercentageOver100();

RoundsToZero

error RoundsToZero();

CallFailed

error CallFailed(bytes response);