Welcome to DeFi4NFT!
Guide
DeFi4NFT is a borrow/lend platform for NFTs on Algorand. At the core a state machine stores the loan health of a pure non-custodial borrow/lend protocol.
Pure non-custodial means assets remain in the owner’s wallet, for borrowers this means collateral assets remain frozen in address. And for liquidity providers this means creating a delegated logicSig promising to provide a loan when a borrower matches, aka promise. And for liquidators this means a three way transaction, where the end receiver is a third party buyer willing to buy the borrower’s collateral NFT and the liquidator pays the debt of the borrower while a third party buyer sends payment of the collateral NFT to liquidator. This system is set up so permissioned tokens can be open to receive liquidity from non-whitelisted addresses.
Get started with DeFi4NFT
Watch this demo video. Go to live demo site.
First step is to optin to the smartcontract.
Optin to DeFi4NFT
As an NFT creator
Transfer your NFT’s admin address to DeFi4NFT. This will make your NFT leverageable for taking loan in DeFi4NFT dapp.
This sets manager and freeze admin address to DeFi4NFT smartcontract
And sets clawback to liquidator smartcontract
As a liquidity provider
Optin to the I-O-U token of DeFi4NFT dapp dUSD, that has 1:1 value with USDCa. This happens automatically when you create a promise to provide liquidity, via the frontend.
Earn (Providing Liquidity)
Choose which NFTs can borrow from your account.
Set maximum amount you are willing to lend.
Set expiration date for aggrement.
Borrow (Leveraging NFT)
Use your NFT as collateral, to borrow USDCa stablecoin.
Set which NFT you want to collateralize
Set amount of collateral
Request loan You’ll get requested loan amount in USDCa and your NFT will be locked.
Repaying loan
Send USDCa to DeFi4NFT contract. Your loan amount state will be decremented by sent repaid amount.
If you pay the full loan amount, your collateral assets will be unfrozen.
Claming USDCa
Send dUSD(I-O-U token of DeFi4NFT contract) to DeFi4NFT contract. You’ll receive a 1:1 USDCa for the dUSD you send.
Circle (Fiat-on ramp)
A fast and easy way to get fiat into our Dapp is using Circle accounts. You can either use a credit/debit card or send USDC from other chains supported by circle.
Swap USDC to Algorand
Powered by circle’s bridge, we now offer wider options to users that want to interact in our pure non-custodial borrow/lend dapp. You can transfer USDC from any chain supported by circle bridge to any algorand address you want to.
First select your circle wallet linked to an algorand address.
Then generate a blockchain address that you’ll deposite USD into and get it in the Algorand address linked to that circle wallet.
You will recieve the deposited amount in your Algorand address soon. For testing purposes we recommend using smaller amounts.
For more, look into Techincal review.
Neos interaction
Getting into Algorand world
Search for Algorand in the worlds menu.
Optin
To optin to DeFi4NFT in neos go through the shimmer.
Extract
Extract your Algorand NFT into neos world to use it as collateral.
Borrowing
Place an item on the top of the borrow table, specify the loan you want then touch the top of the table.
Repay
Place a USDC coin object onto the well, which represents repaying. State the amount you are going to repay and touch the well or click on repay label.
Burn
Get the dUSD representation near the fire, then state how much USDC you want to redeem. Then touch the torch stick(not the fire!) and confirm the transaction.
Portal
Click on the chain to bridge from. And send assets from the testnet of the chain. For ETH the network is Goerli.
Technical review
NFTs used as collateral are frozen in account, only when account takes out loan.
Frozen NFTs are unfrozen when full loan is paid back.
There is no interest rate for borrowing USDCa.
A 3% fee is paid to take out loan.
Lenders sign a delegated logic signature to allow any account to withdraw USDCa that fullfill the following:
Calls DeFi4NFT contract
Withdraws atmost staked amount
Any account that holds dUSD can claim 1:1 USDCa by sending the dUSD to DeFi4NFT contract.
Borrower can borrow from upto 4 lenders
Liquidation
How liquidation happens?
Specify the addresss to liquidate
Pay 95% of collateral’s value to DeFi4NFT contract
Set an account that will receive the liquidated asset
You’ll be sent the collateral to the address you specified
Smartcontract
There are three smartcontracts that power DeFi4NFT dapp.
DeFi4NFT Contract DeFi4NFT contract holds the state machine and locks/unlocks NFT in account (freezes/unfreezes NFT) . State machine, tracks:
xids
tracks which NFT is used as collateralcamt
tracks how much collateral is used for loanlamt
tracks how much loan is borrowedaamt
tracks how much loan is available from lender address
Liquidator Contract Liquidator contract reads current price of NFT from oracle and if loan is more than 90% of collateral it liquidates the NFT locked.
liquidator contract is the clawback address of leveragable NFTs on DeFi4NFT.
after liquidation completes the remainig asset is unfrozen. This is possible by AVM 1.1 (contract to contract call). Liquidator contract calls DeFi4NFT contract to unfreeze the asset.
Manager Contract Manager contract creates all other contracts on behalf of creator address. It also controls the NFTs that are configured to be borrowable in DeFi4NFT.
Notice
We have implemented here the Freeze admin and Clawback of algorand ASA. And IPFS for storing delegated LogicSig. We have also used Circle APIs for blockchain swap.
Install or build project
Building DeFi4NFT Locally
Create a sandbox environment
$ git clone https://github.com/Adg0/DeFi4NFT.git
$ cd DeFi4NFT
$ git clone https://github.com/algorand/sandbox.git
$ cd sandbox
$ ./sandbox up dev
Notice
Visit setting up algorand sandbox for development.
Create the contracts locally
$ cd cmd
$ go install .
$ ./cmd
TroubleShooting
CLI
If you encounter a failed transaction using the CLI, you can send the dryrun file to our contact or evaluate it your-self.
Web interface
Some common problem you might encounter is missing lenders when Borrowing.
Solution is to search again, if the first search fails.
Neos
In VR you might need to scan QR-codes again. Especially for bridge, destroy the first instance and generate a second address if your non-Algorand wallet couldn’t scan the address.
Additional features
Composibility
Since all contracts are written per Standard. You can extend the funcitonality.
One great thing about this project is its composibility. For instance, a liquidity provider at DeFi4NFT can extend the utility of their USDC by placing it in a liquidity pool and attaching a contract that will withdraw the asset from third party liquidity pool and lend it to a borrower at DeFi4NFT. In other words, they can get the best of both worlds.
They have made a promise on DeFi4NFT, that means they will at somepoint get 3%
They have kept the promise in a third party liquidity pool. That means they get some APY until it is actually lent out at DeFi4NFT. It is a profit made in two dapps with the same amount. We think this is gonna be a big incentive for liquidity providers.
Future
The next step for DeFi4NFT is to setup a voice command system so there would be more immersion for players.
Contact
Discord @1egen#0803
Discord @3spear#9556