LibCoorestCarbon

Git Source

Author: must-be-carbon

Handles interaction with the Coorest Pool and child tokens ( CCO2, POCC )

Functions

retireCarbonToken

Retires CCO2

Use this function to retire CCO2.

This function assumes that checks to carbonToken are make higher up in call stack.

It's important to know that Coorest transfers fee portion to it's account & rest amount is burned

function retireCarbonToken(
    address carbonToken,
    uint256 retireAmount,
    uint256 retireAmountWithFee,
    LibRetire.RetireDetails memory details
) internal returns (uint256 poccId);

Parameters

NameTypeDescription
carbonTokenaddressCCO2 token address.
retireAmountuint256The amount of underlying tokens to retire.
retireAmountWithFeeuint256
detailsLibRetire.RetireDetails

Returns

NameTypeDescription
poccIduint256POCC Certificate Id.

getSpecificRetirementFee

Calculates the Coorest fee that needs to be added to desired retire amount

Use this function to compute the Coorest fee.

This function assumes that checks to carbonToken are make higher up in call stack

function getSpecificRetirementFee(address carbonToken, uint256 amount) internal view returns (uint256 feeAmount);

Parameters

NameTypeDescription
carbonTokenaddressCCO2 token address
amountuint256The amount of underlying tokens to retire.

Returns

NameTypeDescription
feeAmountuint256Fee charged by Coorest.

getFeePercent

This function fetches fee percent & divider from CCO2 token contract.

function getFeePercent(address carbonToken) private view returns (FeeParams memory feeParams);

Parameters

NameTypeDescription
carbonTokenaddressCCO2 token address.

Returns

NameTypeDescription
feeParamsFeeParamsFee percentage & the fee divider.

Events

CarbonRetired

event CarbonRetired(
    LibRetire.CarbonBridge carbonBridge,
    address indexed retiringAddress,
    string retiringEntityString,
    address indexed beneficiaryAddress,
    string beneficiaryString,
    string retirementMessage,
    address indexed carbonPool,
    address carbonToken,
    uint256 retiredAmount
);

Errors

FeePercentageGreaterThanDivider

error FeePercentageGreaterThanDivider();

FeeRetireDividerIsZero

error FeeRetireDividerIsZero();

RetireAmountIsZero

error RetireAmountIsZero();

Structs

FeeParams

struct FeeParams {
    uint256 feeRetireBp;
    uint256 feeRetireDivider;
}