Inspiration
We've been inspired by the potential of the upcoming Bitcoin integration on ICP to create a simple and robust borrow/lending protocol to be the foundation of the DeFi ecosystem on the IC.
What it does
Currently it allows you to deposit ICP or XTC, and then take out a collateralized loan of ICP or XTC. Interest will accrue on outstanding loans, and as they get paid back it will create yield for those who loan assets on the protocol. We use a price feed to ensure that outstanding loans do not exceed 75% of the value of deposited assets, in the case of ICP. If, either due to price fluctuation or gained interest, the 75% collateral limit is exceeded then a liquidation event can be triggered by a liquidator. This allows anyone to repay the outstanding loans and receive the lent assets.
The liquidation functionality is not mentioned in the demo video, as its heavily untested, yet it is on the release and it can be checked on the code/candid UI of the FinRisk canister and fTokens (the liquidate()) function.
Functionality resumed:
- Lend assets, receive fToken versions of those assets and accrue interest
- Withdraw fTokens for underlying assets
- Borrow assets against a collateral, pay interest.
- Repay an open borrow.
- Log user transactions on-chain in a Finterest Ledger canister. For example, for tax deciphering.
- Work with real, USD values of tokens. alpha version of an oracle.
- Support XDR as a stablecoin. (XTC = 1T cycles)
- BETA: Liquidate a underwater borrow (borrow value is over allowed collateral value), and take fTokens
How we built it
We built it from the ground up (line by line, keyword by keyword) using Motoko, Rust and React. There are a lot of borrow/lending protocols on various blockchains, so a lot of the underlying math was available. It was mostly rebuilding/reimplementing it with proprietary contracts in Motoko running on the IC.
Challenges we ran into
The non-atomic nature of motoko and the IC create some interesting challenges coming from a Solidity background. We had to create a proprietary payment processing canister to receive and process funds in a horizontally scalable manner. This was based off of Kyle Peacock's invoice canister design, and works around the non-atomic nature of the IC. Also the lack of price oracles or HTTPS requests as of now on the IC caused us to come up with a temporary workaround. In place of a proper decentralized oracle or HTTPS requests we have a server set up with a Rust program querying asset prices from reputable exchanges. Using a private key this then updates our FinRisk canister with the average of the prices.
A big challenge is also the async model of the IC, as new security concerns and complexity is added to developing. In the end, asynchronous programming is vastly superior to synchronous systems, and it's the only way to develop a truly scalable blockchain
Accomplishments that we're proud of
We're proud of overcoming both of the challenges that we mentioned in the previous section. Additionally, we've seen great support from the ICP community on the whole, people seem to be extremely excited about our protocol. We have a great time who has done a great job working together to help create this protocol and we are super excited to see it come to fruition once the BTC integration goes live.
What we learned
We learned a ton about developing on the IC, and on the whole it has been an incredibly positive experience. Motoko is a fun language to pick up after spending so much time with Solidity and Rust, and it has been a breeze creating the front ends for the IC. We were expecting a lot more resistance in the development process, but besides a few hiccups it has gone extremely well.
What's next for Finterest
We're planning on launching a main-net release of Finterest once the Bitcoin integration goes live and we can get our contracts fully audited. We're shooting to become the bedrock of the DeFi ecosystem on ICP, and want to open source our code to help jumpstart other DeFi builders in the ecosystem. We also want to help the IC by developing and open sourcing backend infrastructure - kickstarting the new wave of DeFi, asynchronous DeFi
Built With
- blockchain
- icp
- motoko
- react
- rust

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