From 24e0365940f0434545a9c39573dfdf6b9975fc88 Mon Sep 17 00:00:00 2001 From: erhant Date: Wed, 18 Dec 2024 17:34:41 +0300 Subject: [PATCH] update docs --- .gas-snapshot | 86 ++++---- .gitignore | 1 + README.md | 120 ++++++----- coverage.sh | 24 ++- deployment/.gitignore | 1 + deployment/31337.json | 26 --- deployment/README.md | 1 + lcov.info | 450 +++++++++++++++++++++--------------------- storage.sh | 9 +- 9 files changed, 366 insertions(+), 352 deletions(-) mode change 100644 => 100755 coverage.sh create mode 100644 deployment/.gitignore delete mode 100644 deployment/31337.json create mode 100644 deployment/README.md mode change 100644 => 100755 storage.sh diff --git a/.gas-snapshot b/.gas-snapshot index c9beae8..2b54bbe 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,44 +1,44 @@ -AIAgentTest:test_InBuyPhase() (gas: 4504153) -AIAgentTest:test_InListingPhase() (gas: 4472120) -AIAgentTest:test_RevertWhen_SetAmountPerRoundInBuyPhase() (gas: 4483655) -AIAgentTest:test_RevertWhen_SetFeeWithInvalidRoyalty() (gas: 4492808) -AIAgentTest:test_RevertWhen_SetRoyaltyInListingPhase() (gas: 4473166) -AIAgentTest:test_RevertWhen_WithdrawByAnotherOwner() (gas: 4504441) -AIAgentTest:test_RevertWhen_WithdrawInBuyPhase() (gas: 4511039) -AIAgentTest:test_SetRoyaltyAndAmountPerRound() (gas: 4494015) -AIAgentTest:test_WithdrawInWithdrawPhase() (gas: 4474361) DeployTest:test_Deploy() (gas: 22076) -InvariantTest:invariant_AgentFeeRoyalty() (runs: 20, calls: 10000, reverts: 8980) -InvariantTest:invariant_ArtifactPriceRange() (runs: 20, calls: 10000, reverts: 9028) -InvariantTest:invariant_MaxArtifactCount() (runs: 20, calls: 10000, reverts: 8998) -InvariantTest:invariant_OwnerIsAnOperator() (runs: 20, calls: 10000, reverts: 8992) -SwanFuzzTest:testFuzz_CalculateRoyalties(uint256,uint256,uint256) (runs: 100, μ: 4478115, ~: 4478236) -SwanFuzzTest:testFuzz_ChangeCycleTime(uint256,uint256,uint256,uint256,uint256,uint256) (runs: 100, μ: 6920555, ~: 6921298) -SwanFuzzTest:testFuzz_ListArtifact(string,string,bytes,uint256,string,string,uint96,uint256) (runs: 100, μ: 3923970, ~: 3924013) -SwanFuzzTest:testFuzz_TransferOwnership(address) (runs: 100, μ: 45356, ~: 45356) -SwanIntervalsTest:test_InBuyPhase() (gas: 4484185) -SwanIntervalsTest:test_InListingPhase() (gas: 4472550) -SwanIntervalsTest:test_InWithdrawPhase() (gas: 4487549) -SwanTest:test_CreateAIAgents() (gas: 5663937) -SwanTest:test_PurchaseAnArtifact() (gas: 11297765) -SwanTest:test_RelistArtifact() (gas: 10251837) -SwanTest:test_RevertWhen_CreateAgentWithInvalidRoyalty() (gas: 1619957) -SwanTest:test_RevertWhen_ListInWithdrawPhase() (gas: 5749933) -SwanTest:test_RevertWhen_ListMoreThanmaxArtifactCount() (gas: 10119397) -SwanTest:test_RevertWhen_PurchaseByAnotherAgent() (gas: 10142029) -SwanTest:test_RevertWhen_PurchaseInListingPhase() (gas: 10116892) -SwanTest:test_RevertWhen_PurchaseMoreThanAmountPerRound() (gas: 11333279) -SwanTest:test_RevertWhen_RelistAlreadyPurchasedArtifact() (gas: 11289853) -SwanTest:test_RevertWhen_RelistByAnotherSeller() (gas: 10127804) -SwanTest:test_RevertWhen_RelistInBuyPhase() (gas: 10163113) -SwanTest:test_RevertWhen_RelistInTheSameRound() (gas: 10119934) -SwanTest:test_RevertWhen_RelistInWithdrawPhase() (gas: 10162737) -SwanTest:test_RevertWhen_RelistMoreThanMaxArtifactCount() (gas: 13983200) -SwanTest:test_RevertWhen_SetMarketParametersWithInvalidFee() (gas: 1539671) -SwanTest:test_RevertWhen_UpgradeByNonOwner() (gas: 1543316) -SwanTest:test_SetAmountPerRound() (gas: 5720733) -SwanTest:test_SetFactories() (gas: 5172184) -SwanTest:test_SetMarketParameters() (gas: 5843554) -SwanTest:test_SetOracleParameters() (gas: 5665825) -SwanTest:test_TransferOwnership() (gas: 55416) -SwanTest:test_UpdateState() (gas: 12066139) \ No newline at end of file +InvariantTest:invariant_AgentFeeRoyalty() (runs: 20, calls: 10000, reverts: 8972) +InvariantTest:invariant_ArtifactPriceRange() (runs: 20, calls: 10000, reverts: 9002) +InvariantTest:invariant_MaxArtifactCount() (runs: 20, calls: 10000, reverts: 8966) +InvariantTest:invariant_OwnerIsAnOperator() (runs: 20, calls: 10000, reverts: 8926) +SwanAgentTest:test_InBuyPhase() (gas: 4504405) +SwanAgentTest:test_InListingPhase() (gas: 4472350) +SwanAgentTest:test_RevertWhen_SetAmountPerRoundInBuyPhase() (gas: 4483903) +SwanAgentTest:test_RevertWhen_SetFeeWithInvalidRoyalty() (gas: 4493071) +SwanAgentTest:test_RevertWhen_SetRoyaltyInListingPhase() (gas: 4473396) +SwanAgentTest:test_RevertWhen_WithdrawByAnotherOwner() (gas: 4504683) +SwanAgentTest:test_RevertWhen_WithdrawInBuyPhase() (gas: 4511301) +SwanAgentTest:test_SetRoyaltyAndAmountPerRound() (gas: 4494282) +SwanAgentTest:test_WithdrawInWithdrawPhase() (gas: 4474615) +SwanFuzzTest:testFuzz_CalculateRoyalties(uint256,uint256,uint256) (runs: 100, μ: 4478317, ~: 4478436) +SwanFuzzTest:testFuzz_ChangeCycleTime(uint256,uint256,uint256,uint256,uint256,uint256) (runs: 100, μ: 6920941, ~: 6921698) +SwanFuzzTest:testFuzz_ListArtifact(string,string,bytes,uint256,string,string,uint96,uint256) (runs: 100, μ: 3924204, ~: 3924238) +SwanFuzzTest:testFuzz_TransferOwnership(address) (runs: 100, μ: 45365, ~: 45365) +SwanIntervalsTest:test_InBuyPhase() (gas: 4484429) +SwanIntervalsTest:test_InListingPhase() (gas: 4472772) +SwanIntervalsTest:test_InWithdrawPhase() (gas: 4487796) +SwanTest:test_CreateSwanAgents() (gas: 5664526) +SwanTest:test_PurchaseAnArtifact() (gas: 11299061) +SwanTest:test_RelistArtifact() (gas: 10252952) +SwanTest:test_RevertWhen_CreateAgentWithInvalidRoyalty() (gas: 1620230) +SwanTest:test_RevertWhen_ListInWithdrawPhase() (gas: 5750553) +SwanTest:test_RevertWhen_ListMoreThanmaxArtifactCount() (gas: 10120420) +SwanTest:test_RevertWhen_PurchaseByAnotherAgent() (gas: 10143076) +SwanTest:test_RevertWhen_PurchaseInListingPhase() (gas: 10117930) +SwanTest:test_RevertWhen_PurchaseMoreThanAmountPerRound() (gas: 11334511) +SwanTest:test_RevertWhen_RelistAlreadyPurchasedArtifact() (gas: 11291127) +SwanTest:test_RevertWhen_RelistByAnotherSeller() (gas: 10128856) +SwanTest:test_RevertWhen_RelistInBuyPhase() (gas: 10164182) +SwanTest:test_RevertWhen_RelistInTheSameRound() (gas: 10120976) +SwanTest:test_RevertWhen_RelistInWithdrawPhase() (gas: 10163806) +SwanTest:test_RevertWhen_RelistMoreThanMaxArtifactCount() (gas: 13984372) +SwanTest:test_RevertWhen_SetMarketParametersWithInvalidFee() (gas: 1539932) +SwanTest:test_RevertWhen_UpgradeByNonOwner() (gas: 1543580) +SwanTest:test_SetAmountPerRound() (gas: 5721328) +SwanTest:test_SetFactories() (gas: 5172520) +SwanTest:test_SetMarketParameters() (gas: 5844131) +SwanTest:test_SetOracleParameters() (gas: 5666393) +SwanTest:test_TransferOwnership() (gas: 55434) +SwanTest:test_UpdateState() (gas: 12067589) \ No newline at end of file diff --git a/.gitignore b/.gitignore index c0dc496..433c961 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ storage/ # Dotenv file .env +.preset.sh # appleeeee .DS_Store diff --git a/README.md b/README.md index 88f7afe..3b6252c 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ First, make sure you have the requirements: Clone the repository: ```sh -git clone git@github.com:firstbatchxyz/swan-contracts.git +git clone git@github.com:firstbatchxyz/dria-oracle-contracts.git ``` Install dependencies with: @@ -52,11 +52,13 @@ forge clean && forge build ### Upgradability -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)): +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 (as per their [docs](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades?tab=readme-ov-file#before-running)) before you run `forge script` or `forge test`: - `forge clean` beforehand, e.g. `forge clean && forge test` - include `--force` option when running, e.g. `forge test --force` +> [!NOTE] +> > 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 @@ -71,67 +73,89 @@ To update contracts to the latest library versions, use: forge update ``` -## Deployment +## Usage -**Step 1.** -Import your `ETHERSCAN_API_KEY` to env file. +### Setup -> [!NOTE] -> -> Foundry expects the API key to be defined as `ETHERSCAN_API_KEY` even though you're using another explorer. +To be able to deploy & use our contracts, we need two things: + +- [Ethereum Wallet](#create-wallet) +- [RPC endpoint](#prepare-rpc-endpoint) -**Step 2.** -Create keystores for deployment. [See more for keystores](https://eips.ethereum.org/EIPS/eip-2335) +### Create Wallet + +We use keystores for wallet management, with the help of [`cast wallet`](https://book.getfoundry.sh/reference/cast/wallet-commands) command. + +Use the command below to create your keystore. The command will prompt for your **private key**, and a **password** to encrypt the keystore itself. ```sh -cast wallet import --interactive +cast wallet import --interactive ``` -You can see your wallets with: +> [!ALERT] +> +> Note that you will need to enter the password when you use this keystore. + +You can see your keystores under the default directory (`~/.foundry/keystores`) with the command: ```sh cast wallet list ``` -> [!NOTE] -> -> Recommended to create keystores on directly on your shell. -> You HAVE to type your password on the terminal to be able to use your keys. (e.g when deploying a contract) +### Prepare RPC Endpoint -**Step 3.** -Enter your private key (associated with your address) and password on terminal. You'll see your address on terminal. +To interact with the blockchain, we require an RPC endpoint. You can get one from: -> [!NOTE] -> -> If you want to deploy contracts on localhost please provide local address for the command above. +- [Alchemy](https://www.alchemy.com/) +- [Infura](https://www.infura.io/) +- [(see more)](https://www.alchemy.com/best/rpc-node-providers) + +You will use this endpoint for the commands that interact with the blockchain, such as deploying and upgrading; or while doing fork tests. + +### Deploy & Verify Contract -**Step 4.** Deploy the contract with: ```sh -forge clean && forge script ./script/Deploy.s.sol:Deploy --rpc-url --account --sender --broadcast +forge clean && forge script ./script/Deploy.s.sol:Deploy \ +--rpc-url \ +--account \ +--broadcast ``` -or for instant verification use: +You can see deployed contract addresses under the `deployment/.json` + +You can verify the contract during deployment by adding the verification arguments as well: ```sh -forge clean && forge script ./script/Deploy.s.sol:Deploy --rpc-url --account --sender --broadcast --verify --verifier --verifier-url +forge clean && forge script ./script/Deploy.s.sol:Deploy \ +--rpc-url \ +--account \ +--broadcast \ +--verify --verifier blockscout \ +--verifier-url ``` -> [!NOTE] > `` should be expolorer's homepage url. Forge reads your `` from .env file so you don't need to add this at the end of ``. -> -> e.g. -> `https://base-sepolia.blockscout.com/api/` for `Base Sepolia Network` +You can verify an existing contract with: -You can see deployed contract addresses under the `deployment/.json` +```sh +forge verify-contract ./src/.sol: \ +--verifier blockscout \ +--verifier-url +``` -## Verify Contract +Note that the `--verifier-url` value should be the target explorer's homepage URL. Some example URLs are: -Verify contract manually with: +- `https://base.blockscout.com/api/` for Base (Mainnet) +- `https://base-sepolia.blockscout.com/api/` for Base Sepolia (Testnet) -```sh -forge verify-contract src/$.sol: --verifier --verifier-url -``` +> [!NOTE] +> +> URL should not contain the API key! Foundry will read your `ETHERSCAN_API_KEY` from environment. + +> [!NOTE] +> +> The `--verifier` can accept any of the following: `etherscan`, `blockscout`, `sourcify`, `oklink`. We are using Blockscout most of the time. ## Testing & Diagnostics @@ -139,6 +163,9 @@ Run tests on local network: ```sh forge clean && forge test + +# or -vvv to show reverts in detail +forge clean && forge test -vvv ``` or fork an existing chain and run the tests on it: @@ -147,31 +174,29 @@ or fork an existing chain and run the tests on it: forge clean && forge test --rpc-url ``` -### Coverage +### Code Coverage -Check coverages with: +We have a script that generates the coverage information as an HTML page. This script requires [`lcov`](https://linux.die.net/man/1/lcov) and [`genhtml`](https://linux.die.net/man/1/genhtml) command line tools. To run, do: ```sh -forge clean && bash coverage.sh +forge clean && ./coverage.sh ``` -or to see summarized coverages on terminal: +Alternatively, you can see a summarized text-only output as well: ```sh forge clean && forge coverage --no-match-coverage "(test|mock|script)" ``` -You can see coverages under the coverage directory. - ### Storage Layout Get storage layout with: ```sh -forge clean && bash storage.sh +./storage.sh ``` -You can see storage layouts under the storage directory. +You can see storage layouts under the [`storage`](./storage/) directory. ### Gas Snapshot @@ -185,16 +210,13 @@ You can see the snapshot `.gas-snapshot` file in the current directory. ## Documentation -We have auto-generated documentation under the [`docs`](./docs) folder, generated with the following command: +We have auto-generated MDBook documentations under the [`docs`](./docs) folder, generated with the following command: ```sh forge doc -``` -We provide an MDBook template over it, which you can open via: - -```sh -cd docs && mdbook serve --open +# serves the book as well +forge doc --serve ``` ## License diff --git a/coverage.sh b/coverage.sh old mode 100644 new mode 100755 index f92532c..15612c1 --- a/coverage.sh +++ b/coverage.sh @@ -3,14 +3,28 @@ # exit on error set -e -# Run forge coverage +# give error if `lcov` is not installed +if ! command -v lcov &> /dev/null +then + echo "lcov could not be found. Please install lcov" + exit +fi + +# give error if `genhtml` is not installed +if ! command -v genhtml &> /dev/null +then + echo "genhtml could not be found. Please install lcov" + exit +fi + +# generate coverage info forge coverage \ --report lcov \ --report summary \ --no-match-coverage "(test|mock|script)" -# Install lcov -brew install lcov +# generate HTML report from lcov.info +genhtml lcov.info -o coverage --branch-coverage --ignore-errors inconsistent,category,corrupt -# Generate HTML report from lcov.info -genhtml lcov.info -o coverage --branch-coverage --ignore-errors inconsistent,category,corrupt \ No newline at end of file +# open report +open coverage/index.html diff --git a/deployment/.gitignore b/deployment/.gitignore new file mode 100644 index 0000000..e6a0926 --- /dev/null +++ b/deployment/.gitignore @@ -0,0 +1 @@ +31337.json diff --git a/deployment/31337.json b/deployment/31337.json deleted file mode 100644 index 3a5adfa..0000000 --- a/deployment/31337.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "AIAgentFactory": { - "addr": "0x34a1d3fff3958843c43ad80f30b94c510645c316" - }, - "LLMOracleRegistry": { - "proxyAddr": "0xbb2180ebd78ce97360503434ed37fcf4a1df61c3", - "implAddr": "0xa8452ec99ce0c64f20701db7dd3abdb607c00496" - }, - "LLMOracleCoordinator": { - "proxyAddr": "0x50eef481cae4250d252ae577a09bf514f224c6c4", - "implAddr": "0xdb8cff278adccf9e9b5da745b44e754fc4ee3c76" - }, - "ArtifactFactory": { - "addr": "0x90193c961a926261b756d1e5bb255e67ff9498a1" - }, - "Swan": { - "proxyAddr": "0xdeb1e9a6be7baf84208bb6e10ac9f9bbe1d70809", - "implAddr": "0x62c20aa1e0272312bc100b4e23b4dc1ed96dd7d1" - }, - "SwanAgentFactory": { - "addr": "0x34a1d3fff3958843c43ad80f30b94c510645c316" - }, - "SwanArtifactFactory": { - "addr": "0x90193c961a926261b756d1e5bb255e67ff9498a1" - } -} \ No newline at end of file diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 0000000..1f5296f --- /dev/null +++ b/deployment/README.md @@ -0,0 +1 @@ +# Deployment Commands diff --git a/lcov.info b/lcov.info index d336526..3a4c8ad 100644 --- a/lcov.info +++ b/lcov.info @@ -1,22 +1,159 @@ TN: -SF:src/AIAgent.sol -DA:12,1251 -FN:12,AIAgentFactory.deploy -FNDA:1251,AIAgentFactory.deploy -DA:19,1251 +SF:src/Swan.sol +DA:117,44 +FN:117,Swan.constructor +FNDA:44,Swan.constructor +DA:118,44 +DA:128,1 +FN:128,Swan._authorizeUpgrade +FNDA:1,Swan._authorizeUpgrade +DA:133,647 +FN:133,Swan.initialize +FNDA:647,Swan.initialize +DA:142,44 +DA:144,44 +BRDA:144,0,0,- +BRDA:144,0,1,44 +DA:147,44 +DA:148,44 +DA:151,44 +DA:152,44 +DA:153,44 +DA:154,44 +DA:157,44 +DA:159,44 +DA:165,700 +FN:165,Swan.transferOwnership +FNDA:700,Swan.transferOwnership +DA:166,102 +BRDA:166,1,0,1 +DA:167,1 +DA:170,101 +DA:173,101 +DA:176,101 +DA:186,1238 +FN:186,Swan.createAgent +FNDA:1238,Swan.createAgent +DA:192,1238 +DA:193,660 +DA:195,660 +DA:204,790 +FN:204,Swan.list +FNDA:790,Swan.list +DA:207,790 +DA:208,790 +DA:211,157 +BRDA:211,2,0,1 +DA:212,1 +DA:215,156 +BRDA:215,3,0,1 +DA:216,1 +DA:219,155 +BRDA:219,4,0,13 +DA:220,13 +DA:224,142 +DA:225,142 +DA:236,142 +DA:239,142 +DA:241,142 +DA:248,595 +FN:248,Swan.relist +FNDA:595,Swan.relist +DA:249,595 +DA:252,595 +BRDA:252,5,0,588 +DA:253,588 +DA:257,7 +BRDA:257,6,0,1 +DA:258,1 +DA:268,6 +DA:269,6 +BRDA:269,7,0,1 +DA:270,1 +DA:274,5 +BRDA:274,8,0,1 +DA:275,1 +DA:279,4 +DA:280,4 +DA:283,4 +BRDA:283,9,0,2 +DA:284,2 +DA:288,2 +DA:289,2 +BRDA:289,10,0,1 +DA:290,1 +DA:294,1 +DA:305,1 +DA:308,1 +DA:310,1 +DA:314,143 +FN:314,Swan.transferRoyalties +FNDA:143,Swan.transferRoyalties +DA:316,143 +DA:317,143 +DA:318,143 +DA:322,143 +DA:325,143 +DA:328,143 +DA:333,677 +FN:333,Swan.purchase +FNDA:677,Swan.purchase +DA:334,677 +DA:337,677 +BRDA:337,11,0,673 +DA:338,673 +DA:342,4 +BRDA:342,12,0,- +DA:343,0 +DA:347,4 +DA:351,4 +DA:352,4 +DA:355,4 +DA:356,4 +DA:358,4 +DA:365,598 +FN:365,Swan.setFactories +FNDA:598,Swan.setFactories +DA:366,1 +DA:367,1 +DA:371,5 +FN:371,Swan.getListingPrice +FNDA:5,Swan.getListingPrice +DA:372,5 +DA:376,125 +FN:376,Swan.getListedArtifacts +FNDA:125,Swan.getListedArtifacts +DA:377,125 +DA:381,141 +FN:381,Swan.getListing +FNDA:141,Swan.getListing +DA:382,141 +FNF:13 +FNH:13 +LF:88 +LH:87 +BRF:14 +BRH:12 +end_of_record +TN: +SF:src/SwanAgent.sol +DA:12,1264 +FN:12,SwanAgentFactory.deploy +FNDA:1264,SwanAgentFactory.deploy +DA:19,1264 DA:121,2 -FN:121,AIAgent.onlyAuthorized -FNDA:2,AIAgent.onlyAuthorized +FN:121,SwanAgent.onlyAuthorized +FNDA:2,SwanAgent.onlyAuthorized DA:123,2 BRDA:123,0,0,1 DA:124,1 -DA:136,1251 -FN:136,AIAgent.constructor -FNDA:1251,AIAgent.constructor -DA:144,1249 -DA:146,1249 -BRDA:146,1,0,5 -DA:147,5 +DA:136,1264 +FN:136,SwanAgent.constructor +FNDA:1264,SwanAgent.constructor +DA:144,1264 +DA:146,1264 +BRDA:146,1,0,13 +DA:147,13 DA:150,660 DA:151,660 DA:152,660 @@ -26,31 +163,31 @@ DA:155,660 DA:159,660 DA:160,660 DA:169,0 -FN:169,AIAgent.minFundAmount -FNDA:0,AIAgent.minFundAmount +FN:169,SwanAgent.minFundAmount +FNDA:0,SwanAgent.minFundAmount DA:170,1 DA:175,0 -FN:175,AIAgent.oracleResult -FNDA:0,AIAgent.oracleResult +FN:175,SwanAgent.oracleResult +FNDA:0,SwanAgent.oracleResult DA:177,5 BRDA:177,2,0,- DA:178,0 DA:181,5 DA:191,2 -FN:191,AIAgent.oracleStateRequest -FNDA:2,AIAgent.oracleStateRequest +FN:191,SwanAgent.oracleStateRequest +FNDA:2,SwanAgent.oracleStateRequest DA:193,1 DA:195,1 DA:198,1 DA:208,4 -FN:208,AIAgent.oraclePurchaseRequest -FNDA:4,AIAgent.oraclePurchaseRequest +FN:208,SwanAgent.oraclePurchaseRequest +FNDA:4,SwanAgent.oraclePurchaseRequest DA:210,4 DA:212,4 DA:215,4 DA:221,2 -FN:221,AIAgent.updateState -FNDA:2,AIAgent.updateState +FN:221,SwanAgent.updateState +FNDA:2,SwanAgent.updateState DA:223,1 DA:226,1 DA:227,0 @@ -61,8 +198,8 @@ DA:233,1 DA:236,1 DA:238,1 DA:245,7 -FN:245,AIAgent.purchase -FNDA:7,AIAgent.purchase +FN:245,SwanAgent.purchase +FNDA:7,SwanAgent.purchase DA:247,6 DA:250,5 DA:251,1 @@ -82,8 +219,8 @@ DA:274,4 DA:278,3 DA:280,3 DA:287,3 -FN:287,AIAgent.withdraw -FNDA:3,AIAgent.withdraw +FN:287,SwanAgent.withdraw +FNDA:3,SwanAgent.withdraw DA:288,2 DA:292,2 BRDA:292,6,0,1 @@ -92,24 +229,24 @@ BRDA:295,7,0,1 DA:296,1 DA:301,1 DA:306,1 -FN:306,AIAgent.treasury -FNDA:1,AIAgent.treasury +FN:306,SwanAgent.treasury +FNDA:1,SwanAgent.treasury DA:307,2 DA:312,19 -FN:312,AIAgent._checkRoundPhase -FNDA:19,AIAgent._checkRoundPhase +FN:312,SwanAgent._checkRoundPhase +FNDA:19,SwanAgent._checkRoundPhase DA:313,19 DA:314,19 BRDA:314,8,0,3 DA:315,3 DA:318,16 DA:325,1319 -FN:325,AIAgent._computeCycleTime -FNDA:1319,AIAgent._computeCycleTime +FN:325,SwanAgent._computeCycleTime +FNDA:1319,SwanAgent._computeCycleTime DA:326,1319 DA:333,1319 -FN:333,AIAgent._computePhase -FNDA:1319,AIAgent._computePhase +FN:333,SwanAgent._computePhase +FNDA:1319,SwanAgent._computePhase DA:338,1319 DA:339,1319 DA:340,1319 @@ -123,8 +260,8 @@ BRDA:347,10,1,24 DA:348,625 DA:350,24 DA:359,798 -FN:359,AIAgent.getRoundPhase -FNDA:798,AIAgent.getRoundPhase +FN:359,SwanAgent.getRoundPhase +FNDA:798,SwanAgent.getRoundPhase DA:360,819 DA:362,819 BRDA:362,11,0,419 @@ -143,16 +280,16 @@ DA:392,400 DA:394,400 DA:396,400 DA:404,4 -FN:404,AIAgent.setFeeRoyalty -FNDA:4,AIAgent.setFeeRoyalty +FN:404,SwanAgent.setFeeRoyalty +FNDA:4,SwanAgent.setFeeRoyalty DA:405,4 DA:407,3 BRDA:407,12,0,2 DA:408,2 DA:410,1 DA:417,3 -FN:417,AIAgent.setAmountPerRound -FNDA:3,AIAgent.setAmountPerRound +FN:417,SwanAgent.setAmountPerRound +FNDA:3,SwanAgent.setAmountPerRound DA:418,3 DA:420,2 FNF:17 @@ -163,18 +300,18 @@ BRF:16 BRH:14 end_of_record TN: -SF:src/Artifact.sol -DA:11,766 -FN:11,ArtifactFactory.deploy -FNDA:766,ArtifactFactory.deploy -DA:15,766 -DA:27,766 -FN:27,Artifact.constructor -FNDA:766,Artifact.constructor -DA:34,766 -DA:35,766 -DA:38,766 -DA:41,766 +SF:src/SwanArtifact.sol +DA:11,764 +FN:11,SwanArtifactFactory.deploy +FNDA:764,SwanArtifactFactory.deploy +DA:15,764 +DA:27,764 +FN:27,SwanArtifact.constructor +FNDA:764,SwanArtifact.constructor +DA:34,764 +DA:35,764 +DA:38,764 +DA:41,761 FNF:2 FNH:2 LF:7 @@ -183,185 +320,48 @@ BRF:0 BRH:0 end_of_record TN: -SF:src/Swan.sol -DA:116,44 -FN:116,Swan.constructor -FNDA:44,Swan.constructor -DA:117,44 -DA:127,1 -FN:127,Swan._authorizeUpgrade -FNDA:1,Swan._authorizeUpgrade -DA:132,666 -FN:132,Swan.initialize -FNDA:666,Swan.initialize -DA:141,44 -DA:143,44 -BRDA:143,0,0,- -BRDA:143,0,1,44 -DA:146,44 -DA:147,44 -DA:150,44 -DA:151,44 -DA:152,44 -DA:153,44 -DA:156,44 -DA:158,44 -DA:164,736 -FN:164,Swan.transferOwnership -FNDA:736,Swan.transferOwnership -DA:165,102 -BRDA:165,1,0,1 -DA:166,1 -DA:169,101 -DA:172,101 -DA:175,101 -DA:185,1271 -FN:185,Swan.createAgent -FNDA:1271,Swan.createAgent -DA:191,1271 -DA:192,660 -DA:194,660 -DA:203,780 -FN:203,Swan.list -FNDA:780,Swan.list -DA:206,780 -DA:207,780 -DA:210,157 -BRDA:210,2,0,1 -DA:211,1 -DA:214,156 -BRDA:214,3,0,1 -DA:215,1 -DA:218,155 -BRDA:218,4,0,13 -DA:219,13 -DA:223,142 -DA:224,142 -DA:235,142 -DA:238,142 -DA:240,142 -DA:247,682 -FN:247,Swan.relist -FNDA:682,Swan.relist -DA:248,682 -DA:251,682 -BRDA:251,5,0,675 -DA:252,675 -DA:256,7 -BRDA:256,6,0,1 -DA:257,1 -DA:267,6 -DA:268,6 -BRDA:268,7,0,1 -DA:269,1 -DA:273,5 -BRDA:273,8,0,1 -DA:274,1 -DA:278,4 -DA:279,4 -DA:282,4 -BRDA:282,9,0,2 -DA:283,2 -DA:287,2 -DA:288,2 -BRDA:288,10,0,1 -DA:289,1 -DA:293,1 -DA:304,1 -DA:307,1 -DA:309,1 -DA:313,143 -FN:313,Swan.transferRoyalties -FNDA:143,Swan.transferRoyalties -DA:315,143 -DA:316,143 -DA:317,143 -DA:321,143 -DA:324,143 -DA:327,143 -DA:332,697 -FN:332,Swan.purchase -FNDA:697,Swan.purchase -DA:333,697 -DA:336,697 -BRDA:336,11,0,693 -DA:337,693 -DA:341,4 -BRDA:341,12,0,- -DA:342,0 -DA:346,4 -DA:350,4 -DA:351,4 -DA:354,4 -DA:355,4 -DA:357,4 -DA:364,606 -FN:364,Swan.setFactories -FNDA:606,Swan.setFactories -DA:365,1 -DA:366,1 -DA:370,5 -FN:370,Swan.getListingPrice -FNDA:5,Swan.getListingPrice -DA:371,5 -DA:375,125 -FN:375,Swan.getListedArtifacts -FNDA:125,Swan.getListedArtifacts -DA:376,125 -DA:380,141 -FN:380,Swan.getListing -FNDA:141,Swan.getListing -DA:381,141 -FNF:13 -FNH:13 -LF:88 -LH:87 -BRF:14 -BRH:12 -end_of_record -TN: SF:src/SwanManager.sol -DA:60,44 -FN:60,SwanManager.constructor +DA:59,44 +FN:59,SwanManager.constructor FNDA:44,SwanManager.constructor -DA:61,44 -DA:69,1679 -FN:69,SwanManager.getMarketParameters +DA:60,44 +DA:68,1679 +FN:68,SwanManager.getMarketParameters FNDA:1679,SwanManager.getMarketParameters -DA:70,1679 -DA:74,6 -FN:74,SwanManager.getOracleParameters +DA:69,1679 +DA:73,6 +FN:73,SwanManager.getOracleParameters FNDA:6,SwanManager.getOracleParameters -DA:75,6 -DA:81,796 -FN:81,SwanManager.setMarketParameters -FNDA:796,SwanManager.setMarketParameters -DA:82,202 -BRDA:82,0,0,1 -BRDA:82,0,1,201 +DA:74,6 +DA:80,872 +FN:80,SwanManager.setMarketParameters +FNDA:872,SwanManager.setMarketParameters +DA:81,202 +BRDA:81,0,0,1 +BRDA:81,0,1,201 +DA:82,201 DA:83,201 -DA:84,201 -DA:90,658 -FN:90,SwanManager.setOracleParameters -FNDA:658,SwanManager.setOracleParameters -DA:91,1 -DA:96,1 -FN:96,SwanManager.getOracleFee +DA:89,654 +FN:89,SwanManager.setOracleParameters +FNDA:654,SwanManager.setOracleParameters +DA:90,1 +DA:95,1 +FN:95,SwanManager.getOracleFee FNDA:1,SwanManager.getOracleFee +DA:96,1 DA:97,1 -DA:98,1 -DA:109,584 -FN:109,SwanManager.addOperator -FNDA:584,SwanManager.addOperator -DA:110,0 -DA:117,665 -FN:117,SwanManager.removeOperator -FNDA:665,SwanManager.removeOperator -DA:118,0 -DA:123,1366 -FN:123,SwanManager.getCurrentMarketParameters +DA:108,569 +FN:108,SwanManager.addOperator +FNDA:569,SwanManager.addOperator +DA:109,0 +DA:116,654 +FN:116,SwanManager.removeOperator +FNDA:654,SwanManager.removeOperator +DA:117,0 +DA:122,1366 +FN:122,SwanManager.getCurrentMarketParameters FNDA:1366,SwanManager.getCurrentMarketParameters -DA:124,1828 +DA:123,1828 FNF:9 FNH:9 LF:21 diff --git a/storage.sh b/storage.sh old mode 100644 new mode 100755 index cfe6a75..2637c5b --- a/storage.sh +++ b/storage.sh @@ -1,12 +1,13 @@ #!/bin/bash OUTPUT_PATH=${1:-storage} -EXCLUDE="test|mock|script" +EXCLUDE="test|mock|script|" +# FIXME: what does IFS do here? IFS=$'\n' CONTRACT_FILES=($(find ./src -type f)) unset IFS -echo "Generating layouts in $OUTPUT_PATH" +echo "Outputting storage layouts to: $OUTPUT_PATH" mkdir -p $OUTPUT_PATH for file in "${CONTRACT_FILES[@]}"; @@ -16,6 +17,6 @@ do fi contract=$(basename "$file" .sol) - echo "Generating storage layout of $contract" + echo "Generating storage layout for: $contract" forge inspect "$contract" storage --pretty > "$OUTPUT_PATH/$contract.md" -done \ No newline at end of file +done