Aphelion DEX Fees and Committed Distributions Demystified

Aphelion DEX
7 min readAug 25, 2018

--

With our latest desktop wallet version 2.4.3 and DEX update we integrated what will likely be very close to the actual fees users of the mainnet Aphelion DEX will see, as well as, the actual distribution model for fee sharing in the Aphelion Commit/Compound/Claim feature and key differentiator. We are very proud at how the model turned out, there is nothing like it anywhere and it includes incentives for higher volume trading and holding Aphelion. DEX is getting developed into the mobile and web wallet as we speak and we’ll be moving quickly into cross chain (storage first then trading).

The experience of p2p trading directly in the wallet with the unique fee structure and distribution model is an elegant answer to alternative trading options and it must be experienced to truly understand its utility, ease of use, not to mention the savings and fee sharing that go along with it all. We’ve always wanted to build something special and unique that benefits the users and community first and we are very proud of where we’ve landed. We invite everyone to experience the Aphelion difference for yourself.

Its important to point out this is still on testnet so in order to see the DEX and experience the commit features users will have to toggle to testnet in the wallet settings.

Its also important to note that trading volume is very low since the DEX is still on testnet so the distributions and fees collected will be small in the interim. Because the fees distributed are directly related to the fees collected, the more trading happens to more fees get distributed.

We’ve also come up with a great way to incentive higher volume trading that we’ll share in the example and chart. In this article we’ll breakdown the model, share our algorithm and give an example and chart to illustrate the process.

Aphelion Fees and Fee Distribution

Fees from trades are held in the the Aphelion trading contract and can be claimed by Aphelion holders that have committed their Aphelion balance to take part in fee sharing. On each match, the taker pays the match fee based on the market settings. A percentage of the match fee adds to a total fees collected contract storage value to be claimed by people that commit funds to the contract, the remaining percentage of the fee goes to the contract owner balance.

Aphelion Fees Dymystified

We have been finalizing our algorithm for fees per match and are now ready to explain the fee that will be assessed per match. Each market on Aphelion has a minimum trade size in the quote asset. For a trade to be placed the contract enforces that it must be greater than the minimum trade size. There is a base fee per match that is will be charged when making a trade of the minimum trade size.

BaseFee = Amount charged for a match of the minimum trade size

In order to calculate the fee multiplier for the base fee we first need to calculate the ratio of the the trade size compared to the minimum trade size, which we will refer to as the trade size multiplier.

TradeSizeMultiplier = QuoteAssetUnits / MinimumTradeSize

On a traditional exchange the fees for an order grow linearly with order size. On Aphelion’s exchange we will employ a logarithmic equation so that fees will grow at a slower rate as the order size increases

FeeMultiplier = 1 + LogBase2(TradeSizeMulitiplier)

Fee = BaseFee * FeeMultiplier

All in one formula:

Fee = BaseFee * LogBase2(QuoteAssetUnits / MinimumTradeSize)

Where a traditional exchange may set a fixed percentage fee for takes of 0.25%, on the Aphelion exchange we plan to set our base fee such that our worst case fee price would be the same as that of a traditional exchange, and our best or usual case would be significantly less expensive. An example will follow to demonstrate.

Example Aphelion Fees vs Traditional Fee Structure

Consider a minimum trade size of 1 GAS in a NEO-GAS market where NEO is the base asset and GAS is the quote asset. We will assume a GAS price of $5 (USD) for our example and an APH price of $0.20 (USD). A traditional exchange may set a fixed percentage fee for takers of 0.25%. If we set our base fee price to be the Aphelion equivalent of 0.25% of $5 (USD price of 1 GAS) = $0.0125, that would result in our base fee price being 0.0625 APH ($0.0125 / $0.20 = .0625 APH).

Now we can graph the Fees for a typical trade in such a market on the Aphelion exchange compared to the fees on a traditional exchange. To be able to make the graph we need to assume the approximate amount of GAS that will be traded per match. The worst case would be 1 GAS per match since 1 GAS is the minimum trade size and in that case our price would be the same as a traditional exchange. We will also show in our example graph the price if the average gas per match were 2, 8, and 20 respectively.

You’ll notice, that because of the base fee and trade size multiplier that fees shrink with higher volume trading. This lends incentive to volume and market making on the DEX. The Aphelion DEX will be distinctly less expensive than any other exchange centralized or decentralized. And if the unique fee structure isn’t enough, the distribution commit/claim/compound features gives additional value for users.

Here is a breakdown of how that works:

Commit, Claim, and Compound

1 Commit APH to gain interest from Fees

The Aphelion Wallet will facilitate committing APH to gain a portion of trading fees.

1.1 Fee Distribution

80% of Fees shall be awarded back to Aphelion holders that commit APH tokens to the contract.

1.1.2 Calculation of Fee Distribution

The contract will keep track of the total accumulated Aphelion Fees due to committers in contract storage (referred to as totalFeesCollected). Each time a trade matches and completes this value will increase by 80% of the fee collected. 20% of the fee collected will be added to the contract owner's balance.

When a user commits fees to the contract, a snapshot of the total fees collected by the contract will be taken to be used to determine the total fees collected during the time of the user’s commitment. The committer’s weight is calculated as their committed balance multiplied by the fees collected since they committed into the contract. Consider a graph where the x axis is the total fees collected by the contract and the y axis is total units currently committed by users. The area under the graph during the time the of the commitment will determine the contract weight during the commitment. The fees due to the committer shall be the total fees collected during the time of the user’s commitment multiplied by the committer’s weight divided by the contract weight during the commitment.

1.2.1 Updating the total fee-units for determining contract weight

Considering again a graph where the x axis is the total fees collected by the contract and the y axis is total units currently committed by users. It is necessary to keep a total running area under the graph to determine the contract weights during commitments (referred to as totalFeeUnits). This weight shall be updated first to account for newly collected fees each time a commit or claim operation is performed. The calculation for determining updating the totalFeeUnits is:

totalFeeUnits = totalFeeUnits + totalUnitsCommitted * (totalFeesCollected - lastAppliedFeeSnapshot)

1.2.2 Commit: (New Deposit)

Upon APH being deposited as an investment, a snapshot of the totalFeesCollected will be recorded in storage (referred to as totalFeesCollectedSnapshot) along with the APH balance (referred to as unitsCommitted) held by the depositing address and a snapshot of the current contract weight (referred to as totalFeeUnitsSnapshot). The unitsCommitted will be added to a storage value keeping track of the total invested balances from all investors (referred to as totalInvestedBalance).

1.2.3 Claim: transfers committed APH and Fees back to user’s wallet Address

When fees are claimed the following formulas will be applied:

feesCollectedDuringCommitment = totalFeesCollected - totalFeesCollectedSnapshot

feeUnitsDuringCommitment = totalFeeUnits - totalFeeUnitsSnapshot

userFeeUnitWeight = unitsCommitted * feesCollectedDuringCommitment

feesToRedeem = feesCollectedDuringCommitment * userFeeUnitWeight / feeUnitsDuringCommitment

This feesToRedeem will be added to the unitsCommitted and the storage for the user's committment will be cleared at the time the claim is processed by the NeoVM.

1.2.4 Compound

In order to take advantage of compounding interest, and to ensure minimal dilution due to new investors, the compound operation can be performed. Compound can be called by the owner of the wallet being compounded, or by the contract owner or manager on their behalf. It will have a cool down timer of 4800 blocks (~20 hours with 15 sec blocks).

The compound operation shall add any fees due back to the unitsCommitted and reset the totalFeesCollectedSnapshot and totalFeeUnitsSnapshot. It will not initiate any actual nep5 transfer of a user’s contribution back to their wallet address. Calling compound does not reset the cool down timer for being able to collect fees after commit.

I hope this helped to dispel any confusion on the unique fee structure and distribution model. We are excited to switch live and bring our groundbreaking model mainstream and finally allow peer to peer wallet based trading with minimal fees and incentives for volume trading and committing Aphelion.

--

--