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

Introduce standard batched call under a lock #81

Closed
wants to merge 10 commits into from

Conversation

snreynolds
Copy link
Member

Related Issue

Which issue does this pull request resolve?

It might be helpful for integrating contracts to have a way to call multiple functions on core under one lock. This is a start to making a standard for that.

Description of changes

  • Add SafeCallback to enforce that lockAcquired is only callable by the pool manager
  • Add abstract contract LockAndBatchCall which handles the base contract for batching calls under a lock
  • Add example simple batch contract SimpleBatchCall showing how a contract could be built on top of LockAndBatchCall

I think there could be some improvements in a more standard interface for _settle and _handleAfterExecute. I wonder if there is a way we could also be passing LESS data up and back.. lmk thoughts/improvements/suggestions

Copy link
Collaborator

@saucepoint saucepoint left a comment

Choose a reason for hiding this comment

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

cool stuff. will prob have more feedback once I try building with it but so far looks like a very great start

Comment on lines 43 to 44
bytes memory settleData =
abi.encode(SimpleBatchCall.SettleConfig({withdrawTokens: true, settleUsingTransfer: true}));
Copy link
Collaborator

Choose a reason for hiding this comment

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

unused, no?

contracts/base/LockAndBatchCall.sol Show resolved Hide resolved
function _handleAfterExecute(bytes memory callReturnData, bytes memory settleReturnData) internal virtual;

/// @param executeData The function selectors and calldata for any of the function selectors in ICallsWithLock encoded as an array of bytes.
function execute(bytes memory executeData, bytes memory settleData) external {
Copy link
Collaborator

Choose a reason for hiding this comment

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

just my opinion and happy to keep as-is, but I think we should type settleData with SettleConfig

the serialization/deserialization feels cumbersome from a devex POV

Copy link
Collaborator

Choose a reason for hiding this comment

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

i prefer cleaner function signatures so I think you can drop the WithLock suffixes

contracts/SimpleBatchCall.sol Show resolved Hide resolved
Comment on lines 43 to 47
if (config.withdrawTokens) {
poolManager.mint(currency, address(this), uint256(-delta));
} else {
poolManager.take(currency, address(this), uint256(-delta));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is mixed up right? withdraw=true should be take

@snreynolds
Copy link
Member Author

Closing for now. We can create a generalized lock and batch call example for integrators in the future though.

This PR will add all the SafeCallback logic though to standardize some Hook Example development

@snreynolds snreynolds closed this Jun 18, 2024
@saucepoint saucepoint deleted the lock-and-batch-call branch August 5, 2024 06:27
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