Fees

How fees are calculated

FeeUtils.sol

FeeUtils.sol on Github

getFeeBasisPoints

function getFeeBasisPoints(
        uint256 currentVaultAmount,
        uint256 targetVaultAmount,
        int256 _tokenTransferAmount,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints
    ) public pure returns (uint256)

Calculates the fee percentage based on whether or not the deposit or withdrawal brings the given token closer to its target Balance, determined by its set weight. This is a pure function, not altering any stored values.

In order to tell if a token transfer will improve the token’s balance in relation to the entire Index, the initial difference between the currentVaultAmount and the targetVaultAmount and difference after the transfer are calculated. If the difference after is less than the initial difference, then the transfer helps the Index weightings, and the transfer will see a rebate, which lowers the fee. The larger the initial difference, the higher the rebate. If the rebate brings the fee lower than the minimumFee, the final fee becomes the minimumFee.

If the difference after is not less than the initial difference, and the average difference (initialDiff + nextDiff) / 2 is greater than the targetVaultAmount, then the transfer generates the maximum tax, which is added to _feeBasisPoints to increase the final fee percentage.

If the difference after is not less than the initial difference, and the average difference (initialDiff + nextDiff) / 2 is less than or equal to the targetVaultAmount, then the _taxBasisPoints is multiplied by the averageDiff, then divided by the targetVaultAmount to obtain the tax. The higher the averageDiff, the higher the tax.

In all cases, the final fee basis points (percentage) is returned to the deposit(), withdraw(), or calculateFee() function.

Parameters:

Returns:

Last updated