11// SPDX-License-Identifier: GPL-3.0-or-later
22pragma solidity 0.6.12 ;
33
4- import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol " ;
5- import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol " ;
6- import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol " ;
4+ import {
5+ SafeMathUpgradeable
6+ } from "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol " ;
7+ import {
8+ IERC20Upgradeable
9+ } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol " ;
10+ import {
11+ OwnableUpgradeable
12+ } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol " ;
713
814/**
915 * @title XC(cross-chain)Ample ERC20 token
@@ -15,9 +21,9 @@ import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
1521 * Additionally, the XCAmple contract lets the XCAmpleController
1622 * `mint` or `burn` tokens.
1723 */
18- contract XCAmple is IERC20 , OwnableUpgradeSafe {
24+ contract XCAmple is IERC20Upgradeable , OwnableUpgradeable {
1925 // PLEASE EXERCISE CAUTION BEFORE CHANGING ANY ACCOUNTING OR MATH
20- using SafeMath for uint256 ;
26+ using SafeMathUpgradeable for uint256 ;
2127
2228 event LogRebase (uint256 indexed epoch , uint256 globalAMPLSupply );
2329 event ControllerUpdated (address controller );
@@ -80,6 +86,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
8086
8187 /**
8288 * @dev XCAmpleController notifies this contract about a new rebase cycle.
89+ * @param epoch The rebase epoch number.
8390 * @param newGlobalAMPLSupply The new total supply of AMPL from the base chain.
8491 * @return The new total AMPL supply.
8592 */
@@ -128,15 +135,15 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
128135 /**
129136 * @dev Returns the name of the token.
130137 */
131- function name () public view returns (string memory ) {
138+ function name () external view returns (string memory ) {
132139 return _name;
133140 }
134141
135142 /**
136143 * @dev Returns the symbol of the token, usually a shorter version of the
137144 * name.
138145 */
139- function symbol () public view returns (string memory ) {
146+ function symbol () external view returns (string memory ) {
140147 return _symbol;
141148 }
142149
@@ -149,22 +156,22 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
149156 * no way affects any of the arithmetic of the contract, including
150157 * {IERC20-balanceOf} and {IERC20-transfer}.
151158 */
152- function decimals () public view returns (uint8 ) {
159+ function decimals () external view returns (uint8 ) {
153160 return _decimals;
154161 }
155162
156163 /**
157164 * @return The total supply of xcAmples.
158165 */
159- function totalSupply () public view override returns (uint256 ) {
166+ function totalSupply () external view override returns (uint256 ) {
160167 return _totalSupply;
161168 }
162169
163170 /**
164171 * @param who The address to query.
165172 * @return The balance of the specified address.
166173 */
167- function balanceOf (address who ) public view override returns (uint256 ) {
174+ function balanceOf (address who ) external view override returns (uint256 ) {
168175 return _gonBalances[who].div (_gonsPerAMPL);
169176 }
170177
@@ -174,7 +181,12 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
174181 * @param value The amount to be transferred.
175182 * @return True on success, false otherwise.
176183 */
177- function transfer (address to , uint256 value ) public override validRecipient (to) returns (bool ) {
184+ function transfer (address to , uint256 value )
185+ external
186+ override
187+ validRecipient (to)
188+ returns (bool )
189+ {
178190 uint256 gonValue = value.mul (_gonsPerAMPL);
179191 _gonBalances[msg .sender ] = _gonBalances[msg .sender ].sub (gonValue);
180192 _gonBalances[to] = _gonBalances[to].add (gonValue);
@@ -188,7 +200,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
188200 * @param spender The address which will spend the funds.
189201 * @return The number of tokens still available for the spender.
190202 */
191- function allowance (address owner_ , address spender ) public view override returns (uint256 ) {
203+ function allowance (address owner_ , address spender ) external view override returns (uint256 ) {
192204 return _allowedXCAmples[owner_][spender];
193205 }
194206
@@ -202,7 +214,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
202214 address from ,
203215 address to ,
204216 uint256 value
205- ) public override validRecipient (to) returns (bool ) {
217+ ) external override validRecipient (to) returns (bool ) {
206218 _allowedXCAmples[from][msg .sender ] = _allowedXCAmples[from][msg .sender ].sub (value);
207219
208220 uint256 gonValue = value.mul (_gonsPerAMPL);
@@ -224,7 +236,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
224236 * @param spender The address which will spend the funds.
225237 * @param value The amount of tokens to be spent.
226238 */
227- function approve (address spender , uint256 value ) public override returns (bool ) {
239+ function approve (address spender , uint256 value ) external override returns (bool ) {
228240 _allowedXCAmples[msg .sender ][spender] = value;
229241 emit Approval (msg .sender , spender, value);
230242 return true ;
@@ -237,7 +249,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
237249 * @param spender The address which will spend the funds.
238250 * @param addedValue The amount of tokens to increase the allowance by.
239251 */
240- function increaseAllowance (address spender , uint256 addedValue ) public returns (bool ) {
252+ function increaseAllowance (address spender , uint256 addedValue ) external returns (bool ) {
241253 _allowedXCAmples[msg .sender ][spender] = _allowedXCAmples[msg .sender ][spender].add (
242254 addedValue
243255 );
@@ -251,7 +263,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
251263 * @param spender The address which will spend the funds.
252264 * @param subtractedValue The amount of tokens to decrease the allowance by.
253265 */
254- function decreaseAllowance (address spender , uint256 subtractedValue ) public returns (bool ) {
266+ function decreaseAllowance (address spender , uint256 subtractedValue ) external returns (bool ) {
255267 uint256 oldValue = _allowedXCAmples[msg .sender ][spender];
256268 if (subtractedValue >= oldValue) {
257269 _allowedXCAmples[msg .sender ][spender] = 0 ;
@@ -268,7 +280,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
268280 * @param who The address of the beneficiary.
269281 * @param xcAmpleAmount The amount of xcAmple tokens to be minted.
270282 */
271- function mint (address who , uint256 xcAmpleAmount ) public onlyController validRecipient (who) {
283+ function mint (address who , uint256 xcAmpleAmount ) external onlyController validRecipient (who) {
272284 uint256 gonValue = xcAmpleAmount.mul (_gonsPerAMPL);
273285 _gonBalances[who] = _gonBalances[who].add (gonValue);
274286 _totalSupply = _totalSupply.add (xcAmpleAmount);
@@ -285,7 +297,7 @@ contract XCAmple is IERC20, OwnableUpgradeSafe {
285297 * @param who The address of the beneficiary.
286298 * @param xcAmpleAmount The amount of xcAmple tokens to be burned.
287299 */
288- function burn (address who , uint256 xcAmpleAmount ) public onlyController {
300+ function burn (address who , uint256 xcAmpleAmount ) external onlyController {
289301 require (who != address (0 ), "XCAmple: burn address zero address " );
290302
291303 uint256 gonValue = xcAmpleAmount.mul (_gonsPerAMPL);
0 commit comments