Skip to content
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

Chainlink Integration #1135

Merged
merged 18 commits into from
Aug 21, 2024
Merged

Chainlink Integration #1135

merged 18 commits into from
Aug 21, 2024

Conversation

jalextowle
Copy link
Contributor

Resolved Issues

Fixes: #1104

Description

This PR adds a chainlink integration. This can be used with general price feeds, although the intended use is with price feeds like the wsteth-eth reference rate on Gnosis Chain. This integration uses the output of a given Chainlink aggregator as the vault share price. It doesn't support base as a deposit asset since the base token may not even exist. Some documentation is included in the implementation that describes how Chainlink downtime or deprecation will impact the instance.

Review Checklists

Please check each item before approving the pull request. While going
through the checklist, it is recommended to leave comments on items that are
referenced in the checklist to make sure that they are reviewed. If there are
multiple reviewers, copy the checklists into sections titled ## [Reviewer Name].
If the PR doesn't touch Solidity, the corresponding checklist can
be removed.

[[Reviewer Name]]

  • Tokens
    • Do all approve calls use forceApprove?
    • Do all transfer calls use safeTransfer?
    • Do all transferFrom calls use msg.sender as the from address?
      • If not, is the function access restricted to prevent unauthorized
        token spend?
  • Low-level calls (call, delegatecall, staticcall, transfer, send)
    • Is the returned success boolean checked to handle failed calls?
    • If using delegatecall, are there strict access controls on the
      addresses that can be called? It shouldn't be possible to delegatecall
      arbitrary addresses, so the list of possible targets should either be
      immutable or tightly controlled by an admin.
  • Reentrancy
    • Are functions that make external calls or transfer ether marked as nonReentrant?
      • If not, is there documentation that explains why reentrancy is
        not a concern or how it's mitigated?
  • Gas Optimizations
    • Is the logic as simple as possible?
    • Are the storage values that are used repeatedly cached in stack or
      memory variables?
    • If loops are used, are there guards in place to avoid out-of-gas
      issues?
  • Visibility
    • Are all payable functions restricted to avoid stuck ether?
  • Math
    • Is all of the arithmetic checked or guarded by if-statements that will
      catch underflows?
    • If Safe functions are altered, are potential underflows and
      overflows caught so that a failure flag can be thrown?
    • Are all of the rounding directions clearly documented?
  • Testing
    • Are there new or updated unit or integration tests?
    • Do the tests cover the happy paths?
    • Do the tests cover the unhappy paths?
    • Are there an adequate number of fuzz tests to ensure that we are
      covering the full input space?

@jalextowle jalextowle changed the title Jalextowle/integration/chainlink Chainlink Integration Aug 17, 2024
@coveralls
Copy link
Collaborator

coveralls commented Aug 17, 2024

Pull Request Test Coverage Report for Build 10483818456

Details

  • 57 of 64 (89.06%) changed or added relevant lines in 20 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 90.7%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contracts/src/deployers/chainlink/ChainlinkHyperdriveDeployerCoordinator.sol 13 20 65.0%
Totals Coverage Status
Change from base Build 10483721874: -0.04%
Covered Lines: 2292
Relevant Lines: 2527

💛 - Coveralls

Copy link
Contributor

@jrhea jrhea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I just had a couple of nits, but I will go ahead and approve. I would consider having @DannyDelott take a look at the PR in case he has any issues with the lack of a baseToken.

@jrhea jrhea requested a review from DannyDelott August 17, 2024 18:12
Copy link
Contributor

@mcclurejt mcclurejt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome stuff! coolest integration yet imo

Copy link

Hyperdrive Gas Benchmark

Benchmark suite Current: 8ae7cd9 Previous: 4f070b3 Deviation Status
addLiquidity: min 33893 gas 33893 gas 0% 🟰
addLiquidity: avg 196852 gas 197337 gas -0.2458%
addLiquidity: max 474700 gas 474700 gas 0% 🟰
checkpoint: min 40316 gas 40316 gas 0% 🟰
checkpoint: avg 144443 gas 144535 gas -0.0637%
checkpoint: max 256108 gas 256108 gas 0% 🟰
closeLong: min 31384 gas 31384 gas 0% 🟰
closeLong: avg 135729 gas 135808 gas -0.0582%
closeLong: max 2539399 gas 2539399 gas 0% 🟰
closeShort: min 31327 gas 31327 gas 0% 🟰
closeShort: avg 131314 gas 131449 gas -0.1027%
closeShort: max 271272 gas 271272 gas 0% 🟰
initialize: min 31305 gas 31305 gas 0% 🟰
initialize: avg 352431 gas 352459 gas -0.0079%
initialize: max 418737 gas 418737 gas 0% 🟰
openLong: min 33370 gas 33370 gas 0% 🟰
openLong: avg 174007 gas 174093 gas -0.0494%
openLong: max 333737 gas 333737 gas 0% 🟰
openShort: min 33936 gas 33936 gas 0% 🟰
openShort: avg 174290 gas 174137 gas 0.0879% 🚨
openShort: max 415133 gas 415068 gas 0.0157% 🚨
redeemWithdrawalShares: min 31211 gas 31211 gas 0% 🟰
redeemWithdrawalShares: avg 74819 gas 74608 gas 0.2828% 🚨
redeemWithdrawalShares: max 305184 gas 305184 gas 0% 🟰
removeLiquidity: min 31217 gas 31217 gas 0% 🟰
removeLiquidity: avg 214368 gas 215105 gas -0.3426%
removeLiquidity: max 403247 gas 403526 gas -0.0691%

This comment was automatically generated by workflow using github-action-benchmark.

@jalextowle jalextowle added this pull request to the merge queue Aug 21, 2024
Merged via the queue into main with commit 7e32c9f Aug 21, 2024
32 checks passed
@jalextowle jalextowle deleted the jalextowle/integration/chainlink branch August 21, 2024 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wstETH L2 Integration
4 participants