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

Recipient mapping! #246

Merged
merged 5 commits into from
Aug 2, 2024
Merged

Recipient mapping! #246

merged 5 commits into from
Aug 2, 2024

Conversation

hensha256
Copy link
Contributor

@hensha256 hensha256 commented Aug 2, 2024

closes #202
mapping recipients with constants for 2 reasons

  • saves gas for the 2 most common use-cases because you pass in lots of 0-calldata which is cheaper
  • makes SDKs much easier to write because the SDK does not need to know the address of the contract, nor the address of the user. Its agnostic to those facts because it can use these constants instead

/// @notice Calculates the address for a action
/// @param recipient The address or address-flag for the action
/// @return output The resultant address for the action
function map(address recipient) internal view returns (address) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wouldve been nice in a library but sadly it needs _msgSender to work. Open to suggestions about where the function should live, and where the constants should live

@@ -0,0 +1 @@
127508
Copy link
Contributor Author

@hensha256 hensha256 Aug 2, 2024

Choose a reason for hiding this comment

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

Having a recipient of a specific address (not a helper constant) is now ~90 more expensive than before. But taking to the msg.sender is now ~50 cheaper than before.
And most importantly - our sdks will be much easier to write haha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously taking to any address: 127419
now taking to specific address: 127508
now taking to msg.sender: 127370

@hensha256 hensha256 merged commit daf74ce into main Aug 2, 2024
3 checks passed
@hensha256 hensha256 deleted the map-take-recipient branch August 2, 2024 20:10
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.

[routing] support router paying for swaps
2 participants