Skip to content

Commit

Permalink
update docs + readme
Browse files Browse the repository at this point in the history
  • Loading branch information
caglacelik committed Dec 4, 2024
1 parent 71d5f1b commit 9405ff2
Show file tree
Hide file tree
Showing 20 changed files with 467 additions and 864 deletions.
13 changes: 1 addition & 12 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
# Deployer key (REQUIRED)
PUBLIC_KEY=

### Base URLs ###
# Mainnet
BASE_MAIN_RPC_URL=

# Testnet
BASE_TEST_RPC_URL=https://sepolia.base.org

# Blockscout API Key (RQUIRED FOR CONTRACT VERIFICATION)
# Foundry expects the API key to be defined as ETHERSCAN_API_KEY
ETHERSCAN_API_KEY=
PUBLIC_KEY=change_me
88 changes: 41 additions & 47 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
BuyerAgentTest:test_InBuyPhase() (gas: 182615337)
BuyerAgentTest:test_InSellPhase() (gas: 182593663)
BuyerAgentTest:test_RevertWhen_SetAmountPerRoundInBuyPhase() (gas: 182596518)
BuyerAgentTest:test_RevertWhen_SetFeeWithInvalidRoyalty() (gas: 182603480)
BuyerAgentTest:test_RevertWhen_SetRoyaltyInSellPhase() (gas: 182595095)
BuyerAgentTest:test_RevertWhen_WithdrawByAnotherOwner() (gas: 182621624)
BuyerAgentTest:test_RevertWhen_WithdrawInBuyPhase() (gas: 182608980)
BuyerAgentTest:test_SetRoyaltyAndAmountPerRound() (gas: 182604536)
BuyerAgentTest:test_WithdrawInWithdrawPhase() (gas: 182585003)
DeployTest:test_Deploy() (gas: 101371)
LLMOracleCoordinatorTest:test_Deployment() (gas: 86478543)
LLMOracleCoordinatorTest:test_RegisterOracles() (gas: 86763309)
LLMOracleCoordinatorTest:test_ValidatorIsGenerator() (gas: 87180676)
LLMOracleCoordinatorTest:test_WithValidation() (gas: 87839545)
LLMOracleCoordinatorTest:test_WithoutValidation() (gas: 87420651)
LLMOracleRegistryTest:test_Deployment() (gas: 18798876)
LLMOracleRegistryTest:test_RegisterGeneratorOracle() (gas: 19137915)
LLMOracleRegistryTest:test_RegisterValidatorOracle() (gas: 19137984)
LLMOracleRegistryTest:test_RevertWhen_RegisterSameGeneratorTwice() (gas: 19141313)
LLMOracleRegistryTest:test_RevertWhen_RegistryHasNotApprovedByOracle() (gas: 18938187)
LLMOracleRegistryTest:test_RevertWhen_UnregisterSameGeneratorTwice() (gas: 19157453)
LLMOracleRegistryTest:test_UnregisterOracle() (gas: 19154341)
LLMOracleRegistryTest:test_WithdrawStakesAfterUnregistering() (gas: 19179317)
SwanIntervalsTest:test_ChangeCycleTime() (gas: 184999199)
SwanIntervalsTest:test_InBuyPhase() (gas: 182573254)
SwanIntervalsTest:test_InSellPhase() (gas: 182568456)
SwanIntervalsTest:test_InWithdrawPhase() (gas: 182576467)
SwanTest:test_CreateBuyerAgents() (gas: 183760248)
SwanTest:test_Deployment() (gas: 179280562)
SwanTest:test_PurchaseAnAsset() (gas: 188748932)
SwanTest:test_RelistAsset() (gas: 187998184)
SwanTest:test_RevertWhen_CreateBuyerWithInvalidRoyalty() (gas: 179349648)
SwanTest:test_RevertWhen_ListInWithdrawPhase() (gas: 183823955)
SwanTest:test_RevertWhen_ListMoreThanMaxAssetCount() (gas: 187892487)
SwanTest:test_RevertWhen_PurchaseByAnotherBuyer() (gas: 187906998)
SwanTest:test_RevertWhen_PurchaseInSellPhase() (gas: 187890335)
SwanTest:test_RevertWhen_PurchaseMoreThanAmountPerRound() (gas: 188775426)
SwanTest:test_RevertWhen_RelistAlreadyPurchasedAsset() (gas: 188743009)
SwanTest:test_RevertWhen_RelistByAnotherSeller() (gas: 187888798)
SwanTest:test_RevertWhen_RelistInBuyPhase() (gas: 187920803)
SwanTest:test_RevertWhen_RelistInTheSameRound() (gas: 187893814)
SwanTest:test_RevertWhen_RelistInWithdrawPhase() (gas: 187920820)
SwanTest:test_SetAmountPerRound() (gas: 183801616)
SwanTest:test_SetFactories() (gas: 183318192)
SwanTest:test_SetMarketParameters() (gas: 183900237)
SwanTest:test_SetOracleParameters() (gas: 183743049)
SwanTest:test_UpdateState() (gas: 189350579)
BuyerAgentTest:test_InBuyPhase() (gas: 4504258)
BuyerAgentTest:test_InSellPhase() (gas: 4472291)
BuyerAgentTest:test_RevertWhen_SetAmountPerRoundInBuyPhase() (gas: 4483755)
BuyerAgentTest:test_RevertWhen_SetFeeWithInvalidRoyalty() (gas: 4492886)
BuyerAgentTest:test_RevertWhen_SetRoyaltyInSellPhase() (gas: 4473243)
BuyerAgentTest:test_RevertWhen_WithdrawByAnotherOwner() (gas: 4504563)
BuyerAgentTest:test_RevertWhen_WithdrawInBuyPhase() (gas: 4511184)
BuyerAgentTest:test_SetRoyaltyAndAmountPerRound() (gas: 4494097)
BuyerAgentTest:test_WithdrawInWithdrawPhase() (gas: 4474465)
DeployTest:test_Deploy() (gas: 101342)
InvariantTest:invariant_AssetPriceRange() (runs: 256, calls: 128000, reverts: 114801)
InvariantTest:invariant_BuyerAgentFeeRoyalty() (runs: 256, calls: 128000, reverts: 114890)
InvariantTest:invariant_MaxAssetCount() (runs: 256, calls: 128000, reverts: 115004)
InvariantTest:invariant_OwnerIsAnOperator() (runs: 256, calls: 128000, reverts: 114875)
SwanFuzz:testFuzz_CalculateRoyalties(uint256,uint256,uint256) (runs: 256, μ: 4478247, ~: 4478369)
SwanFuzz:testFuzz_ChangeCycleTime(uint256,uint256,uint256,uint256,uint256,uint256) (runs: 256, μ: 6920247, ~: 6921025)
SwanFuzz:testFuzz_ListAsset(string,string,bytes,uint256,string,string,uint96,uint256) (runs: 256, μ: 3922593, ~: 3933255)
SwanFuzz:testFuzz_TransferOwnership(address) (runs: 256, μ: 45378, ~: 45378)
SwanIntervalsTest:test_InBuyPhase() (gas: 4484235)
SwanIntervalsTest:test_InSellPhase() (gas: 4472621)
SwanIntervalsTest:test_InWithdrawPhase() (gas: 4488191)
SwanTest:test_CreateBuyerAgents() (gas: 5663905)
SwanTest:test_PurchaseAnAsset() (gas: 11220979)
SwanTest:test_RelistAsset() (gas: 10183767)
SwanTest:test_RevertWhen_CreateBuyerWithInvalidRoyalty() (gas: 1619856)
SwanTest:test_RevertWhen_ListInWithdrawPhase() (gas: 5743065)
SwanTest:test_RevertWhen_ListMoreThanMaxAssetCount() (gas: 10051316)
SwanTest:test_RevertWhen_PurchaseByAnotherBuyer() (gas: 10073950)
SwanTest:test_RevertWhen_PurchaseInSellPhase() (gas: 10048903)
SwanTest:test_RevertWhen_PurchaseMoreThanAmountPerRound() (gas: 11265761)
SwanTest:test_RevertWhen_RelistAlreadyPurchasedAsset() (gas: 11222356)
SwanTest:test_RevertWhen_RelistByAnotherSeller() (gas: 10059833)
SwanTest:test_RevertWhen_RelistInBuyPhase() (gas: 10094987)
SwanTest:test_RevertWhen_RelistInTheSameRound() (gas: 10052006)
SwanTest:test_RevertWhen_RelistInWithdrawPhase() (gas: 10094678)
SwanTest:test_SetAmountPerRound() (gas: 5720554)
SwanTest:test_SetFactories() (gas: 5172073)
SwanTest:test_SetMarketParameters() (gas: 5843489)
SwanTest:test_SetOracleParameters() (gas: 5665639)
SwanTest:test_TransferOwnership() (gas: 55405)
SwanTest:test_UpdateState() (gas: 11985754)
73 changes: 0 additions & 73 deletions Makefile

This file was deleted.

73 changes: 38 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
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.

## Compile

Compile the contracts with:

```sh
make build
forge build
```

> [!NOTE]
>
> Please prepare a valid `.env` according to `.env.example` before running tests.
> 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`.
## Test

Run tests on forked base-sepolia with:
Run tests on local:

```sh
make test
forge test
```

Run invariant tests on local with:
or on any other evm chain:

```sh
make test-inv
forge test --rpc-url <CHAIN_RPC_URL>
```

## Deployment
Expand All @@ -38,13 +40,12 @@ Import your `PUBLIC_KEY` and `ETHERSCAN_API_KEY` to env file.
Create keystores for deployment. [See more for keystores](https://eips.ethereum.org/EIPS/eip-2335)

```sh
make local-key
cast wallet import <FILE_NAME_OF_YOUR_KEYSTORE> --interactive
```

or for Base Sepolia
You can see your wallets with:

```sh
make base-sepolia-key
cast wallet list
```

> [!NOTE]
Expand All @@ -57,49 +58,51 @@ Enter your private key (associated with the public key you added to env file) an

> [!NOTE]
>
> If you want to deploy contracts on localhost please provide localhost public key for the command above.
> If you want to deploy contracts on localhost please provide local public key for the command above.
**Step 4.** Required only for local deployment.

Start a local node with:

```sh
make anvil
anvil
```

**Step 5.**
Deploy the contracts on localhost (forked Base Sepolia by default) using Deploy script:
Deploy the contracts on local with:

```sh
make deploy
forge script ./script/Deploy.s.sol:Deploy --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_PUBLIC_KEY> --broadcast
```

or Base Sepolia with the command below:
or for instant verification use:

```sh
make deploy base-sepolia
forge script ./script/Deploy.s.sol:Deploy --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_PUBLIC_KEY> --broadcast --verify --verifier <etherscan|blockscout|sourcify>
```

Deployment for another chain add `--rpc-url <CHAIN_URL>` to commands above.

You can see deployed contract addresses under the `deployment/<chainid>.json`

## Verify Contract

Verify contract manually with:

```sh
make verify base-sepolia <contractAddress> <contractName>
forge verify-contract <CONTRACT_ADDRESS> src/$<CONTRACT_NAME>.sol:<CONTRACT_NAME> --verifier <etherscan|blockscout|sourcify>
```

## Coverage

Check coverages with:

```sh
bash coverage.sh
forge clean && bash coverage.sh
```
or to see summarized coverages on terminal:

```sh
make cov
forge clean && forge coverage --no-match-coverage "(test|mock|script)"
```

You can see coverages under the coverage directory.
Expand All @@ -109,43 +112,43 @@ You can see coverages under the coverage directory.
Get storage layout with:

```sh
bash storage.sh
forge clean && bash storage.sh
```

You can see storage layouts under the storage directory.

## Format
## Gas Snapshot

Format code with:
Take the gas snapshot with:

```sh
make fmt
forge clean && forge snapshot
```

## Update
You can see the snapshot `.gas-snapshot` file in the current directory.

Update modules with:
## Format

Format code with:

```sh
make update
forge fmt
```

## Gas Snapshot
## Generate documentation

Take the gas snapshot with:
Generate documentation with:

```sh
make snapshot
forge doc
```

You can see the snapshot `.gas-snapshot` file in the current directory.

## Generate documentation
## Update

Generate documentation with:
Update modules with:

```sh
make doc
forge update
```

You can see the documentation under the `docs/` directory.
Loading

0 comments on commit 9405ff2

Please sign in to comment.