-
Notifications
You must be signed in to change notification settings - Fork 35
chore: set self as posm consistency #1064
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| { | ||
| "borrowWithSig": "215893", | ||
| "repayWithSig": "189160", | ||
| "setSelfAsUserPositionManagerWithSig": "75402", | ||
| "setSelfAsUserPositionManagerWithSig": "74858", | ||
| "setUsingAsCollateralWithSig": "85053", | ||
| "supplyWithSig": "153205", | ||
| "updateUserDynamicConfigWithSig": "62769", | ||
| "updateUserRiskPremiumWithSig": "61579", | ||
| "withdrawWithSig": "131696" | ||
| "withdrawWithSig": "131713" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,12 +95,18 @@ interface ISignatureGateway is IMulticall, INoncesKeyed, IGatewayBase { | |
| /// with a typed signature from `user`. | ||
| /// @dev The signature is consumed on the the specified registered `spoke`. | ||
| /// @dev The given data is passed to the `spoke` for the signature to be verified. | ||
| /// @param spoke The address of the spoke. | ||
| /// @param params The structured setSelfAsUserPositionManager parameters. | ||
| /// @param spoke The address of the registered spoke. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, that the given |
||
| /// @param user The address of the user on whose behalf this gateway can act. | ||
| /// @param approve True to approve the gateway, false to revoke approval. | ||
| /// @param nonce The key-prefixed nonce for the signature. | ||
| /// @param deadline The deadline for the signature. | ||
| /// @param signature The signed bytes for the intent. | ||
| function setSelfAsUserPositionManagerWithSig( | ||
| address spoke, | ||
| EIP712Types.SetUserPositionManager calldata params, | ||
| address user, | ||
| bool approve, | ||
| uint256 nonce, | ||
| uint256 deadline, | ||
| bytes calldata signature | ||
| ) external; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (c) 2025 Aave Labs | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import 'tests/unit/misc/SignatureGateway/SignatureGateway.Base.t.sol'; | ||
|
|
||
| contract SignatureGatewaySetSelfAsUserPositionManagerTest is SignatureGatewayBaseTest { | ||
| function test_setSelfAsUserPositionManagerWithSig_revertsWith_SpokeNotRegistered() public { | ||
| vm.expectRevert(IGatewayBase.SpokeNotRegistered.selector); | ||
| vm.prank(vm.randomAddress()); | ||
| gateway.setSelfAsUserPositionManagerWithSig({ | ||
| spoke: address(spoke2), | ||
| user: vm.randomAddress(), | ||
| approve: vm.randomBool(), | ||
| nonce: vm.randomUint(), | ||
| deadline: vm.randomUint(), | ||
| signature: vm.randomBytes(72) | ||
| }); | ||
| } | ||
|
|
||
| function test_setSelfAsUserPositionManagerWithSig_forwards_correct_call() public { | ||
| address user = vm.randomAddress(); | ||
| bool approve = vm.randomBool(); | ||
| uint256 nonce = vm.randomUint(); | ||
| uint256 deadline = vm.randomUint(); | ||
| bytes memory signature = vm.randomBytes(72); | ||
|
|
||
| vm.expectCall( | ||
| address(spoke1), | ||
| abi.encodeCall( | ||
| ISpoke.setUserPositionManagerWithSig, | ||
| (address(gateway), user, approve, nonce, deadline, signature) | ||
| ), | ||
| 1 | ||
| ); | ||
| vm.prank(vm.randomAddress()); | ||
| gateway.setSelfAsUserPositionManagerWithSig({ | ||
| spoke: address(spoke1), | ||
| user: user, | ||
| approve: approve, | ||
| nonce: nonce, | ||
| deadline: deadline, | ||
| signature: signature | ||
| }); | ||
| } | ||
|
|
||
| function test_setSelfAsUserPositionManagerWithSig_ignores_underlying_spoke_reverts() public { | ||
| vm.mockCallRevert( | ||
| address(spoke1), | ||
| ISpoke.setUserPositionManagerWithSig.selector, | ||
| vm.randomBytes(64) | ||
| ); | ||
|
|
||
| vm.prank(vm.randomAddress()); | ||
| gateway.setSelfAsUserPositionManagerWithSig({ | ||
| spoke: address(spoke1), | ||
| user: vm.randomAddress(), | ||
| approve: vm.randomBool(), | ||
| nonce: vm.randomUint(), | ||
| deadline: vm.randomUint(), | ||
| signature: vm.randomBytes(72) | ||
| }); | ||
|
|
||
| assertFalse(spoke1.isPositionManager(alice, address(gateway))); | ||
| } | ||
|
|
||
| function test_setSelfAsUserPositionManagerWithSig() public { | ||
| uint192 nonceKey = _randomNonceKey(); | ||
| vm.prank(alice); | ||
| spoke1.useNonce(nonceKey); | ||
| EIP712Types.SetUserPositionManager memory p = EIP712Types.SetUserPositionManager({ | ||
| positionManager: address(gateway), | ||
| user: alice, | ||
| approve: true, | ||
| nonce: spoke1.nonces(alice, nonceKey), // note: this typed sig is forwarded to spoke | ||
| deadline: _warpBeforeRandomDeadline() | ||
| }); | ||
| bytes memory signature = _sign(alicePk, _getTypedDataHash(spoke1, p)); | ||
|
|
||
| vm.prank(SPOKE_ADMIN); | ||
| spoke1.updatePositionManager(address(gateway), true); | ||
| vm.prank(alice); | ||
| spoke1.setUserPositionManager(address(gateway), false); | ||
|
|
||
| gateway.setSelfAsUserPositionManagerWithSig({ | ||
| spoke: address(spoke1), | ||
| user: p.user, | ||
| approve: p.approve, | ||
| nonce: p.nonce, | ||
| deadline: p.deadline, | ||
| signature: signature | ||
| }); | ||
|
|
||
| assertTrue(spoke1.isPositionManager(alice, address(gateway))); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think this struct now is never used in src, can rm here or in valentin's posm pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to refactor the types & typehash to move them to related Interfaces, and split up the EIP712 Hashes lib for each use cases, so ig better to make a PR just for that refactor, so that this PR and other impacted by signature type rft can rebase afterwards and prevent too much conflicts