Enable simple lending from bitgo wallet

Simple Compound Lending Portal from both Metamask and Bitgo Wallet


Compound is famous lending protocol and a lot of crypt users pay attention nowadays mainly because they would like to earn interest with their own idle crypt asset. Bitgo is the famous enterprise wallet having multi-sig capability, which usually used for business purpose. My portal gives user easy interface to lend to /redeem from Compound protocol with both MetaMask and Bitgo Wallet Compound Finance portal already provide seamless integration with Metamask wallet, so this may be reinvention of wheel. However I haven't see any good Compound interface interacting with Bitgo. So I did try to make it. Since Bitgo is used for enterprise user, you could consider my portal is intended to be hosted as intranet application and used by internal employee only. In other words, this application is intended to help enterprise user to use Compound protocol without moving their asset from secure Bitgo Wallet. These are a list of functions 1) Supply/Redeem of Compound Two Token(ETH and DAI) are supported. 2) Show APR of each Token 3) Show balance of tokens in each wallet 4) Support both Metamask and Bitgo Wallet 5) Initialization In Metamask, wallet needs to confirm the site, which can be done in "Enable Metamask" button. In Bitgo, wallet needs approval from Compound to interact with DAI. This is supported in "Enable DAI Interaction" button. Please note there are a couple of limitation due to proto type product built in limited time - Covered asset are ETH and DAI only. However apparently, any ERC20 token supported by both Bitgo and Compound can be handled in similar manner - Especially Bitgo portal, security function is not considered. In other words, there is no proper authentication mechanizm such as JWT auth token when interacting with frontend and backend API. - Redeem function of Bitgo is still in progress.

Enable simple lending from bitgo wallet showcase

How it's made

As mentioned, I used both Metamask and Bitgo wallet to interact with Compound protocol and created two separate pages. In business perspective, Metamask integration does not have much point as it is already widely available. But since I am new to smart contract industry, it was very good learning exercise. On the other hand, Bitgo integration is something new, at least not widely available. In technical perspective, although UI seems very similar in these two wallet pages, the implementation was very different. In Metamask, it has web3 provider function, so that most of the implementation is done on client side using java script libararies such as Compound.js and web3.js and that is usually enough. In the meantime, Bitgo wallet SDK should be hosted in a server so that most of interaction with smart contract should be done at server side using installed nodejs libraries of Compound/Web3 together with Infura API as web3 provider. In addition, the way interacting with smart contract from Bitgo needs lower layer implementation, meaning that we should kick ETH transaction to interact with cToken smart contract including hex encoded input data in data field where the detail method call and parameters used in destination smart contract are stored. Although a tool is prepared to create hex encoded input data for smart contract, this was a bit challenging part for me and I was stucked with a couple of error prone coming from Bitgo product specification which took me quite some time. Fortunately, a mentor of Bitgo helped me well to identify the issue in discord channel so that I could move on.

Technologies used