This was inspired by the many uncollateralized lending solutions that exist currently. I wanted to add additional security to these systems, while still following the scrypto asset-oriented mindset.

What it does

Trifold is built on scrypto and Next.js (React) with Tailwind CSS.

Trifold has many common DeFi lending features:

  • Lenders are able to deposit XRD and will be compensated one to one in lnXRD for the amount of XRD they deposit.
  • Borrowers are able to borrow XRD from the pool with no collateral, and will be charged interest per epoch.
  • Lenders are able to withdraw XRD, along with any profit they have earned through interest, by returning the lnXRD they have received, provided the pool has enough liquidity to cover the withdrawal.

As stated earlier, Trifold's namesake is due to its three factors of security. Each factor provides its own layer of security, and works in the lender's best interests. The three factors are:

  1. Offchain Verification
  2. Voting Consensus
  3. Karma

Offchain Verification

The instantiator of the contract is responsible for the off-chain governance of the contract. They are given an admin badge which is used to approve borrowers. Off the chain, a borrower approaches the instantiator of the contract to request a borrower approval. The instantiator of the contract is then given the opportunity to approve or deny the borrower in real life. If the borrower is approved, the instantiator can then place an approval request on the /admin endpoint. The instantiator should provide the name of the borrower (or the company's name), the RADIX address of the holder, and a website that claims responsibility for the address.


Karma is a system within the Trifold contract which allows for borrowers to increase their lending limits depending on their past reputation. Borrowers are initially given a set amount of karma, which can be traded 1 to 1 for XRD. If they take out a loan, a corresponding amount of karma will be burned. If the borrower defaults, the borrower will lose the amount of karma they had initially. However, if the borrower pays back the loan, now that interest has been accrued, the borrower will gain more karma than they had initially. This allows for borrowers to continue to increase their lending limits, and prevents malicious borrowers from abusing the system.

Emergency Shutdown

Holders of the contract can request an emergency shutdown of the contract by sending all of their lnXRD to a specified address. This will compensate the holder with a lockdown special token, and if the amount of lnXRD is over 50% of the total public supply of lnXRD, it shows that a majority of the lnXRD holders believe that the contract is in a bad state. This will cause prevent the contract from accepting any new loans, approving borrowers, withdrawing lends, and all major functions, until the lockdown is ended by withdrawing the lnXRD from the lockdown vault by returning the lockdown token.

How we built it

I built it with Next.js (ts) and tailwind for the front-end and obviously rust and scrypto for the "backend".

Challenges we ran into

The scrypto language doesn't allow for many possible security features that I was planning to implement, which caused several challenges.

Accomplishments that we're proud of

What we learned

The scrypto platform seems incredibly promising and as we approach Babylon, this could be a very important contender in the web3 world. This is my first project working with smart contracts and cryptocurrency, and it was an amazing prompt to work with.

What's next for Trifold

Finding more ways to secure the protocol is the main step in discovering how to improve the system.

Built With

Share this project: