Search
K

Registry

Inherits: RegistryAuth
Registry entity - manages Factory and Entity state info.

State Variables

treasury

Treasury address can receives fees.
address public treasury;

baseToken

Base Token address is the stable coin contract used throughout the system.
ERC20 public immutable baseToken;

isApprovedFactory

Mapping of approved factory contracts that are allowed to register new Entities.
mapping(address => bool) public isApprovedFactory;

isActiveEntity

Mapping of active status of entities.
mapping(Entity => bool) public isActiveEntity;

defaultDonationFee

Maps entity type to donation fee percentage stored as a zoc, where type(uint32).max represents 0.
mapping(uint8 => uint32) defaultDonationFee;

donationFeeReceiverOverride

Maps specific entity receiver to donation fee percentage stored as a zoc.
mapping(Entity => uint32) donationFeeReceiverOverride;

defaultPayoutFee

Maps entity type to payout fee percentage stored as a zoc, where type(uint32).max represents 0.
mapping(uint8 => uint32) defaultPayoutFee;

payoutFeeOverride

Maps specific entity sender to payout fee percentage stored as a zoc.
mapping(Entity => uint32) payoutFeeOverride;

defaultTransferFee

Maps sender entity type to receiver entity type to fee percentage as a zoc.
mapping(uint8 => mapping(uint8 => uint32)) defaultTransferFee;

transferFeeSenderOverride

Maps specific entity sender to receiver entity type to fee percentage as a zoc.
mapping(Entity => mapping(uint8 => uint32)) transferFeeSenderOverride;

transferFeeReceiverOverride

Maps sender entity type to specific entity receiver to fee percentage as a zoc.
mapping(uint8 => mapping(Entity => uint32)) transferFeeReceiverOverride;

isSwapperSupported

Maps swap wrappers to their enabled/disabled status.
mapping(ISwapWrapper => bool) public isSwapperSupported;

isActivePortfolio

Maps portfolios to their enabled/disabled status.
mapping(Portfolio => bool) public isActivePortfolio;

Functions

requiresAuth

Modifier for methods that require auth and that the manager cannot access.
Overridden from Auth.sol. Reason: use custom error.
modifier requiresAuth() override;

constructor

constructor(address _admin, address _treasury, ERC20 _baseToken) RegistryAuth(_admin, Authority(address(this)));

_parseFeeWithFlip

Fee parsing to convert the special "type(uint32).max" value to zero, and zero to the "max".
After converting, "type(uint32).max" will cause overflow/revert when used as a fee percentage multiplier and zero will mean no fee.
function _parseFeeWithFlip(uint32 _value) private pure returns (uint32);
Parameters
Name
Type
Description
_value
uint32
The value to be converted.
Returns
Name
Type
Description
<none>
uint32
The parsed fee to use.

setTreasury

Sets a new Endaoment treasury address.
function setTreasury(address _newTreasury) external requiresAuth;
Parameters
Name
Type
Description
_newTreasury
address
The new treasury.

setFactoryApproval

Sets the approval state of a factory. Grants the factory permissions to set entity status.
function setFactoryApproval(address _factory, bool _isApproved) external requiresAuth;
Parameters
Name
Type
Description
_factory
address
The factory whose approval state is to be updated.
_isApproved
bool
True if the factory should be approved, false otherwise.

setEntityStatus

Sets the enable/disable state of an Entity.
function setEntityStatus(Entity _entity, bool _isActive) external requiresAuth;
Parameters
Name
Type
Description
_entity
Entity
The entity whose active state is to be updated.
_isActive
bool
True if the entity should be active, false otherwise.

setEntityActive

Sets Entity as active. This is a special method to be called only by approved factories. Other callers should use setEntityStatus instead.
function setEntityActive(Entity _entity) external;
Parameters
Name
Type
Description
_entity
Entity
The entity.

setPortfolioStatus

Sets the enable/disable state of a Portfolio.
function setPortfolioStatus(Portfolio _portfolio, bool _isActive) external requiresAuth;
Parameters
Name
Type
Description
_portfolio
Portfolio
Portfolio.
_isActive
bool
True if setting portfolio to active, false otherwise.

getDonationFee

Gets default donation fee pct (as a zoc) for an Entity.
Makes use of _parseFeeWithFlip, so if no default exists, "max" will be returned.
function getDonationFee(Entity _entity) external view returns (uint32);
Parameters
Name
Type
Description
_entity
Entity
The receiving entity of the donation for which the fee is being fetched.
Returns
Name
Type
Description
<none>
uint32
uint32 The default donation fee for the entity's type.

getDonationFeeWithOverrides

Gets lowest possible donation fee pct (as a zoc) for an Entity, among default and override.
Makes use of _parseFeeWithFlip, so if no default or override exists, "max" will be returned.
function getDonationFeeWithOverrides(Entity _entity) external view returns (uint32);
Parameters
Name
Type
Description
_entity
Entity
The receiving entity of the donation for which the fee is being fetched.
Returns
Name
Type
Description
<none>
uint32
uint32 The minimum of the default donation fee and the receiver's fee override.

getPayoutFee

Gets default payout fee pct (as a zoc) for an Entity.
Makes use of _parseFeeWithFlip, so if no default exists, "max" will be returned.
function getPayoutFee(Entity _entity) external view returns (uint32);
Parameters
Name
Type
Description
_entity
Entity
The sender entity of the payout for which the fee is being fetched.
Returns
Name
Type
Description
<none>
uint32
uint32 The default payout fee for the entity's type.

getPayoutFeeWithOverrides

Gets lowest possible payout fee pct (as a zoc) for an Entity, among default and override.
Makes use of _parseFeeWithFlip, so if no default or override exists, "max" will be returned.
function getPayoutFeeWithOverrides(Entity _entity) external view returns (uint32);
Parameters
Name
Type
Description
_entity
Entity
The sender entity of the payout for which the fee is being fetched.
Returns
Name
Type
Description
<none>
uint32
uint32 The minimum of the default payout fee and the sender's fee override.

getTransferFee

Gets default transfer fee pct (as a zoc) between sender & receiver Entities.
Makes use of _parseFeeWithFlip, so if no default exists, "type(uint32).max" will be returned.
function getTransferFee(Entity _sender, Entity _receiver) external view returns (uint32);
Parameters
Name
Type
Description
_sender
Entity
The sending entity of the transfer for which the fee is being fetched.
_receiver
Entity
The receiving entity of the transfer for which the fee is being fetched.
Returns
Name
Type
Description
<none>
uint32
uint32 The default transfer fee.

getTransferFeeWithOverrides

Gets lowest possible transfer fee pct (as a zoc) between sender & receiver Entities, among default and overrides.
Makes use of _parseFeeWithFlip, so if no default or overrides exist, "type(uint32).max" will be returned.
function getTransferFeeWithOverrides(Entity _sender, Entity _receiver) external view returns (uint32);
Parameters
Name
Type
Description
_sender
Entity
The sending entity of the transfer for which the fee is being fetched.
_receiver
Entity
The receiving entity of the transfer for which the fee is being fetched.
Returns
Name
Type
Description
<none>
uint32
uint32 The minimum of the default transfer fee, and sender and receiver overrides.

setDefaultDonationFee

Sets the default donation fee for an entity type.
function setDefaultDonationFee(uint8 _entityType, uint32 _fee) external requiresAuth;
Parameters
Name
Type
Description
_entityType
uint8
Entity type.
_fee
uint32
The fee percentage to be set (a zoc).

setDonationFeeReceiverOverride

Sets the donation fee receiver override for a specific entity.
function setDonationFeeReceiverOverride(Entity _entity, uint32 _fee) external requiresAuth;
Parameters
Name
Type
Description
_entity
Entity
Entity.
_fee
uint32
The overriding fee (a zoc).

setDefaultPayoutFee

Sets the default payout fee for an entity type.
function setDefaultPayoutFee(uint8 _entityType, uint32 _fee) external requiresAuth;
Parameters
Name
Type
Description
_entityType
uint8
Entity type.
_fee
uint32
The fee percentage to be set (a zoc).

setPayoutFeeOverride

Sets the payout fee override for a specific entity.
function setPayoutFeeOverride(Entity _entity, uint32 _fee) external requiresAuth;
Parameters
Name
Type
Description
_entity
Entity
Entity.
_fee
uint32
The overriding fee (a zoc).

setDefaultTransferFee

Sets the default transfer fee for transfers from one specific entity type to another.
function setDefaultTransferFee(uint8 _fromEntityType, uint8 _toEntityType, uint32 _fee) external requiresAuth;
Parameters
Name
Type
Description
_fromEntityType
uint8
The entityType making the transfer.
_toEntityType
uint8
The receiving entityType.
_fee
uint32
The transfer fee percentage (a zoc).

setTransferFeeSenderOverride

Sets the transfer fee override for transfers from one specific entity to entities of a given type.
function setTransferFeeSenderOverride(Entity _fromEntity, uint8 _toEntityType, uint32 _fee) external requiresAuth;
Parameters
Name
Type
Description
_fromEntity
Entity
The entity making the transfer.
_toEntityType
uint8
The receiving entityType.
_fee
uint32
The overriding fee percentage (a zoc).

setTransferFeeReceiverOverride

Sets the transfer fee override for transfers from entities of a given type to a specific entity.
function setTransferFeeReceiverOverride(uint8 _fromEntityType, Entity _toEntity, uint32 _fee) external requiresAuth;
Parameters
Name
Type
Description
_fromEntityType
uint8
The entityType making the transfer.
_toEntity
Entity
The receiving entity.
_fee
uint32
The overriding fee percentage (a zoc).

setSwapWrapperStatus

Sets the enable/disable state of a SwapWrapper. System owners must ensure meticulous review of SwapWrappers before approving them.
function setSwapWrapperStatus(ISwapWrapper _swapWrapper, bool _supported) external requiresAuth;
Parameters
Name
Type
Description
_swapWrapper
ISwapWrapper
A contract that implements ISwapWrapper.
_supported
bool
true if supported, false if unsupported.

Events

FactoryApprovalSet

The event emitted when a factory is approved (whitelisted) or has it's approval removed.
event FactoryApprovalSet(address indexed factory, bool isApproved);

EntityStatusSet

The event emitted when an entity is set active or inactive.
event EntityStatusSet(address indexed entity, bool isActive);

SwapWrapperStatusSet

The event emitted when a swap wrapper is set active or inactive.
event SwapWrapperStatusSet(address indexed swapWrapper, bool isSupported);

PortfolioStatusSet

The event emitted when a portfolio is set active or inactive.
event PortfolioStatusSet(address indexed portfolio, bool isActive);

DefaultDonationFeeSet

Emitted when a default donation fee is set for an entity type.
event DefaultDonationFeeSet(uint8 indexed entityType, uint32 fee);

DonationFeeReceiverOverrideSet

Emitted when a donation fee override is set for a specific receiving entity.
event DonationFeeReceiverOverrideSet(address indexed entity, uint32 fee);

DefaultPayoutFeeSet

Emitted when a default payout fee is set for an entity type.
event DefaultPayoutFeeSet(uint8 indexed entityType, uint32 fee);

PayoutFeeOverrideSet

Emitted when a payout fee override is set for a specific sender entity.
event PayoutFeeOverrideSet(address indexed entity, uint32 fee);

DefaultTransferFeeSet

Emitted when a default transfer fee is set for transfers between entity types.
event DefaultTransferFeeSet(uint8 indexed fromEntityType, uint8 indexed toEntityType, uint32 fee);

TransferFeeSenderOverrideSet

Emitted when a transfer fee override is set for transfers from an entity to a specific entityType.
event TransferFeeSenderOverrideSet(address indexed fromEntity, uint8 indexed toEntityType, uint32 fee);

TransferFeeReceiverOverrideSet

Emitted when a transfer fee override is set for transfers from an entityType to an entity.
event TransferFeeReceiverOverrideSet(uint8 indexed fromEntityType, address indexed toEntity, uint32 fee);

TreasuryChanged

Emitted when the registry treasury contract is changed.
event TreasuryChanged(address oldTreasury, address indexed newTreasury);