Geminon Protocol

Decentralized Forex

The stablecoin exchange (ForDEX) module is integrated into the minting contract (SC Minter) and can be considered an extension of its functionality. Its function is to allow the exchange of any pair of Geminon stablecoins without price slippage.
The stablecoin exchange systems (stableswaps) that have implemented most protocols to date are based on liquidity pools. The system proposed by Geminon is completely different, since it does not use liquidity but is purely algorithmic: it takes advantage of the native capacity of the protocol to mint and burn coins, this being the reason why the Geminon Stableswap module has been integrated into the SC Minter contract. The system proposed by Geminon has several advantages over systems based on liquidity pools:
  • It does not depend on the presence of external actors to function. An LP-based stableswap requires liquidity providers and arbitrageurs to keep the price of each traded pair close to its reference value, while our system works fully independently.
  • Better results in operations for users: the inefficiencies inherent in the existence of intermediaries (LPs and arbitrageurs) who obtain their benefit precisely from sliding prices are eliminated, at the expense of users. Our system always provides an exact price on exchanges regardless of the amount of the operation (infinite liquidity).
  • The implementation of the algorithmic solution is noticeably simpler, and therefore less prone to vulnerabilities.

Oracle front running attacks

Geminon stablecoins use Chainlink oracles to obtain real-time prices against the dollar of the fiat currency that they replicate. However, due to the intrinsic characteristics of blockchain technology, there is a delay (lag) between the moment the price is observed in the market and the moment the data is written to the blockchain. This delay is the sum of the time it takes for the Chainlink network to reach consensus on the value of the price data, the time it takes for Chainlink to send the transaction to the destination blockchain with the new value, and the time that the network takes to process the transaction and include it in the next block. The total time that this process lasts can be more than a minute.
Due to the significant delay with which the oracle reflects on-chain prices, it is theoretically possible for an attacker to make a risk-free profit by trading an on-chain asset that is priced using this oracle, since it would only be necessary to observe the price of the asset in the real world to know in advance how its price will change on the blockchain in the immediate future (temporary arbitrage). The attack will only be economically viable if the cost of the operation (gas + commissions + slippage) is less than the expected price movement. Since our system does not slip, the attack threshold is lower and the amount is unlimited, so a security system has been designed to make this type of attack unfeasible.

Probability of the attack

The Forex market is one of the least volatile in the world, especially when it comes to major pairs like EUR/USD, whose one-hour volatility rarely exceeds 0.3%. This low volatility means that the base commission usually charged by a decentralized exchange on the blockchain is higher than the expected profit of almost any intraday operation in the foreign exchange market, so the probability of this type of attack is generally quite low. , since it would also be unprofitable if successful. However, since the described attack is theoretically possible if there is enough volatility in the market, it is necessary to implement measures to ensure that it cannot be carried out under any circumstances.

Stableswap Guard

The StableswapGuard contract implements a security system based on an internal price oracle that tracks global stablecoin positions taken in the last 5 minutes on both SC Minter and Stableswap. Every time an operation is carried out in stable currency, the contract checks if contrary positions have been opened in the last 5 minutes that produce an abnormal profit, and if so, it applies an extra security fee to the operation equal to the volatility of the period. between the opening and closing of the position, eliminating its possible profit.
Scalping on low timeframes using the Geminon Stableswap module is not recommended. When operating, always check the amount of the commission applied, and if it is higher than normal, wait a few minutes to carry out your operation.

Internal oracle algorithm

The StableSwapGuard algorithm is similar to that used for the internal GLP oracle and for the Geminon token mint limiter. It is based on an adaptive exponential moving average whose parameter varies depending on the relationship between the volume of the current operation and the total volume accumulated in the last 5 minutes:
Δt=tntn1\Delta t = t_n - t_{n-1}
Vn={     vnif Δt>300Vn1+vnif Δt300V_n = \begin{cases} \ \ \ \ \ v_n &\text{if } \Delta t > 300 \\ V_{n-1}+v_n &\text{if } \Delta t \le 300 \end{cases}
wn={     1if Δt>300vnvn+Vnif Δt300w_n = \begin{cases} \ \ \ \ \ 1 &\text{if } \Delta t > 300 \\ \dfrac {v_n}{v_n+V_n} &\text{if } \Delta t \le 300 \end{cases}
mn=wnpn+(1wn)mn1m_n = w_n p_n + (1-w_n) m_{n-1}
Δt\Delta t
is the time interval in seconds since the last trade,
is the volume (in US dollars) of the current trade, and
is the current price of the stablecoin (in US dollars).
The StableSwapGuard contract stores the previous amount for each stablecoin by separating buy trades and sell trades. To calculate the safety fee, the difference between the current price and the average value of the operations of the opposite sign is compared, and if said value is higher than the base fee, the safety fee is applied to the operation.