Before you go, check out these stories!

Hackernoon logoAPY.Finance: What's Under The Hood? by@ashkykharoo

APY.Finance: What's Under The Hood?

Author profile picture


Engineer with love for technology, especially those that solve real-user problems.

Technological developments and their rapid adoption make this the right time for a new decentralized financial system to emerge. So far, the products with more traction have been protocols offering lending/borrowing of crypto assets.

For example, with BTC as collateral, borrowers can get USDC loans and lenders get the interest fee. Today these products are already seeing real usage, with a total of USD volumes in hundreds of millions. 

With the rapid increase in the number of DeFi protocols and the fact that interest rate changes at a block-by-block pace (~ 15 seconds), it is difficult for yield farmers to optimize their financial returns. To do so they should continuously monitor and manually move their funds from a protocol to another.

With APY.Finance, users can seamlessly yield the best available rate among different DeFi protocols (lending, liquidity pools) without a need to continuously monitor or manually transfer the funds.

It's all automatic. You don’t have to give your funds to any asset manager or rely on a centralized system. It is completely non-custodial and has a decentralized rebalancing mechanism.

Approach to making pool non-custodian:

DeFi protocols employ an approach similar to traditional mutual funds that allow DeFi protocols to be non-custodial. When users deposit their funds to DeFi protocols (e.g. lending), they receive interest-bearing tokens in exchange.

These tokens accrue interest every Ethereum block (~15 seconds) and can be transferred to anyone. Whoever holds these interest-bearing tokens can redeem them for the principal plus interest at any time. The most common interest-bearing tokens are Compound cToken (e.g. cDAI, cETH) and Aave’s aTokens (e.g. aDAI, aETH).

Approach to rebalance:

Rebalance is a process of moving funds from one strategy to another to maximize gains. 

Let's consider a user who holds DAI and puts his funds in the Compound pool. Now meanwhile in other protocols, let's say Fulcrum’s DAI pool interest rates have increased (more than Compound). To tap on the opportunity, the user moves his funds to the Fulcrum pool.

Looks simple, Right?. In reality, users have to go through the pain of continuously monitoring and evaluating changes in interest rates, and manually manage multiple transactions. The situation would look as follows:

  1. Once, a user sends DAI to compound pool, s/he receives proof of ownership token (ex, cDAI from Compound), 
  2. Watches tracking tools,
  3. Analyzes rebalance return opportunity - transaction fee, potential gains, time etc.
  4. If any benefit with rebalance, they proceed to exchange cDAI to DAI first, then move DAI to Fulcrum pool and get their proof of ownership token (iDAI).

With APY.Finance, users get the best interest rate on their DAI automatically. The platform’s monitoring system called robo advisor automatically triggers a rebalance if it spots a better-performing risk-adjusted pool on behalf of the users, saving time and gas fee. Platform also contains an additional logic that is a minimum % threshold to reduce false-positive signals.

Threshold takes into account:

  1. the transaction costs (gas fee) associated with changing the strategy employed;
  2. the potential gain in yield should the new strategy be deployed; and
  3. how long it will take to recoup the transaction fees for the change.

How does the platform save gas fee?

Instead of multiple transactions and incur $3-5 gas fee per transaction, all users deposits are collected in a pool. As the value in the pool gets accumulated, the APY platform routes the entire fund in a single transaction to the respective strategy. This way users save gas fees in excess of 99% making yield farming accessible for all investor kinds (big or small).

How is the process automated?

Do users have to rely on a centralized automated system in order to always have the best available rate on the market? Short answer: No.

Ethereum users often get the false impression that some decentralized applications function autonomously when it’s actually the work of organizations running bots in the background which creates the illusion of automation. 

An example of this is the Maker system, in which you can lock ETH as collateral to take out a loan in DAI. If the ETH collateral decreases in equivalent USD value below a certain threshold, your position will be liquidated and your outstanding debt thereby paid off. 

But does the liquidation really happen automatically? No, this liquidation process is conducted by bots called “Maker Keepers.” These bots are run by competing individuals and organizations that are financially incentivized to do so. For each successful liquidation, these bot owners can expect a nice payoff. Without the people behind the bots, bad debt positions would never be liquidated on-time, and the entire Maker system would collapse.

Imagine a scenario without these bots in which the users have to monitor debt positions, exchange rates, and manually end liquidation - 24/7 to have optimal yield returns. In such a scenario, DeFi would not really be all that great or usable by anyone if there weren’t any bots around.

Similar to Maker Keeper, APY.Finance leverages on the wide network of Gelato’s Keepers. Writing bots (automation task) to keep up with every new DeFi protocol is a time-consuming and cumbersome challenge. Gelato provides these bots that work with every smart contract on Ethereum so that developers don't have to set up their own relay infrastructure.

Using Gelato, APY.Finance gets access to Ethereum bots - Gelato’s automated smart contracts that will execute transactions on behalf of users under the conditions specified by dApp developers. For example, in the case of APY.Finance, automatically rebalance funds between multiple lending protocols to always get the highest yield. 

And here is the sweet spot: users can propose new strategies using simple pick and drops tools. You don't have to write a single line of code. True to DeFi spirit, users still have full custody over their funds and their smart contracts are open sourced and audited.

How users can propose new strategies to APY.Finance library: 

Community (or users) can propose new strategies by using simple drag and drop tools to insert shapes (like pieces of lego) and arrange them in order to visualize the flow. At the back-end, each lego (shape) has a piece of code. Once flow is complete and set by the user, the tool packages all the legos into one complete smart contract.

As soon as the flow is complete, it goes for community vote to accept the proposal. If approved, the new strategy gets added to the library. This way, inclusion of new strategies takes little to no time for implementation. 

Governance token role: 

Governance tokens in the DeFi platform serve as a capital that offers some control over the distribution of economic resources across a group of people. In other words, whoever has this capital, has the power to decide which inputs are to be used to create things or useful work or provide services.

As the resources (TVL) in DeFi protocols grow, so does the influence of the governance token, making it valuable. Therefore, its influence must be distributed among the community so that no single person controls this tremendous power.

APY.Finance plans to give the community increasing amount of power over the governance of the platform by allowing the community to: 

  • vote on risk scores for strategies.
  • determine their level of risk tolerance.
  • propose new strategies and
  • allow changes to the strategies. 

This way the platform also keeps itself up-to-date with the users (community) latest interest. Additionally, it adapts to the strategies proactively as the marketplace evolves, thereby ensuring continued usage.

Competitor analysis:

There are more competitors in similar category like Harvest Finance, however, for the comparison, it was excluded.


Join Hacker Noon

Create your free account to unlock your custom reading experience.