-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathPositionManagerBase.sol
More file actions
73 lines (66 loc) · 2.14 KB
/
PositionManagerBase.sol
File metadata and controls
73 lines (66 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity 0.8.28;
import {SafeERC20, IERC20} from 'src/dependencies/openzeppelin/SafeERC20.sol';
import {IERC20Permit} from 'src/dependencies/openzeppelin/IERC20Permit.sol';
import {Multicall} from 'src/utils/Multicall.sol';
import {EIP712Types} from 'src/libraries/types/EIP712Types.sol';
import {ISpoke} from 'src/spoke/interfaces/ISpoke.sol';
import {IPositionManagerBase} from 'src/position-manager/interfaces/IPositionManagerBase.sol';
/// @title PositionManagerBase
/// @author Aave Labs
/// @notice Base implementation for position manager common functionalities.
abstract contract PositionManagerBase is IPositionManagerBase, Multicall {
using SafeERC20 for IERC20;
/// @inheritdoc IPositionManagerBase
ISpoke public immutable override SPOKE;
/// @dev Constructor.
/// @param spoke_ The address of the spoke contract.
constructor(address spoke_) {
require(spoke_ != address(0), InvalidAddress());
SPOKE = ISpoke(spoke_);
}
/// @inheritdoc IPositionManagerBase
function setSelfAsUserPositionManagerWithSig(
EIP712Types.SetUserPositionManager calldata params,
bytes calldata signature
) external {
try
SPOKE.setUserPositionManagerWithSig(
address(this),
params.user,
params.approve,
params.nonce,
params.deadline,
signature
)
{} catch {}
}
/// @inheritdoc IPositionManagerBase
function permitReserve(
uint256 reserveId,
address onBehalfOf,
uint256 value,
uint256 deadline,
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external {
address underlying = address(_getReserveUnderlying(reserveId));
try
IERC20Permit(underlying).permit({
owner: onBehalfOf,
spender: address(this),
value: value,
deadline: deadline,
v: permitV,
r: permitR,
s: permitS
})
{} catch {}
}
/// @return The underlying asset for `reserveId` on the Spoke.
function _getReserveUnderlying(uint256 reserveId) internal view returns (IERC20) {
return IERC20(SPOKE.getReserve(reserveId).underlying);
}
}