-
Notifications
You must be signed in to change notification settings - Fork 0
Initial commit with contracts and boilerplate files #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7a6f9ab
Initial commit with contracts and boilerplate files
acenolaza 84ab037
Removes changeset
acenolaza 83d7f77
Uses Linkspector for checking links on md files
acenolaza 5b20710
Removes engines config from package.json
acenolaza 874a910
Removes ignorePatterns from linkspector.yml
acenolaza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| node_modules | ||
| .env | ||
| dist | ||
|
|
||
| # Hardhat files | ||
| /cache | ||
| /artifacts | ||
|
|
||
| # TypeChain files | ||
| /typechain | ||
| /typechain-types | ||
|
|
||
| # solidity-coverage files | ||
| /coverage | ||
| /coverage.json | ||
|
|
||
| gas_report | ||
|
|
||
| contracts/vendor |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| module.exports = { | ||
| extends: ['plugin:@api3/eslint-plugin-commons/universal', 'plugin:@api3/eslint-plugin-commons/jest'], | ||
| parserOptions: { | ||
| project: ['./tsconfig.json'], | ||
| }, | ||
| rules: { | ||
| camelcase: 'off', | ||
| 'no-nested-ternary': 'off', | ||
|
|
||
| 'functional/no-try-statements': 'off', | ||
|
|
||
| 'jest/no-conditional-in-test': 'off', | ||
|
|
||
| 'lodash/prefer-constant': 'off', | ||
| 'lodash/prefer-lodash-typecheck': 'off', | ||
| 'lodash/prefer-noop': 'off', | ||
|
|
||
| 'unicorn/filename-case': 'off', | ||
| 'unicorn/no-anonymous-default-export': 'off', | ||
| 'unicorn/prefer-export-from': 'off', | ||
| 'unicorn/prefer-object-from-entries': 'off', | ||
| 'unicorn/prefer-ternary': 'off', | ||
|
|
||
| '@typescript-eslint/max-params': 'off', | ||
| '@typescript-eslint/no-unnecessary-type-assertion': 'off', | ||
| '@typescript-eslint/no-unsafe-call': 'off', | ||
| '@typescript-eslint/require-await': 'off', | ||
| }, | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| aliveStatusCodes: | ||
| - 200 | ||
| - 406 | ||
| dirs: | ||
| - . | ||
| - .github | ||
| useGitIgnore: true |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: Check Markdown links | ||
|
|
||
| on: push | ||
|
|
||
| jobs: | ||
| check-md-links: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Clone @api3/data-feed-proxy-combinators | ||
| uses: actions/checkout@v4 | ||
| - name: Check Markdown links | ||
| uses: umbrelladocs/action-linkspector@v1 | ||
| with: | ||
| reporter: github-pr-review | ||
| config_file: .github/config/linkspector.yml | ||
| fail_on_error: true |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Continuous build | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| lint-build-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Clone @api3/data-feed-proxy-combinators | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up pnpm | ||
| uses: pnpm/action-setup@v3 | ||
|
|
||
| - name: Set up Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20.17.0' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Lint | ||
| run: pnpm lint | ||
|
|
||
| - name: Build | ||
| run: pnpm build | ||
|
|
||
| - name: Verify vendor contracts | ||
| run: pnpm verify-vendor-contracts | ||
|
|
||
| - name: Test | ||
| run: pnpm test |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| node_modules | ||
| .env | ||
| dist | ||
|
|
||
| # Hardhat files | ||
| /cache | ||
| /artifacts | ||
|
|
||
| # TypeChain files | ||
| /typechain | ||
| /typechain-types | ||
|
|
||
| # solidity-coverage files | ||
| /coverage | ||
| /coverage.json | ||
|
|
||
| gas_report |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| node_modules | ||
| .env | ||
| dist | ||
|
|
||
| # Hardhat files | ||
| /cache | ||
| /artifacts | ||
|
|
||
| # TypeChain files | ||
| /typechain | ||
| /typechain-types | ||
|
|
||
| # solidity-coverage files | ||
| /coverage | ||
| /coverage.json | ||
|
|
||
| gas_report | ||
|
|
||
| contracts/vendor |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "bracketSpacing": true, | ||
| "printWidth": 120, | ||
| "singleQuote": true, | ||
| "trailingComma": "es5", | ||
| "useTabs": false, | ||
| "plugins": ["prettier-plugin-solidity"], | ||
| "overrides": [ | ||
| { | ||
| "files": "*.md", | ||
| "options": { | ||
| "parser": "markdown" | ||
| } | ||
| }, | ||
| { | ||
| "files": "*.sol", | ||
| "options": { | ||
| "parser": "antlr", | ||
| "printWidth": 80, | ||
| "tabWidth": 4, | ||
| "useTabs": false, | ||
| "singleQuote": false, | ||
| "bracketSpacing": false | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = { | ||
| skipFiles: ['mock', 'test', 'vendor'], | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "extends": "solhint:recommended", | ||
| "rules": { | ||
| "compiler-version": "off", | ||
| "func-visibility": ["warn", { "ignoreConstructors": true }], | ||
| "not-rely-on-time": "off", | ||
| "no-empty-blocks": "off", | ||
| "no-global-import": "off", | ||
| "func-name-mixedcase": "off", | ||
| "immutable-vars-naming": "off", | ||
| "gas-custom-errors": "off" | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| node_modules | ||
| .env | ||
| dist | ||
|
|
||
| # Hardhat files | ||
| /cache | ||
| /artifacts | ||
|
|
||
| # TypeChain files | ||
| /typechain | ||
| /typechain-types | ||
|
|
||
| # solidity-coverage files | ||
| /coverage | ||
| /coverage.json | ||
|
|
||
| gas_report | ||
|
|
||
| contracts/vendor |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2024 API3 Foundation | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or 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 +1 @@ | ||
| # data-feed-proxy-combinators | ||
| # data-feed-proxy-combinators | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.27; | ||
|
|
||
| import "@api3/contracts/interfaces/IApi3ReaderProxy.sol"; | ||
| import "./interfaces/IInverseApi3ReaderProxyV1.sol"; | ||
|
|
||
| /// @title An immutable proxy contract that inverts the value returned by an | ||
| /// IApi3ReaderProxy data feed | ||
| /// @dev This contract implements the AggregatorV2V3Interface to be compatible | ||
| /// with Chainlink aggregators. This allows the contract to be used as a drop-in | ||
| /// replacement for Chainlink aggregators in existing dApps. | ||
| /// Refer to https://github.com/api3dao/migrate-from-chainlink-to-api3 for more | ||
| /// information about the Chainlink interface implementation. | ||
| contract InverseApi3ReaderProxyV1 is IInverseApi3ReaderProxyV1 { | ||
| /// @notice IApi3ReaderProxy contract address | ||
| address public immutable override proxy; | ||
|
|
||
| /// @param proxy_ IApi3ReaderProxy contract address | ||
| constructor(address proxy_) { | ||
| if (proxy_ == address(0)) { | ||
| revert ZeroProxyAddress(); | ||
| } | ||
| proxy = proxy_; | ||
| } | ||
|
|
||
| /// @notice Returns the inverted value of the underlying IApi3ReaderProxy | ||
| /// @dev This inverts the 18-decimal fixed-point value using 1e36 / value. | ||
| /// The operation will revert if `baseValue` is zero (division by zero) or if | ||
| /// `baseValue` is so small (yet non-zero) that the resulting inverted value | ||
| /// would overflow the `int224` type. | ||
| /// @return value Inverted value of the underlying proxy | ||
| /// @return timestamp Timestamp from the underlying proxy | ||
| function read() | ||
| public | ||
| view | ||
| override | ||
| returns (int224 value, uint32 timestamp) | ||
| { | ||
| (int224 baseValue, uint32 baseTimestamp) = IApi3ReaderProxy(proxy) | ||
| .read(); | ||
|
|
||
| value = int224((1e36) / int256(baseValue)); | ||
| timestamp = baseTimestamp; | ||
| } | ||
|
|
||
| /// @dev AggregatorV2V3Interface users are already responsible with | ||
| /// validating the values that they receive (e.g., revert if the spot price | ||
| /// of an asset is negative). Therefore, this contract omits validation. | ||
| function latestAnswer() external view override returns (int256 value) { | ||
| (value, ) = read(); | ||
| } | ||
|
|
||
| /// @dev A Chainlink feed contract returns the block timestamp at which the | ||
| /// feed was last updated. On the other hand, an Api3 feed timestamp | ||
| /// denotes the point in time at which the first-party oracles signed the | ||
| /// data used to do the last update. We find this to be a reasonable | ||
| /// approximation, considering that usually the timestamp is only used to | ||
| /// check if the last update is stale. | ||
| function latestTimestamp() | ||
| external | ||
| view | ||
| override | ||
| returns (uint256 timestamp) | ||
| { | ||
| (, timestamp) = read(); | ||
| } | ||
|
|
||
| /// @dev Api3 feeds are updated asynchronously and not in rounds | ||
| function latestRound() external pure override returns (uint256) { | ||
| revert FunctionIsNotSupported(); | ||
| } | ||
|
|
||
| /// @dev Functions that use the round ID as an argument are not supported | ||
| function getAnswer(uint256) external pure override returns (int256) { | ||
| revert FunctionIsNotSupported(); | ||
| } | ||
|
|
||
| /// @dev Functions that use the round ID as an argument are not supported | ||
| function getTimestamp(uint256) external pure override returns (uint256) { | ||
| revert FunctionIsNotSupported(); | ||
| } | ||
|
|
||
| /// @dev Api3 feeds always use 18 decimals | ||
| function decimals() external pure override returns (uint8) { | ||
| return 18; | ||
| } | ||
|
|
||
| /// @dev Underlying proxy dApp ID and dAPI name act as the description, and | ||
| /// this is left empty to save gas on contract deployment | ||
| function description() external pure override returns (string memory) { | ||
| return ""; | ||
| } | ||
|
|
||
| /// @dev A unique version is chosen to easily check if an unverified | ||
| /// contract that acts as a Chainlink feed is a InverseApi3ReaderProxyV1 | ||
| function version() external pure override returns (uint256) { | ||
| return 4915; | ||
| } | ||
|
|
||
| /// @dev Functions that use the round ID as an argument are not supported | ||
| function getRoundData( | ||
| uint80 | ||
| ) | ||
| external | ||
| pure | ||
| override | ||
| returns (uint80, int256, uint256, uint256, uint80) | ||
| { | ||
| revert FunctionIsNotSupported(); | ||
| } | ||
|
|
||
| /// @dev Rounds IDs are returned as `0` as invalid values. | ||
| /// Similar to `latestAnswer()`, we leave the validation of the returned | ||
| /// value to the caller. | ||
| function latestRoundData() | ||
| external | ||
| view | ||
| override | ||
| returns ( | ||
| uint80 roundId, | ||
| int256 answer, | ||
| uint256 startedAt, | ||
| uint256 updatedAt, | ||
| uint80 answeredInRound | ||
| ) | ||
| { | ||
| roundId = answeredInRound = 0; | ||
| (answer, startedAt) = read(); | ||
| updatedAt = startedAt; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.