DeFi lending protocol for NFTs using Chainlink Oracles on Polygon. Deposit NFTs as collateral to borrow ERC20 tokens.
Team:
- Natalja
- Rudolf
Directory structure:
contract
: lending protocol smart contract code written in Solidity, works with Truflation NFT Index using Chainlink Data Feedsfrontend
: React web app that interacts with the contractriskoracle
: data gathering and processing Chainlink oracle using IPFS, Bacalhau and QuickNode
- go into the
contract
directory - run
npm install
- run
npm run-script deploy
Note: You may need to update the risk oracle URL in the deploy.js
file to a publicly accessible URL if you are trying to test a locally running copy.
This will deploy the test tokens and test NFT, and deploy the lending protocol contract. The contract address will be printed out.
After deploying the contracts to Polygon testnet, you can get LINK tokens from the testnet faucet.
Run the frontend by going into the frontend
directory and running npm start
.
Access it at http://localhost:3000
For publishing, the frontend can be built by running npm run-script build
. After building the frontend/dist
is moved to ./docs
which is hosted on GitHub Pages and can be accessed here: https://hackathon-chainlinkfall2022.github.io/
Run the risk oracle by going into the riskoracle
directory and running npm start
. This URL needs a domain name so that it can be accessed by the Chainlink nodes.
For testing purposes you should be able to go to http://localhost:8080/ and see a JSON response that contains a riskScore
field. You can supply the ?a=some_address_here
as a query parameter to see what the risk score for that wallet address is.
- You will need a QuickNode endpoint to Ethereum or Polygon chains.
- You will need bacalhau working locally
Train the model:
npm install
# Get the data from the blockchain and process it into a CSV file
npm run-script gather
npm run-script train
When running index.js
through npm start
, the model will be downloaded from IPFS.
bacalhau version
bacalhau docker run --rm \
-v ./:/inputs \
-v ./:/outputs \
node:16-alpine \
sh -c "npm install && npm run-script train"
The model is trained through Bacalhau and the trained model is saved and uploaded to IPFS.