Automated Market Maker

Every liquidity pool is based on an automatic market making (AMM) algorithm that determines the prices and amounts of tokens in each trade. Geminon's GLPs use a proprietary algorithm derived from the constant product AMM that gives them the liquidity creation capabilities of an LBP.

Constant product AMM

Practically all of the decentralized exchange (DEX) protocols that exist today use the so-called constant product formula for their liquidity pools:

Generalized constant product AMM

From the previous equations it is derived that the quote or relative price of one token based on another in the pool depends exclusively on the balances and relative weights of both tokens in the pool:

Geminon AMM

The AMM algorithm developed for the Geminon GLPs also alters the value of the pool invariant, although it employs a completely different mechanism. The main differences are:

  • The variation of the liquidity constant is completely automatic in GLP: it is not possible to manually alter the weights of the tokens in the pool, and therefore the prices.

  • The parameterization of liquidity in a GLP varies depending on the operations carried out, not depending on time as it happens in LBPs.

  • The GLP algorithm does not vary the weights of the tokens in the pool, but rather the balance of the GEX token.

Algorithm description

The Geminon AMM works in two steps:

  1. The amount of the output token is calculated using the constant product AMM formula with the liquidity available at that moment in the pool, that is, in this step the LPG behaves exactly the same as a Uniswap-type liquidity pool.

  2. In the second step, the balance of the GEX token in the pool is modified by minting or burning tokens. The variation of the supply of the GEX token is calculated from the number of tokens that the user has received or delivered to the pool, depending on the operation carried out.

To help reduce trade slippage, which negatively impacts user output, the pool automatically splits the input amount in half and runs the above steps twice, so that on the second iteration the user benefits from the increase in liquidity that he himself has generated. This mechanism is especially effective when the liquidity of the pool is very low.

Mint GEX tokens (mintSwap)

Finally, the commissions for minting the protocol are deducted from the number of GEX tokens to be sent to the user.

3. The final price of the GEX token in the pool after the transaction is lower than the price that would be obtained in a pool of pure constant product. It is easy to intuitively see that by increasing the balance of GEX tokens in the pool, the relative price of this token against the other token should decrease:

The irreversibility of the operations presents important advantages for the security of the Geminon protocol, since it implies that flash loan attacks cannot be carried out on a GLP: since the amount lent cannot be repaid in its entirety, the transaction will revert. In general, any attack that involves price manipulation in a GLP using large transactions that must be undone in a short period of time, will mean a financial loss for the attacker in favor of the protocol.

Redeem GEX tokens (redeemSwap)

And the new balances that determine the liquidity product of the pool:

Price curve

Last updated