-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Expand file tree
/
Copy pathdraft-IERC7246.sol
More file actions
63 lines (53 loc) · 2.75 KB
/
draft-IERC7246.sol
File metadata and controls
63 lines (53 loc) · 2.75 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
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
interface IERC7246 is IERC20 {
/// @dev Emitted when `amount` tokens are encumbered from `owner` to `spender`.
event Encumber(address indexed owner, address indexed spender, uint256 amount);
/// @dev Emitted when the encumbrance of a `spender` to an `owner` is reduced by `amount`.
event Release(address indexed owner, address indexed spender, uint256 amount);
/**
* @dev Returns the total amount of tokens owned by `owner` that are currently encumbered.
*
* - MUST never exceed `balanceOf(owner)`
* - Any function which would reduce `balanceOf(owner)` below `encumberedBalanceOf(owner)` MUST revert
*/
function encumberedBalanceOf(address owner) external view returns (uint256);
/**
* @dev Convenience function for reading the unencumbered balance of an address.
* Trivially implemented as `balanceOf(owner) - encumberedBalanceOf(owner)`
*/
function availableBalanceOf(address owner) external view returns (uint256);
/**
* @dev Returns the number of tokens that `owner` has encumbered to `spender`.
*
* - This value increases when {encumber} or {encumberFrom} are called by the `owner` or by another permitted account.
* - This value decreases when {release} or {transferFrom} are called by `spender`.
*/
function encumbrances(address owner, address spender) external view returns (uint256);
/**
* @dev Increases the amount of tokens that the caller has encumbered to `spender` by `amount`.
* Grants `spender` a guaranteed right to transfer `amount` from the caller's by using `transferFrom`.
*
* - MUST revert if caller does not have `amount` tokens available
* (e.g. if `balanceOf(caller) - encumbrances(caller) < amount`).
* - Emits an {IERC7246-Encumber} event.
*/
function encumber(address spender, uint256 amount) external;
/**
* @dev Increases the amount of tokens that `owner` has encumbered to `spender` by `amount`.
* Grants `spender` a guaranteed right to transfer `amount` from `owner` using transferFrom.
*
* - The function SHOULD revert unless the owner account has deliberately authorized the sender of the message via some mechanism.
* - MUST revert if `owner` does not have `amount` tokens available
* (e.g. if `balanceOf(owner) - encumbrances(owner) < amount`).
* - Emits an {IERC7246-Encumber} event.
*/
function encumberFrom(address owner, address spender, uint256 amount) external;
/**
* @dev Reduces amount of tokens encumbered from `owner` to caller by `amount`
*
* - Emits a {IERC7246-Release} event.
*/
function release(address owner, uint256 amount) external;
}