Democratizing cross chain staking and yield farming
Majority of the most popular Defi projects are on Ethereum. This includes Curve, AAVE, Convex, Yearn, Uniswap. These Defi platforms represent some of the most stable yield sources, i.e. users can earn fees and interests by providing liquidity or lending. However, users who want to participate on these platforms face significant friction because the gas fee on Ethereum L1 is notoriously high. For most average users, the gas fees far outweigh the potential gain in yield, which prevents wider defi adoption.
At the same time, with a Multichain world, more and more assets are residing on different chains. For example, wrapped ETH exists on almost all major alt L1s. But earning yield on wrapped assets is inaccessible and overly-complex for average person. For example, if someone has $100 worth of wrapped ETH on Algorand, they would have to first go through Wormhole before finding a stable yield source on Eth and spend over $30 in gas along the way.
In this project we propose a solution to these two problem average users face by combining the low fees on modern high throughput blockchains such as Algorand, and the cross-chain messaging platform Wormhole, into a service that allows users to earn yield from Ethereum Defi protocols without leaving the low fe environment on Algorand. This makes it super simple (1-click) and cheap (pay only Algorand gas fees <$1) while retaining security through smart contracts.
Consider a user on Algorand who owns say 100 ALGO coins. In order for them to earn yield from Lido, while remaining liquid with their funds they have to
The combined gas fee for these transaction could easily exceed the value of 100ALGO, and is convoluted. In the next section we illustrate how our service can allow this user to earn staking reward on Ethereum with low gas fees.
The user was able to do everything in one step, and pay only Algorand gas fees (<$1). All the benefits are retained (wsETH_LP is a fully liquid token, native to Algorand, and redeemable anytime for the underlying staked ETH and rewards) and more (Algorand's instant finality and no-forks means this process is faster and more secure).
We believe that the future is Multichain, so demand will grow exponentially for low-fee, easy-to-use, cross-chain solutions. This makes xStaking a key primitive in the cross-chain DeFi landscape.
See the deployment here:
Frontend: skynet deployment (If you want to use it, you need wETH and also OptIn all the assets listed below)
Algorand ASA IDs: 91208285, 91208322
Ropsten Ethereum Endpoint: 0x5a09E033863f74E80973491930d067Dc3B8797Cd
WETH_ADDRESS_ROPSTEN = "0xc778417E063141139Fce010982780140Aa0cD5Ab"
stETH_ADDRESS_ROPSTEN = "0xd40EefCFaB888C9159a61221def03bF77773FC19"
The key observation is that although Ethereum transactions have high gas fees, the gas fee does not scale with the value of the transaction. Meaning, for the same transfer transaction for example, the gas fee is the same whether you are transferring 0.1ETH or 100 ETH. Our solution to the high gas fee problem is to aggregate individual users transaction into batches so that the users in each batch pay for the gas fee once, effectively reducing the gas fee by a factor of ~n, where n is the number of users in the batch.
Our solution consists of two "xStaking endpoints". Endpoint A sits on the Algorand side, and endpoint B sits on the Ethereum side. Different users can deposit deposit wETH into endpoint A (they can also directly deposit ALGO to endpointA, which will in the background use C3 exchange to swap ALGO for wETH). After depositing, users are issued stETH_LP tokens (implemented as an Algorand Standard Asset or ASA) that represent their shares in the staking pool.
Once endpoint A's balance in wETH exceeds a prefixed threshold (say 10 wETH), the contract will automatically trigger a transaction over Wormhole, bridging the entire wETH balance in endpoint A to endpoint B on Ethereum in the form of native ETH. At this point endpoint B will automatically deposit the ETH balance to the LIDO contract, receiving stETH in return. Endpoint B will keep custody of these stETH until the users want to redeem.
To redeem, users can send the stETH_LP, along with a destination wallet on Ethereum, to Algorand endpoint A, which will then send a message to Ethereum endpoint B via Wormhole, telling endpoint B to release the funds to the user specified address.
Note that since stETH_LP (which sits on Algorand) represents the ability to redeem stETH on Ethereum, its' value should be pegged to the value of the stETH that it can redeem. This means that users can trade stETH_LP for ALGO / other tokens on Algorand at any time. In particular, they can use stETH_LP as collateral to borrow assets on Algorand via for example C3. This means that the users remain liquid on Algorand, while their assets are earning staking reward on Ethereum!
We used Algorand extensively. First, we created a new token with PyTeal, stETH_LP, as a fully fungible, interoperable, Algorand-Standard-Asset, pegged by underlying stETH reserves on Ethereum. The Algorand SDK was also used to construct a secure deposit address that accepts wETH deposits and issues stETH_LP. In order to accurately provide data on various statistic about our stETH pools, we used The Graph's subgraph service, this plays an important role as its crucial that users can monitor the up-to-date status of their stETH and the pool. Since the stETH stored on our Ethereum contract is what backs the value of wstETH_LP on Algorand, this information is crucial for users to be able to be confident with their funds.
An Algorand indexer is used to monitor the amount of wETH in the staging pool, and when a certain threshold is reached, a Wormhole transaction is triggered. In particular, the Wormhole Token Bridge SDK was used to trustlessly bridge over all wETH in the Algorand staging pool to an Ethereum Smart Contract. Since the indexer is an off-chain component, it was important that it remain as open and transparent as possible. Thus, we used Storj to publish all transactions that are triggered off-chain by the indexer, allowing anyone to verify and follow the logic of our dApp. Using IPFS provided by Storj was very valuable, as this enables the logs and transaction history of the indexer to always remain public and accessible.
The Ethereum smart contract, written with Solidity and the Hardhat testing framework, accepted wETH from the Wormhole Bridge, unwrapped it, and staked it via transacting with the LIDO liquid staking protocol.
We also implemented a front-end using React and integrations with Algosigner to enable users to use this dApp with one click. The front-end also integrated the C3 Collateral Engine to enable users to get wETH easily on Algorand and not have to bridge it over from Ethereum. Finally, in the spirit of web3, we host the front-end using Skynet, a decentralized service.
Algorand and wormhole are both relatively new ecosystems. Our team also had zero experience with these ecosystems before. A lot of the SDKs were in flux over the weekend. As a result, integrating these things were challenging.
Programming Algorand smart contract is quite different from programming Solidity. Algorand in particular have some unique features (e.g. ASA, OptIn, etc) that quite interesting.
Combined protocol: https://github.com/jasony123123/xStaking
Smart contract / subgraph: https://github.com/theothersteven/CrossChainStaking
Backend Infra: https://github.com/jasony123123/wormhole-algo-eth
Front end: https://github.com/nick-casa/SkynetFrontend