Skip to content

Commit 2751634

Browse files
committed
docs: use consistent natspec comment format; minor doc improvements
1 parent 078a811 commit 2751634

File tree

2 files changed

+68
-43
lines changed

2 files changed

+68
-43
lines changed

contracts/OffsetHelper.sol

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ contract OffsetHelper is OffsetHelperStorage {
185185
autoRetire(tco2s, amounts);
186186
}
187187

188-
/// @notice Checks whether an address can be used by the contract.
189-
/// @param _erc20Address address of the ERC20 token to be checked
190-
/// @return True if the address can be used by the contract
188+
/**
189+
* @notice Checks whether an address can be used by the contract.
190+
* @param _erc20Address address of the ERC20 token to be checked
191+
* @return True if the address can be used by the contract
192+
*/
191193
function isEligible(address _erc20Address) private view returns (bool) {
192194
bool isToucanContract = IToucanContractRegistry(contractRegistryAddress)
193195
.checkERC20(_erc20Address);
@@ -200,19 +202,23 @@ contract OffsetHelper is OffsetHelperStorage {
200202
return false;
201203
}
202204

203-
/// @notice Checks whether an address can be used in a token swap
204-
/// @param _erc20Address address of token to be checked
205-
/// @return True if the specified address can be used in a swap
205+
/**
206+
* @notice Checks whether an address can be used in a token swap
207+
* @param _erc20Address address of token to be checked
208+
* @return True if the specified address can be used in a swap
209+
*/
206210
function isSwapable(address _erc20Address) private view returns (bool) {
207211
if (_erc20Address == eligibleTokenAddresses["USDC"]) return true;
208212
if (_erc20Address == eligibleTokenAddresses["WETH"]) return true;
209213
if (_erc20Address == eligibleTokenAddresses["WMATIC"]) return true;
210214
return false;
211215
}
212216

213-
/// @notice Checks whether an address is a Toucan pool token address
214-
/// @param _erc20Address address of token to be checked
215-
/// @return True if the address is a Toucan pool token address
217+
/**
218+
* @notice Checks whether an address is a Toucan pool token address
219+
* @param _erc20Address address of token to be checked
220+
* @return True if the address is a Toucan pool token address
221+
*/
216222
function isRedeemable(address _erc20Address) private view returns (bool) {
217223
if (_erc20Address == eligibleTokenAddresses["BCT"]) return true;
218224
if (_erc20Address == eligibleTokenAddresses["NCT"]) return true;
@@ -256,11 +262,13 @@ contract OffsetHelper is OffsetHelperStorage {
256262
return amountsIn[0];
257263
}
258264

259-
/// @notice uses SushiSwap to exchange eligible tokens for BCT / NCT
260-
/// @param _fromToken token to deposit and swap
261-
/// @param _toToken token to swap for (will be held within contract)
262-
/// @param _amount amount of NCT / BCT wanted
263-
/// @notice needs to be approved on the client side
265+
/**
266+
* @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap
267+
* @dev Needs to be approved on the client side
268+
* @param _fromToken token to deposit and swap
269+
* @param _toToken token to swap for (will be held within contract)
270+
* @param _amount amount of NCT / BCT wanted
271+
*/
264272
function swap(
265273
address _fromToken,
266274
address _toToken,
@@ -348,10 +356,11 @@ contract OffsetHelper is OffsetHelperStorage {
348356
return amounts[0];
349357
}
350358

351-
/// @notice uses SushiSwap to exchange MATIC for BCT / NCT
352-
/// @param _toToken token to swap for (will be held within contract)
353-
/// @param _amount amount of NCT / BCT wanted
354-
/// @notice needs to be provided a message value on client side
359+
/**
360+
* @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap
361+
* @param _toToken token to swap for (will be held within contract)
362+
* @param _amount amount of NCT / BCT wanted
363+
*/
355364
function swap(address _toToken, uint256 _amount) public payable {
356365
// check tokens
357366
require(isRedeemable(_toToken), "Token not eligible");
@@ -393,7 +402,9 @@ contract OffsetHelper is OffsetHelperStorage {
393402
balances[msg.sender][path[2]] += _amount;
394403
}
395404

396-
/// @notice allow users to withdraw tokens they have deposited
405+
/**
406+
* @notice allow users to withdraw tokens they have deposited
407+
*/
397408
function withdraw(address _erc20Addr, uint256 _amount) public {
398409
require(
399410
balances[msg.sender][_erc20Addr] >= _amount,
@@ -404,21 +415,25 @@ contract OffsetHelper is OffsetHelperStorage {
404415
balances[msg.sender][_erc20Addr] -= _amount;
405416
}
406417

407-
/// @notice allow people to deposit BCT / NCT
408-
/// @notice needs to be approved
418+
/**
419+
* @notice allow people to deposit BCT / NCT
420+
* @dev needs to be approved
421+
*/
409422
function deposit(address _erc20Addr, uint256 _amount) public {
410423
require(isRedeemable(_erc20Addr), "Token not eligible");
411424

412425
IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);
413426
balances[msg.sender][_erc20Addr] += _amount;
414427
}
415428

416-
/// @notice Redeems the specified amount of NCT / BCT for TCO2
417-
/// @param _fromToken could be the address of NCT or BCT
418-
/// @param _amount amount to redeem
419-
/// @notice needs to be approved on the client side
420-
/// @return tco2s an array of the TCO2 addresses that were redeemed
421-
/// @return amounts an array of the amounts of each TCO2 that were redeemed
429+
/**
430+
* @notice Redeems the specified amount of NCT / BCT for TCO2
431+
* @dev needs to be approved on the client side
432+
* @param _fromToken could be the address of NCT or BCT
433+
* @param _amount amount to redeem
434+
* @return tco2s an array of the TCO2 addresses that were redeemed
435+
* @return amounts an array of the amounts of each TCO2 that were redeemed
436+
*/
422437
function autoRedeem(address _fromToken, uint256 _amount)
423438
public
424439
returns (address[] memory tco2s, uint256[] memory amounts)
@@ -446,9 +461,11 @@ contract OffsetHelper is OffsetHelperStorage {
446461
emit Redeemed(msg.sender, _fromToken, tco2s, amounts);
447462
}
448463

449-
/// @notice Retire the specified TCO2 tokens.
450-
/// @param _tco2s the addresses of the TCO2s to retire
451-
/// @param _amounts the amounts to retire from the matching TCO2
464+
/**
465+
* @notice Retire the specified TCO2 tokens.
466+
* @param _tco2s the addresses of the TCO2s to retire
467+
* @param _amounts the amounts to retire from the matching TCO2
468+
*/
452469
function autoRetire(address[] memory _tco2s, uint256[] memory _amounts)
453470
public
454471
{
@@ -478,18 +495,22 @@ contract OffsetHelper is OffsetHelperStorage {
478495
// Admin methods
479496
// ----------------------------------------
480497

481-
/// @notice you can use this to change or add eligible tokens and their addresses if needed
482-
/// @param _tokenSymbol symbol of the token to add
483-
/// @param _address the address of the token to add
498+
/**
499+
* @notice you can use this to change or add eligible tokens and their addresses if needed
500+
* @param _tokenSymbol symbol of the token to add
501+
* @param _address the address of the token to add
502+
*/
484503
function setEligibleTokenAddress(
485504
string memory _tokenSymbol,
486505
address _address
487506
) public virtual onlyOwner {
488507
eligibleTokenAddresses[_tokenSymbol] = _address;
489508
}
490509

491-
/// @notice you can use this to delete eligible tokens if needed
492-
/// @param _tokenSymbol symbol of the token to add
510+
/**
511+
* @notice you can use this to delete eligible tokens if needed
512+
* @param _tokenSymbol symbol of the token to add
513+
*/
493514
function deleteEligibleTokenAddress(string memory _tokenSymbol)
494515
public
495516
virtual
@@ -498,8 +519,10 @@ contract OffsetHelper is OffsetHelperStorage {
498519
delete eligibleTokenAddresses[_tokenSymbol];
499520
}
500521

501-
/// @notice you can use this to change the TCO2 contracts registry if needed
502-
/// @param _address the contract registry to use
522+
/**
523+
* @notice you can use this to change the TCO2 contracts registry if needed
524+
* @param _address the contract registry to use
525+
*/
503526
function setToucanContractRegistry(address _address)
504527
public
505528
virtual

docs/OffsetHelper.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ example, BCT or NCT.
216216
function swap(address _fromToken, address _toToken, uint256 _amount) public
217217
```
218218

219-
uses SushiSwap to exchange eligible tokens for BCT / NCT
220-
needs to be approved on the client side
219+
Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap
220+
221+
_Needs to be approved on the client side_
221222

222223
| Name | Type | Description |
223224
| ---- | ---- | ----------- |
@@ -261,8 +262,7 @@ desired amount of a Toucan pool token, for example, BCT or NCT.
261262
function swap(address _toToken, uint256 _amount) public payable
262263
```
263264

264-
uses SushiSwap to exchange MATIC for BCT / NCT
265-
needs to be provided a message value on client side
265+
Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap
266266

267267
| Name | Type | Description |
268268
| ---- | ---- | ----------- |
@@ -284,7 +284,8 @@ function deposit(address _erc20Addr, uint256 _amount) public
284284
```
285285

286286
allow people to deposit BCT / NCT
287-
needs to be approved
287+
288+
_needs to be approved_
288289

289290
### autoRedeem
290291

@@ -293,7 +294,8 @@ function autoRedeem(address _fromToken, uint256 _amount) public returns (address
293294
```
294295

295296
Redeems the specified amount of NCT / BCT for TCO2
296-
needs to be approved on the client side
297+
298+
_needs to be approved on the client side_
297299

298300
| Name | Type | Description |
299301
| ---- | ---- | ----------- |

0 commit comments

Comments
 (0)