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

Hardhat tasks #2234

Merged
merged 11 commits into from
Sep 16, 2024
Merged

Hardhat tasks #2234

merged 11 commits into from
Sep 16, 2024

Conversation

naddison36
Copy link
Collaborator

@naddison36 naddison36 commented Sep 15, 2024

  • New Hardhat tasks exitValidators and removeValidators make it easier to bulk exit and remove validators.
  • Added Base support for vault hardhat tasks. eg npx hardhat snapVault --network base
  • Added Hardhat task manuallyFixAccounting
  • Created ForceEtherSender contract to transfer ETH to contracts on self destruct
  • Added mine Hardhat task that mines a number of blocks
  • Added snapAero Hardhat task

The bulk Hardhat tasks are an alternative off-chain solution to PR #2185

Example snapAero task

npx hardhat snapAero --network base

Pool price       : 0.9999818609 OETHb/WETH, -1 tick
Pool WETH        : 6642.222726861587167611 (19.89%), 6642222726861587167611 wei
Pool OETH        : 26737.010414482733100435 (80.1%), 26737010414482733100435 wei
Pool total       : 33379.233141344320268046

Tick WETH        : 5921.046466451057867835 (18.14%), 5921046466451057867835 wei
Tick OETH        : 26718.611544742131398853 (81.85%), 26718611544742131398853 wei
Tick total       : 30088.173428977392745968 97.78% of pool

Tick strat WETH  : 5458.190551583556444397 (18.14%), 6642222726861587167611 wei
Tick strat OETH  : 24629.982877393836301571 (81.85%), 26737010414482733100435 wei
Tick strat total : 30088.173428977392745968 92.18% of tick, 90.14% of pool

Strategy balance : 30088.123925492579520043 ether, 30088123925492579520043 wei
Vault WETH       : 74.209998063405065213, 74209998063405065213 wei

Copy link

codecov bot commented Sep 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.57%. Comparing base (d5c237c) to head (09967c6).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2234   +/-   ##
=======================================
  Coverage   56.57%   56.57%           
=======================================
  Files          75       75           
  Lines        3848     3848           
  Branches     1014     1014           
=======================================
  Hits         2177     2177           
  Misses       1668     1668           
  Partials        3        3           

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

@naddison36 naddison36 changed the title Added bulk Hardhat tasks exitValidators and removeValidators Hardhat tasks Sep 16, 2024
Added simulation Hardhat tasks deployForceEtherSender and forceSend
Copy link

github-actions bot commented Sep 16, 2024

Warnings
⚠️ 👀 This PR needs at least 2 reviewers

Generated by 🚫 dangerJS against 09967c6

Copy link

openzeppelin-code bot commented Sep 16, 2024

Hardhat tasks

Generated at commit: 09967c614f2d21cf6b259bf748ef2792b484f147

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
3
0
18
42
66
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

sparrowDom
sparrowDom previously approved these changes Sep 16, 2024
Copy link
Member

@sparrowDom sparrowDom left a comment

Choose a reason for hiding this comment

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

LGTM left a couple of comments

const sugarHelper = await resolveContract(base.sugarHelper, "ISugarHelper");

const Q96 = BigNumber.from(2).pow(96);
const sqrtRatioX96TickLower = BigNumber.from("79224201403219477170569942574"); // -1 tick
Copy link
Member

Choose a reason for hiding this comment

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

These could be read from the strategy contract. Would make it easier to use the same script for different strategies:
https://github.com/OriginProtocol/origin-dollar/blob/master/contracts/contracts/strategies/aerodrome/AerodromeAMOStrategy.sol#L87

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. I'll add

const weth = await resolveAsset("WETH");
const vault = await resolveContract("OETHBaseVaultProxy", "IVault");
const oeth = await resolveContract("OETHBaseProxy", "OETHBase");
const pool = await resolveContract(base.aerodromeOETHbWETHClPool, "ICLPool");
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

could, but I'll leave it from addresses.js

); // 0 tick

const { tick, sqrtPriceX96 } = await pool.connect(signer).slot0({ blockTag });
const { liquidityGross } = await pool.connect(signer).ticks(-1, { blockTag });
Copy link
Member

Choose a reason for hiding this comment

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

the -1 tick is true for this strategy, might be a different thing for other chain strategies. Available as a constant here: https://github.com/OriginProtocol/origin-dollar/blob/master/contracts/contracts/strategies/aerodrome/AerodromeAMOStrategy.sol#L67

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good idea. I'll change

.mul(10000000000)
.div(Q96)
.div(Q96);
const poolWethBalance = await weth
Copy link
Member

Choose a reason for hiding this comment

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

good to know this isn't WETH liquidity in the pool, rather WETH balance/tokens of the pool.
WETH balance = WETH liquidity + unclaimed WETH
Unclaimed WETH can originate from decreasing liquidity in the pool and not yet collecting it. (the decrease + collect are separate calls).
In most cases though the WETH on the pool will probably be the pool's liquidity.
Also I think the WETH swap fees remain on the pool (since those are claimed by the veAreo voters)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add the pool balances so we can see when its different to the actual WETH balance

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought there was a getBalances function but there isn't. It needs to be calculated from the sqrtPriceX96 and liquidity. I'll leave for now but can add if you thinks its useful information

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it is pretty annoying that there isn't a simple way to get that data off of the contract

console.log(
`Pool price : ${formatUnits(poolPrice, 10)} OETHb/WETH, ${tick} tick`
);
console.log(
Copy link
Member

Choose a reason for hiding this comment

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

I think these are fine, maybe there should be just additional notice, that these balances include unclaimed WETH/OETH from swap fees and liquidity decreases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added a comment

@naddison36 naddison36 merged commit a9676f4 into master Sep 16, 2024
15 of 18 checks passed
@naddison36 naddison36 deleted the nicka/hh-bulk-exit branch September 16, 2024 10:09
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