Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/oss #17

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/assets/garden_horizontal_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions .github/assets/garden_logomark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
.DS_Store

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down
131 changes: 92 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,105 @@
## Solidity Smart Contracts for Garden Finance
# Garden Finance - Blockchain Assets

**Introduction**
<div align="center">
<img src="./.github/assets/garden_logomark.svg" alt="GitKeeper logo" width="128px">
<p>the first instant liquidity
layer for bitcoin</p>
</div>

This repository contains the solidity smart contracts for the Garden Finance project. These contracts are designed to facilitate payment channels, HTLCs, and staking functionalities within the ethereum ecosystem.
---

**Smart Contract Breakdown**
[Garden](https://garden.finance) supercharges your Bitcoin to capture DeFi value across any chain, with blazing speeds and deep liquidity.

The contracts are organized into the following directories, each containing related functionalities:
## About Repository

- **Contracts:**
- [**Flower.sol:**](./contracts/Flower.sol) This contract Follows ERC721 NFT standard and is responsible for minting Flower NFTs.
- [**SEED.sol:**](./contracts/SEED.sol) This contract follows ERC20 standard and is the base token used across all garden decentralized applications.
- [**fee:**](./contracts/fee/README.md)
- [**FeeAccount.sol:**](./contracts/fee/FeeAccount.sol) This contract is used to manage the funds of a channel between a funder and a recipient using `Payment Channel` Architecture along with `HTLC`.
- [**FeeAccountFactory.sol:**](./contracts/fee/FeeAccountFactory.sol) This contract is used to deploy and manage the fee channels per signer.
- [**htlc:**](./contracts/htlc/Readme.md)
- [**HTLC.sol:**](./contracts/htlc/HTLC.sol) This contract is used to settle an order which is committed offchain.
- [**stake:**](./contracts/stake/README.md)
- [**BaseStaker.sol:**](./contracts/stake/BaseStaker.sol) Serves as Base Class for GardenStaker, Contains all State for FillerManager and DelegateManager.
- [**DelegateManager.sol:**](./contracts/stake/DelegateManager.sol) This contract is responsible for managing the delegation of voting power to fillers.
- [**FillerManager.sol:**](./contracts/stake/FillerManager.sol) This contract is responsible for managing the fillers.
- [**GardenStaker.sol:**](./contracts/stake/GardenStaker.sol) Acts as Entry point for staking functionalities.
This repository contains the Smart Contracts and Bitcoin scripts for Garden Finance. The Garden blockchain assets are building blocks for the Garden ecosystem, enabling **cross-chain atomic swaps**, **SEED staking** and **off-chain payment channels**. All the Smart Contracts are written in Solidity and Bitcoin Scripts are written in TypeScript. The Garden blockchain assets are organized into the following directories with logical separation as per their functionality:

## Prerequisites
- [Hardhat](https://hardhat.org/)
- [Solidity](https://docs.soliditylang.org/)
- Node >= 20
- Slither [https://github.com/crytic/slither]
- Uses TypeChain
`bitcoin/`: Bitcoin Scripts for Atomic Swaps.
`contracts/`: Smart Contracts for SEED token and Garden NFT.
`contracts/stake/`: Smart Contracts for SEED staking.
`contracts/htlc/`: Smart Contracts for Atomic Swaps.
`contracts/fee/`: Smart Contracts for off-chain Payment Channels.

**Getting Started**
Audits are an important part of the development process for Garden. We have engaged with several security firms to audit the Garden contracts and here are the reports:

For developers familiar with Hardhat and Solidity, follow these steps to set up the development environment:
- [OtterSec](https://github.com/catalogfi/audits/blob/main/OtterSec.pdf)
- [Trail of Bits](https://github.com/catalogfi/audits/blob/main/TrailOfBits.pdf)

1. **Install dependencies:**
```bash
yarn install
```
## Usage

2. Compile the contracts
```bash
npx hardhat compile
```
### Prerequisites

3. **Run the tests:**
```bash
npx hardhat test
```
There are a few things you need to have installed before you can setup Garden locally:

- [Node.js](https://nodejs.org/en/download/)
- [Yarn](https://yarnpkg.com/getting-started/install/)
- [HardHat](https://hardhat.org/hardhat-runner/docs/getting-started/)
- [Docker](https://docs.docker.com/get-docker/) (optional)

Now that you have all the prerequisites installed, you can setup Garden locally. So let's get started!

### Setup

Garden can be setup locally using Hardhat Network or Docker. You can choose the method that suits you best.

> The Docker method is helpful for users who do not want to install the prerequisites on their local machine.

#### Hardhat Network

```bash
# Clone the repository
git clone https://github.com/gardenfi/garden-sol.git
cd garden-sol

# Install dependencies
yarn install

# Start the Hardhat network in another terminal
npx hardhat node

# Deploy the contracts
npx hardhat ignition deploy ignition/modules/fullDeploy.ts --network hardhat --reset
```

#### Docker

```bash
# Clone the repository
git clone https://github.com/gardenfi/garden-sol.git
cd garden-sol

# Build the Docker image
docker build -t garden-sol .

# Run the Docker container
docker run -it garden-sol
```

### Testing

Garden has a comprehensive test suite that covers all the Smart Contracts and Bitcoin Scripts. It ensures that the code is working as expected and there are no regressions.

```bash
# Clone the repository
git clone https://github.com/gardenfi/garden-sol.git
cd garden-sol

# Install dependencies
yarn install

# Run the tests
npx hardhat test

# Run the coverage (optional)
npx hardhat coverage
```

## Security

If you discover a security vulnerability within Garden, please send an e-mail to [[email protected]](mailto:[email protected]). We take these issues very seriously and will respond promptly.

You may view our full security and bug bounty policy [here](https://docs.garden.finance/home/security/bug-bounty).

## License
This project is licensed under the MIT License.

This project is licensed under the [MIT License](./LICENSE).