Fees

How fees are calculated

FeeUtils.sol

getFeeBasisPoints

function getFeeBasisPoints(
        uint256 currentVaultAmount,
        uint256 targetVaultAmount,
        int256 _tokenTransferAmount,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints,
        uint256 _minFee
    ) 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.

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 _minFee, the final fee becomes the _minFee.

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 arrive at 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:

Name
Type
Description

_currentVaultAmount

uint256

The amount of tokens currently deposited in a token’s Bank

_targetVaultAmount

uint256

The amount of tokens in the Bank that when divided by the total Index’s value would perfectly match the token’s set weight

_tokenTransferAmount

int256

The amount of tokens being transferred

_feeBasisPoints

uint256

The base fee percentage set by the owner

_taxBasisPoints

uint256

The base tax percentage set by the owner

_minFee

uint256

The minimum deposit/withdrawal fee set by the owner

Returns:

Name
Type
Description

unnamed

uint256

The final fee calculation for the token transfer

Last updated