ITaxCollector

Git Source

Inherits: IAuthorizable, IModifiable, IModifiablePerCollateral

Functions

params

Getter for the contract parameters struct

function params() external view returns (TaxCollectorParams memory _taxCollectorParams);

Returns

NameTypeDescription
_taxCollectorParamsTaxCollectorParamsTax 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

NameTypeDescription
_primaryTaxReceiveraddressPrimary tax receiver address
_globalStabilityFeeuint256Global stability fee [ray]
_maxStabilityFeeRangeuint256Max stability fee range [ray]
_maxSecondaryReceiversuint256Max number of secondary tax receivers

cParams

Getter for the collateral parameters struct

function cParams(bytes32 _cType) external view returns (TaxCollectorCollateralParams memory _taxCollectorCParams);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_taxCollectorCParamsTaxCollectorCollateralParamsTax collector collateral parameters struct

_cParams

Getter for the unpacked collateral parameters struct

function _cParams(bytes32 _cType) external view returns (uint256 _stabilityFee);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_stabilityFeeuint256Stability fee [ray]

cData

Getter for the collateral data struct

function cData(bytes32 _cType) external view returns (TaxCollectorCollateralData memory _taxCollectorCData);

Parameters

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_taxCollectorCDataTaxCollectorCollateralDataTax 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

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

Returns

NameTypeDescription
_nextStabilityFeeuint256Per second borrow rate to be applied at the next taxation [ray]
_updateTimeuint256When Stability Fee was last collected
_secondaryReceiverAllotedTaxuint256Percentage 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

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_receiveraddressTax receiver address to check

Returns

NameTypeDescription
_secondaryTaxReceiverTaxReceiverTax 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

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_receiveraddressTax receiver address to check

Returns

NameTypeDescription
_secondaryReceiveraddressSecondary tax receiver address
_canTakeBackTaxboolWhether this receiver can accept a negative rate (taking SF from it)
_taxPercentageuint256Percentage 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

NameTypeDescription
_startuint256Index of the first collateral type to check
_enduint256Index of the last collateral type to check

Returns

NameTypeDescription
_okboolWhether 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

NameTypeDescription
_startuint256Index in collateralList from which to start looping and calculating the tax outcome
_enduint256Index in collateralList at which we stop looping and calculating the tax outcome

Returns

NameTypeDescription
_okboolWhether the tax outcome can be computed
_radint256The 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

NameTypeDescription
_cTypebytes32Collateral type to compute the taxation outcome for

Returns

NameTypeDescription
_newlyAccumulatedRateuint256The newly accumulated rate
_deltaRateint256The 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

NameTypeDescription
_receiveraddressTax receiver address to check

Returns

NameTypeDescription
_isSecondaryReceiverboolWhether 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

NameTypeDescription
_secondaryReceiveraddressSecondary tax receiver address to check

Returns

NameTypeDescription
_secondaryReceiverRevenueSourcesListbytes32[]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

NameTypeDescription
_startuint256Index in collateralList from which to start looping and calculating the tax outcome
_enduint256Index 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

NameTypeDescription
_cTypebytes32Collateral type to tax

Returns

NameTypeDescription
_latestAccumulatedRateuint256The 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

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_receiveraddressAddress 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

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_receiveraddressAddress of the new secondary tax receiver
_taxPercentageuint256Percentage of SF allocated to this receiver
_canTakeBackTaxboolWhether 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

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_latestAccumulatedRateuint256The newly accumulated rate
_deltaRateint256The 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

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type
_targetaddressAddress of the tax receiver
_taxCutint256Amount 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;
}