{"id":26775567,"url":"https://github.com/jocoders/token-vesting-gas-optimization","last_synced_at":"2025-08-23T12:35:55.850Z","repository":{"id":277420356,"uuid":"926763512","full_name":"jocoders/token-vesting-gas-optimization","owner":"jocoders","description":"Gas Optimization of Existing Smart Contracts with Detailed Audit Reports","archived":false,"fork":false,"pushed_at":"2025-02-21T11:35:05.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T03:19:05.648Z","etag":null,"topics":["foundry","gas-optimization","smart-contracts","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jocoders.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-03T20:19:13.000Z","updated_at":"2025-02-21T11:35:08.000Z","dependencies_parsed_at":"2025-02-13T21:35:34.463Z","dependency_job_id":null,"html_url":"https://github.com/jocoders/token-vesting-gas-optimization","commit_stats":null,"previous_names":["jocoders/token-vesting-gas-optimization"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jocoders/token-vesting-gas-optimization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jocoders%2Ftoken-vesting-gas-optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jocoders%2Ftoken-vesting-gas-optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jocoders%2Ftoken-vesting-gas-optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jocoders%2Ftoken-vesting-gas-optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jocoders","download_url":"https://codeload.github.com/jocoders/token-vesting-gas-optimization/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jocoders%2Ftoken-vesting-gas-optimization/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271747028,"owners_count":24813605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["foundry","gas-optimization","smart-contracts","solidity"],"created_at":"2025-03-29T03:19:08.258Z","updated_at":"2025-08-23T12:35:55.823Z","avatar_url":"https://github.com/jocoders.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gas Optimization Audit Report - TokenVesting\n\n## Overview\n\n- **Contract Audited:** TokenVesting.sol \u0026 TokenVestingOptimized.sol\n- **Optimization Techniques Used:** Solady library, storage optimization, function unification, constant storage references\n- **Audit Focus:** Reducing gas costs for deployment and function execution\n- **Findings Summary:**\n  - **Deployment Gas Reduced:** 1,251,225 -\u003e 1,248,551 (↓ 0.2%)\n  - **Deployment Size Reduced:** 6,797 -\u003e 6,766 (↓ 0.5%)\n  - **Gas Savings on Function Calls:** Small improvements across multiple functions\n\n## Optimizations \u0026 Gas Savings\n\n### 1️⃣ Replaced OpenZeppelin with Solady for `Ownable` \u0026 `SafeTransferLib`\n\n- **Before:** Used OpenZeppelin’s `Ownable` and `SafeTransfer`.\n- **After:** Replaced with Solady’s optimized versions.\n- **Gas Improvement:** Solady’s functions are more gas-efficient, reducing overhead for ownership and transfers.\n\n### 2️⃣ Packed `beneficiary` and `revocable` into a Single Storage Slot\n\n- **Before:** Stored `beneficiary` (address) and `revocable` (bool) separately.\n- **After:** Combined them into a single slot to reduce storage operations.\n- **Gas Improvement:** Reduced SLOAD costs by storing them together.\n\n### 3️⃣ Unified `_releasableAmount` and `_vestedAmount` Functions\n\n- **Before:** Had two separate functions performing similar calculations.\n- **After:** Merged them into a single function to reduce redundant calls.\n- **Gas Improvement:** Saves function execution gas by avoiding duplicated logic.\n\n### 4️⃣ Used Constant Storage References in `_releasableAmount`\n\n- **Before:** Accessed the same storage variables multiple times in `_releasableAmount`.\n- **After:** Stored them in memory once and reused them.\n- **Gas Improvement:** Reduces redundant SLOAD operations, making calculations cheaper.\n\n## 📊 Gas Usage Comparison (Before vs After)\n\n| Function Name       | Before (Avg) | After (Avg) | Improvement |\n| ------------------- | ------------ | ----------- | ----------- |\n| **Deployment Cost** | 1,251,225    | 1,248,551   | **↓ 0.2%**  |\n| **Deployment Size** | 6,797        | 6,766       | **↓ 0.5%**  |\n| `emergencyRevoke`   | 63,780       | 62,563      | **↓ 1.9%**  |\n| `getReleased`       | 1,873        | 1,851       | ↓ 1.2%      |\n| `getRevoked`        | 2,892        | 2,959       | ↑ 2.3%      |\n| `release`           | 93,996       | 92,555      | **↓ 1.5%**  |\n| `revoke`            | 75,909       | 74,294      | **↓ 2.1%**  |\n\n## ✅ Conclusion\n\n- **Achieved small gas savings on function executions, particularly `emergencyRevoke` (-1.9%) and `revoke` (-2.1%).**\n- **Minor reduction in deployment cost (-0.2%) and contract size (-0.5%).**\n- **Most optimizations came from reducing redundant logic and storage operations.**\n\nThese changes make `TokenVestingOptimized.sol` slightly more efficient, reducing execution gas and storage costs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjocoders%2Ftoken-vesting-gas-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjocoders%2Ftoken-vesting-gas-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjocoders%2Ftoken-vesting-gas-optimization/lists"}