Inspiration
Wanting to reduce the uncertainties around cryptocurrencies, especially stablecoins.
What it does
StableRatioSwap swaps TUSD to another stablecoin (USDC, USDT, DAI, BUSD) with the highest APY if the assets (coins in circulation) to reserves (dollars in a bank) ratio is higher than a comfortable amount. This is useful for both individuals to have peace of mind in holding a truly stablecoin and for institutions which many need to comply with investor and/or legal requirements.
How we built it
- The React frontend primarily uses Ether.js to interact with the StableRatioSwap contract and a little Web3 and Infura to use aave-js.
- The Solidity backend, managed via Hardhat and deployed via Infura to Kovan, calls Chainlink, Aave, Uniswap, and OpenZeppelin utilities. For quick frontend UI testing, a mocked version of the StableRatioSwap contract was used locally. The frontend was ultimately deployed to GitHub pages.
- The external adapter is hosted on AWS with Lambda and API Gateway and deployed in the Chainlink ecosystem by a helpful node operator.
Challenges we ran into
- We tried using Aave’s flash loan and Uniswap to swap collaterals in multiple ways. However, after experimentation and asking on Discord, we discovered Aave on Kovan only supports a few pairs of tokens to swap (specifically only ETH to any other coin). As a result, we could not swap TUSD to another stablecoin although our final implementation seems to be correct. This is why we ended up doing the collateral swap on the frontend even though the original plan was to do it on the backend. Note: this is also why in the demo the real Aave amount gets “added” to another stablecoin’s balance in the frontend even though the swap hasn’t actually occurred on Aave.
- As this was our first blockchain project ever (only prior experience was CryptoZombies tutorials), we spent a lot of time researching various L1/L2 chains, developer tools, and feasibility of project ideas.
- As a full-time Software Engineer, it would have been great to have more time for this evenings and weekends project given the huge amount of learning and building necessary.
Accomplishments that we're proud of
- Successfully fetch user data with our deployed solidity code in the Aave Lending Pool.
- Create a new Chainlink external adapter, deploy it, and call it in the backend solidity code.
- Collaborate with a teammate in a different continent.
What we learned
- How to develop a Dapp with Hardhat.
- Debugging external contracts’ code across GitHub, node modules, and etherscan.io.
- How to navigate the solidity code we try to import.
- Figuring out where the Kovan address for contracts we used were (a few took a lot of searching).
- How to deploy a contract and use etherscan for validation and debugging purposes.
- How to make calls between a web frontend and blockchain backend.
What's next for StableRatioSwap
- Add a periodic swapping feature with an adapter job spec that has a cron initiator and ethx adaptor that periodically checks the TUSD asset:reserve ratio and automatically swaps on behalf of a user. The reason an opt in/out button exists in our frontend is so a user can opt in or out of this feature whenever they’d like.
- Add a textbox and button that shows the current asset:reserve ratio before users try to manually swap for convenience and ETH saving purposes.
- In addition to APY, also factor in asset:reserve ratios for the non-TUSD stablecoins if possible to calculate.
Built With
- aave
- amazon-web-services
- armanino
- chainlink
- ethereum
- hardhat
- infura
- lambda
- npm
- react
- solidity
- tusd
- uniswap






Log in or sign up for Devpost to join the conversation.