{"id":21766689,"url":"https://github.com/mohitchandel/twap-oracle-yield","last_synced_at":"2026-04-16T00:31:26.929Z","repository":{"id":232752810,"uuid":"675094875","full_name":"mohitchandel/twap-oracle-yield","owner":"mohitchandel","description":"TWAPYield is a Solidity smart contract that calculates the time-weighted average price (TWAP) and yield amount for a given Uniswap V3 token pair with support for fee tiers.","archived":false,"fork":false,"pushed_at":"2023-08-05T18:56:24.000Z","size":85,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-06T08:14:59.866Z","etag":null,"topics":["defi","solidity","twap","uniswap"],"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/mohitchandel.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":"2023-08-05T18:55:22.000Z","updated_at":"2024-10-15T19:26:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"6f7751af-0cd7-4594-ae8b-eebadd46fd1a","html_url":"https://github.com/mohitchandel/twap-oracle-yield","commit_stats":null,"previous_names":["mohitchandel/twap-oracle-yield"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mohitchandel/twap-oracle-yield","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitchandel%2Ftwap-oracle-yield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitchandel%2Ftwap-oracle-yield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitchandel%2Ftwap-oracle-yield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitchandel%2Ftwap-oracle-yield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohitchandel","download_url":"https://codeload.github.com/mohitchandel/twap-oracle-yield/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohitchandel%2Ftwap-oracle-yield/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31866229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["defi","solidity","twap","uniswap"],"created_at":"2024-11-26T13:18:28.921Z","updated_at":"2026-04-16T00:31:26.920Z","avatar_url":"https://github.com/mohitchandel.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TWAPYield Smart Contract\n\nThis is a smart contract that provides functionalities for calculating the time-weighted average price (TWAP) and yield amount based on the percentage change in the TWAP for a given token pair on Uniswap V3.\n\n## Requirements\n\n- Solidity Compiler Version: 0.7.6\n- Uniswap V3 Core: [IUniswapV3Pool.sol](https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/interfaces/IUniswapV3Pool.sol)\n- Uniswap V3 Periphery: [OracleLibrary.sol](https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/libraries/OracleLibrary.sol) and [PoolAddress.sol](https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/libraries/PoolAddress.sol)\n- Uniswap V3 Factory: [IUniswapV3Factory.sol](https://github.com/Uniswap/uniswap-v3-core/blob/main/contracts/interfaces/IUniswapV3Factory.sol)\n\n## Functions\n\n### `isPairSupported(address _tokenA, address _tokenB, uint24 _fee) internal pure returns (bool)`\n\nCheck if the provided token pair is supported in the Uniswap V3 factory with the given fee tier.\n\n- `_tokenA`: The address of the first token of the pair.\n- `_tokenB`: The address of the second token of the pair.\n- `_fee`: The fee tier of the pool.\n\nReturns `true` if the pair is supported; otherwise, returns `false`.\n\n### `getTwap(address _tokenIn, address _tokenOut, uint32 _secondsAgo, uint24 _fee) internal view returns (uint256)`\n\nGet the time-weighted average price for the given token pair with the given fee tier.\n\n- `_tokenIn`: The address of the first token of the pair.\n- `_tokenOut`: The address of the second token of the pair.\n- `_secondsAgo`: The amount of time to look back for the TWAP, in seconds.\n- `_fee`: The fee tier of the pool.\n\nReturns the time-weighted average price as a `uint256`.\n\n### `calculateYield(address _tokenIn, address _tokenOut, uint256 amount, uint24 _secondsAgo, uint24 _fee) external view returns (uint256 yieldAmount)`\n\nCalculates the yield amount based on the percentage change in the time-weighted average price.\n\n- `_tokenIn`: The address of the first token of the pair.\n- `_tokenOut`: The address of the second token of the pair.\n- `amount`: The amount of tokens to calculate the yield for.\n- `_secondsAgo`: The amount of time to look back for the initial TWAP, in seconds.\n- `_fee`: The fee tier of the pool.\n\nReturns the calculated yield amount as a `uint256`.\n\n## Usage\n\n1. Deploy the smart contract on the Ethereum network.\n\n2. Use the `calculateYield` function to calculate the yield amount based on the percentage change in the TWAP for a given token pair.\n\n**Note**: Make sure to import the required Uniswap V3 interfaces and libraries before deploying the smart contract.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohitchandel%2Ftwap-oracle-yield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohitchandel%2Ftwap-oracle-yield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohitchandel%2Ftwap-oracle-yield/lists"}