Cover photo

How Tren Finance uses Time-Weighted Automated Market Maker (TWAMM)

Tren Finance features Time-Weighted Automated Market Maker (TWAMM), a concept introduced by researchers at Paradigm. This novel automated market maker (AMM) addresses the challenge of executing large orders with minimal slippage and cost-efficient gas fees without adversely impacting market prices. TWAMM achieves this objective by autonomously breaking down large orders into smaller ones, enabling a gradual and smooth execution over time.

This article will explain the concept and mention how Tren Finance implements TWAMM.

To understand what TWAMM is and its method of executing trades, we need to look at it precursors in both traditional finance and decentralized finance.

Time-Weighted Average Price (TWAP)

TWAP is the average price of an asset over a specified time. It is the traditional finance or off-chain equivalent of TWAMM and it is considered the most basic type of algorithmic trade.

A TWAP strategy is used to execute trades on large transactions in a way to minimizes the impact of the large order on the market in terms of price improvement. This strategy is employed to ensure that the trades contribute to maintaining the market price in proximity to its actual value. In essence, TWAP orders involve the systematic execution of trades throughout a predetermined period. For example, a TWAP order to buy $50 million dollars worth of stock over 6 hours would be executed at a price close to the time-weighted average price of that particular stock over that period.

TWAP orders are usually carried out by brokers who have the infrastructure to minimize or eliminate the operational difficulty of many small trades. They also have a direct connection to the market and pay a reduced transaction fee.

AMM

An AMM is a smart contract protocol that enables decentralized exchanges to carry out non-custodial and autonomous trading. It is the onchain precursor of TWAMM and was made popular by the likes of Uniswap and Curve. Before the advent of AMMs, centralized exchange platforms, also referred to as market makers used a classical order book mechanism to match trading orders correctly. An order book consists of different offers from buyers and sellers for an asset. It lists the quantities and prices that traders are willing to buy and sell for and gives users asset price information.

Unfortunately, they suffer from liquidity issues, which is when a seller cannot be successfully matched with a buyer — usually due to price differences. When liquidity is low there is a risk of slippage. Therefore, there is a need to conduct transactions instantaneously to reduce slippage risk.

How is an AMM different?

An AMM replaces the conventional matching system and order books with an automated liquidity pool which is controlled by the constant product formula. This allows anyone to provide liquidity. In return, liquidity providers will receive minted derivative tokens that represent the number of tokens contributed and can be used to redeem their supplied assets. They are also given a percentage fee that matches their stake in the liquidity pool.

For any exchange operation, two liquidity pools are needed. To make sure the ratio of the assets in the liquidity pools remains as balanced as possible to eliminate discrepancies in the pricing of pooled assets, the constant product formula comes into play:

X * Y = k

X = the quantity of token A in the liquidity pool

Y = the quantity of token B in the liquidity pool

K = constant

Executing large orders on AMM is expensive and requires manual order splitting where the orders are split into several smaller ones (and usually sent to several AMMs). However, these smaller orders are usually still large to an extent and can be affected by limited liquidity on the AMMs or impaired by price impact. Price impact is the difference between the current market price and the expected price of an asset, a correlation between an incoming order and the subsequent price change. It usually occurs when a trader is swapping a large volume of assets and it is a function of the trade size relative to the liquidity pool size and it is the reason why a solution like TWAMM is needed.

Time-Weighted Automated Market Maker (TWAMM)

TWAMM resolves this dilemma by breaking large orders into many infinitely small ones to ensure perfectly smooth execution over time. Interestingly, using a special mathematical relationship with its embedded AMM, it can drastically reduce gas costs across these small orders. Also, since it processes trades at the start of each block, it is less susceptible to MEV attacks.

The primary goal of the TWAMM is to execute its long-term orders smoothly over time so that they are executed for close to the prevailing time-weighted average price. This is similar to the goal of TWAP. As the size of the trade is broken down into small ones, price movement on the AMM becomes intensely reduced and becomes less visible.

In most cases, MEV bots play a significant role in executing Market-to-Market arbitrage. These bots continually monitor liquidity pools for opportunities to capitalize on price discrepancies. This automated process helps in swiftly correcting any deviations from the desired price peg.

How does Tren Finance use the TWAMM?

Collateral Based Interest

Existing lending and CDP protocols rely on interest rates to encourage users to borrow during periods of low rates and repay their loans when rates are high. However, this model faces challenges when applied to long-tail assets that inherently lack abundant liquidity. Dealing with the concern of collateral liquidation, it becomes impractical to raise interest rates during high utilization. To prevent unnecessary compounding of principal interest, we have implemented collateral-based interest, wherein the collateral deposited in Tren is liquidated every block.

The introduction of the TWAMM becomes important in this case. Previous attempts at selling parts of collateral, such as Curve’s LLAMMA soft liquidations, fall short, especially when dealing with the assets offered by Tren Finance. Instead, the approach adopted is to liquidate the collateral in every block. While attempting this on a regular AMM would expose the process to MEV attacks and incur considerable gas fees, the TWAMM enables gas-efficient liquidation with zero risk of MEV attacks, as orders are naturally placed at the forefront of the queue.

Benefits include assets directly contributing to the DAO treasury, enhancing the reserve factor, without waiting for the loan to be fully repaid. Furthermore, high interest rates set by liquidation-based interest models serve to protect against bad debt rather than exacerbating the issue.

Buybacks

Tren Finance, similar to Frax and MakerDAO, leverages the TWAMM to consistently repurchase the TREN token using fees generated in each pool and profits from the liquidation bot. By employing the TWAMM for the TREN token buyback, the platform mitigates the risk of MEV bots front-running the transaction. Additionally, this approach injects buying pressure into the TREN token every block through actual revenue.

Conclusion

While TWAP strategies have traditionally aimed at minimizing market impact, and AMMs revolutionized trading mechanisms with automated liquidity pools, TWAMM emerges as the optimal solution, seamlessly blending efficiency and cost-effectiveness. The implementation of TWAMM in Tren Finance is strategically employed in two critical aspects: Collateral-Based Interest and Buybacks. The collateral-based interest model leverages TWAMM to execute liquidations efficiently in every block, contributing to the DAO treasury and fortifying the reserve factor. Meanwhile, TWAMM facilitates buybacks for the TREN token, ensuring a consistent injection of buying pressure and mitigating the risk of MEV bots front-running transactions.

In essence, Tren Finance not only adopts the TWAMM concept but strategically integrates it into essential aspects of its protocol, demonstrating a forward-thinking approach to decentralized finance challenges. As Tren Finance continues to develop, the implementation of TWAMM by the platform will also be improved to enhance efficiency, reduce gas costs, and fortify the resilience of the ecosystem.


About Tren Finance

Tren Finance is a CDP protocol designed to provide liquidity for various types of assets. Our team comprises of core contributors from various successful DeFi projects, boasting a combined TVL surpassing $1 billion. Drawing insights from our experiences at Venom, MakerDAO, Ajna, Parity Technologies, Parallel Finance, Casper Labs, and more, we bring a wealth of knowledge to the table.

We are excited to unveil numerous use cases for users interested in exploring leveraged staking, restaking and farming opportunities.

Websiteã…£X (Twitter)ã…£Telegramã…£Discordã…£Blog

Loading...
highlight
Collect this post to permanently own it.
Tren Finance logo
Subscribe to Tren Finance and never miss a post.
#defi#cdp