@@ -13,12 +13,6 @@ import {IERC6372} from "@openzeppelin/contracts/interfaces/IERC6372.sol";
13
13
* data. This function can call external oracles or use any local storage.
14
14
*/
15
15
abstract contract ERC20Collateral is ERC20 , IERC6372 {
16
- // Structure that stores the details of the collateral
17
- struct Collateral {
18
- uint256 amount;
19
- uint48 timestamp;
20
- }
21
-
22
16
/**
23
17
* @dev Liveness duration of collateral, defined in seconds.
24
18
*/
@@ -66,7 +60,7 @@ abstract contract ERC20Collateral is ERC20, IERC6372 {
66
60
/**
67
61
* @dev Returns the collateral data of the token.
68
62
*/
69
- function collateral () public view virtual returns (Collateral memory );
63
+ function collateral () public view virtual returns (uint256 amount , uint48 timestamp );
70
64
71
65
/**
72
66
* @dev See {ERC20-_update}.
@@ -75,16 +69,16 @@ abstract contract ERC20Collateral is ERC20, IERC6372 {
75
69
super ._update (from, to, value);
76
70
77
71
if (from == address (0 )) {
78
- Collateral memory _collateral = collateral ();
72
+ ( uint256 amount , uint48 timestamp ) = collateral ();
79
73
80
- uint48 expiration = _collateral. timestamp + liveness ();
74
+ uint48 expiration = timestamp + liveness ();
81
75
if (expiration < clock ()) {
82
- revert ERC20ExpiredCollateral (_collateral. timestamp, expiration);
76
+ revert ERC20ExpiredCollateral (timestamp, expiration);
83
77
}
84
78
85
79
uint256 supply = totalSupply ();
86
- if (supply > _collateral. amount) {
87
- revert ERC20ExceededSupply (supply, _collateral. amount);
80
+ if (supply > amount) {
81
+ revert ERC20ExceededSupply (supply, amount);
88
82
}
89
83
}
90
84
}
0 commit comments