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

Add closeCampaign() to CurvePoolBooster. #2360

Merged

Conversation

clement-ux
Copy link
Contributor

@clement-ux clement-ux commented Jan 22, 2025

Description

On VotemarketV2, when a campaign has ended, the campaign manager may invoke the closeCampaign() function to claim all non-claimed bribe tokens. This action is not strictly mandatory, as it can also be performed by the StakeDAO team. However, this pull request aims to introduce this functionality for improved accessibility.

Note: No tests are added for this one as it will require complex cross-chain messaging setup.

Dependencies

The following deployed implementation doesn't have this functionality.

Code Change Checklist

To be completed before internal review begins:

  • The contract code is complete
  • Executable deployment file
  • Fork tests that test after the deployment file runs
  • Unit tests *if needed
  • The owner has done a full checklist review of the code + tests

Internal review:

  • Two approvals by internal reviewers

Copy link

github-actions bot commented Jan 22, 2025

Warnings
⚠️ 👀 This PR needs at least 2 reviewers

Generated by 🚫 dangerJS against ec53c6d

@clement-ux clement-ux changed the title feat: add closeCampaign function to CurvePoolBooster. Add closeCampaign() to CurvePoolBooster. Jan 22, 2025
@clement-ux clement-ux marked this pull request as ready for review January 22, 2025 07:51
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 10 lines in your changes missing coverage. Please review.

Project coverage is 51.46%. Comparing base (b7baf9d) to head (ec53c6d).
Report is 1 commits behind head on clement/pool-booster-curve.

Files with missing lines Patch % Lines
...ontracts/contracts/strategies/CurvePoolBooster.sol 50.00% 10 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           clement/pool-booster-curve    #2360      +/-   ##
==============================================================
- Coverage                       51.98%   51.46%   -0.52%     
==============================================================
  Files                              92       92              
  Lines                            4492     4510      +18     
  Branches                         1189     1195       +6     
==============================================================
- Hits                             2335     2321      -14     
- Misses                           2154     2186      +32     
  Partials                            3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

const cCreateX = await ethers.getContractAt(createxAbi, addresses.createX);

// Generate encoded salt (deployer address || crossChainProtectionFlag || bytes11(keccak256(rewardToken, gauge)))
const addressDeployerBytes20 = ethers.utils.hexlify(
Copy link
Member

Choose a reason for hiding this comment

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

Can we separate the salt creation code into a deploy utilities source file? It is going to be used in many deploy files and it should improve readability and risk of making mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in this commit: f2bf316

const initData = cCurvePoolBooster.interface.encodeFunctionData(
"initialize(address,uint16,address)",
// --- Deploy implementation --- //
const cachedInitCodeImpl = ethers.utils.concat([
Copy link
Member

Choose a reason for hiding this comment

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

Pretty cool that you've made this work with the IMPL contract as well. Also nice to see first hand how the constructor parameters are just encoded and appended to the contract bytecode.

Just wanted to leave a remark, that we don't really need matching implementation addresses cross chain. And in favor of less complexity we shouldn't probably do it in the future. I am fine though leaving this one is as it is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, matching implementation doesn't bring any value, 100% agree. (it's just even more satisfying).

Since I'd already started, I thought I might as well continue with the same method, in order to have an exemple of it done once (if for any reason we could need it in the futur).

I prefer to keep it like this for this implementation, but 100% agree on just using CreateX for Proxy for next time 👍

Copy link
Member

Choose a reason for hiding this comment

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

agreed :)

const initializeImplem = cCurvePoolBooster.interface.encodeFunctionData(
"initialize(address,uint16,address,address)",
[
addresses.base.multichainStrategist, // strategist
Copy link
Member

Choose a reason for hiding this comment

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

we should create another entry in address.js:

addresses.arbitrumOne.multichainStrategist = "0x...";

or rather set it under a non chain variable with a comment :

// works on Ethereum, Arbitrum, Base, Optimism
addresses.multichainStrategist = "0x...";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I used directly the one available, my bad.
But indeed, I could be nice to have another entry in address.js.
I'm personally in favor of addresses.multichainStrategist = "0x...";, but no problem with the chain specific one.

Copy link
Member

Choose a reason for hiding this comment

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

agreed addresses.multichainStrategist is better

"initialize(address,address,bytes)",
[
implementationAddress, // implementation
addresses.mainnet.Timelock, // governor
Copy link
Member

Choose a reason for hiding this comment

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

we don't have a timelock on Arbitrum yet right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I just copy/pasted the code from mainnet to be sure that this doesn't break cross-chain replication.
However we can setup another owner of the proxy in Arbitrum, it will not change deployment address.

And, yes, we don't have Timelock on arbitrum. Any suggestion for which address should I use instead?

Copy link
Member

Choose a reason for hiding this comment

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

5/8 multisig on Arbitrum would be a good one: https://docs.originprotocol.com/registry/contracts#arbitrum

@@ -20,7 +20,7 @@ describe("ForkTest: CurvePoolBooster", function () {

Copy link
Member

Choose a reason for hiding this comment

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

lets also add Arbitrum fork tests and verify the initial state works. Ideally, we would want to verify that we can execute the closeCampaing function. Though I am not sure how complex it is to setup preconditions for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I'll add tests there too.
However we can try to add a test for closeCampaing, but it will not really test the complete logic, as we dont have the bridging message tech. But better than nothing 👍

Copy link
Member

Choose a reason for hiding this comment

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

Can we create the campaign on Arbitrum and then also try to close it on Arbitrum? Or does the creation of the campain need to originate from the Mainnet?

Copy link
Contributor Author

@clement-ux clement-ux Jan 23, 2025

Choose a reason for hiding this comment

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

In our case the campaign originate from Mainnet.
However, even if we deployed it on Arbitrum, from what I've understand, they still need to bridge the message.
Because the main entry to create a bribe is not directly on VotemarketV2 but using the CampaignRemoteManager contract, which will bridge message.

So I think this is something that we will need to test in prod too.

@clement-ux clement-ux merged commit 6627d35 into clement/pool-booster-curve Jan 23, 2025
10 of 19 checks passed
@clement-ux clement-ux deleted the clement/pool-booster-curve-upgrade branch January 23, 2025 20:40
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.

2 participants