Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion snapshots/SignatureGateway.Operations.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"borrowWithSig": "215605",
"repayWithSig": "188872",
"setSelfAsUserPositionManagerWithSig": "75402",
"setSelfAsUserPositionManagerWithSig": "75597",
"setUsingAsCollateralWithSig": "85053",
"supplyWithSig": "153205",
"updateUserDynamicConfigWithSig": "62769",
Expand Down
1 change: 1 addition & 0 deletions src/position-manager/SignatureGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ contract SignatureGateway is ISignatureGateway, GatewayBase, NoncesKeyed, Multic
EIP712Types.SetUserPositionManager calldata params,
bytes calldata signature
) external onlyRegisteredSpoke(spoke) {
require(params.positionManager == address(this), InvalidSignature());
try
ISpoke(spoke).setUserPositionManagerWithSig(
address(this),
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/misc/SignatureGateway/SignatureGateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,22 @@ contract SignatureGatewayTest is SignatureGatewayBaseTest {
_assertGatewayHasNoBalanceOrAllowance(spoke1, gateway, alice);
_assertGatewayHasNoActivePosition(spoke1, gateway);
}

function test_setSelfAsUserPositionManagerWithSig_revertsWith_InvalidSignature() public {
address randomPositionManager = vm.randomAddress();
assumeUnusedAddress(randomPositionManager);

EIP712Types.SetUserPositionManager memory p = EIP712Types.SetUserPositionManager({
positionManager: randomPositionManager,
user: alice,
approve: true,
nonce: spoke1.nonces(address(alice), _randomNonceKey()), // note: this typed sig is forwarded to spoke
deadline: _warpBeforeRandomDeadline()
});
bytes memory signature = _sign(alicePk, _getTypedDataHash(spoke1, p));

vm.expectRevert(ISignatureGateway.InvalidSignature.selector);
vm.prank(vm.randomAddress());
gateway.setSelfAsUserPositionManagerWithSig(address(spoke1), p, signature);
}
}
Loading