Skip to content

Inconsistent use of return and input arguments in (pool) redeemAuto()/redeemAuto2() and (tco2) retire() #5

Closed
@danceratopz

Description

@danceratopz

This is a minor issue that impacts developers working directly with the Toucan core contracts.

  1. The pool functions (e.g. in NCT.sol) redeemAuto() and redeemAuto2() return arrays of TCO2 addresses and corresponding amounts that were redeemed in exchange for the pool token. These arrays contain entries corresponding to the TCO2s with the lowest scores from scoredTCO2s. In particular, if the lowest scored TCO2 is not present in the NCT pool (i.e., the pool has balance 0) then these functions still return the TCO2 address with a corresponding entry of 0 in the amounts array.
  2. The TCO2 retire() function (from ToucanCarbonOffsets.sol) takes a uint256 specifying the amount to retire. If this value is zero the transaction gets reverted, as _retire() then calls registerEvent()from RetirementCertifiates.sol which understandably requires that amount to be non-zero, see:
    amount != 0 && amount >= minValidRetirementAmount,
    .

A user would intuitively expect to be able to loop over the outputs of redeemAuto() and provide them to retire() as inputs, which is currently the case in the OffsetHelper, see example-implementations/blob/d5e6...94cf8/contracts/OffsetHelper.sol#L494.

Perhaps it would be better to remove TCO2 addresses with corresponding amount 0 from the output of the redeemAuto functions?

The background that led to this observation is described in ToucanProtocol/example-implementations#31.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions