yearn + aave == yAAVE
After testing out Cream’s v2 aka Iron Bank, Sam and I decided to join the Market Make hackathon that Aave was sponsoring and we wanted to try out the credit delegation feature. I never used Aave before, so it was a perfect excuse.
To start, let’s make sure everyone is on the same page by understanding what Credit Delegation is.
Credit delegation allows a depositor to deposit funds in the protocol to earn interest, and delegate borrowing power (i.e. their credit) to other users.
A simple use case example is:
- Alice deposits USDC, gets aUSDC
- Alice approves delegation of weth to Bob
- Bob borrows weth using Alice collateral and invests somewhere
- Bob repays the debt
What if we pool borrowing power and deposit it into a yearn vault?
Benefits for the delegator:
- They can keep their aToken position without incurring a taxable event to enter the vault
- Additional return (based on what’s arranged with the delegatee)
- Increase exposure to other assets
Benefits for the delegatee:
- Uncollateralized loan
- Getting a return through a deployed smart contract
The implemented use case
Actors
— Alice, a delegator who only trusts us with 1 ether
— Bob, another delegator who trusts us with all his reserves
— The Router, a smart contract that will be the delegatee
— Gov, the owner of the router contract
— steCRV yVault, the yearn vault, the investment opportunity
— ZapSteth, the zap contract to deposit into the vault
Please, try to read the test of what’s happening but if you can’t read code, the example is:
- Alice approves delegation to Router with 1 eth
- Bob approves delegation with all his reserves
- Router’s Gov adds Alice and Bob as delegators
- Router can calculate its eth borrowing power, (50% of the total borrowing power)
- Gov invests 2 eth through the Router into the vault using ZapSteth
- The test travels one week into the future
- The test forces a harvest in the vault
- Router withdraws from the vault using ZapSteth
- The test asserts that the Router made a profit after paying out the debt
- Gov is allow to transfer the profit out
Check the full project src code at https://github.com/macarse/yAAVE
Concerns and Issues
We have discussed the possibility of pushing this to mainnet but we need to iterate a bit more on the process. Here are some open questions.
1:1 Credit Delegation
This is the biggest concern to be able to scale. Since the credit delegation is done one to one, if the Router wants to borrow a big amount, it would need to borrow from each individual separately, keeping tabs with each delegator.
This not only makes the code more complicated but also very gas-intensive.
The implementation as it is is only usable by aTokens whales.
Delegators are not blocked from doing their own borrowing
Example: Router takes a loan with 50% of the delegator borrowing power but that doesn’t block the delegator to take the additional 50% and push us close to a liquidation state. It’s harder for the delegatee to monitor the health factor because it not only depends on its actions.
Profit Distribution
For now, the profit stays in the Router contract. We are still discussing which is the best way to make the distribution more efficient. While waiting for the profit claims from delegators, should the router… convert profit to an aToken and become a delegator itself? Keep a balance of the borrowed asset just in case health factor deteriorates? Send aTokens directly to delegators?
Staking aTokens
To avoid some of the issues mentioned above, another idea is to stake aTokens. The Router contract can receive deposits of aTokens and borrow against itself. This approach is totally valid and is compatible with other borrowing platforms. Router contract would be able to take [a|c|cr]Tokens, borrow in each platform separately and invest.
Perhaps someone is already working on it…
https://twitter.com/AndreCronjeTech/status/1355337578367447042
Looking forward to the future
We already witness the huge success of Iron Bank. Yearn is using cream unused capital for better yield and now Alpha Homora is using it for their v2 release. AAVE’s credit delegation is another way strategists can tap into unused capital.
We believe that the next step in borrowing platforms is letting the token depositor decide more granularly how their funds are going to be used. Imagine being able to decide how your borrowing power can be utilized and how profits are going to be returned to you? Let’s go through an example.
Alice has a portfolio of 10 ETH, 10 CREAM, and 10k HEGIC. She uses the borrowing platform as her DeFi saving account. Apart from the traditional lending interest, she wants a percentage of her assets to be invested.
She wants to participate in sushi farming so she credits delegates 50% of her borrowing power to a router contract. This router contract will loan eth+dai using her collateral and will deposit into Sushiswap LPs to farm sushi. As a final step to start the process, she needs to decide what profit settlement she wants. Increase her portfolio tokens or sushi claims?
Granular Strategy Control
The settlement layer gives a lot of flexibility to the investor portfolio. If the user can define what they want as output, they can build a portfolio out of profits.
Tax efficiency
Alice's assets were never converted and/or transferred, so no taxable events while depositing. Profit would be taxable when claimed.
This full last example is a bit impossible nowadays but with a good integration across systems, we can see something like this happening in 2021.
Keep Building…
Carlos and Sam