smartcontractkit/defi-minimal là dự án mã nguồn mở trên GitHub, viết chủ yếu bằng JavaScript, với 493 sao. This repo is dedicated to making minimal repos of existing defi primatives.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
This repo is dedicated to making minimal repos of existing defi primatives.
:exclamation: ** WARNING None of the contracts are audited!
Completed (but unreviewed) minimal contracts:
Lending.sol: Based off Aave
Staking.sol: Based off Synthetix
RewardToken.sol: Based off Synthetix
Exchange.sol , Factory.sol , Token.sol : Based off Uniswap v1. The used pricing formula is documented here
DecentralizedStableCoin: Based off DAI
CentralizedStableCoin: Based off USDC
Uncompleted:
Options.sol: Based off nothing
Not a minimal contract:
Swap.sol: Based off Uniswap - shows how a smart contract can integrate with a Uniswap-like dex.
Table Of Contents
Defi Minimal
Completed (but unreviewed) minimal contracts:
Uncompleted:
Not a minimal contract:
Table Of Contents
Getting Started
Requirements
Quickstart
Usage
Deploying Contracts
Run a Local Network
Using a Testnet or Live Network (like Mainnet or Polygon)
Rinkeby Ethereum Testnet Setup
Code Formating
Slither Static Analysis
Contributing
Thank You!
Resources
Getting Started
It's recommended that you've gone through the hardhat getting started documentation before proceeding here.
Requirements
git
You'll know you did it right if you can run git --version and you see a response like git version x.x.x
Nodejs
You'll know you've installed nodejs right if you can run:
node --versionand get an ouput like: vx.x.x
Yarn instead of npm
You'll know you've installed yarn right if you can run:
yarn --version And get an output like: x.x.x
You might need to install it with npm
If you're familiar with npx and npm instead of yarn, you can use npx for execution and npm for installing dependencies.
Quickstart
Clone and install dependencies
After installing all the requirements, run the following:
git clone https://github.com/smartcontractkit/defi-minimal/
cd defi-minimal
Then:
yarn
or
npm i
You can now do stuff!
yarn hardhat test
or
npx hardhat test
Usage
If you run yarn hardhat --help you'll get an output of all the tasks you can run.
Deploying Contracts
yarn hardhat deploy
This will deploy your contracts to a local network. Additionally, if on a local network, it will deploy mock Chainlink contracts for you to interact with. If you'd like to interact with your deployed contracts, skip down to Interacting with Deployed Contracts.
Run a Local Network
One of the best ways to test and interact with smart contracts is with a local network. To run a local network with all your contracts in it, run the following:
yarn hardhat node
You'll get a local blockchain, private keys, contracts deployed (from the deploy folder scripts), and an endpoint to potentially add to an EVM wallet.
Using a Testnet or Live Network (like Mainnet or Polygon)
In your hardhat.config.js you'll see section like:
This section of the file is where you define which networks you want to interact with. You can read more about that whole file in the hardhat documentation.
To interact with a live or test network, you'll need:
An rpc URL
A Private Key
ETH & LINK token (either testnet or real)
Let's look at an example of setting these up using the Rinkeby testnet.
Rinkeby Ethereum Testnet Setup
First, we will need to set environment variables. We can do so by setting them in our .env file (create it if it's not there). You can also read more about environment variables from the linked twilio blog. You'll find a sample of what this file will look like in .env.example
IMPORTANT: MAKE SURE YOU'D DONT EXPOSE THE KEYS YOU PUT IN THIS .env FILE. By that, I mean don't push them to a public repo, and please try to keep them keys you use in development not associated with any real funds.
Set your RINKEBY_RPC_URL environment variable.
You can get one for free from Alchmey, Infura, or Moralis. This is your connection to the blockchain.
Set your PRIVATE_KEY environment variable.
This is your private key from your wallet, ie MetaMask. This is needed for deploying contracts to public networks. You can optionally set your MNEMONIC environment variable instead with some changes to the hardhat.config.js.
WARNING
When developing, it's best practice to use a Metamask that isn't associated with any real money. A good way to do this is to make a new browser profile (on Chrome, Brave, Firefox, etc) and install Metamask on that brower, and never send this wallet money.
Don't commit and push any changes to .env files that may contain sensitive information, such as a private key! If this information reaches a public GitHub repository, someone can use it to check if you have any Mainnet funds in that wallet address, and steal them!
You can also use a MNEMONIC instead of a PRIVATE_KEY environment variable by uncommenting the section in the hardhat.config.js, and commenting out the PRIVATE_KEY line. However this is not recommended.
For other networks like mainnet and polygon, you can use different environment variables for your RPC URL and your private key. See the hardhat.config.js to learn more.
Get some Rinkeby Testnet ETH and LINK
Head over to the Chainlink faucets and get some ETH and LINK. Please follow the chainlink documentation if unfamiliar.
Code Formating
This will format both your javascript and solidity to look nicer.
yarn format
Slither Static Analysis
You'll need python and slither installed.
yarn slither
Contributing
Contributions are always welcome! Open a PR or an issue!
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/smartcontractkit/defi-minimal là nguồn chính thức.
smartcontractkit/defi-minimal có phải mã nguồn mở không?
Có — smartcontractkit/defi-minimal phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/smartcontractkit/defi-minimal.
smartcontractkit/defi-minimal có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho smartcontractkit/defi-minimal. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
smartcontractkit/defi-minimal dùng license gì?
smartcontractkit/defi-minimal phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
smartcontractkit/defi-minimal là gì?
smartcontractkit/defi-minimal (smartcontractkit/defi-minimal) là dự án JavaScript trên GitHub. Theo mô tả gốc: This repo is dedicated to making minimal repos of existing defi primatives.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc defi-minimal có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về defi-minimal.