As explained in the Overview, the DMEX token contract automatically buys back tokens from token holders. Here we will discuss in detail the buyback process.
In DMEX all trading fees and funding fees are accumulated on the FeeAccount, which is an Ethereum address. After each trade a percentage of the trade value is transferred to the fee account. This happens in real-time straight on the smart contract (the fees are deposited to the FeeAccount during each trade).
The fee account is an Ethereum account that collects the trading fees on the DMEX smart contract. To collect the fees from the Exchange, the fee account must request the withdrawal of funds (as would any user).
The DMEX Token contract implements the DMEX Exchange interface and is able to access the withdraw function on the exchange contract.
To collect the fees, the Token Contract calls the Exchange contract and requests a withdrawal of the full balance from the fee account. Funds arrive into the Token Contract and are split into 2 shares:
Operational Share (61.8%)
Buyback Share (38.2%)
The operational share is immediately sent to the operational wallet defined in the token contract. The Buyback share is used to buy available tokens on the DMEX token Uniswap exchange.
On the Ethereum blockchain, no transaction is possible without an external trigger, therefore we cannot schedule the buyback to happen periodically. However, this is not an issue, because:
We need the operational share (61.8%) to cover the running costs of the exchange. The only way to collect the operational share is by implicitly initiating a buyback.
The extractFeesFromDmex() method on the token contract is public and can be triggered by anyone, therefore if we don't trigger it, anyone can.