ITaxCollector
Inherits: IAuthorizable, IModifiable, IModifiablePerCollateral
Functions
params
Getter for the contract parameters struct
function params() external view returns (TaxCollectorParams memory _taxCollectorParams);
Returns
Name | Type | Description |
---|---|---|
_taxCollectorParams | TaxCollectorParams | Tax collector parameters struct |
_params
Getter for the unpacked contract parameters struct
function _params()
external
view
returns (
address _primaryTaxReceiver,
uint256 _globalStabilityFee,
uint256 _maxStabilityFeeRange,
uint256 _maxSecondaryReceivers
);
Returns
Name | Type | Description |
---|---|---|
_primaryTaxReceiver | address | Primary tax receiver address |
_globalStabilityFee | uint256 | Global stability fee [ray] |
_maxStabilityFeeRange | uint256 | Max stability fee range [ray] |
_maxSecondaryReceivers | uint256 | Max number of secondary tax receivers |
cParams
Getter for the collateral parameters struct
function cParams(bytes32 _cType) external view returns (TaxCollectorCollateralParams memory _taxCollectorCParams);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
Returns
Name | Type | Description |
---|---|---|
_taxCollectorCParams | TaxCollectorCollateralParams | Tax collector collateral parameters struct |
_cParams
Getter for the unpacked collateral parameters struct
function _cParams(bytes32 _cType) external view returns (uint256 _stabilityFee);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
Returns
Name | Type | Description |
---|---|---|
_stabilityFee | uint256 | Stability fee [ray] |
cData
Getter for the collateral data struct
function cData(bytes32 _cType) external view returns (TaxCollectorCollateralData memory _taxCollectorCData);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
Returns
Name | Type | Description |
---|---|---|
_taxCollectorCData | TaxCollectorCollateralData | Tax collector collateral data struct |
_cData
Getter for the unpacked collateral data struct
function _cData(bytes32 _cType)
external
view
returns (uint256 _nextStabilityFee, uint256 _updateTime, uint256 _secondaryReceiverAllotedTax);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
Returns
Name | Type | Description |
---|---|---|
_nextStabilityFee | uint256 | Per second borrow rate to be applied at the next taxation [ray] |
_updateTime | uint256 | When Stability Fee was last collected |
_secondaryReceiverAllotedTax | uint256 | Percentage of SF that goes to other addresses apart from the primary receiver |
secondaryTaxReceivers
Getter for the data about a specific secondary tax receiver
function secondaryTaxReceivers(
bytes32 _cType,
address _receiver
) external view returns (TaxReceiver memory _secondaryTaxReceiver);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_receiver | address | Tax receiver address to check |
Returns
Name | Type | Description |
---|---|---|
_secondaryTaxReceiver | TaxReceiver | Tax receiver struct |
_secondaryTaxReceivers
Getter for the unpacked data about a specific secondary tax receiver
function _secondaryTaxReceivers(
bytes32 _cType,
address _receiver
) external view returns (address _secondaryReceiver, bool _canTakeBackTax, uint256 _taxPercentage);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_receiver | address | Tax receiver address to check |
Returns
Name | Type | Description |
---|---|---|
_secondaryReceiver | address | Secondary tax receiver address |
_canTakeBackTax | bool | Whether this receiver can accept a negative rate (taking SF from it) |
_taxPercentage | uint256 | Percentage of SF allocated to this receiver |
safeEngine
Address of the SAFEEngine contract
function safeEngine() external view returns (ISAFEEngine _safeEngine);
collectedManyTax
Check if multiple collateral types are up to date with taxation
function collectedManyTax(uint256 _start, uint256 _end) external view returns (bool _ok);
Parameters
Name | Type | Description |
---|---|---|
_start | uint256 | Index of the first collateral type to check |
_end | uint256 | Index of the last collateral type to check |
Returns
Name | Type | Description |
---|---|---|
_ok | bool | Whether all collateral types are up to date |
taxManyOutcome
Check how much SF will be charged (to collateral types between indexes 'start' and 'end' in the collateralList) during the next taxation
function taxManyOutcome(uint256 _start, uint256 _end) external view returns (bool _ok, int256 _rad);
Parameters
Name | Type | Description |
---|---|---|
_start | uint256 | Index in collateralList from which to start looping and calculating the tax outcome |
_end | uint256 | Index in collateralList at which we stop looping and calculating the tax outcome |
Returns
Name | Type | Description |
---|---|---|
_ok | bool | Whether the tax outcome can be computed |
_rad | int256 | The total amount of SF that will be charged during the next taxation |
taxSingleOutcome
Get how much SF will be distributed after taxing a specific collateral type
function taxSingleOutcome(bytes32 _cType) external view returns (uint256 _newlyAccumulatedRate, int256 _deltaRate);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Collateral type to compute the taxation outcome for |
Returns
Name | Type | Description |
---|---|---|
_newlyAccumulatedRate | uint256 | The newly accumulated rate |
_deltaRate | int256 | The delta between the new and the last accumulated rates |
secondaryReceiversListLength
Get the secondary tax receiver list length
function secondaryReceiversListLength() external view returns (uint256 _secondaryReceiversListLength);
collateralListLength
Get the collateralList length
function collateralListLength() external view returns (uint256 _collateralListLength);
isSecondaryReceiver
Check if a tax receiver is at a certain position in the list
function isSecondaryReceiver(address _receiver) external view returns (bool _isSecondaryReceiver);
Parameters
Name | Type | Description |
---|---|---|
_receiver | address | Tax receiver address to check |
Returns
Name | Type | Description |
---|---|---|
_isSecondaryReceiver | bool | Whether the tax receiver for at least one collateral type |
secondaryReceiversList
Get the list of all secondary tax receivers
function secondaryReceiversList() external view returns (address[] memory _secondaryReceiversList);
secondaryReceiverRevenueSourcesList
Get the list of all collateral types for which a specific address is a secondary tax receiver
function secondaryReceiverRevenueSourcesList(address _secondaryReceiver)
external
view
returns (bytes32[] memory _secondaryReceiverRevenueSourcesList);
Parameters
Name | Type | Description |
---|---|---|
_secondaryReceiver | address | Secondary tax receiver address to check |
Returns
Name | Type | Description |
---|---|---|
_secondaryReceiverRevenueSourcesList | bytes32[] | List of collateral types for which the address is a secondary tax receiver |
taxMany
Collect tax from multiple collateral types at once
function taxMany(uint256 _start, uint256 _end) external;
Parameters
Name | Type | Description |
---|---|---|
_start | uint256 | Index in collateralList from which to start looping and calculating the tax outcome |
_end | uint256 | Index in collateralList at which we stop looping and calculating the tax outcome |
taxSingle
Collect tax from a single collateral type
function taxSingle(bytes32 _cType) external returns (uint256 _latestAccumulatedRate);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Collateral type to tax |
Returns
Name | Type | Description |
---|---|---|
_latestAccumulatedRate | uint256 | The newly accumulated rate after taxation |
Events
SetPrimaryReceiver
Emitted when a new primary tax receiver is set
event SetPrimaryReceiver(bytes32 indexed _cType, address indexed _receiver);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_receiver | address | Address of the new primary tax receiver |
SetSecondaryReceiver
Emitted when a new secondary tax receiver is set
(taxPercentage, canTakeBackTax) = (0, false) means that the receiver is removed
event SetSecondaryReceiver(
bytes32 indexed _cType, address indexed _receiver, uint256 _taxPercentage, bool _canTakeBackTax
);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_receiver | address | Address of the new secondary tax receiver |
_taxPercentage | uint256 | Percentage of SF allocated to this receiver |
_canTakeBackTax | bool | Whether this receiver can accept a negative rate (taking SF from it) |
CollectTax
Emitted once when a collateral type taxation is processed
event CollectTax(bytes32 indexed _cType, uint256 _latestAccumulatedRate, int256 _deltaRate);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_latestAccumulatedRate | uint256 | The newly accumulated rate |
_deltaRate | int256 | The delta between the new and the last accumulated rates |
DistributeTax
Emitted when a collateral type taxation is distributed (one event per receiver)
SF can be negative if the receiver can take back tax
event DistributeTax(bytes32 indexed _cType, address indexed _target, int256 _taxCut);
Parameters
Name | Type | Description |
---|---|---|
_cType | bytes32 | Bytes32 representation of the collateral type |
_target | address | Address of the tax receiver |
_taxCut | int256 | Amount of SF collected for this receiver |
Errors
TaxCollector_InvalidIndexes
Throws when inputting an invalid index for the collateral type list
error TaxCollector_InvalidIndexes();
TaxCollector_NullAccount
Throws when trying to add a null address as a tax receiver
error TaxCollector_NullAccount();
TaxCollector_PrimaryReceiverCannotBeSecondary
Throws when trying to add a tax receiver that is already the primary receiver
error TaxCollector_PrimaryReceiverCannotBeSecondary();
TaxCollector_CollateralTypeNotInitialized
Throws when trying to modify parameters for a collateral type that is not initialized
error TaxCollector_CollateralTypeNotInitialized();
TaxCollector_ExceedsMaxReceiverLimit
Throws when trying to add a tax receiver that would surpass the max number of receivers
error TaxCollector_ExceedsMaxReceiverLimit();
TaxCollector_NullSF
Throws when trying to collect tax for a receiver with null tax percentage
error TaxCollector_NullSF();
TaxCollector_TaxCutExceedsHundred
Throws when trying to add a receiver such that the total tax percentage would surpass 100%
error TaxCollector_TaxCutExceedsHundred();
TaxCollector_TaxCutTooBig
Throws when trying to modify a receiver such that the total tax percentage would surpass 100%
error TaxCollector_TaxCutTooBig();
Structs
TaxCollectorParams
struct TaxCollectorParams {
address primaryTaxReceiver;
uint256 globalStabilityFee;
uint256 maxStabilityFeeRange;
uint256 maxSecondaryReceivers;
}
TaxCollectorCollateralParams
struct TaxCollectorCollateralParams {
uint256 stabilityFee;
}
TaxCollectorCollateralData
struct TaxCollectorCollateralData {
uint256 nextStabilityFee;
uint256 updateTime;
uint256 secondaryReceiverAllotedTax;
}
TaxReceiver
struct TaxReceiver {
address receiver;
bool canTakeBackTax;
uint256 taxPercentage;
}