Search…
⌃K

Entity

Entity contract inherited by Org and Fund contracts (and all future kinds of Entities).

Methods

ETH_PLACEHOLDER

function ETH_PLACEHOLDER() external view returns (address)
Placeholder address used in swapping method to denote usage of ETH instead of a token.

Returns

Name
Type
Description
_0
address
undefined

authority

function authority() external view returns (contract RolesAuthority)
The contract used to source permissions for accounts targeting this contract.

Returns

Name
Type
Description
_0
contract RolesAuthority
undefined

balance

function balance() external view returns (uint256)
The current balance for the entity, denominated in the base token's units.

Returns

Name
Type
Description
_0
uint256
undefined

baseToken

function baseToken() external view returns (contract ERC20)

Returns

Name
Type
Description
_0
contract ERC20
undefined

callAsEntity

function callAsEntity(address _target, uint256 _value, bytes _data) external payable returns (bytes)
Permissioned method that allows Endaoment admin to make arbitrary calls acting as this Entity.

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
_0
bytes
_return The data returned by the call.
function donate(uint256 _amount) external nonpayable
Receives a donated amount of base tokens to be added to the entity's balance. Transfers default fee to treasury.
Reverts if the donation fee percentage is larger than 100% (equal to 1e4 when represented as a zoc).Reverts if the token transfer fails.

Parameters

Name
Type
Description
_amount
uint256
Amount donated in base token.

donateWithOverrides

function donateWithOverrides(uint256 _amount) external nonpayable
Receives a donated amount of base tokens to be added to the entity's balance. Transfers default or overridden fee to treasury.
Reverts if the donation fee percentage is larger than 100% (equal to 1e4 when represented as a zoc).Reverts if the token transfer fails.

Parameters

Name
Type
Description
_amount
uint256
Amount donated in base token.

entityType

function entityType() external pure returns (uint8)
Each entity will implement this function to allow a caller to interrogate what kind of entity it is.

Returns

Name
Type
Description
_0
uint8
undefined

initialize

function initialize(contract Registry _registry, address _manager) external nonpayable
One time method to be called at deployment to configure the contract. Required so Entity contracts can be deployed as minimal proxies (clones).

Parameters

Name
Type
Description
_registry
contract Registry
The registry to host the Entity.
_manager
address
The address of the Entity's manager.

initialize

function initialize(contract RolesAuthority _authority, bytes20 _specialTarget) external nonpayable
One time method to be called at deployment to configure the contract. Required so EndaomentAuth contracts can be deployed as minimal proxies (clones).

Parameters

Name
Type
Description
_authority
contract RolesAuthority
Contract that will be used to source permissions for accounts targeting this contract.
_specialTarget
bytes20
The bytes that this contract will pass as the "target" when looking up permissions from the authority. If set to empty bytes, this contract will pass its own address instead.

manager

function manager() external view returns (address)
The entity's manager.

Returns

Name
Type
Description
_0
address
undefined

payout

function payout(address _to, uint256 _amount) external nonpayable
Pays out an amount of base tokens from the entity to an address. Transfers the fee calculated by the default fee multiplier to the treasury.
Reverts with Unauthorized if the msg.sender is not a privileged role.Reverts if the fee percentage is larger than 100% (equal to 1e4 when represented as a zoc).Reverts if the token transfer fails.

Parameters

Name
Type
Description
_to
address
The address to receive the tokens.
_amount
uint256
Amount donated in base token.

payoutWithOverrides

function payoutWithOverrides(address _to, uint256 _amount) external nonpayable
Pays out an amount of base tokens from the entity to an address. Transfers the fee calculated by the default fee multiplier to the treasury.
Reverts with Unauthorized if the msg.sender is not a privileged role.Reverts if the fee percentage is larger than 100% (equal to 1e4 when represented as a zoc).Reverts if the token transfer fails.

Parameters

Name
Type
Description
_to
address
undefined
_amount
uint256
Amount donated in base token.

portfolioDeposit

function portfolioDeposit(contract Portfolio _portfolio, uint256 _amount, bytes _data) external nonpayable returns (uint256)
Deposits an amount of Entity's baseToken into an Endaoment-approved Portfolio.

Parameters

Name
Type
Description
_portfolio
contract Portfolio
An Endaoment-approved portfolio.
_amount
uint256
Amount of baseToken to deposit into the portfolio.
_data
bytes
Data required by a portfolio to deposit.

Returns

Name
Type
Description
_0
uint256
_shares Amount of portfolio share tokens Entity received as a result of this deposit.

portfolioRedeem

function portfolioRedeem(contract Portfolio _portfolio, uint256 _shares, bytes _data) external nonpayable returns (uint256)
Redeems an amount of Entity's portfolio shares for an amount of baseToken.

Parameters

Name
Type
Description
_portfolio
contract Portfolio
An Endaoment-approved portfolio.
_shares
uint256
Amount of share tokens to redeem.
_data
bytes
Data required by a portfolio to redeem.

Returns

Name
Type
Description
_0
uint256
_received Amount of baseToken Entity received as a result of this redemption.

receiveTransfer

function receiveTransfer(uint256 _transferAmount) external nonpayable
Updates the receiving entity balance on a transfer, after verifying that the receiver's ERC20 balance has increased appropriately.
This function is public, but is restricted such that it can only be called by other entities.

Parameters

Name
Type
Description
_transferAmount
uint256
The amount being received on the transfer.

reconcileBalance

function reconcileBalance() external nonpayable
This method should be called to reconcile the Entity's internal baseToken accounting with the baseToken contract's accounting. There are a 2 situations where calling this method is appropriate: 1. To process amounts of baseToken that arrived at this Entity through methods besides Entity:donate or Entity:transfer. For example, if this Entity receives a normal ERC20 transfer of baseToken, the amount received will be unavailable for Entity use until this method is called to adjust the balance and process fees. OrgFundFactory.sol:_donate makes use of this method to do this as well. 2. Unusually, the Entity's perspective of balance could be lower than baseToken.balanceOf(this). This could happen if Entity:callAsEntity is used to transfer baseToken. In this case, this method provides a way of correcting the Entity's internal balance.

registry

function registry() external view returns (contract Registry)
The base registry to which the entity is connected.

Returns

Name
Type
Description
_0
contract Registry
undefined

setManager

function setManager(address _manager) external nonpayable
Set a new manager for this entity.
Callable by current manager or permissioned role.

Parameters

Name
Type
Description
_manager
address
Address of new manager.

specialTarget

function specialTarget() external view returns (bytes20)
If set to a non-zero value, this contract will pass these byes as the target contract to the RolesAuthority's canCall method, rather than its own contract. This allows a single RolesAuthority permission to manage permissions simultaneously for a group of contracts that identify themselves as a certain type. For example: set a permission for all "entity" contracts.

Returns

Name
Type
Description
_0
bytes20
undefined

swapAndDonate

function swapAndDonate(contract ISwapWrapper _swapWrapper, address _tokenIn, uint256 _amountIn, bytes _data) external payable
Receive a donated amount of ETH or ERC20 tokens, swaps them to base tokens, and adds the output to the entity's balance. Fee calculated using default rate and sent to treasury.

Parameters

Name
Type
Description
_swapWrapper
contract ISwapWrapper
The swap wrapper to use for the donation. Must be whitelisted on the Registry.
_tokenIn
address
The address of the ERC20 token to swap and donate, or ETH_PLACEHOLDER if donating ETH.
_amountIn
uint256
The amount of tokens or ETH being swapped and donated.
_data
bytes
Additional call data required by the ISwapWrapper being used.

swapAndDonateWithOverrides

function swapAndDonateWithOverrides(contract ISwapWrapper _swapWrapper, address _tokenIn, uint256 _amountIn, bytes _data) external payable
Receive a donated amount of ETH or ERC20 tokens, swaps them to base tokens, and adds the output to the entity's balance. Fee calculated using override rate and sent to treasury.

Parameters

Name
Type
Description
_swapWrapper
contract ISwapWrapper
The swap wrapper to use for the donation. Must be whitelisted on the Registry.
_tokenIn
address
The address of the ERC20 token to swap and donate, or ETH_PLACEHOLDER if donating ETH.
_amountIn
uint256
The amount of tokens or ETH being swapped and donated.
_data
bytes
Additional call data required by the ISwapWrapper being used.

swapAndReconcileBalance

function swapAndReconcileBalance(contract ISwapWrapper _swapWrapper, address _tokenIn, uint256 _amountIn, bytes _data) external nonpayable
Takes stray tokens or ETH sent directly to this Entity, swaps them for base token, then adds them to the Entity's balance after paying the appropriate fee to the treasury.

Parameters

Name
Type
Description
_swapWrapper
contract ISwapWrapper
The swap wrapper to use to convert the assets. Must be whitelisted on the Registry.
_tokenIn
address
The address of the ERC20 token to swap, or ETH_PLACEHOLDER if ETH.
_amountIn
uint256
The amount of tokens or ETH being swapped and added to the balance.
_data
bytes
Additional call data required by the ISwapWrapper being used.

transfer

function transfer(contract Entity _to, uint256 _amount) external nonpayable
Transfers an amount of base tokens from one entity to another. Transfers default fee to treasury.
Reverts if the entity is inactive or if the token transfer fails.Reverts if the transfer fee percentage is larger than 100% (equal to 1e4 when represented as a zoc).Reverts with Unauthorized if the msg.sender is not the entity manager or a privileged role.

Parameters

Name
Type
Description
_to
contract Entity
The entity to receive the tokens.
_amount
uint256
Contains the amount being donated (denominated in the base token's units).

transferWithOverrides

function transferWithOverrides(contract Entity _to, uint256 _amount) external nonpayable
Transfers an amount of base tokens from one entity to another. Transfers default or overridden fee to treasury.
Reverts if the entity is inactive or if the token transfer fails.Reverts if the transfer fee percentage is larger than 100% (equal to 1e4 when represented as a zoc).Reverts with Unauthorized if the msg.sender is not the entity manager or a privileged role.

Parameters

Name
Type
Description
_to
contract Entity
The entity to receive the tokens.
_amount
uint256
Contains the amount being donated (denominated in the base token's units).

Events

EntityBalanceCorrected

event EntityBalanceCorrected(address indexed entity, uint256 newBalance)
Emitted when a base token balance is used to correct the internal contract balance.

Parameters

Name
Type
Description
entity indexed
address
undefined
newBalance
uint256
undefined

EntityBalanceReconciled

event EntityBalanceReconciled(address indexed entity, uint256 amountReceived, uint256 amountFee)
Emitted when a base token reconciliation completes

Parameters

Name
Type
Description
entity indexed
address
undefined
amountReceived
uint256
undefined
amountFee
uint256
undefined

EntityDeposit

event EntityDeposit(address indexed portfolio, uint256 baseTokenDeposited, uint256 sharesRecieved)
Emitted when a portfolio deposit is made.

Parameters

Name
Type
Description
portfolio indexed
address
undefined
baseTokenDeposited
uint256
undefined
sharesRecieved
uint256
undefined

EntityDonationReceived

event EntityDonationReceived(address indexed from, address indexed to, uint256 amountReceived, uint256 amountFee)
Emitted when a donation is made.

Parameters

Name
Type
Description
from indexed
address
undefined
to indexed
address
undefined
amountReceived
uint256
undefined
amountFee
uint256
undefined

EntityFundsPaidOut

event EntityFundsPaidOut(address indexed from, address indexed to, uint256 amountSent, uint256 amountFee)
Emitted when a payout is made from an entity.

Parameters

Name
Type
Description
from indexed
address
undefined
to indexed
address
undefined
amountSent
uint256
undefined
amountFee
uint256
undefined

EntityFundsTransferred

event EntityFundsTransferred(address indexed from, address indexed to, uint256 amountReceived, uint256 amountFee)
Emitted when a transfer is made between entities.

Parameters

Name
Type
Description
from indexed
address
undefined
to indexed
address
undefined
amountReceived
uint256
undefined
amountFee
uint256
undefined

EntityManagerSet

event EntityManagerSet(address indexed oldManager, address indexed newManager)
Emitted when manager is set.

Parameters

Name
Type
Description
oldManager indexed
address
undefined
newManager indexed
address
undefined

EntityRedeem

event EntityRedeem(address indexed portfolio, uint256 sharesRedeemed, uint256 baseTokenReceived)
Emitted when a portfolio share redemption is made.

Parameters

Name
Type
Description
portfolio indexed
address
undefined
sharesRedeemed
uint256
undefined
baseTokenReceived
uint256
undefined

Errors

AlreadyInitialized

error AlreadyInitialized()
Thrown if there is a second call to initialize.

CallFailed

error CallFailed(bytes response)

Parameters

Name
Type
Description
response
bytes
undefined

EntityInactive

error EntityInactive()

InsufficientFunds

error InsufficientFunds()

InvalidAction

error InvalidAction()

InvalidAuthority

error InvalidAuthority()
Thrown if there is an attempt to deploy with address 0 as the authority.

InvalidTransferAttempt

error InvalidTransferAttempt()

PortfolioInactive

error PortfolioInactive()

Unauthorized

error Unauthorized()
Thrown when an account without proper permissions calls a privileged method.