Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yield-earning Warp Routes with ERC4626 #2450

Closed
nambrot opened this issue Jun 29, 2023 · 20 comments
Closed

Yield-earning Warp Routes with ERC4626 #2450

nambrot opened this issue Jun 29, 2023 · 20 comments
Assignees
Labels

Comments

@nambrot
Copy link
Contributor

nambrot commented Jun 29, 2023

Context

Tokens that are held in Warp Route's HypERC20Collateral back the synthetic HypERC20 tokens on the remote chains. A warp route deployer may want to create a warp route that puts these tokens to productive use. ERC4626 standard was created to allow yield-sources to easily be used without custom integration.

This bounty calls for a HypERC20Collateral variant that can deposit the underlying token into a 4626 vault (and withdraws it from the vault on unlock). When withdrawing, the user should get returned the original amount, with the yield accumulating in the warp route (which is tracked and withdrawable by the owner). The change itself should be pretty simple, so to complete this issue, you should also:

This is especially compelling as that allows let's say app-rollup/chain operators to monetize the deposits and capture value from a service they are providing. Obviously this is fundamentally already possible, but having ready to go contracts/products for this use case is key.

@vinhyenvodoi98
Copy link

i would like to do this issue

@vinhyenvodoi98
Copy link

vinhyenvodoi98 commented Jul 5, 2023

so i need to create PR to this hyperlane-token and try to deploy by use hyperlane-deploy, right ?

@nambrot
Copy link
Contributor Author

nambrot commented Jul 5, 2023

We actually moved Warp Routes back to the monorepo, so you should make a PR to the monorepo and then yes use it in hyperlane-deploy (you will need to deploy your own NPM package for that during development)

@nambrot
Copy link
Contributor Author

nambrot commented Jul 10, 2023

@vinhyenvodoi98 I would recommend reading up a bit more on the 4626 standard and how it works

@vinhyenvodoi98
Copy link

i have read it but i am having a bit of trouble demo it on testnet environment.
like I can manually deploy the sDai contract and then use it. However, if they have sDai on testnet environment, that's �would be perfect
I'm also having trouble implementing on the hyperlane-monorepo repo. I guess I need more time to understand it

@nambrot
Copy link
Contributor Author

nambrot commented Jul 12, 2023

You should be able to use any 4626 compatible token

@vinhyenvodoi98
Copy link

i want confirm about

/**
     * @dev Transfers `_amount` of `wrappedToken` from `msg.sender` to this contract.
     * @inheritdoc TokenRouter
     */
    function _transferFromSender(uint256 _amount)
        internal
        override
        returns (bytes memory)
    {
        wrappedToken.safeTransferFrom(msg.sender, address(this), _amount);
        return bytes(""); // no metadata
    }

    /**
     * @dev Transfers `_amount` of `wrappedToken` from this contract to `_recipient`.
     * @inheritdoc TokenRouter
     */
    function _transferTo(
        address _recipient,
        uint256 _amount,
        bytes calldata // no metadata
    ) internal override {
        wrappedToken.safeTransfer(_recipient, _amount);
    }
  • _transferFromSender: will be used when user send token from A chain to B chain
  • _transferTo: will be used when user send token back from B chain to A chain

@vinhyenvodoi98
Copy link

vinhyenvodoi98 commented Jul 13, 2023

@nambrot

for example

  • user send 10 ETH from eth -> polygon
  • user's 10ETH will be 10stETH and store in HypERC20Collateral and have 10ETH in polygon
  • after 3months 1stETH != 1 ETH. user want to send back 3ETH from polygon to eth
    • should i use withdraw function in ERC4626 to withdraw exact 3ETH and send back to user
    • or redeem 3stETH and send back to user 3.03ETH ( assumption )

@nambrot
Copy link
Contributor Author

nambrot commented Jul 13, 2023

It's more generic then that, depends a lot of what A and B chain is. In general, for a warp route, there is a single HypERC20Collateral contract which holds the token as collateral (i.e. collateralizes it by eventually calling _transferFromSender and releases the collateral from _transferTo.

Use sDAI for an easier example.

  • User sends 10 DAI from ETH to polygon.
  • warp route deposits the 10 DAI into sDAI (and lets say gets 100 sDAI shares)
  • after 3 months, user sends money back, the user should ge back 10 DAI (and leave the 0.01 DAI that was earned in the meantime in the 4626 vault)
  • owner should be able to move the interest elsewhere (but not move the collateral for all HypERC20 that is outstanding)

@AceVikings
Copy link

I would like to work on this issue

@vinhyenvodoi98
Copy link

@AceVikings
sorry but i still working on this 🙇

@nambrot
Copy link
Contributor Author

nambrot commented Aug 28, 2023

@vinhyenvodoi98 I would say you had quite a lot of time on this ticket, so I'll open it up to the public again. If you end up getting your work completed with the full-scope, you obviously remain eligible

@AceVikings
Copy link

Hey, could I be assigned this now ?

@avious00 avious00 assigned AceVikings and unassigned AceVikings Sep 19, 2023
@avious00
Copy link
Contributor

Hey @AceVikings feel free to attempt this, When you open up the PR, tag our CTO @ nambrot for a review

@avious00
Copy link
Contributor

@RohanShrothrium and megabyte also asked, but Ace was first

@AceVikings
Copy link

Hey @AceVikings feel free to attempt this, When you open up the PR, tag our CTO @ nambrot for a review

Got it, thanks!

@ltyu
Copy link
Contributor

ltyu commented Dec 15, 2023

Hello, can I work on this?

@avious00
Copy link
Contributor

hey lee @ltyu - go for it!

@yorhodes yorhodes moved this to In Review in Hyperlane Tasks Jan 2, 2024
@yorhodes yorhodes moved this from In Review to In Progress in Hyperlane Tasks Jan 2, 2024
@nambrot nambrot moved this from In Progress to In Review in Hyperlane Tasks Mar 5, 2024
@avious00
Copy link
Contributor

avious00 commented Mar 5, 2024

linking this to @ltyu's PR #3076

ltyu added a commit that referenced this issue Mar 13, 2024
### Description
Integrates ERC4626 compatible vaults. This PR assumes that the vault
`asset` is the same as `wrappedToken`
- `_transferFromSender()` deposits into the vault
- `_transferTo()` withdraws from the vault
- `sweep()` redeems excess shares for the vault asset
- Uses internal `assetDeposited` store to keep track of assets
deposited. Used to calculate excess shares to be withdrawn by owner
- Makes minor changes to existing test files to allow new tests to
inherit

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues


- Implements #2450


### Backward compatibility
Yes

### Testing
Manual/Unit Tests

---------

Co-authored-by: Yorke Rhodes <[email protected]>
@avious00
Copy link
Contributor

linking #3076

@github-project-automation github-project-automation bot moved this from In Review to Done in Hyperlane Tasks Mar 14, 2024
yorhodes added a commit that referenced this issue Mar 22, 2024
### Description
Integrates ERC4626 compatible vaults. This PR assumes that the vault
`asset` is the same as `wrappedToken`
- `_transferFromSender()` deposits into the vault
- `_transferTo()` withdraws from the vault
- `sweep()` redeems excess shares for the vault asset
- Uses internal `assetDeposited` store to keep track of assets
deposited. Used to calculate excess shares to be withdrawn by owner
- Makes minor changes to existing test files to allow new tests to
inherit

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues


- Implements #2450


### Backward compatibility
Yes

### Testing
Manual/Unit Tests

---------

Co-authored-by: Yorke Rhodes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

5 participants