LibRetire

Git Source

Author: Cujo

Functions

retireReceivedCarbon

Retire received carbon based on the bridge of the provided pool tokens using default redemption

function retireReceivedCarbon(
    address poolToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage
) internal;

Parameters

NameTypeDescription
poolTokenaddressPool token used to retire
amountuint256The amount of carbon to retire
retiringAddressaddress
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

retireReceivedExactCarbonSpecific

Retire received carbon based on the bridge of the provided pool tokens using specific redemption

function retireReceivedExactCarbonSpecific(
    address poolToken,
    address projectToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage
) internal returns (uint256 redeemedAmount);

Parameters

NameTypeDescription
poolTokenaddressPool token used to retire
projectTokenaddressProject token being retired
amountuint256The amount of carbon to retire
retiringAddressaddress
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

retireReceivedCreditToken

Retire received carbon based on the bridge of the provided pool tokens using default redemption

function retireReceivedCreditToken(
    address creditToken,
    uint256 tokenId,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage
) internal;

Parameters

NameTypeDescription
creditTokenaddressPool token used to retire
tokenIduint256
amountuint256The amount of carbon to retire
retiringAddressaddress
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

retireReceivedCarbonSpecificFromSource

Additional function to handle the differences in wanting to fully retire x pool tokens specifically

function retireReceivedCarbonSpecificFromSource(
    address poolToken,
    address projectToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage
) internal returns (uint256 redeemedAmount);

Parameters

NameTypeDescription
poolTokenaddressPool token used to retire
projectTokenaddressProject token being retired
amountuint256The amount of carbon to retire
retiringAddressaddress
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

Returns

NameTypeDescription
redeemedAmountuint256Number of pool tokens redeemed

getTotalCarbon

Returns the total carbon needed fee included

function getTotalCarbon(uint256 retireAmount) internal view returns (uint256 totalCarbon);

Parameters

NameTypeDescription
retireAmountuint256Pool token used to retire

Returns

NameTypeDescription
totalCarbonuint256Total pool token needed

getTotalCarbonSpecific

Returns the total carbon needed fee included

function getTotalCarbonSpecific(address poolToken, uint256 retireAmount) internal view returns (uint256 totalCarbon);

Parameters

NameTypeDescription
poolTokenaddressPool token used to retire
retireAmountuint256Amount of carbon wanting to retire

Returns

NameTypeDescription
totalCarbonuint256Total pool token needed

getFee

Returns the total fee needed to retire x number of tokens

function getFee(uint256 carbonAmount) internal view returns (uint256 fee);

Parameters

NameTypeDescription
carbonAmountuint256Amount being retired

Returns

NameTypeDescription
feeuint256Total fee charged

saveRetirementDetails

Saves the details of the retirement over to KlimaCarbonRetirements and project details within AppStorage

function saveRetirementDetails(
    address poolToken,
    address projectToken,
    uint256 amount,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage
) internal;

Parameters

NameTypeDescription
poolTokenaddressPool token used to retire
projectTokenaddressPool token used to retire
amountuint256Amount of carbon wanting to retire
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

getTotalRetirements

function getTotalRetirements(address account) internal view returns (uint256 totalRetirements);

getTotalCarbonRetired

function getTotalCarbonRetired(address account) internal view returns (uint256 totalCarbonRetired);

getTotalPoolRetired

function getTotalPoolRetired(address account, address poolToken) internal view returns (uint256 totalPoolRetired);

getTotalProjectRetired

function getTotalProjectRetired(address account, address projectToken) internal view returns (uint256);

getTotalRewardsClaimed

function getTotalRewardsClaimed(address account) internal view returns (uint256 totalClaimed);

getRetirementDetails

function getRetirementDetails(address account, uint256 retirementIndex)
    internal
    view
    returns (
        address poolTokenAddress,
        address projectTokenAddress,
        address beneficiaryAddress,
        string memory beneficiary,
        string memory retirementMessage,
        uint256 amount
    );

Structs

RetireDetails

struct RetireDetails {
    address retiringAddress;
    string retiringEntityString;
    address beneficiaryAddress;
    string beneficiaryString;
    string retirementMessage;
}

Enums

CarbonBridge

enum CarbonBridge {
    TOUCAN,
    MOSS,
    C3,
    ICR
}