-
Notifications
You must be signed in to change notification settings - Fork 5.1k
/
IERC3475.sol
197 lines (174 loc) · 9.11 KB
/
IERC3475.sol
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;
interface IERC3475 {
// STRUCTURE
/**
* @dev Values structure of the Metadata
*/
struct Values {
string stringValue;
uint uintValue;
address addressValue;
bool boolValue;
}
/**
* @dev structure allows the transfer of any given number of bonds from one address to another.
* @title": "defining the title information",
* @type": "explaining the type of the title information added",
* @description": "little description about the information stored in the bond",
*/
struct Metadata {
string title;
string _type;
string description;
}
/**
* @dev structure allows the transfer of any given number of bonds from one address to another.
* @classId is the class id of the bond.
* @nonceId is the nonce id of the given bond class. This param is for distinctions of the issuing conditions of the bond.
* @amount is the amount of the bond that will be transferred.
*/
struct Transaction {
uint256 classId;
uint256 nonceId;
uint256 _amount;
}
// WRITABLES
/**
* @dev allows the transfer of a bond from one address to another (either single or in batches).
* @param _from is the address of the holder whose balance is about to decrease.
* @param _to is the address of the recipient whose balance is about to increase.
* @param _transactions is the object defining {class,nonce and amount of the bonds to be transferred}.
*/
function transferFrom(address _from, address _to, Transaction[] calldata _transactions) external;
/**
* @dev allows the transfer of allowance from one address to another (either single or in batches).
* @param _from is the address of the holder whose balance about to decrease.
* @param _to is the address of the recipient whose balance is about to increased.
* @param _transactions is the object defining {class,nonce and amount of the bonds to be allowed to transferred}.
*/
function transferAllowanceFrom(address _from, address _to, Transaction[] calldata _transactions) external;
/**
* @dev allows issuing of any number of bond types to an address.
* The calling of this function needs to be restricted to bond issuer contract.
* @param _to is the address to which the bond will be issued.
* @param _transactions is the object defining {class,nonce and amount of the bonds to be issued for given whitelisted bond}.
*/
function issue(address _to, Transaction[] calldata _transactions) external;
/**
* @dev allows redemption of any number of bond types from an address.
* The calling of this function needs to be restricted to bond issuer contract.
* @param _from is the address _from which the bond will be redeemed.
* @param _transactions is the object defining {class,nonce and amount of the bonds to be redeemed for given whitelisted bond}.
*/
function redeem(address _from, Transaction[] calldata _transactions) external;
/**
* @dev allows the transfer of any number of bond types from an address to another.
* The calling of this function needs to be restricted to bond issuer contract.
* @param _from is the address of the holder whose balance about to decrees.
* @param _transactions is the object defining {class,nonce and amount of the bonds to be redeemed for given whitelisted bond}.
*/
function burn(address _from, Transaction[] calldata _transactions) external;
/**
* @dev Allows _spender to withdraw from your account multiple times, up to the amount.
* @notice If this function is called again, it overwrites the current allowance with amount.
* @param _spender is the address the caller approve for his bonds.
* @param _transactions is the object defining {class,nonce and amount of the bonds to be approved for given whitelisted bond}.
*/
function approve(address _spender, Transaction[] calldata _transactions) external;
/**
* @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
* @dev MUST emit the ApprovalForAll event on success.
* @param _operator Address to add to the set of authorized operators
* @param _approved "True" if the operator is approved, "False" to revoke approval.
*/
function setApprovalFor(address _operator, bool _approved) external;
// READABLES
/**
* @dev Returns the total supply of the bond in question.
*/
function totalSupply(uint256 classId, uint256 nonceId) external view returns (uint256);
/**
* @dev Returns the redeemed supply of the bond in question.
*/
function redeemedSupply(uint256 classId, uint256 nonceId) external view returns (uint256);
/**
* @dev Returns the active supply of the bond in question.
*/
function activeSupply(uint256 classId, uint256 nonceId) external view returns (uint256);
/**
* @dev Returns the burned supply of the bond in question.
*/
function burnedSupply(uint256 classId, uint256 nonceId) external view returns (uint256);
/**
* @dev Returns the balance of the giving bond classId and bond nonce.
*/
function balanceOf(address _account, uint256 classId, uint256 nonceId) external view returns (uint256);
/**
* @dev Returns the JSON metadata of the classes.
* The metadata SHOULD follow a set of structure explained later in eip-3475.md
*/
function classMetadata(uint256 metadataId) external view returns ( Metadata memory);
/**
* @dev Returns the JSON metadata of the nonces.
* The metadata SHOULD follow a set of structure explained later in eip-3475.md
*/
function nonceMetadata(uint256 classId, uint256 metadataId) external view returns ( Metadata memory);
/**
* @dev Returns the values of the given classId.
* the metadata SHOULD follow a set of structures explained in eip-3475.md
*/
function classValues(uint256 classId, uint256 metadataId) external view returns ( Values memory);
/**
* @dev Returns the values of given nonceId.
* @param metadataId index number of structure as explained in the metadata section in eip-3475.md
* @param classId is the class of bonds for which you determine the nonce.
* @param nonceId is the nonce for which you return the value struct info.
* Returns the values object corresponding to the given value.
*/
function nonceValues(uint256 classId, uint256 nonceId, uint256 metadataId) external view returns ( Values memory);
/**
* @dev Returns the information about the progress needed to redeem the bond
* @notice Every bond contract can have its own logic concerning the progress definition.
* @param classId The class of bonds.
* @param nonceId is the nonce of bonds for finding the progress.
* Returns progressAchieved is the current progress achieved.
* Returns progressRemaining is the remaining progress.
*/
function getProgress(uint256 classId, uint256 nonceId) external view returns (uint256 progressAchieved, uint256 progressRemaining);
/**
* @notice Returns the amount which spender is still allowed to withdraw from _owner.
* @param _owner is the address whose owner allocates some amount to the _spender address.
* @param classId is the classId of bond .
* @param nonceId is the nonce corresponding to the class for which you are approving the spending of total amount of bonds.
*/
function allowance(address _owner, address _spender, uint256 classId, uint256 nonceId) external view returns (uint256);
/**
* @notice Queries the approval status of an operator for a given owner.
* @param _owner is the current holder of the bonds for all classes / nonces.
* @param _operator is the address which is having access to the bonds of _owner for transferring
* Returns "true" if the operator is approved, "false" if not
*/
function isApprovedFor(address _owner, address _operator) external view returns (bool);
// EVENTS
/**
* @notice MUST trigger when tokens are transferred, including zero value transfers.
*/
event Transfer(address indexed _operator, address indexed _from, address indexed _to, Transaction[] _transactions);
/**
* @notice MUST trigger when tokens are issued
*/
event Issue(address indexed _operator, address indexed _to, Transaction[] _transactions);
/**
* @notice MUST trigger when tokens are redeemed
*/
event Redeem(address indexed _operator, address indexed _from, Transaction[] _transactions);
/**
* @notice MUST trigger when tokens are burned
*/
event Burn(address indexed _operator, address indexed _from, Transaction[] _transactions);
/**
* @dev MUST emit when approval for a second party/operator address to manage all bonds from a classId given for an owner address is enabled or disabled (absence of an event assumes disabled).
*/
event ApprovalFor(address indexed _owner, address indexed _operator, bool _approved);
}