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

VAL-104 Run crank lazily #104

Merged
merged 9 commits into from
Nov 29, 2022
Merged

VAL-104 Run crank lazily #104

merged 9 commits into from
Nov 29, 2022

Conversation

ams9198
Copy link
Contributor

@ams9198 ams9198 commented Nov 29, 2022

This runs the crank lazily on several mutating Pool functions (let me know if I missed some, or if this is too burdensome..).

Gas cost for a crank that actually does something is ~330k, for one that short-circuits, around 110k.

The behavior of the global crank was also tweaked slightly -- if there's 0 shares to redeem, that still "counts" as the crank for that period, and it can't be re-run in that period. I also added a PoolCranked event that's emitted when the crank runs for that period.

The mutating functions that the crank lazily executes on are:

  • requestRedeem
  • requestWithdraw
  • cancelRedeemRequest
  • cancelWithdrawRequest
  • deposit
  • mint
  • withdraw
  • redeem
  • fundLoan
  • defaultLoan

In the PermissionedPool, it can be called directly via the PoolController / PA, or from a "valid participant"; in the Pool.sol, anyone can run it.

@@ -129,7 +138,7 @@ interface IPool is IERC4626 {
/**
* @dev Cranks the pool's withdrawals
*/
function crank() external returns (uint256);
function crank() external;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can add this back in, but since we're emitting an event with more information, felt duplicative?

Copy link
Contributor

Choose a reason for hiding this comment

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

The return value doesn't seem very meaningful anyway. I can't think of an on-chain use case off the top of my head.

Copy link
Contributor

@bricestacey bricestacey left a comment

Choose a reason for hiding this comment

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

Looks good

@@ -129,7 +138,7 @@ interface IPool is IERC4626 {
/**
* @dev Cranks the pool's withdrawals
*/
function crank() external returns (uint256);
function crank() external;
Copy link
Contributor

Choose a reason for hiding this comment

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

The return value doesn't seem very meaningful anyway. I can't think of an on-chain use case off the top of my head.

@ams9198 ams9198 merged commit 5f5ce3f into circlefin:master Nov 29, 2022
@ams9198 ams9198 deleted the VAL-104-rebase branch November 29, 2022 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.

2 participants