@@ -185,9 +185,11 @@ contract OffsetHelper is OffsetHelperStorage {
185
185
autoRetire (tco2s, amounts);
186
186
}
187
187
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
+ */
191
193
function isEligible (address _erc20Address ) private view returns (bool ) {
192
194
bool isToucanContract = IToucanContractRegistry (contractRegistryAddress)
193
195
.checkERC20 (_erc20Address);
@@ -200,19 +202,23 @@ contract OffsetHelper is OffsetHelperStorage {
200
202
return false ;
201
203
}
202
204
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
+ */
206
210
function isSwapable (address _erc20Address ) private view returns (bool ) {
207
211
if (_erc20Address == eligibleTokenAddresses["USDC " ]) return true ;
208
212
if (_erc20Address == eligibleTokenAddresses["WETH " ]) return true ;
209
213
if (_erc20Address == eligibleTokenAddresses["WMATIC " ]) return true ;
210
214
return false ;
211
215
}
212
216
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
+ */
216
222
function isRedeemable (address _erc20Address ) private view returns (bool ) {
217
223
if (_erc20Address == eligibleTokenAddresses["BCT " ]) return true ;
218
224
if (_erc20Address == eligibleTokenAddresses["NCT " ]) return true ;
@@ -256,11 +262,13 @@ contract OffsetHelper is OffsetHelperStorage {
256
262
return amountsIn[0 ];
257
263
}
258
264
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
+ */
264
272
function swap (
265
273
address _fromToken ,
266
274
address _toToken ,
@@ -348,10 +356,11 @@ contract OffsetHelper is OffsetHelperStorage {
348
356
return amounts[0 ];
349
357
}
350
358
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
+ */
355
364
function swap (address _toToken , uint256 _amount ) public payable {
356
365
// check tokens
357
366
require (isRedeemable (_toToken), "Token not eligible " );
@@ -393,7 +402,9 @@ contract OffsetHelper is OffsetHelperStorage {
393
402
balances[msg .sender ][path[2 ]] += _amount;
394
403
}
395
404
396
- /// @notice allow users to withdraw tokens they have deposited
405
+ /**
406
+ * @notice allow users to withdraw tokens they have deposited
407
+ */
397
408
function withdraw (address _erc20Addr , uint256 _amount ) public {
398
409
require (
399
410
balances[msg .sender ][_erc20Addr] >= _amount,
@@ -404,21 +415,25 @@ contract OffsetHelper is OffsetHelperStorage {
404
415
balances[msg .sender ][_erc20Addr] -= _amount;
405
416
}
406
417
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
+ */
409
422
function deposit (address _erc20Addr , uint256 _amount ) public {
410
423
require (isRedeemable (_erc20Addr), "Token not eligible " );
411
424
412
425
IERC20 (_erc20Addr).safeTransferFrom (msg .sender , address (this ), _amount);
413
426
balances[msg .sender ][_erc20Addr] += _amount;
414
427
}
415
428
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
+ */
422
437
function autoRedeem (address _fromToken , uint256 _amount )
423
438
public
424
439
returns (address [] memory tco2s , uint256 [] memory amounts )
@@ -446,9 +461,11 @@ contract OffsetHelper is OffsetHelperStorage {
446
461
emit Redeemed (msg .sender , _fromToken, tco2s, amounts);
447
462
}
448
463
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
+ */
452
469
function autoRetire (address [] memory _tco2s , uint256 [] memory _amounts )
453
470
public
454
471
{
@@ -478,18 +495,22 @@ contract OffsetHelper is OffsetHelperStorage {
478
495
// Admin methods
479
496
// ----------------------------------------
480
497
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
+ */
484
503
function setEligibleTokenAddress (
485
504
string memory _tokenSymbol ,
486
505
address _address
487
506
) public virtual onlyOwner {
488
507
eligibleTokenAddresses[_tokenSymbol] = _address;
489
508
}
490
509
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
+ */
493
514
function deleteEligibleTokenAddress (string memory _tokenSymbol )
494
515
public
495
516
virtual
@@ -498,8 +519,10 @@ contract OffsetHelper is OffsetHelperStorage {
498
519
delete eligibleTokenAddresses[_tokenSymbol];
499
520
}
500
521
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
+ */
503
526
function setToucanContractRegistry (address _address )
504
527
public
505
528
virtual
0 commit comments