Skip to content

Conversation

@sentilesdal
Copy link
Contributor

@sentilesdal sentilesdal commented Mar 26, 2024

Adds a codegen tool to generate much of boilerplate code necessary for new integrations of hyperdrive. The overall goal is to be to just define a simple config.yaml file and then be able to run:

hyperdrive-codegen --config path/to/config.yaml --out contracts/src

This will generate a slew of files:

deployers/
    testeth/
      TestETHHyperdriveCoreDeployer.sol
      TestETHHyperdriveDeployerCoordinator.sol
      TestETHTarget0Deployer.sol
      TestETHTarget1Deployer.sol
      TestETHTarget2Deployer.sol
      TestETHTarget3Deployer.sol
      TestETHTarget4Deployer.sol

instances/
    testeth/
      TestETHBase.sol
      TestETHHyperdrive.sol
      TestETHTarget0.sol
      TestETHTarget1.sol
      TestETHTarget2.sol
      TestETHTarget3.sol
      TestETHTarget4.sol

interfaces/
      ITestETH.sol
      ITestETHHyperdrive.sol

The configuration yaml will allow us to create certain preconfigured defaults, such as disabling base deposits and stubbing out default functions for those.

I've also added a github workflow to test the different configurations by making sure all the generated code compiles.

@sentilesdal sentilesdal changed the title Integrations Boilerplate Codegen Integrations Boilerplate Codegen Tool Mar 26, 2024
@sentilesdal sentilesdal force-pushed the matt-add-integrations-codegen branch 5 times, most recently from 670d20d to dc8f348 Compare March 26, 2024 23:25
@sentilesdal sentilesdal marked this pull request as ready for review March 26, 2024 23:31
Copy link
Contributor

@cashd cashd left a comment

Choose a reason for hiding this comment

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

Great job this is going to be soo useful! can't wait to use it in the next integration. I ran through the readme and got every working very smoothly.

@sentilesdal sentilesdal force-pushed the matt-add-integrations-codegen branch 2 times, most recently from 2bce5fa to 1d520f2 Compare March 27, 2024 15:39
@github-actions
Copy link

github-actions bot commented Mar 27, 2024

Hyperdrive Gas Benchmark

Benchmark suite Current: 2324490 Previous: 46c834d Deviation Status
addLiquidity: min 33915 gas 1546 gas 2093.7257% 🚨
addLiquidity: avg 144974 gas 67936 gas 113.3979% 🚨
addLiquidity: max 405253 gas 293159 gas 38.2366% 🚨
checkpoint: min 29232 gas 1182 gas 2373.0964% 🚨
checkpoint: avg 104011 gas 48477 gas 114.5574% 🚨
checkpoint: max 211255 gas 191559 gas 10.2819% 🚨
closeLong: min 31428 gas 1492 gas 2006.4343% 🚨
closeLong: avg 132847 gas 29374 gas 352.2605% 🚨
closeLong: max 366431 gas 152303 gas 140.5934% 🚨
closeShort: min 31349 gas 1494 gas 1998.3266% 🚨
closeShort: avg 127809 gas 33444 gas 282.1582% 🚨
closeShort: max 201614 gas 149156 gas 35.1699% 🚨
initialize: min 31283 gas 1451 gas 2055.9614% 🚨
initialize: avg 252986 gas 213962 gas 18.2388% 🚨
initialize: max 322173 gas 253953 gas 26.8632% 🚨
openLong: min 33503 gas 1499 gas 2135.0233% 🚨
openLong: avg 167005 gas 51658 gas 223.2897% 🚨
openLong: max 252525 gas 185562 gas 36.0866% 🚨
openShort: min 33848 gas 1520 gas 2126.8421% 🚨
openShort: avg 169664 gas 51482 gas 229.5598% 🚨
openShort: max 363609 gas 181325 gas 100.5289% 🚨
redeemWithdrawalShares: min 31227 gas 1488 gas 1998.5887% 🚨
redeemWithdrawalShares: avg 63501 gas 22375 gas 183.8034% 🚨
redeemWithdrawalShares: max 161900 gas 109301 gas 48.1231% 🚨
removeLiquidity: min 31323 gas 1530 gas 1947.2549% 🚨
removeLiquidity: avg 218596 gas 151225 gas 44.5502% 🚨
removeLiquidity: max 376082 gas 325781 gas 15.4401% 🚨

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

Copy link
Contributor

@jalextowle jalextowle left a comment

Choose a reason for hiding this comment

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

This looks great, really nice job dude! Aside from the licensing comment, I have one other high-level comment. I think it would be good to keep the interfaces/ directory flattened for consistency. If we're going to add folders, we should add folders everywhere. Since that isn't something that we've done for the old yield sources, I'd prefer updating this to output the autogenerated interface into the contracts/src/interfaces.

@sentilesdal
Copy link
Contributor Author

@jalextowle flattened interfaces/ files and updated the license. left a comment about the GPL license in IERC20.sol

Copy link
Contributor

@jalextowle jalextowle left a comment

Choose a reason for hiding this comment

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

Looks great! I think the last thing you should do is add yourself and cash as codeowners for the codegen/ folder so that you can make changes to the tool without needing a review from me or Jonny. We'll still need to review new instances for now.

@sentilesdal sentilesdal force-pushed the matt-add-integrations-codegen branch from 3c5bb6f to 70dde7c Compare April 1, 2024 18:03
@sentilesdal sentilesdal merged commit 5ff6cce into main Apr 1, 2024
@sentilesdal sentilesdal deleted the matt-add-integrations-codegen branch April 1, 2024 18:08
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.

4 participants