-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
349 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,6 @@ storage/ | |
|
||
# Dotenv file | ||
.env | ||
|
||
# appleeeee | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,74 @@ | ||
# Swan Protocol | ||
Swan is a **Decentralized Protocol** where AI agents (buyers) dynamically interact with asset creators. Agents operate with budgets to purchase assets that match their objectives. Asset creators design assets to align with buyers’ needs to convince the LLM to buy their asset/assets. | ||
<p align="center"> | ||
<img src="https://raw.githubusercontent.com/firstbatchxyz/.github/refs/heads/master/branding/swan-logo-square.svg" alt="logo" width="168"> | ||
</p> | ||
|
||
<p align="center"> | ||
<h1 align="center"> | ||
Swan Protocol | ||
</h1> | ||
<p align="center"> | ||
<i>Simulated Worlds with AI Narratives.</i> | ||
</p> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://opensource.org/licenses/Apache-2-0" target="_blank"> | ||
<img alt="License: Apache 2.0" src="https://img.shields.io/badge/license-Apache_2.0-7CB9E8.svg"> | ||
</a> | ||
<a href="./.github/workflows/test.yml" target="_blank"> | ||
<img alt="Workflow: Tests" src="https://github.com/firstbatchxyz/dria-oracle-contracts/actions/workflows/test.yml/badge.svg?branch=master"> | ||
</a> | ||
<a href="https://discord.gg/dria" target="_blank"> | ||
<img alt="Discord" src="https://dcbadge.vercel.app/api/server/dria?style=flat"> | ||
</a> | ||
</p> | ||
|
||
Swan is a decentralized protocol where AI agents dynamically interact with users who create artifacts inlined with agent's narratives. | ||
|
||
## Installation | ||
|
||
First, make sure you have the requirements: | ||
|
||
- We are using [Foundry](https://book.getfoundry.sh/), so make sure you [install](https://book.getfoundry.sh/getting-started/installation) it first. | ||
- Upgradable contracts make use of [NodeJS](https://nodejs.org/en), so you should [install](https://nodejs.org/en/download/package-manager) that as well. | ||
|
||
Clone the repository: | ||
|
||
## Compile | ||
```sh | ||
git clone [email protected]:firstbatchxyz/swan-contracts.git | ||
``` | ||
|
||
Install dependencies with: | ||
|
||
```sh | ||
forge install | ||
``` | ||
|
||
Compile the contracts with: | ||
|
||
```sh | ||
forge clean && forge build | ||
``` | ||
|
||
> [!NOTE] | ||
> | ||
> Openzeppelin' foundry modules expect that running `forge clean` before running Foundry script or test or include `--force` option when running `forge script` or `forge test`. | ||
### Upgradability | ||
|
||
## Test | ||
We are using [openzeppelin-foundry-upgrades](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades) library. To make sure upgrades are **safe**, you must do one of the following before you run `forge script` or `forge test` (as per their [docs](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades?tab=readme-ov-file#before-running)): | ||
|
||
Run tests on local: | ||
- `forge clean` beforehand, e.g. `forge clean && forge test` | ||
- include `--force` option when running, e.g. `forge test --force` | ||
|
||
```sh | ||
forge clean && forge test | ||
``` | ||
> Note that for some users this may fail (see [issue](https://github.com/firstbatchxyz/dria-oracle-contracts/issues/16)) due to a missing NPM package called `@openzeppelin/upgrades-core`. To fix it, do: | ||
> | ||
> ```sh | ||
> npm install @openzeppelin/upgrades-core@latest -g | ||
> ``` | ||
### Updates | ||
or on any other evm chain: | ||
To update contracts to the latest library versions, use: | ||
```sh | ||
forge clean && forge test --rpc-url <RPC_URL> | ||
forge update | ||
``` | ||
## Deployment | ||
|
@@ -42,6 +86,7 @@ Create keystores for deployment. [See more for keystores](https://eips.ethereum. | |
```sh | ||
cast wallet import <FILE_NAME_OF_YOUR_KEYSTORE> --interactive | ||
``` | ||
|
||
You can see your wallets with: | ||
|
||
```sh | ||
|
@@ -66,18 +111,17 @@ Deploy the contract with: | |
```sh | ||
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast | ||
``` | ||
|
||
or for instant verification use: | ||
|
||
```sh | ||
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL> | ||
``` | ||
|
||
> [!NOTE] | ||
> `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`. | ||
> [!NOTE] > `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`. | ||
> | ||
> e.g. | ||
> e.g. | ||
> `https://base-sepolia.blockscout.com/api/` for `Base Sepolia Network` | ||
> | ||
You can see deployed contract addresses under the `deployment/<chainid>.json` | ||
|
||
|
@@ -89,13 +133,28 @@ Verify contract manually with: | |
forge verify-contract <CONTRACT_ADDRESS> src/$<CONTRACT_NAME>.sol:<CONTRACT_NAME> --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL> | ||
``` | ||
|
||
## Coverage | ||
## Testing & Diagnostics | ||
|
||
Run tests on local network: | ||
|
||
```sh | ||
forge clean && forge test | ||
``` | ||
|
||
or fork an existing chain and run the tests on it: | ||
|
||
```sh | ||
forge clean && forge test --rpc-url <RPC_URL> | ||
``` | ||
|
||
### Coverage | ||
|
||
Check coverages with: | ||
|
||
```sh | ||
forge clean && bash coverage.sh | ||
``` | ||
|
||
or to see summarized coverages on terminal: | ||
|
||
```sh | ||
|
@@ -104,7 +163,7 @@ forge clean && forge coverage --no-match-coverage "(test|mock|script)" | |
|
||
You can see coverages under the coverage directory. | ||
|
||
## Storage Layout | ||
### Storage Layout | ||
|
||
Get storage layout with: | ||
|
||
|
@@ -114,7 +173,7 @@ forge clean && bash storage.sh | |
|
||
You can see storage layouts under the storage directory. | ||
|
||
## Gas Snapshot | ||
### Gas Snapshot | ||
|
||
Take the gas snapshot with: | ||
|
||
|
@@ -124,28 +183,20 @@ forge clean && forge snapshot | |
|
||
You can see the snapshot `.gas-snapshot` file in the current directory. | ||
|
||
## Format | ||
## Documentation | ||
|
||
Format code with: | ||
|
||
```sh | ||
forge fmt | ||
``` | ||
|
||
## Generate documentation | ||
|
||
Generate documentation with: | ||
We have auto-generated documentation under the [`docs`](./docs) folder, generated with the following command: | ||
|
||
```sh | ||
forge doc | ||
``` | ||
|
||
## Update | ||
|
||
Update modules with: | ||
We provide an MDBook template over it, which you can open via: | ||
|
||
```sh | ||
forge update | ||
cd docs && mdbook serve --open | ||
``` | ||
|
||
You can see the documentation under the `docs/` directory. | ||
## License | ||
|
||
We are using Apache-2.0 license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.