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

Avalanche root gauge factory v2 #2540

Merged
merged 11 commits into from
Aug 10, 2023
Merged

Conversation

jubeira
Copy link
Contributor

@jubeira jubeira commented Aug 4, 2023

Description

Introduces new root gauge that can bridge tokens using the new LZ contract as described in #2531.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests are included for all code paths --> the bridge itself shall be tested in the fork test
  • The base branch is either master, or there's a description of how to merge

Issue Resolution

Closes #2531.

@jubeira jubeira marked this pull request as ready for review August 9, 2023 18:32
Comment on lines +227 to +232
if (_lzBALProxy.useCustomAdapterParams()) {
uint256 minDstGas = _lzBALProxy.minDstGasLookup(_AVALANCHE_LZ_CHAIN_ID, _SEND_PACKET_TYPE);
return abi.encodePacked(_ADAPTER_PARAMS_VERSION, minDstGas);
} else {
return bytes("");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't trivial to get this right, but this should:

  • not revert downstream after the bal proxy takes over the execution
  • not require any additional config. Also, by performing the same operations that the proxy will perform when it's called, we should hit the same storage slots and perform warm reads which are cheaper.

The only way to actually test this properly is in the fork test. I've added some tests at the end that bridge BAL tokens many times using different amounts for both configurations in balancer/balancer-deployments#76.

Copy link
Collaborator

@EndymionJkb EndymionJkb left a comment

Choose a reason for hiding this comment

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

Looks exhausting - but good for this stage. Developing these is tough without complete docs; the many links and references will help. (And a good side effect of having that markdown check is we'll know if the docs change!)

return amount - dust;
}

function bytes32Recipient(address recipient) internal pure returns (bytes32) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could also comment here why we need to cast it: some networks have different address sizes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a short description.
This is what the proxy accepts anyway, as it can be seen in the gauge code. It's just separated so that it can be tested easily (testing with the factory and the proxy outside a fork test is a nightmare).

@jubeira jubeira merged commit 2276839 into master Aug 10, 2023
16 checks passed
@jubeira jubeira deleted the dev/avax-root-gauge-factory-v2 branch August 10, 2023 00:19
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.

Develop new Avalanche root gauge for new LZ bridge
2 participants