KlimaDAO contracts

Local Development

Install foundry:

https://book.getfoundry.sh/getting-started/installation

For Linux and MacOS users:

curl -L https://foundry.paradigm.xyz | bash

This will download foundryup. Then install Foundry by running:

foundryup

Deploy

These examples use a localhost fork running on the anvil command

Base Protocol Contracts

  • Deploy the Klima tokens (KLIMA, sKLIMA, wsKLIMA).

    forge script script/deployProtocolTokens.s.sol:DeployKlimaProtocolTokens --fork-url http://localhost:8545 --broadcast --ffi
    
  • Update .env with the KLIMA and sKLIMA addresses from the previous step and deploy the Klima treasury.

    forge script script/deployProtocolTreasury.s.sol:DeployKlimaTreasury --fork-url http://localhost:8545 --broadcast --ffi
    
  • Update .env with the treasury address from the previous step. Also, configure the desired parameters for the first epoch number, block, and epoch length in the deploy script below.

    forge script script/deployProtocolStaking.s.sol:DeployKlimaStaking --fork-url http://localhost:8545 --broadcast --ffi
    

Infinity Diamond Deployment

  • Deploy the base Diamond, facet implementations, and perform the diamon cut with the following script.
    forge script script/deployInfinity.s.sol:DeployInfinityScript --fork-url http://localhost:8545 --broadcast --ffi
    

Deprecated Contracts

Note that the AlphaKlimaRedeemUpgradeable will fail to get built by default, and therefore has been marked deprecated.

In order to compile this contract, you will need to manually update the @openzeppelin/contracts-upgradeable contracts that are downloaded in your node_modules by changing _trustedForwarder in metatx/ERC2771ContextUpgradeable.sol from a private to a public address.

There is another issue related to the _trustedForwarder in that contract that has not yet been resolved.

Since aKLIMA was a prelaunch coupon and the existing deployed versino of the redemption contract works as expected, this contract is no longer needed.

Contents

Contents

Contents

Contents

RedeemC3PoolFacet

Git Source

Inherits: ReentrancyGuard

Functions

c3RedeemPoolDefault

Redeems default underlying carbon tokens from a C3 Pool

function c3RedeemPoolDefault(
    address sourceToken,
    address poolToken,
    uint256 amount,
    uint256 maxAmountIn,
    LibTransfer.From fromMode,
    LibTransfer.To toMode
) external nonReentrant returns (address[] memory projectTokens, uint256[] memory amounts);

Parameters

NameTypeDescription
sourceTokenaddressSource token to use in the redemption
poolTokenaddressPool token to redeem
amountuint256Amount to redeem
maxAmountInuint256Max amount of source token to spend
fromModeLibTransfer.FromFrom Mode for transfering tokens
toModeLibTransfer.ToTo Mode for where undlerying tokens are sent

Returns

NameTypeDescription
projectTokensaddress[]List of underlying tokens received
amountsuint256[]Amounts of underlying tokens received

c3RedeemPoolSpecific

Redeems default underlying carbon tokens from a C3 Pool

function c3RedeemPoolSpecific(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    address[] memory projectTokens,
    uint256[] memory amounts,
    LibTransfer.From fromMode,
    LibTransfer.To toMode
) external nonReentrant returns (uint256[] memory redeemedAmounts);

Parameters

NameTypeDescription
sourceTokenaddressSource token to use in the redemption
poolTokenaddressPool token to redeem
maxAmountInuint256Max amount of source token to spend
projectTokensaddress[]Underlying tokens to redeem
amountsuint256[]Amounts of underlying tokens to redeem
fromModeLibTransfer.FromFrom Mode for transfering tokens
toModeLibTransfer.ToTo Mode for where undlerying tokens are sent

Returns

NameTypeDescription
redeemedAmountsuint256[]Amounts of underlying tokens redeemed

RetireC3C3TFacet

Git Source

Inherits: ReentrancyGuard

Functions

c3RetireExactC3T

This contract assumes that the token being provided is a raw TCO2 token.

The transactions will revert otherwise.

Redeems C3T directly

function c3RetireExactC3T(
    address carbonToken,
    uint256 amount,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
carbonTokenaddressPool token to redeem
amountuint256Amounts of underlying tokens to redeem
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

c3RetireExactC3TWithEntity

Redeems C3T directly

function c3RetireExactC3TWithEntity(
    address carbonToken,
    uint256 amount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
carbonTokenaddressPool token to redeem
amountuint256Amounts of underlying tokens to redeem
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

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
);

Contents

RetireICRFacet

Git Source

Inherits: ReentrancyGuard

Functions

icrRetireExactCarbon

This contract assumes that the token being provided is a raw ICR project token.

The transactions will revert otherwise.

Redeems ICR credit directly

function icrRetireExactCarbon(
    address projectToken,
    uint256 tokenId,
    uint256 amount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
projectTokenaddressProject token address
tokenIduint256Token ID for project to retire
amountuint256Amounts of underlying tokens to redeem
retiringEntityStringstringString description for the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

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 tokenId,
    uint256 retiredAmount
);

Contents

RedeemToucanPoolFacet

Git Source

Inherits: ReentrancyGuard

Functions

toucanRedeemExactCarbonPoolDefault

Redeems default underlying carbon tokens from a Toucan Pool

function toucanRedeemExactCarbonPoolDefault(
    address sourceToken,
    address poolToken,
    uint256 amount,
    uint256 maxAmountIn,
    LibTransfer.From fromMode,
    LibTransfer.To toMode
) external nonReentrant returns (address[] memory projectTokens, uint256[] memory amounts);

Parameters

NameTypeDescription
sourceTokenaddressSource token to use in the redemption
poolTokenaddressPool token to redeem
amountuint256Amount to redeem
maxAmountInuint256Max amount of source token to spend
fromModeLibTransfer.FromFrom Mode for transfering tokens
toModeLibTransfer.ToTo Mode for where undlerying tokens are sent

Returns

NameTypeDescription
projectTokensaddress[]List of underlying tokens received
amountsuint256[]Amounts of underlying tokens received

toucanRedeemExactCarbonPoolSpecific

Redeems specific underlying carbon tokens from a Toucan Pool

function toucanRedeemExactCarbonPoolSpecific(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    address[] memory projectTokens,
    uint256[] memory amounts,
    LibTransfer.From fromMode,
    LibTransfer.To toMode
) external nonReentrant returns (uint256[] memory redeemedAmounts);

Parameters

NameTypeDescription
sourceTokenaddressSource token to use in the redemption
poolTokenaddressPool token to redeem
maxAmountInuint256Maximum amount of source token to spend
projectTokensaddress[]Underlying tokens to redeem
amountsuint256[]Amounts of underlying tokens to redeem
fromModeLibTransfer.FromFrom Mode for transfering tokens
toModeLibTransfer.ToTo Mode for where undlerying tokens are sent

Returns

NameTypeDescription
redeemedAmountsuint256[]Amounts of underlying tokens redeemed

RetireToucanTCO2Facet

Git Source

Inherits: ReentrancyGuard

Functions

toucanRetireExactTCO2

This contract assumes that the token being provided is a raw TCO2 token.

The transactions will revert otherwise

Redeems TCO2 directly

function toucanRetireExactTCO2(
    address carbonToken,
    uint256 amount,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
carbonTokenaddressPool token to redeem
amountuint256Amounts of underlying tokens to redeem
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

toucanRetireExactTCO2WithEntity

Redeems TCO2 directly

function toucanRetireExactTCO2WithEntity(
    address carbonToken,
    uint256 amount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
carbonTokenaddressPool token to redeem
amountuint256Amounts of underlying tokens to redeem
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

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
);

Contents

RetireCarbonFacet

Git Source

Inherits: ReentrancyGuard

Functions

retireExactCarbonDefault

Retires an exact amount of carbon using default redemption

function retireExactCarbonDefault(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external payable nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
sourceTokenaddressSource ERC-20 token to use for the retirement
poolTokenaddressPool token to use for this retirement
maxAmountInuint256Maximum amount of source tokens to spend in this retirement
retireAmountuint256The amount of carbon to retire
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

retireExactCarbonSpecific

Retires an exact amount of carbon using specific redemption

function retireExactCarbonSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 maxAmountIn,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external payable nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
sourceTokenaddressSource ERC-20 token to use for the retirement
poolTokenaddressPool token to use for this retirement
projectTokenaddressProject token to redeem and retire
maxAmountInuint256Maximum amount of source tokens to spend in this retirement
retireAmountuint256The amount of carbon to retire
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

Events

CarbonRetired

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

RetireCarbonmarkFacet

Git Source

Inherits: ReentrancyGuard

Functions

retireCarbonmarkListing

Retires an exact amount of carbon using default redemption

function retireCarbonmarkListing(
    ICarbonmark.CreditListing memory listing,
    uint256 maxAmountIn,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external payable nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
listingICarbonmark.CreditListing
maxAmountInuint256Maximum amount of USDC tokens to spend for this retirement
retireAmountuint256The amount of carbon to retire
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

Events

CarbonRetired

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

RetireInfoFacet

Git Source

Functions

getTotalRetirements

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

getTotalCarbonRetired

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

getTotalPoolRetired

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

getTotalProjectRetired

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

getTotalRewardsClaimed

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

getRetirementDetails

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

RetireSourceFacet

Git Source

Inherits: ReentrancyGuard

Functions

retireExactSourceDefault

Retires an exact amount of a source token using default redemption

function retireExactSourceDefault(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external payable nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
sourceTokenaddressSource ERC-20 token to use for the retirement
poolTokenaddressPool token to use for this retirement
maxAmountInuint256Maximum amount of source tokens to spend in this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

retireExactSourceSpecific

Retires an exact amount of a source token using specific redemption

Initial value set assuming source == pool.

function retireExactSourceSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 maxAmountIn,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    LibTransfer.From fromMode
) external payable nonReentrant returns (uint256 retirementIndex);

Parameters

NameTypeDescription
sourceTokenaddressSource ERC-20 token to use for the retirement
poolTokenaddressPool token to use for this retirement
projectTokenaddressProject token to redeem and retire
maxAmountInuint256Maximum amount of source tokens to spend in this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement
fromModeLibTransfer.FromFrom Mode for transfering tokens

Returns

NameTypeDescription
retirementIndexuint256The latest retirement index for the beneficiary address

Events

CarbonRetired

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

DiamondCutFacet

Git Source

Inherits: IDiamondCut


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /*****************************************************************************

Functions

diamondCut

Add/replace/remove any number of functions and optionally execute a function with delegatecall

function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external override;

Parameters

NameTypeDescription
_diamondCutFacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init

DiamondLoupeFacet

Git Source

Inherits: IDiamondLoupe, IERC165


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /*****************************************************************************

Functions

facets

These functions are expected to be called frequently by tools.

Gets all facets and their selectors.

function facets() external view override returns (Facet[] memory facets_);

Returns

NameTypeDescription
facets_Facet[]Facet

facetFunctionSelectors

Gets all the function selectors provided by a facet.

function facetFunctionSelectors(address _facet)
    external
    view
    override
    returns (bytes4[] memory facetFunctionSelectors_);

Parameters

NameTypeDescription
_facetaddressThe facet address.

Returns

NameTypeDescription
facetFunctionSelectors_bytes4[]facetFunctionSelectors_

facetAddresses

Get all the facet addresses used by a diamond.

function facetAddresses() external view override returns (address[] memory facetAddresses_);

Returns

NameTypeDescription
facetAddresses_address[]facetAddresses_

facetAddress

Gets the facet that supports the given selector.

If facet is not found return address(0).

function facetAddress(bytes4 _functionSelector) external view override returns (address facetAddress_);

Parameters

NameTypeDescription
_functionSelectorbytes4The function selector.

Returns

NameTypeDescription
facetAddress_addressThe facet address.

supportsInterface

function supportsInterface(bytes4 _interfaceId) external view override returns (bool);

DustFacet

Git Source

Inherits: ReentrancyGuard

Author: Cujo

Functions

sendDust

function sendDust() external payable;

ERC1155ReceiverFacet

Git Source

Inherits: ReentrancyGuard, IERC1155Receiver

Functions

onERC1155Received

function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data)
    external
    virtual
    override
    returns (bytes4);

onERC1155BatchReceived

function onERC1155BatchReceived(
    address operator,
    address from,
    uint256[] calldata ids,
    uint256[] calldata values,
    bytes calldata data
) external virtual override returns (bytes4);

ERC721ReceiverFacet

Git Source

Inherits: ReentrancyGuard, IERC721Receiver

Functions

onERC721Received

function onERC721Received(address, address, uint256 tokenId, bytes memory) external virtual override returns (bytes4);

MetaTransactionsFacet

Git Source

Inherits: ReentrancyGuard

State Variables

META_TRANSACTION_TYPEHASH

bytes32 private constant META_TRANSACTION_TYPEHASH =
    keccak256(bytes("MetaTransaction(uint256 nonce,address from,bytes functionSignature)"));

Functions

convertBytesToBytes4

function convertBytesToBytes4(bytes memory inBytes) internal pure returns (bytes4 outBytes4);

getDomainSeparator

function getDomainSeparator() private view returns (bytes32);

toTypedMessageHash

Accept message hash and returns hash message in EIP712 compatible form So that it can be used to recover signer from signature signed using EIP712 formatted data https://eips.ethereum.org/EIPS/eip-712 "\x19" makes the encoding deterministic "\x01" is the version byte to make it compatible to EIP-191

function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32);

hashMetaTransaction

function hashMetaTransaction(MetaTransaction memory metaTx) internal pure returns (bytes32);

getNonce

Query the latest nonce of an address

function getNonce(address user) external view returns (uint256 nonce_);

Parameters

NameTypeDescription
useraddressAddress to query

Returns

NameTypeDescription
nonce_uint256The latest nonce for the address

verify

function verify(address user, MetaTransaction memory metaTx, bytes32 sigR, bytes32 sigS, uint8 sigV)
    internal
    view
    returns (bool);

executeMetaTransaction

function executeMetaTransaction(
    address userAddress,
    bytes memory functionSignature,
    bytes32 sigR,
    bytes32 sigS,
    uint8 sigV
) public payable returns (bytes memory);

Events

MetaTransactionExecuted

event MetaTransactionExecuted(address userAddress, address payable relayerAddress, bytes functionSignature);

Structs

MetaTransaction

struct MetaTransaction {
    uint256 nonce;
    address from;
    bytes functionSignature;
}

OwnershipFacet

Git Source

Inherits: IERC173

Functions

transferOwnership

function transferOwnership(address _newOwner) external override;

owner

function owner() external view override returns (address owner_);

RetirementQuoter

Git Source

Author: Cujo

State Variables

s

AppStorage internal s;

Functions

getSourceAmountSwapOnly

function getSourceAmountSwapOnly(address sourceToken, address carbonToken, uint256 amountOut)
    public
    view
    returns (uint256 amountIn);

getSourceAmountDefaultRetirement

function getSourceAmountDefaultRetirement(address sourceToken, address carbonToken, uint256 retireAmount)
    public
    view
    returns (uint256 amountIn);

getSourceAmountSpecificRetirement

function getSourceAmountSpecificRetirement(address sourceToken, address carbonToken, uint256 retireAmount)
    public
    view
    returns (uint256 amountIn);

getSourceAmountDefaultRedeem

function getSourceAmountDefaultRedeem(address sourceToken, address carbonToken, uint256 redeemAmount)
    public
    view
    returns (uint256 amountIn);

getSourceAmountSpecificRedeem

function getSourceAmountSpecificRedeem(address sourceToken, address carbonToken, uint256[] memory redeemAmounts)
    public
    view
    returns (uint256 amountIn);

getRetireAmountSourceDefault

function getRetireAmountSourceDefault(address sourceToken, address carbonToken, uint256 amount)
    public
    view
    returns (uint256 amountOut);

getRetireAmountSourceSpecific

function getRetireAmountSourceSpecific(address sourceToken, address carbonToken, uint256 amount)
    public
    view
    returns (uint256 amountOut);

TokenFacet

Git Source

Author: Publius

SPDX-License-Identifier: MIT

Functions

transferToken

Transfer

function transferToken(
    IERC20 token,
    address recipient,
    uint256 amount,
    LibTransfer.From fromMode,
    LibTransfer.To toMode
) external payable;

wrapMatic

Weth

function wrapMatic(uint256 amount, LibTransfer.To mode) external payable;

unwrapMatic

function unwrapMatic(uint256 amount, LibTransfer.From mode) external payable;

getInternalBalance

Getters

function getInternalBalance(address account, IERC20 token) public view returns (uint256 balance);

getInternalBalances

function getInternalBalances(address account, IERC20[] memory tokens)
    external
    view
    returns (uint256[] memory balances);

getExternalBalance

function getExternalBalance(address account, IERC20 token) public view returns (uint256 balance);

getExternalBalances

function getExternalBalances(address account, IERC20[] memory tokens)
    external
    view
    returns (uint256[] memory balances);

getBalance

function getBalance(address account, IERC20 token) public view returns (uint256 balance);

getBalances

function getBalances(address account, IERC20[] memory tokens) external view returns (uint256[] memory balances);

getAllBalance

function getAllBalance(address account, IERC20 token) public view returns (Balance memory b);

getAllBalances

function getAllBalances(address account, IERC20[] memory tokens) external view returns (Balance[] memory balances);

Events

InternalBalanceChanged

event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta);

Structs

Balance

struct Balance {
    uint256 internalBalance;
    uint256 externalBalance;
    uint256 totalBalance;
}

Contents

DiamondInit

Git Source


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 Implementation of a diamond. /*****************************************************************************

State Variables

s

AppStorage internal s;

MAX_INT

uint256 private constant MAX_INT = 2 ** 256 - 1;

Functions

init

function init() external;

InitProjectTotals

Git Source

State Variables

s

AppStorage internal s;

Functions

init

function init() external;

_EmptyInit

Git Source

Functions

init

function init() external;

Contents

IC3Pool

Git Source

Functions

freeRedeem

function freeRedeem(uint256 amount) external;

taxedRedeem

function taxedRedeem(address[] memory erc20Addresses, uint256[] memory amount) external;

getFreeRedeemAddresses

function getFreeRedeemAddresses() external view returns (address[] memory);

getERC20Tokens

function getERC20Tokens() external view returns (address[] memory);

feeRedeem

function feeRedeem() external view returns (uint256);

IC3ProjectToken

Git Source

Functions

offsetFor

function offsetFor(uint256 amount, address beneficiary, string memory transferee, string memory reason) external;

IC3ProjectFactory

Git Source

Functions

isTokenExists

function isTokenExists(address _address) external returns (bool);

ICarbonChain

Git Source

Functions

offsetCarbon

function offsetCarbon(uint256 _carbonTon, string calldata _transactionInfo, string calldata _onBehalfOf) external;

ICarbonmark

Git Source

Functions

createListing

This function creates a new listing and returns the resulting listing ID

function createListing(address token, uint256 amount, uint256 unitPrice, uint256 minFillAmount, uint256 deadline)
    external
    returns (bytes32 id);

Parameters

NameTypeDescription
tokenaddressThe token being listed
amountuint256The amount to be listed
unitPriceuint256The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000
minFillAmountuint256The minimum number of tons needed to be purchased to fill this listing
deadlineuint256The block timestamp at which this listing will expire

Returns

NameTypeDescription
idbytes32The ID of the listing that was created

fillListing

This function fills an existing listing

function fillListing(
    bytes32 id,
    address listingAccount,
    address listingToken,
    uint256 listingUnitPrice,
    uint256 amount,
    uint256 maxCost
) external;

Parameters

NameTypeDescription
idbytes32The listing ID to update
listingAccountaddressThe account that created the listing you are filling
listingTokenaddressThe token you are swapping for
listingUnitPriceuint256The unit price per token to fill the listing
amountuint256Amount of the listing to fill
maxCostuint256Maximum cost in USDC for filling this listing

getListingOwner

function getListingOwner(bytes32 id) external view returns (address);

getUnitPrice

function getUnitPrice(bytes32 id) external view returns (uint256);

getRemainingAmount

function getRemainingAmount(bytes32 id) external view returns (uint256);

getListingDeadline

function getListingDeadline(bytes32 id) external view returns (uint256);

Structs

CreditListing

Struct containing all of the detail information needed to fill a listing

struct CreditListing {
    bytes32 id;
    address account;
    address token;
    uint256 tokenId;
    uint256 remainingAmount;
    uint256 unitPrice;
}

Properties

NameTypeDescription
idbytes32
accountaddressEthereum address of the account who owns the listing
tokenaddressEthereum address of the token being listing
tokenIduint256
remainingAmountuint256Remaining amount that can be filled on this listing
unitPriceuint256The unit price in USDC of the listing

IDiamond

Git Source


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /*****************************************************************************

Events

DiamondCut

event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);

Structs

FacetCut

struct FacetCut {
    address facetAddress;
    FacetCutAction action;
    bytes4[] functionSelectors;
}

Enums

FacetCutAction

enum FacetCutAction {
    Add,
    Replace,
    Remove
}

IDiamondCut

Git Source


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /*****************************************************************************

Functions

diamondCut

Add/replace/remove any number of functions and optionally execute a function with delegatecall

function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external;

Parameters

NameTypeDescription
_diamondCutFacetCut[]Contains the facet addresses and function selectors
_initaddressThe address of the contract or facet to execute _calldata
_calldatabytesA function call, including function selector and arguments _calldata is executed with delegatecall on _init

Events

DiamondCut

event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);

Structs

FacetCut

struct FacetCut {
    address facetAddress;
    FacetCutAction action;
    bytes4[] functionSelectors;
}

Enums

FacetCutAction

enum FacetCutAction {
    Add,
    Replace,
    Remove
}

IDiamondLoupe

Git Source


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /*****************************************************************************

Functions

facets

Gets all facet addresses and their four byte function selectors.

function facets() external view returns (Facet[] memory facets_);

Returns

NameTypeDescription
facets_Facet[]Facet

facetFunctionSelectors

Gets all the function selectors supported by a specific facet.

function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);

Parameters

NameTypeDescription
_facetaddressThe facet address.

Returns

NameTypeDescription
facetFunctionSelectors_bytes4[]facetFunctionSelectors_

facetAddresses

Get all the facet addresses used by a diamond.

function facetAddresses() external view returns (address[] memory facetAddresses_);

Returns

NameTypeDescription
facetAddresses_address[]facetAddresses_

facetAddress

Gets the facet that supports the given selector.

If facet is not found return address(0).

function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);

Parameters

NameTypeDescription
_functionSelectorbytes4The function selector.

Returns

NameTypeDescription
facetAddress_addressThe facet address.

Structs

Facet

These functions are expected to be called frequently by tools.

struct Facet {
    address facetAddress;
    bytes4[] functionSelectors;
}

IERC1155Receiver

Git Source

Functions

onERC1155Received

Handles the receipt of a single ERC1155 token type. This function is called at the end of a safeTransferFrom after the balance has been updated. NOTE: To accept the transfer, this must return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")) (i.e. 0xf23a6e61, or its own function selector).

function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data)
    external
    returns (bytes4);

Parameters

NameTypeDescription
operatoraddressThe address which initiated the transfer (i.e. msg.sender)
fromaddressThe address which previously owned the token
iduint256The ID of the token being transferred
valueuint256The amount of tokens being transferred
databytesAdditional data with no specified format

Returns

NameTypeDescription
<none>bytes4bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")) if transfer is allowed

onERC1155BatchReceived

Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a safeBatchTransferFrom after the balances have been updated. NOTE: To accept the transfer(s), this must return bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) (i.e. 0xbc197c81, or its own function selector).

function onERC1155BatchReceived(
    address operator,
    address from,
    uint256[] calldata ids,
    uint256[] calldata values,
    bytes calldata data
) external returns (bytes4);

Parameters

NameTypeDescription
operatoraddressThe address which initiated the batch transfer (i.e. msg.sender)
fromaddressThe address which previously owned the token
idsuint256[]An array containing ids of each token being transferred (order and length must match values array)
valuesuint256[]An array containing amounts of each token being transferred (order and length must match ids array)
databytesAdditional data with no specified format

Returns

NameTypeDescription
<none>bytes4bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) if transfer is allowed

IERC165

Git Source

Functions

supportsInterface

Query if a contract implements an interface

Interface identification is specified in ERC-165. This function uses less than 30,000 gas.

function supportsInterface(bytes4 interfaceId) external view returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The interface identifier, as specified in ERC-165

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

IERC173

Git Source

Functions

owner

Get the address of the owner

function owner() external view returns (address owner_);

Returns

NameTypeDescription
owner_addressThe address of the owner.

transferOwnership

Set the address of the new owner of the contract

Set _newOwner to address(0) to renounce any ownership.

function transferOwnership(address _newOwner) external;

Parameters

NameTypeDescription
_newOwneraddressThe address of the new owner of the contract

Events

OwnershipTransferred

This emits when ownership of a contract changes.

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

IERC721Receiver

Git Source

Interface for any contract that wants to support safeTransfers from ERC721 asset contracts.

Functions

onERC721Received

Whenever an {IERC721} tokenId token is transferred to this contract via {IERC721-safeTransferFrom} by operator from from, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with IERC721Receiver.onERC721Received.selector.

function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)
    external
    returns (bytes4);

ICarbonContractRegistry

Git Source

Functions

getTokenVaultBeaconAddress

function getTokenVaultBeaconAddress() external view returns (address);

getVerifiedVaultAddress

function getVerifiedVaultAddress(uint256 id) external view returns (address);

getSerializationAddress

function getSerializationAddress(string calldata serialization) external view returns (address);

getProjectAddressFromId

function getProjectAddressFromId(uint256 projectId) external view returns (address);

getProjectIdFromAddress

function getProjectIdFromAddress(address projectAddress) external view returns (uint256);

getBeaconAddress

function getBeaconAddress() external view returns (address);

IProject

Git Source

Functions

retire

function retire(
    uint256 tokenId,
    uint256 amount,
    address beneficiary,
    string memory retireeName,
    string memory customUri,
    string memory comment,
    bytes memory data
) external returns (uint256 nftTokenId);

IStaking

Git Source

Functions

unstake

function unstake(uint256 _amount, bool _trigger) external;

IStakingHelper

Git Source

Functions

stake

function stake(uint256 _amount) external;

IwsKLIMA

Git Source

Functions

wrap

function wrap(uint256 _amount) external returns (uint256);

unwrap

function unwrap(uint256 _amount) external returns (uint256);

wKLIMATosKLIMA

function wKLIMATosKLIMA(uint256 _amount) external view returns (uint256);

sKLIMATowKLIMA

function sKLIMATowKLIMA(uint256 _amount) external view returns (uint256);

IKlimaRetirementBond

Git Source

Functions

swapToExact

function swapToExact(address poolToken, uint256 amount) external;

getKlimaAmount

function getKlimaAmount(uint256 poolAmount, address poolToken) external view returns (uint256 klimaNeeded);

owner

function owner() external returns (address);

IKlimaCarbonRetirements

Git Source

Functions

carbonRetired

function carbonRetired(
    address _retiree,
    address _pool,
    uint256 _amount,
    string calldata _beneficiaryString,
    string calldata _retirementMessage
) external;

getUnclaimedTotal

function getUnclaimedTotal(address _minter) external view returns (uint256);

offsetClaimed

function offsetClaimed(address _minter, uint256 _amount) external returns (bool);

getRetirementIndexInfo

function getRetirementIndexInfo(address _retiree, uint256 _index)
    external
    view
    returns (address, uint256, string memory, string memory);

getRetirementPoolInfo

function getRetirementPoolInfo(address _retiree, address _pool) external view returns (uint256);

getRetirementTotals

function getRetirementTotals(address _retiree) external view returns (uint256, uint256, uint256);

IKlimaInfinity

Git Source

Functions

toucan_retireExactCarbonPoolDefault

function toucan_retireExactCarbonPoolDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

toucan_retireExactCarbonPoolWithEntityDefault

function toucan_retireExactCarbonPoolWithEntityDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

toucan_retireExactSourcePoolDefault

function toucan_retireExactSourcePoolDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

toucan_retireExactSourcePoolWithEntityDefault

function toucan_retireExactSourcePoolWithEntityDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

toucan_retireExactCarbonPoolSpecific

function toucan_retireExactCarbonPoolSpecific(
    address sourceToken,
    address carbonToken,
    address projectToken,
    uint256 amount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

toucan_retireExactCarbonPoolWithEntitySpecific

function toucan_retireExactCarbonPoolWithEntitySpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

toucan_retireExactSourcePoolWithEntitySpecific

function toucan_retireExactSourcePoolWithEntitySpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 sourceAmount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

toucan_retireExactSourcePoolSpecific

function toucan_retireExactSourcePoolSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 sourceAmount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

moss_retireExactCarbonPoolDefault

function moss_retireExactCarbonPoolDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

moss_retireExactCarbonPoolWithEntityDefault

function moss_retireExactCarbonPoolWithEntityDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

moss_retireExactSourcePoolDefault

function moss_retireExactSourcePoolDefault(
    address sourceToken,
    address carbonToken,
    uint256 sourceAmount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

moss_retireExactSourcePoolWithEntityDefault

function moss_retireExactSourcePoolWithEntityDefault(
    address sourceToken,
    address carbonToken,
    uint256 sourceAmount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactCarbonPoolDefault

function c3_retireExactCarbonPoolDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactCarbonPoolWithEntityDefault

function c3_retireExactCarbonPoolWithEntityDefault(
    address sourceToken,
    address carbonToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactSourcePoolDefault

function c3_retireExactSourcePoolDefault(
    address sourceToken,
    address carbonToken,
    uint256 sourceAmount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactSourcePoolWithEntityDefault

function c3_retireExactSourcePoolWithEntityDefault(
    address sourceToken,
    address carbonToken,
    uint256 sourceAmount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactCarbonPoolSpecific

function c3_retireExactCarbonPoolSpecific(
    address sourceToken,
    address carbonToken,
    address projectToken,
    uint256 amount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactCarbonPoolWithEntitySpecific

function c3_retireExactCarbonPoolWithEntitySpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 amount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactSourcePoolWithEntitySpecific

function c3_retireExactSourcePoolWithEntitySpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 sourceAmount,
    address retiringAddress,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

c3_retireExactSourcePoolSpecific

function c3_retireExactSourcePoolSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 sourceAmount,
    address retiringAddress,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external returns (uint256 retirementIndex);

IToucanPool

Git Source

Functions

redeemAuto2

function redeemAuto2(uint256 amount) external returns (address[] memory tco2s, uint256[] memory amounts);

redeemMany

function redeemMany(address[] calldata erc20s, uint256[] calldata amounts) external;

feeRedeemPercentageInBase

function feeRedeemPercentageInBase() external pure returns (uint256);

feeRedeemDivider

function feeRedeemDivider() external pure returns (uint256);

redeemFeeExemptedAddresses

function redeemFeeExemptedAddresses(address) external view returns (bool);

getScoredTCO2s

function getScoredTCO2s() external view returns (address[] memory);

IToucanCarbonOffsets

Git Source

Functions

retire

function retire(uint256 amount) external;

retireAndMintCertificate

function retireAndMintCertificate(
    string calldata retiringEntityString,
    address beneficiary,
    string calldata beneficiaryString,
    string calldata retirementMessage,
    uint256 amount
) external;

mintCertificateLegacy

function mintCertificateLegacy(
    string calldata retiringEntityString,
    address beneficiary,
    string calldata beneficiaryString,
    string calldata retirementMessage,
    uint256 amount
) external;

IToucanContractRegistry

Git Source

Functions

isValidERC20

function isValidERC20(address erc20) external returns (bool);

IBentoBoxMinimal

Git Source

Functions

setMasterContractApproval

Approves users' BentoBox assets to a "master" contract.

function setMasterContractApproval(address user, address masterContract, bool approved, uint8 v, bytes32 r, bytes32 s)
    external;

toAmount

function toAmount(IERC20 token, uint256 share, bool roundUp) external view returns (uint256 amount);

ITridentRouter

Git Source

Trident pool router interface.

Functions

exactInputSingleWithNativeToken

function exactInputSingleWithNativeToken(ExactInputSingleParams calldata params)
    external
    payable
    returns (uint256 amountOut);

Structs

ExactInputSingleParams

struct ExactInputSingleParams {
    uint256 amountIn;
    uint256 amountOutMinimum;
    address pool;
    address tokenIn;
    bytes data;
}

ITridentPool

Git Source

Trident pool interface.

Functions

getAmountOut

Simulates a trade and returns the expected output.

The pool does not need to include a trade simulator directly in itself - it can use a library.

function getAmountOut(bytes calldata data) external view returns (uint256 finalAmountOut);

Parameters

NameTypeDescription
databytesABI-encoded params that the pool requires.

Returns

NameTypeDescription
finalAmountOutuint256The amount of output tokens that will be sent to the user if the trade is executed.

getAmountIn

Simulates a trade and returns the expected output.

The pool does not need to include a trade simulator directly in itself - it can use a library.

function getAmountIn(bytes calldata data) external view returns (uint256 finalAmountIn);

Parameters

NameTypeDescription
databytesABI-encoded params that the pool requires.

Returns

NameTypeDescription
finalAmountInuint256The amount of input tokens that are required from the user if the trade is executed.

IUniswapV2Pair

Git Source

Functions

name

function name() external pure returns (string memory);

symbol

function symbol() external pure returns (string memory);

decimals

function decimals() external pure returns (uint8);

totalSupply

function totalSupply() external view returns (uint256);

balanceOf

function balanceOf(address owner) external view returns (uint256);

allowance

function allowance(address owner, address spender) external view returns (uint256);

approve

function approve(address spender, uint256 value) external returns (bool);

transfer

function transfer(address to, uint256 value) external returns (bool);

transferFrom

function transferFrom(address from, address to, uint256 value) external returns (bool);

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32);

PERMIT_TYPEHASH

function PERMIT_TYPEHASH() external pure returns (bytes32);

nonces

function nonces(address owner) external view returns (uint256);

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external;

MINIMUM_LIQUIDITY

function MINIMUM_LIQUIDITY() external pure returns (uint256);

factory

function factory() external view returns (address);

token0

function token0() external view returns (address);

token1

function token1() external view returns (address);

getReserves

function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);

price0CumulativeLast

function price0CumulativeLast() external view returns (uint256);

price1CumulativeLast

function price1CumulativeLast() external view returns (uint256);

kLast

function kLast() external view returns (uint256);

mint

function mint(address to) external returns (uint256 liquidity);

burn

function burn(address to) external returns (uint256 amount0, uint256 amount1);

swap

function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;

skim

function skim(address to) external;

sync

function sync() external;

initialize

function initialize(address, address) external;

Events

Approval

event Approval(address indexed owner, address indexed spender, uint256 value);

Transfer

event Transfer(address indexed from, address indexed to, uint256 value);

Mint

event Mint(address indexed sender, uint256 amount0, uint256 amount1);

Burn

event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);

Swap

event Swap(
    address indexed sender,
    uint256 amount0In,
    uint256 amount1In,
    uint256 amount0Out,
    uint256 amount1Out,
    address indexed to
);

Sync

event Sync(uint112 reserve0, uint112 reserve1);

IUniswapV2Router01

Git Source

Functions

factory

function factory() external pure returns (address);

WETH

function WETH() external pure returns (address);

addLiquidity

function addLiquidity(
    address tokenA,
    address tokenB,
    uint256 amountADesired,
    uint256 amountBDesired,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);

addLiquidityETH

function addLiquidityETH(
    address token,
    uint256 amountTokenDesired,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);

removeLiquidity

function removeLiquidity(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETH

function removeLiquidityETH(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);

removeLiquidityWithPermit

function removeLiquidityWithPermit(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETHWithPermit

function removeLiquidityETHWithPermit(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);

swapExactTokensForTokens

function swapExactTokensForTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapTokensForExactTokens

function swapTokensForExactTokens(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactETHForTokens

function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

swapTokensForExactETH

function swapTokensForExactETH(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactTokensForETH

function swapExactTokensForETH(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapETHForExactTokens

function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

quote

function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB);

getAmountOut

function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountOut);

getAmountIn

function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountIn);

getAmountsOut

function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

getAmountsIn

function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);

IUniswapV2Router02

Git Source

Inherits: IUniswapV2Router01

Functions

removeLiquidityETHSupportingFeeOnTransferTokens

function removeLiquidityETHSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountETH);

removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountETH);

swapExactTokensForTokensSupportingFeeOnTransferTokens

function swapExactTokensForTokensSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

swapExactETHForTokensSupportingFeeOnTransferTokens

function swapExactETHForTokensSupportingFeeOnTransferTokens(
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external payable;

swapExactTokensForETHSupportingFeeOnTransferTokens

function swapExactTokensForETHSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

IWMATIC

Git Source

Inherits: IERC20

Author: Cujo

Functions

deposit

function deposit() external payable;

withdraw

function withdraw(uint256) external;

Contents

Contents

LibC3Carbon

Git Source

Author: Cujo

Functions

freeRedeemAndRetire

Calls freeRedeem on a C3 pool and retires the underlying C3T

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

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
amountuint256Amount of tokens to redeem and retire
retiringAddressaddressAddress initiating this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

redeemSpecificAndRetire

Calls taxedRedeem on a C3 pool and retires the underlying C3T

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

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
projectTokenaddressProject token being redeemed
amountuint256Amount of tokens to redeem and retire
retiringAddressaddressAddress initiating this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

retireC3T

Retire a C3T token

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

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
projectTokenaddressProject token being redeemed
amountuint256Amount of tokens to redeem and retire
retiringAddressaddressAddress initiating this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

getExactCarbonSpecificRedeemFee

Return the additional fee needed to redeem specific number of project tokens.

function getExactCarbonSpecificRedeemFee(address poolToken, uint256 amount)
    internal
    view
    returns (uint256 poolFeeAmount);

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
amountuint256Amount of tokens to redeem and retire

Returns

NameTypeDescription
poolFeeAmountuint256Additional C3 pool tokens needed for the redemption

getExactSourceSpecificRetireAmount

Return the amount that can be specifically redeemed from a C3 given x number of tokens.

function getExactSourceSpecificRetireAmount(address poolToken, uint256 amount)
    internal
    view
    returns (uint256 retireAmount);

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
amountuint256Amount of tokens to redeem and retire

Returns

NameTypeDescription
retireAmountuint256Amount of C3T that can be specifically redeemed from a given pool amount

redeemPoolAuto

Receives and redeems a number of pool tokens and sends the C3T to a destination..

function redeemPoolAuto(address poolToken, uint256 amount, LibTransfer.To toMode)
    internal
    returns (address[] memory allProjectTokens, uint256[] memory amounts);

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
amountuint256Amount of tokens to redeem and retire
toModeLibTransfer.ToWhere to send redeemed tokens to

Returns

NameTypeDescription
allProjectTokensaddress[]Default redeem C3T list from the pool
amountsuint256[]Amount of C3T that was redeemed from the pool

redeemPoolSpecific

Receives and redeems a number of pool tokens and sends the C3T to a destination.

function redeemPoolSpecific(
    address poolToken,
    address[] memory projectTokens,
    uint256[] memory amounts,
    LibTransfer.To toMode
) internal returns (uint256[] memory);

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
projectTokensaddress[]Project tokens to redeem
amountsuint256[]Amounts of the project tokens to redeem
toModeLibTransfer.ToWhere to send redeemed tokens to

Returns

NameTypeDescription
<none>uint256[]redeemedAmounts Amounts of the project tokens redeemed

isValid

function isValid(address token) internal returns (bool);

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
);

LibICRCarbon

Git Source

Author: Cujo

Functions

retireICC

function retireICC(
    address poolToken,
    address projectToken,
    uint256 tokenId,
    uint256 amount,
    LibRetire.RetireDetails memory details
) internal returns (uint256 retiredAmount);

isValid

function isValid(address token) internal view returns (bool);

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 tokenId,
    uint256 retiredAmount
);

LibMossCarbon

Git Source

Author: Cujo

Functions

offsetCarbon

Retires Moss MCO2 tokens on Polygon

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

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
amountuint256Amounts of the project tokens to retire
retiringAddressaddressAddress initiating this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

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
);

LibToucanCarbon

Git Source

Author: Cujo

Functions

redeemAutoAndRetire

Redeems Toucan pool tokens using default redemtion and retires the TCO2

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

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
amountuint256Amount of the project token to retire
retiringAddressaddressAddress initiating this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

redeemSpecificAndRetire

Redeems Toucan pool tokens using specific redemtion and retires the TCO2

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

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
projectTokenaddressProject token to use for this retirement
amountuint256Amount of the project token to retire
retiringAddressaddressAddress initiating this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

Returns

NameTypeDescription
retiredAmountuint256The amount of TCO2 retired

retireTCO2

Redeems Toucan TCO2s

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

Parameters

NameTypeDescription
poolTokenaddressPool token to use for this retirement
projectTokenaddressProject token to use for this retirement
amountuint256Amount of the project token to retire
retiringAddressaddressAddress initiating this retirement
retiringEntityStringstringString description of the retiring entity
beneficiaryAddressaddress0x address for the beneficiary
beneficiaryStringstringString description of the beneficiary
retirementMessagestringString message for this specific retirement

sendRetireCert

Send the ERC-721 retirement certificate received to a beneficiary

function sendRetireCert(address _beneficiary) internal;

Parameters

NameTypeDescription
_beneficiaryaddressBeneficiary to send the certificate to

getSpecificRedeemFee

Calculates the additional pool tokens needed to specifically redeem x TCO2s

function getSpecificRedeemFee(address poolToken, uint256 amount) internal view returns (uint256 poolFeeAmount);

Parameters

NameTypeDescription
poolTokenaddressPool token to redeem
amountuint256Amount of TCO2 needed

Returns

NameTypeDescription
poolFeeAmountuint256Number of additional pool tokens needed

getSpecificRetireAmount

Returns the number of TCO2s retired when selectively redeeming x pool tokens

function getSpecificRetireAmount(address poolToken, uint256 amount) internal view returns (uint256 retireAmount);

Parameters

NameTypeDescription
poolTokenaddressPool token to redeem
amountuint256Amount of pool tokens redeemed

Returns

NameTypeDescription
retireAmountuint256Number TCO2s that can be retired.

redeemPoolAuto

Simple wrapper to use redeem Toucan pools using the default list

function redeemPoolAuto(address poolToken, uint256 amount, LibTransfer.To toMode)
    internal
    returns (address[] memory projectTokens, uint256[] memory amounts);

Parameters

NameTypeDescription
poolTokenaddressPool token to redeem
amountuint256Amount of tokens being redeemed
toModeLibTransfer.ToWhere to send TCO2 tokens

Returns

NameTypeDescription
projectTokensaddress[]TCO2 token addresses redeemed
amountsuint256[]TCO2 token amounts redeemed

redeemPoolSpecific

Simple wrapper to use redeem Toucan pools using the specific list

function redeemPoolSpecific(
    address poolToken,
    address[] memory projectTokens,
    uint256[] memory amounts,
    LibTransfer.To toMode
) internal returns (uint256[] memory);

Parameters

NameTypeDescription
poolTokenaddressPool token to redeem
projectTokensaddress[]Project tokens to redeem
amountsuint256[]Token amounts to redeem
toModeLibTransfer.ToWhere to send TCO2 tokens

Returns

NameTypeDescription
<none>uint256[]redeemedAmounts TCO2 token amounts redeemed

isValid

function isValid(address token) internal returns (bool);

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
);

Contents

LibApprove

Git Source

Author: publius

Functions

approveToken

function approveToken(IERC20 token, address spender, uint256 amount) internal;

LibBalance

Git Source

Author: LeoFib, Publius

Functions

getBalance

function getBalance(address account, IERC20 token) internal view returns (uint256 combined_balance);

increaseInternalBalance

Increases account's Internal Balance for token by amount.

function increaseInternalBalance(address account, IERC20 token, uint256 amount) internal;

decreaseInternalBalance

Decreases account's Internal Balance for token by amount. If allowPartial is true, this function doesn't revert if account doesn't have enough balance, and sets it to zero and returns the deducted amount instead.

function decreaseInternalBalance(address account, IERC20 token, uint256 amount, bool allowPartial)
    internal
    returns (uint256 deducted);

setInternalBalance

Sets account's Internal Balance for token to newBalance. Emits an InternalBalanceChanged event. This event includes delta, which is the amount the balance increased (if positive) or decreased (if negative). To avoid reading the current balance in order to compute the delta, this function relies on the caller providing it directly.

function setInternalBalance(address account, IERC20 token, uint256 newBalance, int256 delta) private;

getInternalBalance

Returns account's Internal Balance for token.

function getInternalBalance(address account, IERC20 token) internal view returns (uint256);

Events

InternalBalanceChanged

Emitted when a account's Internal Balance changes, through interacting using Internal Balance.

event InternalBalanceChanged(address indexed account, IERC20 indexed token, int256 delta);

LibMatic

Git Source

Author: Cujo

Functions

refundMatic

function refundMatic() internal;

LibTransfer

Git Source

Author: publius

Functions

transferToken

function transferToken(IERC20 token, address recipient, uint256 amount, From fromMode, To toMode)
    internal
    returns (uint256 transferredAmount);

receiveToken

function receiveToken(IERC20 token, uint256 amount, address sender, From mode)
    internal
    returns (uint256 receivedAmount);

receive1155Token

function receive1155Token(IERC1155 token, uint256 tokenId, uint256 amount, address sender, From mode)
    internal
    returns (uint256 receivedAmount);

sendToken

function sendToken(IERC20 token, uint256 amount, address recipient, To mode) internal;

Enums

From

enum From {
    EXTERNAL,
    INTERNAL,
    EXTERNAL_INTERNAL,
    INTERNAL_TOLERANT
}

To

enum To {
    EXTERNAL,
    INTERNAL
}

LibWmatic

Git Source

Author: Cujo

State Variables

WMATIC

address constant WMATIC = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270;

Functions

wrap

function wrap(uint256 amount, LibTransfer.To mode) internal;

unwrap

function unwrap(uint256 amount, LibTransfer.From mode) internal;

deposit

function deposit(uint256 amount) private;

withdraw

function withdraw(uint256 amount) private;

Contents

LibSwap

Git Source

Author: Cujo

Functions

swapToExactCarbonDefault

Swaps to an exact number of carbon tokens

function swapToExactCarbonDefault(address sourceToken, address carbonToken, uint256 sourceAmount, uint256 carbonAmount)
    internal
    returns (uint256 carbonReceived);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
carbonTokenaddressPool token needed
sourceAmountuint256Max amount of the source token
carbonAmountuint256Needed amount of tokens out

Returns

NameTypeDescription
carbonReceiveduint256Pool tokens actually received

swapExactSourceToCarbonDefault

Swaps to an exact number of source tokens

function swapExactSourceToCarbonDefault(address sourceToken, address carbonToken, uint256 amount)
    internal
    returns (uint256 carbonReceived);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
carbonTokenaddressPool token needed
amountuint256Amount of the source token to swap

Returns

NameTypeDescription
carbonReceiveduint256Pool tokens actually received

returnTradeDust

Return any dust/slippaged amounts still held by the contract

function returnTradeDust(address sourceToken, address poolToken) internal;

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
poolTokenaddressPool token used

swapToKlimaFromUsdc

Swaps a given amount of USDC for KLIMA using Sushiswap

function swapToKlimaFromUsdc(uint256 sourceAmount, uint256 klimaAmount) internal returns (uint256 klimaReceived);

Parameters

NameTypeDescription
sourceAmountuint256Amount of USDC to swap
klimaAmountuint256Amount of KLIMA to swap for

Returns

NameTypeDescription
klimaReceiveduint256Amount of KLIMA received

swapToKlimaFromOther

Swaps from arbitrary token routed through USDC for KLIMA

function swapToKlimaFromOther(address sourceToken, uint256 sourceAmount, uint256 klimaAmount)
    internal
    returns (uint256 klimaReceived);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
sourceAmountuint256Amount of source token to swap
klimaAmountuint256Amount of KLIMA to swap for

Returns

NameTypeDescription
klimaReceiveduint256Amount of KLIMA received

swapWithRetirementBonds

Performs a swap with Retirement Bonds for carbon to retire.

function swapWithRetirementBonds(address sourceToken, address carbonToken, uint256 sourceAmount, uint256 carbonAmount)
    internal
    returns (uint256 carbonRecieved);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
carbonTokenaddressCarbon token to receive
sourceAmountuint256Amount of source token to swap
carbonAmountuint256Amount of carbon token needed

Returns

NameTypeDescription
carbonRecieveduint256Amount of carbon token received from the swap

getSourceAmount

Get the source amount needed when swapping within a single DEX

function getSourceAmount(address sourceToken, address carbonToken, uint256 amount)
    internal
    view
    returns (uint256 sourceNeeded);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
carbonTokenaddressPool token used
amountuint256Amount of carbon tokens needed

Returns

NameTypeDescription
sourceNeededuint256Total source tokens needed for output amount

getMultipleSourceAmount

Get the source amount needed when swapping between multiple DEXs

function getMultipleSourceAmount(address sourceToken, address carbonToken, uint256 amount)
    internal
    view
    returns (uint256[] memory);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
carbonTokenaddressPool token used
amountuint256Amount of carbon tokens needed

Returns

NameTypeDescription
<none>uint256[]sourcesNeeded Total source tokens needed for output amount

getSourceAmountFromRetirementBond

Fetches the amount of KLIMA needed for a retirement bond, then calculates the source amount needed if a DEX swap is required.

function getSourceAmountFromRetirementBond(address sourceToken, address carbonToken, uint256 amount)
    internal
    view
    returns (uint256 sourceNeeded);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
carbonTokenaddressPool token used
amountuint256Amount of carbon tokens needed

Returns

NameTypeDescription
sourceNeededuint256Total source tokens needed for output amount

getDefaultAmountOut

Get the source amount needed when swapping between multiple DEXs

function getDefaultAmountOut(address sourceToken, address carbonToken, uint256 amount)
    internal
    view
    returns (uint256 amountOut);

Parameters

NameTypeDescription
sourceTokenaddressSource token provided to swap
carbonTokenaddressPool token used
amountuint256Amount of carbon tokens needed

Returns

NameTypeDescription
amountOutuint256Amount of carbonTokens recieved for the input amount

_performToExactSwap

Perform a toExact swap depending on the dex provided

function _performToExactSwap(uint8 dex, address router, address[] memory path, uint256 maxAmountIn, uint256 amount)
    private
    returns (uint256 amountOut);

Parameters

NameTypeDescription
dexuint8Identifier for which DEX to use
routeraddressRouter for the swap
pathaddress[]Trade path to use
maxAmountInuint256Max amount of source tokens to swap
amountuint256Total pool tokens needed

Returns

NameTypeDescription
amountOutuint256Total pool tokens swapped

_performExactSourceSwap

Perform a swap using all source tokens

function _performExactSourceSwap(uint8 dex, address router, address[] memory path, uint256 amount)
    private
    returns (uint256 amountOut);

Parameters

NameTypeDescription
dexuint8Identifier for which DEX to use
routeraddressRouter for the swap
pathaddress[]Trade path to use
amountuint256Amount of tokens to swap

Returns

NameTypeDescription
amountOutuint256Total pool tokens swapped

_getAmountIn

Return the amountIn needed for an exact swap

function _getAmountIn(uint8 dex, address router, address[] memory path, uint256 amount)
    private
    view
    returns (uint256 amountIn);

Parameters

NameTypeDescription
dexuint8Identifier for which DEX to use
routeraddressRouter for the swap
pathaddress[]Trade path to use
amountuint256Total pool tokens needed

Returns

NameTypeDescription
amountInuint256Total pool tokens swapped

_getAmountOut

Return the amountIn needed for an exact swap

function _getAmountOut(uint8 dex, address router, address[] memory path, uint256 amount)
    private
    view
    returns (uint256 amountOut);

Parameters

NameTypeDescription
dexuint8Identifier for which DEX to use
routeraddressRouter for the swap
pathaddress[]Trade path to use
amountuint256Total source tokens spent

Returns

NameTypeDescription
amountOutuint256Total pool tokens swapped

LibTreasurySwap

Git Source

Author: Cujo

Functions

getAmountIn

function getAmountIn(address tokenIn, uint256 amountOut) internal view returns (uint256 amountIn);

swapToExact

function swapToExact(address carbonToken, uint256 amountIn, uint256 amountOut) internal;

LibTridentSwap

Git Source

Author: Cujo

Functions

swapExactTokensForTokens

function swapExactTokensForTokens(address router, address pool, address tokenIn, uint256 amountIn, uint256 minAmountOut)
    internal
    returns (uint256 amountOut);

getAmountIn

function getAmountIn(address pool, address tokenIn, address tokenOut, uint256 amountOut)
    internal
    view
    returns (uint256 amountIn);

getAmountOut

function getAmountOut(address pool, address tokenIn, address tokenOut, uint256 amountIn)
    internal
    view
    returns (uint256 amountOut);

getTridentPool

function getTridentPool(address tokenOne, address tokenTwo) internal view returns (address tridentPool);

LibUniswapV2Swap

Git Source

Author: Cujo

Functions

swapTokensForExactTokens

function swapTokensForExactTokens(address router, address[] memory path, uint256 amountIn, uint256 amountOut)
    internal
    returns (uint256);

swapExactTokensForTokens

function swapExactTokensForTokens(address router, address[] memory path, uint256 amount) internal returns (uint256);

getAmountIn

function getAmountIn(address router, address[] memory path, uint256 amount) internal view returns (uint256);

getAmountOut

function getAmountOut(address router, address[] memory path, uint256 amount) internal view returns (uint256);

LibAppStorage

Git Source

Author: Publius

Functions

diamondStorage

function diamondStorage() internal pure returns (AppStorage storage ds);

LibDiamond

Git Source


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /*****************************************************************************

State Variables

DIAMOND_STORAGE_POSITION

bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");

Functions

diamondStorage

function diamondStorage() internal pure returns (DiamondStorage storage ds);

setContractOwner

function setContractOwner(address _newOwner) internal;

contractOwner

function contractOwner() internal view returns (address contractOwner_);

enforceIsContractOwner

function enforceIsContractOwner() internal view;

diamondCut

function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal;

addFunctions

function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;

replaceFunctions

function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;

removeFunctions

function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;

addFacet

function addFacet(DiamondStorage storage ds, address _facetAddress) internal;

addFunction

function addFunction(DiamondStorage storage ds, bytes4 _selector, uint96 _selectorPosition, address _facetAddress)
    internal;

removeFunction

function removeFunction(DiamondStorage storage ds, address _facetAddress, bytes4 _selector) internal;

initializeDiamondCut

function initializeDiamondCut(address _init, bytes memory _calldata) internal;

enforceHasContractCode

function enforceHasContractCode(address _contract, string memory _errorMessage) internal view;

Events

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

DiamondCut

event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);

Structs

FacetAddressAndPosition

struct FacetAddressAndPosition {
    address facetAddress;
    uint96 functionSelectorPosition;
}

FacetFunctionSelectors

struct FacetFunctionSelectors {
    bytes4[] functionSelectors;
    uint256 facetAddressPosition;
}

DiamondStorage

struct DiamondStorage {
    mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
    mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
    address[] facetAddresses;
    mapping(bytes4 => bool) supportedInterfaces;
    address contractOwner;
}

LibKlima

Git Source

Author: Cujo

Functions

toWrappedAmount

Returns wsKLIMA amount for provided sKLIMA amount

function toWrappedAmount(uint256 amount) internal view returns (uint256 wrappedAmount);

Parameters

NameTypeDescription
amountuint256sKLIMA provided

Returns

NameTypeDescription
wrappedAmountuint256wsKLIMA amount

toUnwrappedAmount

Returns sKLIMA amount for provided wsKLIMA amount

function toUnwrappedAmount(uint256 amount) internal view returns (uint256 unwrappedAmount);

Parameters

NameTypeDescription
amountuint256wsKLIMA provided

Returns

NameTypeDescription
unwrappedAmountuint256sKLIMA amount

unwrapKlima

Unwraps and unstakes provided wsKLIMA amount

function unwrapKlima(uint256 amount) internal returns (uint256 unwrappedAmount);

Parameters

NameTypeDescription
amountuint256wsKLIMA provided

Returns

NameTypeDescription
unwrappedAmountuint256Final KLIMA amount

unstakeKlima

Unstakes provided sKLIMA amount

function unstakeKlima(uint256 amount) internal;

Parameters

NameTypeDescription
amountuint256sKLIMA provided

wrapKlima

Stakes and wraps provided KLIMA amount

function wrapKlima(uint256 amount) internal returns (uint256 wrappedAmount);

Parameters

NameTypeDescription
amountuint256KLIMA provided

Returns

NameTypeDescription
wrappedAmountuint256Final wsKLIMA amount

stakeKlima

Stakes provided KLIMA amount

function stakeKlima(uint256 amount) internal;

Parameters

NameTypeDescription
amountuint256KLIMA provided

LibMeta

Git Source

State Variables

EIP712_DOMAIN_TYPEHASH

bytes32 internal constant EIP712_DOMAIN_TYPEHASH =
    keccak256(bytes("EIP712Domain(string name,string version,uint256 salt,address verifyingContract)"));

Functions

domainSeparator

function domainSeparator(string memory name, string memory version) internal view returns (bytes32 domainSeparator_);

getChainID

function getChainID() internal view returns (uint256 id);

msgSender

function msgSender() internal view returns (address sender_);

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
}

Contents

ConstantsGetter

Git Source

Author: Cujo

Functions

toucanCert

function toucanCert() external pure returns (address);

mossCarbonChain

function mossCarbonChain() external pure returns (address);

staking

function staking() external pure returns (address);

stakingHelper

function stakingHelper() external pure returns (address);

treasury

function treasury() external pure returns (address);

klima

function klima() external pure returns (address);

sKlima

function sKlima() external pure returns (address);

wsKlima

function wsKlima() external pure returns (address);

usdc

function usdc() external pure returns (address);

bct

function bct() external pure returns (address);

nct

function nct() external pure returns (address);

mco2

function mco2() external pure returns (address);

ubo

function ubo() external pure returns (address);

nbo

function nbo() external pure returns (address);

sushiRouter

function sushiRouter() external pure returns (address);

quickswapRouter

function quickswapRouter() external pure returns (address);

sushiTridentRouter

function sushiTridentRouter() external pure returns (address);

sushiBento

function sushiBento() external pure returns (address);

klimaCarbonRetirements

function klimaCarbonRetirements() external pure returns (address);

klimaRetirementBond

function klimaRetirementBond() external pure returns (address);

carbonmark

function carbonmark() external pure returns (address);

Account

Git Source

Author: Cujo

Structs

Retirement

struct Retirement {
    address poolTokenAddress;
    address projectTokenAddress;
    address beneficiaryAddress;
    string beneficiary;
    string retirementMessage;
    uint256 amount;
    uint256 pledgeID;
}

State

struct State {
    mapping(uint256 => Retirement) retirements;
    mapping(address => uint256) totalPoolRetired;
    mapping(address => uint256) totalProjectRetired;
    uint256 totalRetirements;
    uint256 totalCarbonRetired;
    uint256 totalRewardsClaimed;
}

Storage

Git Source

Structs

CarbonBridge

struct CarbonBridge {
    string name;
    address defaultRouter;
    uint8 routerType;
}

DefaultSwap

struct DefaultSwap {
    uint8[] swapDexes;
    address[] ammRouters;
    mapping(uint8 => address[]) swapPaths;
}

Token1155Settings

Stores the transient details of 1155 tokens received.

struct Token1155Settings {
    uint256 tokenId;
    uint256 value;
    uint256[] ids;
    uint256[] values;
}

Properties

NameTypeDescription
tokenIduint256The last tokenId received from transferSingle
valueuint256The last value received from transferSingle
idsuint256[]The last tokenIds received from transferBatch
valuesuint256[]The last values received from transferBatch

AppStorage

Git Source

struct AppStorage {
    mapping(uint256 => Storage.CarbonBridge) bridges;
    mapping(address => bool) isPoolToken;
    mapping(address => LibRetire.CarbonBridge) poolBridge;
    mapping(address => mapping(address => Storage.DefaultSwap)) swap;
    mapping(address => Account.State) a;
    uint256 lastERC721Received;
    uint256 fee;
    uint256 reentrantStatus;
    mapping(address => mapping(IERC20 => uint256)) internalTokenBalance;
    mapping(address => uint256) metaNonces;
    bytes32 domainSeparator;
    mapping(address => mapping(address => address)) tridentPool;
    Storage.Token1155Settings lastERC1155Received;
}

C

Git Source

Author: Cujo

State Variables

CHAIN_ID

uint256 private constant CHAIN_ID = 137;

KLIMA

address private constant KLIMA = 0x4e78011Ce80ee02d2c3e649Fb657E45898257815;

SKLIMA

address private constant SKLIMA = 0xb0C22d8D350C67420f06F48936654f567C73E8C8;

WSKLIMA

address private constant WSKLIMA = 0x6f370dba99E32A3cAD959b341120DB3C9E280bA6;

STAKING

address private constant STAKING = 0x25d28a24Ceb6F81015bB0b2007D795ACAc411b4d;

STAKING_HELPER

address private constant STAKING_HELPER = 0x4D70a031Fc76DA6a9bC0C922101A05FA95c3A227;

TREASURY

address private constant TREASURY = 0x7Dd4f0B986F032A44F913BF92c9e8b7c17D77aD7;

USDC

address private constant USDC = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;

SUSHI_POLYGON

address private constant SUSHI_POLYGON = 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506;

QUICKSWAP_POLYGON

address private constant QUICKSWAP_POLYGON = 0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff;

SUSHI_BENTO

address private constant SUSHI_BENTO = 0x0319000133d3AdA02600f0875d2cf03D442C3367;

SUSHI_TRIDENT_POLYGON

address private constant SUSHI_TRIDENT_POLYGON = 0xc5017BE80b4446988e8686168396289a9A62668E;

CARBONMARK

address private constant CARBONMARK = 0x7B51dBc2A8fD98Fe0924416E628D5755f57eB821;

BCT

address private constant BCT = 0x2F800Db0fdb5223b3C3f354886d907A671414A7F;

NCT

address private constant NCT = 0xD838290e877E0188a4A44700463419ED96c16107;

MCO2

address private constant MCO2 = 0xAa7DbD1598251f856C12f63557A4C4397c253Cea;

UBO

address private constant UBO = 0x2B3eCb0991AF0498ECE9135bcD04013d7993110c;

NBO

address private constant NBO = 0x6BCa3B77C1909Ce1a4Ba1A20d1103bDe8d222E48;

TOUCAN_RETIRE_CERT

address private constant TOUCAN_RETIRE_CERT = 0x5e377f16E4ec6001652befD737341a28889Af002;

MOSS_CARBON_CHAIN

address private constant MOSS_CARBON_CHAIN = 0xeDAEFCf60e12Bd331c092341D5b3d8901C1c05A8;

KLIMA_CARBON_RETIREMENTS

address private constant KLIMA_CARBON_RETIREMENTS = 0xac298CD34559B9AcfaedeA8344a977eceff1C0Fd;

KLIMA_RETIREMENT_BOND

address private constant KLIMA_RETIREMENT_BOND = 0xa595f0d598DaF144e5a7ca91E6D9A5bAA09dDeD0;

TOUCAN_REGISTRY

address constant TOUCAN_REGISTRY = 0x263fA1c180889b3a3f46330F32a4a23287E99FC9;

C3_PROJECT_FACTORY

address constant C3_PROJECT_FACTORY = 0xa4c951B30952f5E2feFC8a92F4d3c7551925A63B;

ICR_PROJECT_REGISTRY

address constant ICR_PROJECT_REGISTRY = 0x9f87988FF45E9b58ae30fA1685088460125a7d8A;

Functions

toucanCert

function toucanCert() internal pure returns (address);

mossCarbonChain

function mossCarbonChain() internal pure returns (address);

staking

function staking() internal pure returns (address);

stakingHelper

function stakingHelper() internal pure returns (address);

treasury

function treasury() internal pure returns (address);

klima

function klima() internal pure returns (address);

sKlima

function sKlima() internal pure returns (address);

wsKlima

function wsKlima() internal pure returns (address);

usdc

function usdc() internal pure returns (address);

bct

function bct() internal pure returns (address);

nct

function nct() internal pure returns (address);

mco2

function mco2() internal pure returns (address);

ubo

function ubo() internal pure returns (address);

nbo

function nbo() internal pure returns (address);

sushiRouter

function sushiRouter() internal pure returns (address);

quickswapRouter

function quickswapRouter() internal pure returns (address);

sushiTridentRouter

function sushiTridentRouter() internal pure returns (address);

sushiBento

function sushiBento() internal pure returns (address);

klimaCarbonRetirements

function klimaCarbonRetirements() internal pure returns (address);

klimaRetirementBond

function klimaRetirementBond() internal pure returns (address);

toucanRegistry

function toucanRegistry() internal pure returns (address);

c3ProjectFactory

function c3ProjectFactory() internal pure returns (address);

carbonmark

function carbonmark() internal pure returns (address);

icrProjectRegistry

function icrProjectRegistry() internal pure returns (address);

Diamond

Git Source


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 Implementation of a diamond. /*****************************************************************************

State Variables

s

AppStorage internal s;

Functions

constructor

constructor(address _contractOwner, address _diamondCutFacet) payable;

fallback

fallback() external payable;

receive

receive() external payable;

ReentrancyGuard

Git Source

Author: Beanstalk Farms

State Variables

_NOT_ENTERED

uint256 private constant _NOT_ENTERED = 1;

_ENTERED

uint256 private constant _ENTERED = 2;

s

AppStorage internal s;

Functions

nonReentrant

modifier nonReentrant();

Contents

Contents

Contents

IUniswapV2Router01

Git Source

Functions

factory

function factory() external pure returns (address);

WETH

function WETH() external pure returns (address);

addLiquidity

function addLiquidity(
    address tokenA,
    address tokenB,
    uint256 amountADesired,
    uint256 amountBDesired,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);

addLiquidityETH

function addLiquidityETH(
    address token,
    uint256 amountTokenDesired,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);

removeLiquidity

function removeLiquidity(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETH

function removeLiquidityETH(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);

removeLiquidityWithPermit

function removeLiquidityWithPermit(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETHWithPermit

function removeLiquidityETHWithPermit(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);

swapExactTokensForTokens

function swapExactTokensForTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapTokensForExactTokens

function swapTokensForExactTokens(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactETHForTokens

function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

swapTokensForExactETH

function swapTokensForExactETH(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactTokensForETH

function swapExactTokensForETH(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapETHForExactTokens

function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

quote

function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB);

getAmountOut

function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountOut);

getAmountIn

function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountIn);

getAmountsOut

function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

getAmountsIn

function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);

IUniswapV2Router02

Git Source

Inherits: IUniswapV2Router01

Functions

removeLiquidityETHSupportingFeeOnTransferTokens

function removeLiquidityETHSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountETH);

removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountETH);

swapExactTokensForTokensSupportingFeeOnTransferTokens

function swapExactTokensForTokensSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

swapExactETHForTokensSupportingFeeOnTransferTokens

function swapExactETHForTokensSupportingFeeOnTransferTokens(
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external payable;

swapExactTokensForETHSupportingFeeOnTransferTokens

function swapExactTokensForETHSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

Contents

KeeperBase

Git Source

Functions

preventExecution

method that allows it to be simulated via eth_call by checking that the sender is the zero address.

function preventExecution() internal view;

cannotExecute

modifier that allows it to be simulated via eth_call by checking that the sender is the zero address.

modifier cannotExecute();

Errors

OnlySimulatedBackend

error OnlySimulatedBackend();

KeeperCompatible

Git Source

Inherits: KeeperBase, KeeperCompatibleInterface

KeeperCompatibleInterface

Git Source

Functions

checkUpkeep

method that is simulated by the keepers to see if any work actually needs to be performed. This method does does not actually need to be executable, and since it is only ever simulated it can consume lots of gas.

To ensure that it is never called, you may want to add the cannotExecute modifier from KeeperBase to your implementation of this method.

function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);

Parameters

NameTypeDescription
checkDatabytesspecified in the upkeep registration so it is always the same for a registered upkeep. This can easily be broken down into specific arguments using abi.decode, so multiple upkeeps can be registered on the same contract and easily differentiated by the contract.

Returns

NameTypeDescription
upkeepNeededboolboolean to indicate whether the keeper should call performUpkeep or not.
performDatabytesbytes that the keeper should call performUpkeep with, if upkeep is needed. If you would like to encode data to decode later, try abi.encode.

performUpkeep

method that is actually executed by the keepers, via the registry. The data returned by the checkUpkeep simulation will be passed into this method to actually be executed.

The input to this method should not be trusted, and the caller of the method should not even be restricted to any single registry. Anyone should be able call it, and the input should be validated, there is no guarantee that the data passed in is the performData returned from checkUpkeep. This could happen due to malicious keepers, racing keepers, or simply a state change while the performUpkeep transaction is waiting for confirmation. Always validate the data passed in.

function performUpkeep(bytes calldata performData) external;

Parameters

NameTypeDescription
performDatabytesis the data which was passed back from the checkData simulation. If it is encoded, it can easily be decoded into other types by calling abi.decode. This data should not be trusted, and should be validated against the contract's current state.

IOwnable

Git Source

Functions

manager

function manager() external view returns (address);

renounceManagement

function renounceManagement() external;

pushManagement

function pushManagement(address newOwner_) external;

pullManagement

function pullManagement() external;

Ownable

Git Source

Inherits: IOwnable

State Variables

_owner

address internal _owner;

_newOwner

address internal _newOwner;

Functions

constructor

constructor();

manager

function manager() public view override returns (address);

onlyManager

modifier onlyManager();

renounceManagement

function renounceManagement() public virtual override onlyManager;

pushManagement

function pushManagement(address newOwner_) public virtual override onlyManager;

pullManagement

function pullManagement() public virtual override;

Events

OwnershipPushed

event OwnershipPushed(address indexed previousOwner, address indexed newOwner);

OwnershipPulled

event OwnershipPulled(address indexed previousOwner, address indexed newOwner);

IUniswapV2Pair

Git Source

Submitted for verification at polygonscan.com on 2021-06-09

Functions

name

function name() external pure returns (string memory);

symbol

function symbol() external pure returns (string memory);

decimals

function decimals() external pure returns (uint8);

totalSupply

function totalSupply() external view returns (uint256);

balanceOf

function balanceOf(address owner) external view returns (uint256);

allowance

function allowance(address owner, address spender) external view returns (uint256);

approve

function approve(address spender, uint256 value) external returns (bool);

transfer

function transfer(address to, uint256 value) external returns (bool);

transferFrom

function transferFrom(address from, address to, uint256 value) external returns (bool);

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32);

PERMIT_TYPEHASH

function PERMIT_TYPEHASH() external pure returns (bytes32);

nonces

function nonces(address owner) external view returns (uint256);

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external;

MINIMUM_LIQUIDITY

function MINIMUM_LIQUIDITY() external pure returns (uint256);

factory

function factory() external view returns (address);

token0

function token0() external view returns (address);

token1

function token1() external view returns (address);

getReserves

function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);

price0CumulativeLast

function price0CumulativeLast() external view returns (uint256);

price1CumulativeLast

function price1CumulativeLast() external view returns (uint256);

kLast

function kLast() external view returns (uint256);

mint

function mint(address to) external returns (uint256 liquidity);

burn

function burn(address to) external returns (uint256 amount0, uint256 amount1);

swap

function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;

skim

function skim(address to) external;

sync

function sync() external;

initialize

function initialize(address, address) external;

Events

Approval

event Approval(address indexed owner, address indexed spender, uint256 value);

Transfer

event Transfer(address indexed from, address indexed to, uint256 value);

Mint

event Mint(address indexed sender, uint256 amount0, uint256 amount1);

Burn

event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);

Swap

event Swap(
    address indexed sender,
    uint256 amount0In,
    uint256 amount1In,
    uint256 amount0Out,
    uint256 amount1Out,
    address indexed to
);

Sync

event Sync(uint112 reserve0, uint112 reserve1);

SafeMathUniswap

Git Source

Functions

add

function add(uint256 x, uint256 y) internal pure returns (uint256 z);

sub

function sub(uint256 x, uint256 y) internal pure returns (uint256 z);

mul

function mul(uint256 x, uint256 y) internal pure returns (uint256 z);

UniswapV2Library

Git Source

Functions

sortTokens

function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1);

pairFor

function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair);

getReserves

function getReserves(address factory, address tokenA, address tokenB)
    internal
    view
    returns (uint256 reserveA, uint256 reserveB);

quote

function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) internal pure returns (uint256 amountB);

getAmountOut

function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
    internal
    pure
    returns (uint256 amountOut);

getAmountIn

function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
    internal
    pure
    returns (uint256 amountIn);

getAmountsOut

function getAmountsOut(address factory, uint256 amountIn, address[] memory path)
    internal
    view
    returns (uint256[] memory amounts);

getAmountsIn

function getAmountsIn(address factory, uint256 amountOut, address[] memory path)
    internal
    view
    returns (uint256[] memory amounts);

TransferHelper

Git Source

Functions

safeApprove

function safeApprove(address token, address to, uint256 value) internal;

safeTransfer

function safeTransfer(address token, address to, uint256 value) internal;

safeTransferFrom

function safeTransferFrom(address token, address from, address to, uint256 value) internal;

safeTransferETH

function safeTransferETH(address to, uint256 value) internal;

IUniswapV2Router01

Git Source

Functions

factory

function factory() external pure returns (address);

WETH

function WETH() external pure returns (address);

addLiquidity

function addLiquidity(
    address tokenA,
    address tokenB,
    uint256 amountADesired,
    uint256 amountBDesired,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);

addLiquidityETH

function addLiquidityETH(
    address token,
    uint256 amountTokenDesired,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);

removeLiquidity

function removeLiquidity(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETH

function removeLiquidityETH(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);

removeLiquidityWithPermit

function removeLiquidityWithPermit(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETHWithPermit

function removeLiquidityETHWithPermit(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);

swapExactTokensForTokens

function swapExactTokensForTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapTokensForExactTokens

function swapTokensForExactTokens(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactETHForTokens

function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

swapTokensForExactETH

function swapTokensForExactETH(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactTokensForETH

function swapExactTokensForETH(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapETHForExactTokens

function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

quote

function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB);

getAmountOut

function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountOut);

getAmountIn

function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountIn);

getAmountsOut

function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

getAmountsIn

function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);

IUniswapV2Router02

Git Source

Inherits: IUniswapV2Router01

Functions

removeLiquidityETHSupportingFeeOnTransferTokens

function removeLiquidityETHSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountETH);

removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountETH);

swapExactTokensForTokensSupportingFeeOnTransferTokens

function swapExactTokensForTokensSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

swapExactETHForTokensSupportingFeeOnTransferTokens

function swapExactETHForTokensSupportingFeeOnTransferTokens(
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external payable;

swapExactTokensForETHSupportingFeeOnTransferTokens

function swapExactTokensForETHSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

IUniswapV2Factory

Git Source

Functions

feeTo

function feeTo() external view returns (address);

feeToSetter

function feeToSetter() external view returns (address);

migrator

function migrator() external view returns (address);

getPair

function getPair(address tokenA, address tokenB) external view returns (address pair);

allPairs

function allPairs(uint256) external view returns (address pair);

allPairsLength

function allPairsLength() external view returns (uint256);

createPair

function createPair(address tokenA, address tokenB) external returns (address pair);

setFeeTo

function setFeeTo(address) external;

setFeeToSetter

function setFeeToSetter(address) external;

setMigrator

function setMigrator(address) external;

Events

PairCreated

event PairCreated(address indexed token0, address indexed token1, address pair, uint256);

IERC20Uniswap

Git Source

Functions

name

function name() external view returns (string memory);

symbol

function symbol() external view returns (string memory);

decimals

function decimals() external view returns (uint8);

totalSupply

function totalSupply() external view returns (uint256);

balanceOf

function balanceOf(address owner) external view returns (uint256);

allowance

function allowance(address owner, address spender) external view returns (uint256);

approve

function approve(address spender, uint256 value) external returns (bool);

transfer

function transfer(address to, uint256 value) external returns (bool);

transferFrom

function transferFrom(address from, address to, uint256 value) external returns (bool);

Events

Approval

event Approval(address indexed owner, address indexed spender, uint256 value);

Transfer

event Transfer(address indexed from, address indexed to, uint256 value);

IWETH

Git Source

Functions

deposit

function deposit() external payable;

transfer

function transfer(address to, uint256 value) external returns (bool);

withdraw

function withdraw(uint256) external;

UniswapV2Router02

Git Source

Inherits: IUniswapV2Router02

State Variables

factory

address public immutable override factory;

WETH

address public immutable override WETH;

Functions

ensure

modifier ensure(uint256 deadline);

constructor

constructor(address _factory, address _WETH) public;

receive

receive() external payable;

_addLiquidity

function _addLiquidity(
    address tokenA,
    address tokenB,
    uint256 amountADesired,
    uint256 amountBDesired,
    uint256 amountAMin,
    uint256 amountBMin
) internal virtual returns (uint256 amountA, uint256 amountB);

addLiquidity

function addLiquidity(
    address tokenA,
    address tokenB,
    uint256 amountADesired,
    uint256 amountBDesired,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external virtual override ensure(deadline) returns (uint256 amountA, uint256 amountB, uint256 liquidity);

addLiquidityETH

function addLiquidityETH(
    address token,
    uint256 amountTokenDesired,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
)
    external
    payable
    virtual
    override
    ensure(deadline)
    returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);

removeLiquidity

function removeLiquidity(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) public virtual override ensure(deadline) returns (uint256 amountA, uint256 amountB);

removeLiquidityETH

function removeLiquidityETH(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) public virtual override ensure(deadline) returns (uint256 amountToken, uint256 amountETH);

removeLiquidityWithPermit

function removeLiquidityWithPermit(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external virtual override returns (uint256 amountA, uint256 amountB);

removeLiquidityETHWithPermit

function removeLiquidityETHWithPermit(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external virtual override returns (uint256 amountToken, uint256 amountETH);

removeLiquidityETHSupportingFeeOnTransferTokens

function removeLiquidityETHSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) public virtual override ensure(deadline) returns (uint256 amountETH);

removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external virtual override returns (uint256 amountETH);

_swap

function _swap(uint256[] memory amounts, address[] memory path, address _to) internal virtual;

swapExactTokensForTokens

function swapExactTokensForTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external virtual override ensure(deadline) returns (uint256[] memory amounts);

swapTokensForExactTokens

function swapTokensForExactTokens(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external virtual override ensure(deadline) returns (uint256[] memory amounts);

swapExactETHForTokens

function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)
    external
    payable
    virtual
    override
    ensure(deadline)
    returns (uint256[] memory amounts);

swapTokensForExactETH

function swapTokensForExactETH(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external virtual override ensure(deadline) returns (uint256[] memory amounts);

swapExactTokensForETH

function swapExactTokensForETH(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external virtual override ensure(deadline) returns (uint256[] memory amounts);

swapETHForExactTokens

function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline)
    external
    payable
    virtual
    override
    ensure(deadline)
    returns (uint256[] memory amounts);

_swapSupportingFeeOnTransferTokens

function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual;

swapExactTokensForTokensSupportingFeeOnTransferTokens

function swapExactTokensForTokensSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external virtual override ensure(deadline);

swapExactETHForTokensSupportingFeeOnTransferTokens

function swapExactETHForTokensSupportingFeeOnTransferTokens(
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external payable virtual override ensure(deadline);

swapExactTokensForETHSupportingFeeOnTransferTokens

function swapExactTokensForETHSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external virtual override ensure(deadline);

quote

function quote(uint256 amountA, uint256 reserveA, uint256 reserveB)
    public
    pure
    virtual
    override
    returns (uint256 amountB);

getAmountOut

function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
    public
    pure
    virtual
    override
    returns (uint256 amountOut);

getAmountIn

function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
    public
    pure
    virtual
    override
    returns (uint256 amountIn);

getAmountsOut

function getAmountsOut(uint256 amountIn, address[] memory path)
    public
    view
    virtual
    override
    returns (uint256[] memory amounts);

getAmountsIn

function getAmountsIn(uint256 amountOut, address[] memory path)
    public
    view
    virtual
    override
    returns (uint256[] memory amounts);

SushiswapGreenSwapWrapper

Git Source

Inherits: Initializable, ContextUpgradeable, OwnableUpgradeable

Author: KlimaDAO

This contracts allows for a sushiswap swap to be offset in a 2nd txn triggered

State Variables

retirementHoldingAddress

address payable public retirementHoldingAddress;

sushiRouterMain

address public sushiRouterMain;

sushiAmountOffset

uint256 public sushiAmountOffset;

Functions

initialize

function initialize() public initializer;

GreenSwapTokensForTokens

This function will do a retirement as well as a swap, while it is
configurable, it can be pre-populated with default values from the Sushi UI

function GreenSwapTokensForTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) public payable;

setRetirementHoldingAddress

function setRetirementHoldingAddress(address _newHoldingAddress) public onlyOwner;

setSushiRouterMain

function setSushiRouterMain(address _newSushiRouter) public onlyOwner;

setSushiAmountOffset

function setSushiAmountOffset(uint256 _newSushiAmountOffset) public onlyOwner;

Events

newRetirementHolder

event newRetirementHolder(address newHolder);

newSushiRouter

event newSushiRouter(address newRouter);

newSushiAmountOffset

event newSushiAmountOffset(uint256 newAmount);

IKlimaRetirementAggregator

Git Source

Functions

retireCarbon

function retireCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage
) external;

IWrappedAsset

Git Source

Functions

deposit

function deposit() external payable;

balanceOf

function balanceOf(address user) external;

approve

function approve(address guy, uint256 wad) external returns (bool);

SwapRetirementHolder

Git Source

Inherits: KeeperCompatibleInterface, Ownable

State Variables

interval

Use an interval in seconds and a timestamp to slow execution of Upkeep

uint256 public interval;

lastTimeStamp

uint256 public lastTimeStamp;

numPendingRetirementAddresses

uint256 public numPendingRetirementAddresses;

continueUpKeeping

bool private continueUpKeeping;

WrappedNativeAssetAddress

address public WrappedNativeAssetAddress;

sourceCarbonToken

address public sourceCarbonToken;

KlimaAggregator

IKlimaRetirementAggregator public KlimaAggregator;

pendingRetirementAmounts

mapping(address => uint256) public pendingRetirementAmounts;

pendingRetirees

mapping(uint256 => address) public pendingRetirees;

pendingAddressQueuePosition

mapping(address => uint256) public pendingAddressQueuePosition;

Functions

constructor

constructor(address _KlimaAggregator, uint256 _interval, address _wrappedNativeAsset, address _carbonToken);

setKlimaAggregator

function setKlimaAggregator(address newAggregator) public onlyManager;

setRetirementInterval

function setRetirementInterval(uint256 newInterval) public onlyManager;

setSourceCarbonToken

function setSourceCarbonToken(address newCarbonToken) public onlyManager;

checkUpkeep

function checkUpkeep(bytes calldata) external view override returns (bool upkeepNeeded, bytes memory);

performUpkeep

function performUpkeep(bytes calldata) external override;

storePendingRetirement

function storePendingRetirement(uint256 amountToStore, address addressToStore) public onlyManager;

replaceAddressInPendingRetirement

function replaceAddressInPendingRetirement(address oldAddress, address replacementAddress) public onlyManager;

receive

receive() external payable;

fallback

fallback() external payable;

Events

intervalUpdated

event intervalUpdated(uint256 newInterval);

aggregatorAddressUpdated

event aggregatorAddressUpdated(address newAddress);

newPendingRetirement

event newPendingRetirement(address retiree, uint256 amount);

newCarbonTokenUpdated

event newCarbonTokenUpdated(address newCarbonTokenUpdate);

testETHSender

Git Source

State Variables

retirementHolderAddress

address payable public retirementHolderAddress;

sushiAmountOffset

uint256 public sushiAmountOffset;

Functions

constructor

constructor(address retirementHolder, uint256 sushiAmount);

sendETHToHolder

function sendETHToHolder(address payable _to) public payable;

Contents

Contents

RetirementBondAllocator

Git Source

Inherits: Ownable2Step

Author: Cujo

A contract for allocating retirement bonds using excess reserves from the Klima Treasury.

State Variables

TREASURY

Address of the Treasury contract.

address public constant TREASURY = 0x7Dd4f0B986F032A44F913BF92c9e8b7c17D77aD7;

DAO

Address of the DAO multi-sig.

address public constant DAO = 0x65A5076C0BA74e5f3e069995dc3DAB9D197d995c;

maxReservePercent

Maximum value of reserves or Treasury balance to allocate. Set by the DAO. 500 = 5%

uint256 public maxReservePercent;

PERCENT_DIVISOR

Divisor used when calculating percentages.

uint256 public constant PERCENT_DIVISOR = 10_000;

bondContract

Retirement bond contract being used.

address public bondContract;

Functions

constructor

constructor(address _bondContract);

onlyDAO

Modifier to ensure that the caller is the DAO multi-sig.

modifier onlyDAO();

fundBonds

Funds retirement bonds with a specified amount of tokens.

function fundBonds(address token, uint256 amount) external onlyOwner;

Parameters

NameTypeDescription
tokenaddressThe address of the token to fund the retirement bonds with.
amountuint256The amount of tokens to fund the retirement bonds with.

closeBonds

Closes the retirement bonds market for a specified token, transferring any remaining tokens to the treasury.

function closeBonds(address token) external onlyOwner;

Parameters

NameTypeDescription
tokenaddressThe address of the token for which to close the retirement bonds market.

updateBondContract

Updates the retirement bond contract being used.

function updateBondContract(address _bondContract) external onlyOwner;

Parameters

NameTypeDescription
_bondContractaddressThe address of the new retirement bond contract.

updateMaxReservePercent

Updates the maximum reserve percentage allowed.

function updateMaxReservePercent(uint256 _maxReservePercent) external onlyDAO;

Parameters

NameTypeDescription
_maxReservePercentuint256The new maximum reserve percentage allowed. 500 = 5%.

Events

MaxPercentUpdated

event MaxPercentUpdated(uint256 oldMax, uint256 newMax);

Contents

CarbonRetirementBondDepository

Git Source

Inherits: Ownable2Step

Author: Cujo

A smart contract that handles the distribution of carbon in exchange for KLIMA tokens. Bond depositors can only use this to retire carbon by providing KLIMA tokens.

State Variables

KLIMA

Address of the KLIMA token contract.

address public constant KLIMA = 0x4e78011Ce80ee02d2c3e649Fb657E45898257815;

DAO

Address of the DAO multi-sig.

address public constant DAO = 0x65A5076C0BA74e5f3e069995dc3DAB9D197d995c;

TREASURY

Address of the Treasury contract.

address public constant TREASURY = 0x7Dd4f0B986F032A44F913BF92c9e8b7c17D77aD7;

INFINITY

address of the Klima Infinity contract.

address public constant INFINITY = 0x8cE54d9625371fb2a068986d32C85De8E6e995f8;

FEE_DIVISOR

Divisor used for calculating percentages.

uint256 public constant FEE_DIVISOR = 10_000;

allocatorContract

Allocator contract used by policy to fund and close markets.

address public allocatorContract;

poolReference

Mapping that stores the KLIMA/X LP used for quoting price references.

mapping(address => address) public poolReference;

referenceKlimaPosition

Mapping that stores whether the KLIMA is token 0 or token 1 in the LP contract.

mapping(address => uint8) public referenceKlimaPosition;

daoFee

Mapping that stores the DAO fee charged for a specific pool token.

mapping(address => uint256) public daoFee;

maxSlippage

Mapping that stores the maximum slippage tolerated for a specific pool token.

mapping(address => uint256) public maxSlippage;

Functions

onlyAllocator

Modifier to ensure that the calling function is being called by the allocator contract.

modifier onlyAllocator();

swapToExact

Swaps the specified amount of pool tokens for KLIMA tokens.

Only callable by the Infinity contract.

function swapToExact(address poolToken, uint256 poolAmount) external;

Parameters

NameTypeDescription
poolTokenaddressThe pool token address.
poolAmountuint256The amount of pool tokens to swap.

retireCarbonDefault

Retires the specified amount of carbon for the given pool token using KI.

Requires KLIMA spend approval for the amount returned by getKlimaAmount()

function retireCarbonDefault(
    address poolToken,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage
) external returns (uint256 retirementIndex);

Parameters

NameTypeDescription
poolTokenaddressThe pool token address.
retireAmountuint256The amount of carbon to retire.
retiringEntityStringstringThe string representing the retiring entity.
beneficiaryAddressaddressThe address of the beneficiary.
beneficiaryStringstringThe string representing the beneficiary.
retirementMessagestringThe message for the retirement.

Returns

NameTypeDescription
retirementIndexuint256The index of the retirement transaction.

retireCarbonSpecific

Retires the specified amount of carbon for the given pool token using KI. Uses the provided project token for the underlying credit to retire.

Requires KLIMA spend approval for the amount returned by getKlimaAmount()

function retireCarbonSpecific(
    address poolToken,
    address projectToken,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage
) external returns (uint256 retirementIndex);

Parameters

NameTypeDescription
poolTokenaddressThe pool token address.
projectTokenaddressThe project token to retire.
retireAmountuint256The amount of carbon to retire.
retiringEntityStringstringThe string representing the retiring entity.
beneficiaryAddressaddressThe address of the beneficiary.
beneficiaryStringstringThe string representing the beneficiary.
retirementMessagestringThe message for the retirement.

Returns

NameTypeDescription
retirementIndexuint256The index of the retirement transaction.

openMarket

Emits event on market allocation.

Only the allocator contract can call this function.

function openMarket(address poolToken) external onlyAllocator;

Parameters

NameTypeDescription
poolTokenaddressThe address of the pool token to open the market for.

closeMarket

Closes the market for a specified pool token by transferring all remaining pool tokens to the treasury address.

Only the allocator contract can call this function.

function closeMarket(address poolToken) external onlyAllocator;

Parameters

NameTypeDescription
poolTokenaddressThe address of the pool token to close the market for.

updateMaxSlippage

Updates the maximum slippage percentage for a specified pool token.

function updateMaxSlippage(address poolToken, uint256 _maxSlippage) external onlyOwner;

Parameters

NameTypeDescription
poolTokenaddressThe address of the pool token to update the maximum slippage percentage for.
_maxSlippageuint256The new maximum slippage percentage.

updateDaoFee

Updates the DAO fee for a specified pool token.

function updateDaoFee(address poolToken, uint256 _daoFee) external onlyOwner;

Parameters

NameTypeDescription
poolTokenaddressThe address of the pool token to update the DAO fee for.
_daoFeeuint256The new DAO fee.

setPoolReference

Sets the reference token for a given pool token. The reference token is used to determine the current price of the pool token in terms of KLIMA. The position of KLIMA in the Uniswap pair for the reference token is also determined.

function setPoolReference(address poolToken, address referenceToken) external onlyOwner;

Parameters

NameTypeDescription
poolTokenaddressThe pool token for which to set the reference token.
referenceTokenaddressThe reference token for the given pool token.

setAllocator

Sets the address of the allocator contract. Only the contract owner can call this function.

function setAllocator(address allocator) external onlyOwner;

Parameters

NameTypeDescription
allocatoraddressThe address of the allocator contract to set.

getKlimaAmount

Calculates the amount of KLIMA tokens needed to retire a specified amount of pool tokens for a pool. The required amount of KLIMA tokens is calculated based on the current market price of the pool token and the amount of pool tokens to be retired. If the raw amount needed from the dex exceeds slippage, than the limited amount is returned.

function getKlimaAmount(uint256 poolAmount, address poolToken) public view returns (uint256 klimaNeeded);

Parameters

NameTypeDescription
poolAmountuint256The amount of pool tokens to retire.
poolTokenaddressThe address of the pool token to retire.

Returns

NameTypeDescription
klimaNeededuint256The amount of KLIMA tokens needed to retire the specified amount of pool tokens.

_transferAndBurnKlima

Transfers and burns a specified amount of KLIMA tokens. A fee is also transferred to the DAO address based on the fee divisor and the configured fee for the pool token.

On extremely small quote amounts this can result in zero

function _transferAndBurnKlima(uint256 totalKlima, address poolToken) private;

Parameters

NameTypeDescription
totalKlimauint256The total amount of KLIMA tokens to transfer and burn.
poolTokenaddressThe address of the pool token to burn KLIMA tokens for.

getMarketQuote

Returns the current market price of the pool token in terms of KLIMA tokens.

Currently all KLIMA LP contracts safely interact with the IUniswapV2Pair abi.

function getMarketQuote(address poolToken, uint256 amountOut) internal view returns (uint256 currentPrice);

Parameters

NameTypeDescription
poolTokenaddressThe address of the pool token to get the market quote for.
amountOutuint256The amount of pool tokens to get the market quote for.

Returns

NameTypeDescription
currentPriceuint256The current market price of the pool token in terms of KLIMA tokens.

Events

AllocatorChanged

event AllocatorChanged(address oldAllocator, address newAllocator);

PoolReferenceChanged

event PoolReferenceChanged(address pool, address oldLp, address newLp);

ReferenceKlimaPositionChanged

event ReferenceKlimaPositionChanged(address lp, uint8 oldPosition, uint8 newPosition);

DaoFeeChanged

event DaoFeeChanged(address pool, uint256 oldFee, uint256 newFee);

PoolSlippageChanged

event PoolSlippageChanged(address pool, uint256 oldSlippage, uint256 newSlippage);

MarketOpened

event MarketOpened(address pool, uint256 amount);

MarketClosed

event MarketClosed(address pool, uint256 amount);

CarbonBonded

event CarbonBonded(address pool, uint256 poolAmount);

KlimaBonded

event KlimaBonded(uint256 daoFee, uint256 klimaBurned);

Contents

IKlima

Git Source

Inherits: IERC20

Functions

mint

function mint(address account_, uint256 amount_) external;

burn

function burn(uint256 amount) external;

burnFrom

function burnFrom(address account_, uint256 amount_) external;

IKlimaTreasury

Git Source

Functions

excessReserves

function excessReserves() external returns (uint256);

manage

function manage(address _token, uint256 _amount) external;

queue

function queue(uint8 _managing, address _address) external returns (bool);

toggle

function toggle(uint8 _managing, address _address, address _calculator) external returns (bool);

ReserveManagerQueue

function ReserveManagerQueue(address _address) external returns (uint256);

isReserveManager

function isReserveManager(address _address) external returns (bool);

IKlimaRetirementBond

Git Source

Functions

owner

function owner() external returns (address);

allocatorContract

function allocatorContract() external returns (address);

DAO

function DAO() external returns (address);

TREASURY

function TREASURY() external returns (address);

openMarket

function openMarket(address poolToken) external;

closeMarket

function closeMarket(address poolToken) external;

updateMaxSlippage

function updateMaxSlippage(address poolToken, uint256 _maxSlippage) external;

updateDaoFee

function updateDaoFee(address poolToken, uint256 _daoFee) external;

setPoolReference

function setPoolReference(address poolToken, address referenceToken) external;

IRetirementBondAllocator

Git Source

Functions

owner

function owner() external returns (address);

fundBonds

function fundBonds(address token, uint256 amount) external;

closeBonds

function closeBonds(address token) external;

updateBondContract

function updateBondContract(address _bondContract) external;

updateMaxReservePercent

function updateMaxReservePercent(uint256 _maxReservePercent) external;

maxReservePercent

function maxReservePercent() external view returns (uint256);

PERCENT_DIVISOR

function PERCENT_DIVISOR() external view returns (uint256);

IKlimaInfinity

Git Source

Functions

retireExactCarbonDefault

function retireExactCarbonDefault(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

retireExactCarbonSpecific

function retireExactCarbonSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 maxAmountIn,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

retireExactSourceDefault

function retireExactSourceDefault(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

retireExactSourceSpecific

function retireExactSourceSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 maxAmountIn,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

getSourceAmountDefaultRetirement

function getSourceAmountDefaultRetirement(address sourceToken, address carbonToken, uint256 retireAmount)
    external
    view
    returns (uint256 amountIn);

getSourceAmountSpecificRetirement

function getSourceAmountSpecificRetirement(address sourceToken, address carbonToken, uint256 retireAmount)
    external
    view
    returns (uint256 amountIn);

getSourceAmountSwapOnly

function getSourceAmountSwapOnly(address sourceToken, address carbonToken, uint256 amountOut)
    external
    view
    returns (uint256 amountIn);

IUniswapV2Pair

Git Source

Functions

name

function name() external pure returns (string memory);

symbol

function symbol() external pure returns (string memory);

decimals

function decimals() external pure returns (uint8);

totalSupply

function totalSupply() external view returns (uint256);

balanceOf

function balanceOf(address owner) external view returns (uint256);

allowance

function allowance(address owner, address spender) external view returns (uint256);

approve

function approve(address spender, uint256 value) external returns (bool);

transfer

function transfer(address to, uint256 value) external returns (bool);

transferFrom

function transferFrom(address from, address to, uint256 value) external returns (bool);

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32);

PERMIT_TYPEHASH

function PERMIT_TYPEHASH() external pure returns (bytes32);

nonces

function nonces(address owner) external view returns (uint256);

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external;

MINIMUM_LIQUIDITY

function MINIMUM_LIQUIDITY() external pure returns (uint256);

factory

function factory() external view returns (address);

token0

function token0() external view returns (address);

token1

function token1() external view returns (address);

getReserves

function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);

price0CumulativeLast

function price0CumulativeLast() external view returns (uint256);

price1CumulativeLast

function price1CumulativeLast() external view returns (uint256);

kLast

function kLast() external view returns (uint256);

mint

function mint(address to) external returns (uint256 liquidity);

burn

function burn(address to) external returns (uint256 amount0, uint256 amount1);

swap

function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;

skim

function skim(address to) external;

sync

function sync() external;

initialize

function initialize(address, address) external;

Events

Approval

event Approval(address indexed owner, address indexed spender, uint256 value);

Transfer

event Transfer(address indexed from, address indexed to, uint256 value);

Mint

event Mint(address indexed sender, uint256 amount0, uint256 amount1);

Burn

event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);

Swap

event Swap(
    address indexed sender,
    uint256 amount0In,
    uint256 amount1In,
    uint256 amount0Out,
    uint256 amount1Out,
    address indexed to
);

Sync

event Sync(uint112 reserve0, uint112 reserve1);

IwsKLIMA

Git Source

Inherits: IERC20

Functions

sKLIMA

function sKLIMA() external returns (address);

wrap

function wrap(uint256 _amount) external returns (uint256);

unwrap

function unwrap(uint256 _amount) external returns (uint256);

wKLIMATosKLIMA

function wKLIMATosKLIMA(uint256 _amount) external view returns (uint256);

sKLIMATowKLIMA

function sKLIMATowKLIMA(uint256 _amount) external view returns (uint256);

Contents

SafeERC20

Git Source

Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a using SafeERC20 for IERC20; statement to your contract, which allows you to call the safe operations as token.safeTransfer(...), etc.

Functions

safeTransfer

function safeTransfer(IERC20 token, address to, uint256 value) internal;

safeTransferFrom

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal;

safeApprove

Deprecated. This function has issues similar to the ones found in IERC20-approve, and its usage is discouraged. Whenever possible, use {safeIncreaseAllowance} and {safeDecreaseAllowance} instead.

function safeApprove(IERC20 token, address spender, uint256 value) internal;

safeIncreaseAllowance

function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal;

safeDecreaseAllowance

function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal;

_callOptionalReturn

Imitates a Solidity high-level call (i.e. a regular_old function call to a contract), relaxing the requirement on the return value: the return value is optional (but if data is returned, it must not be false).

function _callOptionalReturn(IERC20 token, bytes memory data) private;

Parameters

NameTypeDescription
tokenIERC20The token targeted by the call.
databytesThe call data (encoded using abi.encode or one of its variants).

SafeMath

Git Source

Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. SafeMath restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

percentageAmount

function percentageAmount(uint256 total_, uint8 percentage_) internal pure returns (uint256 percentAmount_);

substractPercentage

function substractPercentage(uint256 total_, uint8 percentageToSub_) internal pure returns (uint256 result_);

percentageOfTotal

function percentageOfTotal(uint256 part_, uint256 total_) internal pure returns (uint256 percent_);

average

Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol

Returns the average of two numbers. The result is rounded towards zero.

function average(uint256 a, uint256 b) internal pure returns (uint256);

quadraticPricing

function quadraticPricing(uint256 payment_, uint256 multiplier_) internal pure returns (uint256);

bondingCurve

function bondingCurve(uint256 supply_, uint256 multiplier_) internal pure returns (uint256);

Address

Git Source

Collection of functions related to the address type

Functions

isContract

*Returns true if account is a contract. [IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract. Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====*
function isContract(address account) internal view returns (bool);

sendValue

Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors. https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. sendValue removes this limitation. https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

*Performs a Solidity function call using a low level call. A plaincall is an unsafe replacement for a function call: use this function instead. If target reverts with a revert reason, it is bubbled up by this function (like regular_old Solidity function calls). Returns the raw returned data. To convert to the expected return value, use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[abi.decode]. Requirements:

  • target must be a contract.
  • calling target with data must not revert. Available since v3.1.*
function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

Same as functionCall, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

*Same as functionCall, but also transferring value wei to target. Requirements:

  • the calling contract must have an ETH balance of at least value.
  • the called Solidity function must be payable. Available since v3.1.*
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

Same as functionCallWithValue, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data, string memory errorMessage)
    internal
    view
    returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data, string memory errorMessage)
    internal
    returns (bytes memory);

_verifyCallResult

function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage)
    private
    pure
    returns (bytes memory);

addressToString

function addressToString(address _address) internal pure returns (string memory);

IERC20

Git Source

Interface of the ERC20 standard as defined in the EIP.

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

ITreasury

Git Source

Functions

deposit

function deposit(uint256 _amount, address _token, uint256 _profit) external returns (uint256);

IPOLY

Git Source

Functions

isApprovedSeller

function isApprovedSeller(address _address) external view returns (bool);

ICirculatingOHM

Git Source

Functions

OHMCirculatingSupply

function OHMCirculatingSupply() external view returns (uint256);

AltExercisepOLY

Git Source

Exercise contract for unapproved sellers prior to migrating pOLY. It is not possible for a user to use both (no double dipping).

State Variables

owner

address owner;

newOwner

address newOwner;

pOLY

address immutable pOLY;

OHM

address immutable OHM;

DAI

address immutable DAI;

treasury

address immutable treasury;

circulatingOHMContract

address immutable circulatingOHMContract;

terms

mapping(address => Term) public terms;

walletChange

mapping(address => address) public walletChange;

Functions

constructor

constructor(address _pOLY, address _ohm, address _dai, address _treasury, address _circulatingOHMContract);

setTerms

function setTerms(address _vester, uint256 _rate, uint256 _claimed, uint256 _max) external;

exercise

function exercise(uint256 _amount) external;

pushWalletChange

function pushWalletChange(address _newWallet) external;

pullWalletChange

function pullWalletChange(address _oldWallet) external;

redeemableFor

function redeemableFor(address _vester) public view returns (uint256);

redeemable

function redeemable(Term memory _info) internal view returns (uint256);

pushOwnership

function pushOwnership(address _newOwner) external returns (bool);

pullOwnership

function pullOwnership() external returns (bool);

Structs

Term

struct Term {
    uint256 percent;
    uint256 claimed;
    uint256 max;
}

SafeERC20

Git Source

Submitted for verification at Etherscan.io on 2021-06-03 Submitted for verification at Etherscan.io on 2021-04-14

Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a using SafeERC20 for IERC20; statement to your contract, which allows you to call the safe operations as token.safeTransfer(...), etc.

Functions

safeTransfer

function safeTransfer(IERC20 token, address to, uint256 value) internal;

safeTransferFrom

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal;

safeApprove

Deprecated. This function has issues similar to the ones found in IERC20-approve, and its usage is discouraged. Whenever possible, use {safeIncreaseAllowance} and {safeDecreaseAllowance} instead.

function safeApprove(IERC20 token, address spender, uint256 value) internal;

safeIncreaseAllowance

function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal;

safeDecreaseAllowance

function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal;

_callOptionalReturn

Imitates a Solidity high-level call (i.e. a regular_old function call to a contract), relaxing the requirement on the return value: the return value is optional (but if data is returned, it must not be false).

function _callOptionalReturn(IERC20 token, bytes memory data) private;

Parameters

NameTypeDescription
tokenIERC20The token targeted by the call.
databytesThe call data (encoded using abi.encode or one of its variants).

SafeMath

Git Source

Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. SafeMath restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

percentageAmount

function percentageAmount(uint256 total_, uint8 percentage_) internal pure returns (uint256 percentAmount_);

substractPercentage

function substractPercentage(uint256 total_, uint8 percentageToSub_) internal pure returns (uint256 result_);

percentageOfTotal

function percentageOfTotal(uint256 part_, uint256 total_) internal pure returns (uint256 percent_);

average

Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol

Returns the average of two numbers. The result is rounded towards zero.

function average(uint256 a, uint256 b) internal pure returns (uint256);

quadraticPricing

function quadraticPricing(uint256 payment_, uint256 multiplier_) internal pure returns (uint256);

bondingCurve

function bondingCurve(uint256 supply_, uint256 multiplier_) internal pure returns (uint256);

Address

Git Source

Collection of functions related to the address type

Functions

isContract

*Returns true if account is a contract. [IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract. Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====*
function isContract(address account) internal view returns (bool);

sendValue

Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors. https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. sendValue removes this limitation. https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

*Performs a Solidity function call using a low level call. A plaincall is an unsafe replacement for a function call: use this function instead. If target reverts with a revert reason, it is bubbled up by this function (like regular_old Solidity function calls). Returns the raw returned data. To convert to the expected return value, use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[abi.decode]. Requirements:

  • target must be a contract.
  • calling target with data must not revert. Available since v3.1.*
function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

Same as functionCall, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

*Same as functionCall, but also transferring value wei to target. Requirements:

  • the calling contract must have an ETH balance of at least value.
  • the called Solidity function must be payable. Available since v3.1.*
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

Same as functionCallWithValue, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data, string memory errorMessage)
    internal
    view
    returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data, string memory errorMessage)
    internal
    returns (bytes memory);

_verifyCallResult

function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage)
    private
    pure
    returns (bytes memory);

addressToString

function addressToString(address _address) internal pure returns (string memory);

IERC20

Git Source

Interface of the ERC20 standard as defined in the EIP.

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

ITreasury

Git Source

Functions

deposit

function deposit(uint256 _amount, address _token, uint256 _profit) external returns (uint256);

IPKLIMA

Git Source

Functions

burnFrom

function burnFrom(address account_, uint256 amount_) external;

IOldClaimContract

Git Source

Functions

amountClaimed

function amountClaimed(address _vester) external view returns (uint256);

maxAllowedToClaim

function maxAllowedToClaim(address _vester) external view returns (uint256);

percentCanVest

function percentCanVest(address _vester) external view returns (uint256);

ICirculatingKLIMA

Git Source

Functions

KLIMACirculatingSupply

function KLIMACirculatingSupply() external view returns (uint256);

ExercisepKLIMA

Git Source

State Variables

owner

address public owner;

newOwner

address public newOwner;

pKLIMA

address public immutable pKLIMA;

KLIMA

address public immutable KLIMA;

BCT

address public immutable BCT;

treasury

address public immutable treasury;

circulatingKLIMAContract

address public immutable circulatingKLIMAContract;

terms

mapping(address => Term) public terms;

walletChange

mapping(address => address) public walletChange;

hasMigrated

bool hasMigrated;

Functions

constructor

constructor(address _pKLIMA, address _KLIMA, address _BCT, address _treasury, address _circulatingKLIMAContract);

setTerms

function setTerms(address _vester, uint256 _amountCanClaim, uint256 _rate) external returns (bool);

exercise

function exercise(uint256 _amount) external returns (bool);

pushWalletChange

function pushWalletChange(address _newWallet) external returns (bool);

pullWalletChange

function pullWalletChange(address _oldWallet) external returns (bool);

redeemableFor

function redeemableFor(address _vester) public view returns (uint256);

redeemable

function redeemable(Term memory _info) internal view returns (uint256);

pushOwnership

function pushOwnership(address _newOwner) external returns (bool);

pullOwnership

function pullOwnership() external returns (bool);

Structs

Term

struct Term {
    uint256 percent;
    uint256 claimed;
    uint256 max;
}

Contents

Contents

SafeERC20

Git Source

Functions

safeTransfer

function safeTransfer(IERC20 token, address to, uint256 value) internal;

safeTransferFrom

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal;

safeApprove

function safeApprove(IERC20 token, address spender, uint256 value) internal;

safeIncreaseAllowance

function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal;

safeDecreaseAllowance

function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal;

_callOptionalReturn

function _callOptionalReturn(IERC20 token, bytes memory data) private;

SafeMath

Git Source

Functions

add

function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

function div(uint256 a, uint256 b) internal pure returns (uint256);

div

function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

percentageAmount

function percentageAmount(uint256 total_, uint8 percentage_) internal pure returns (uint256 percentAmount_);

substractPercentage

function substractPercentage(uint256 total_, uint8 percentageToSub_) internal pure returns (uint256 result_);

percentageOfTotal

function percentageOfTotal(uint256 part_, uint256 total_) internal pure returns (uint256 percent_);

average

function average(uint256 a, uint256 b) internal pure returns (uint256);

quadraticPricing

function quadraticPricing(uint256 payment_, uint256 multiplier_) internal pure returns (uint256);

bondingCurve

function bondingCurve(uint256 supply_, uint256 multiplier_) internal pure returns (uint256);

IERC20

Git Source

Functions

totalSupply

function totalSupply() external view returns (uint256);

balanceOf

function balanceOf(address account) external view returns (uint256);

transfer

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

function allowance(address owner, address spender) external view returns (uint256);

approve

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

event Approval(address indexed owner, address indexed spender, uint256 value);

Address

Git Source

Functions

isContract

function isContract(address account) internal view returns (bool);

sendValue

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

functionStaticCall

function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);

functionStaticCall

function functionStaticCall(address target, bytes memory data, string memory errorMessage)
    internal
    view
    returns (bytes memory);

functionDelegateCall

function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);

functionDelegateCall

function functionDelegateCall(address target, bytes memory data, string memory errorMessage)
    internal
    returns (bytes memory);

_verifyCallResult

function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage)
    private
    pure
    returns (bytes memory);

addressToString

function addressToString(address _address) internal pure returns (string memory);

IPolicy

Git Source

Functions

policy

function policy() external view returns (address);

renouncePolicy

function renouncePolicy() external;

pushPolicy

function pushPolicy(address newPolicy_) external;

pullPolicy

function pullPolicy() external;

Policy

Git Source

Inherits: IPolicy

State Variables

_policy

address internal _policy;

_newPolicy

address internal _newPolicy;

Functions

constructor

constructor();

policy

function policy() public view override returns (address);

onlyPolicy

modifier onlyPolicy();

renouncePolicy

function renouncePolicy() public virtual override onlyPolicy;

pushPolicy

function pushPolicy(address newPolicy_) public virtual override onlyPolicy;

pullPolicy

function pullPolicy() public virtual override;

Events

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

ITreasury

Git Source

Functions

mintRewards

function mintRewards(address _recipient, uint256 _amount) external;

Distributor

Git Source

Inherits: Policy

State Variables

KLIMA

address public immutable KLIMA;

treasury

address public immutable treasury;

epochLength

uint256 public immutable epochLength;

nextEpochBlock

uint256 public nextEpochBlock;

adjustments

mapping(uint256 => Adjust) public adjustments;

info

Info[] public info;

Functions

constructor

constructor(address _treasury, address _klima, uint256 _epochLength, uint256 _nextEpochBlock);

distribute

send epoch reward to staking contract

function distribute() external returns (bool);

adjust

increment reward rate for collector

function adjust(uint256 _index) internal;

nextRewardAt

view function for next reward at given rate

function nextRewardAt(uint256 _rate) public view returns (uint256);

Parameters

NameTypeDescription
_rateuint256uint

Returns

NameTypeDescription
<none>uint256uint

nextRewardFor

view function for next reward for specified address

function nextRewardFor(address _recipient) public view returns (uint256);

Parameters

NameTypeDescription
_recipientaddressaddress

Returns

NameTypeDescription
<none>uint256uint

addRecipient

adds recipient for distributions

function addRecipient(address _recipient, uint256 _rewardRate) external onlyPolicy;

Parameters

NameTypeDescription
_recipientaddressaddress
_rewardRateuint256uint

removeRecipient

removes recipient for distributions

function removeRecipient(uint256 _index, address _recipient) external onlyPolicy;

Parameters

NameTypeDescription
_indexuint256uint
_recipientaddressaddress

setAdjustment

set adjustment info for a collector's reward rate

function setAdjustment(uint256 _index, bool _add, uint256 _rate, uint256 _target) external onlyPolicy;

Parameters

NameTypeDescription
_indexuint256uint
_addboolbool
_rateuint256uint
_targetuint256uint

Structs

Info

struct Info {
    uint256 rate;
    address recipient;
}

Adjust

struct Adjust {
    bool add;
    uint256 rate;
    uint256 target;
}

SafeMath

Git Source

Submitted for verification at Etherscan.io on 2021-06-12

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

IERC20

Git Source

Functions

decimals

function decimals() external view returns (uint8);

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

Address

Git Source

Functions

isContract

*Returns true if account is a contract. [IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract. Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====*
function isContract(address account) internal view returns (bool);

sendValue

Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors. https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. sendValue removes this limitation. https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

*Performs a Solidity function call using a low level call. A plaincall is an unsafe replacement for a function call: use this function instead. If target reverts with a revert reason, it is bubbled up by this function (like regular Solidity function calls). Returns the raw returned data. To convert to the expected return value, use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[abi.decode]. Requirements:

  • target must be a contract.
  • calling target with data must not revert. Available since v3.1.*
function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

Same as functionCall, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

*Same as functionCall, but also transferring value wei to target. Requirements:

  • the calling contract must have an ETH balance of at least value.
  • the called Solidity function must be payable. Available since v3.1.*
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

Same as functionCallWithValue, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data, string memory errorMessage)
    internal
    view
    returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data, string memory errorMessage)
    internal
    returns (bytes memory);

_verifyCallResult

function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage)
    private
    pure
    returns (bytes memory);

addressToString

function addressToString(address _address) internal pure returns (string memory);

SafeERC20

Git Source

Functions

safeTransfer

function safeTransfer(IERC20 token, address to, uint256 value) internal;

safeTransferFrom

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal;

safeApprove

Deprecated. This function has issues similar to the ones found in IERC20-approve, and its usage is discouraged. Whenever possible, use {safeIncreaseAllowance} and {safeDecreaseAllowance} instead.

function safeApprove(IERC20 token, address spender, uint256 value) internal;

safeIncreaseAllowance

function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal;

safeDecreaseAllowance

function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal;

_callOptionalReturn

Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement on the return value: the return value is optional (but if data is returned, it must not be false).

function _callOptionalReturn(IERC20 token, bytes memory data) private;

Parameters

NameTypeDescription
tokenIERC20The token targeted by the call.
databytesThe call data (encoded using abi.encode or one of its variants).

IOwnable

Git Source

Functions

manager

function manager() external view returns (address);

renounceManagement

function renounceManagement() external;

pushManagement

function pushManagement(address newOwner_) external;

pullManagement

function pullManagement() external;

Ownable

Git Source

Inherits: IOwnable

State Variables

_owner

address internal _owner;

_newOwner

address internal _newOwner;

Functions

constructor

constructor();

manager

function manager() public view override returns (address);

onlyManager

modifier onlyManager();

renounceManagement

function renounceManagement() public virtual override onlyManager;

pushManagement

function pushManagement(address newOwner_) public virtual override onlyManager;

pullManagement

function pullManagement() public virtual override;

Events

OwnershipPushed

event OwnershipPushed(address indexed previousOwner, address indexed newOwner);

OwnershipPulled

event OwnershipPulled(address indexed previousOwner, address indexed newOwner);

IsKLIMA

Git Source

Functions

rebase

function rebase(uint256 klimaProfit_, uint256 epoch_) external returns (uint256);

circulatingSupply

function circulatingSupply() external view returns (uint256);

balanceOf

function balanceOf(address who) external view returns (uint256);

gonsForBalance

function gonsForBalance(uint256 amount) external view returns (uint256);

balanceForGons

function balanceForGons(uint256 gons) external view returns (uint256);

index

function index() external view returns (uint256);

IWarmup

Git Source

Functions

retrieve

function retrieve(address staker_, uint256 amount_) external;

IDistributor

Git Source

Functions

distribute

function distribute() external returns (bool);

KlimaStaking

Git Source

Inherits: Ownable

State Variables

KLIMA

address public immutable KLIMA;

sKLIMA

address public immutable sKLIMA;

epoch

Epoch public epoch;

distributor

address public distributor;

locker

address public locker;

totalBonus

uint256 public totalBonus;

warmupContract

address public warmupContract;

warmupPeriod

uint256 public warmupPeriod;

warmupInfo

mapping(address => Claim) public warmupInfo;

Functions

constructor

constructor(address _KLIMA, address _sKLIMA, uint256 _epochLength, uint256 _firstEpochNumber, uint256 _firstEpochBlock);

stake

stake KLIMA to enter warmup

function stake(uint256 _amount, address _recipient) external returns (bool);

Parameters

NameTypeDescription
_amountuint256uint
_recipientaddress

Returns

NameTypeDescription
<none>boolbool

claim

retrieve sKLIMA from warmup

function claim(address _recipient) public;

Parameters

NameTypeDescription
_recipientaddressaddress

forfeit

forfeit sKLIMA in warmup and retrieve KLIMA

function forfeit() external;

toggleDepositLock

prevent new deposits to address (protection from malicious activity)

function toggleDepositLock() external;

unstake

redeem sKLIMA for KLIMA

function unstake(uint256 _amount, bool _trigger) external;

Parameters

NameTypeDescription
_amountuint256uint
_triggerboolbool

index

returns the sKLIMA index, which tracks rebase growth

function index() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint

rebase

trigger rebase if epoch over

function rebase() public;

contractBalance

returns contract KLIMA holdings, including bonuses provided

function contractBalance() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint

giveLockBonus

provide bonus to locked staking contract

function giveLockBonus(uint256 _amount) external;

Parameters

NameTypeDescription
_amountuint256uint

returnLockBonus

reclaim bonus from locked staking contract

function returnLockBonus(uint256 _amount) external;

Parameters

NameTypeDescription
_amountuint256uint

setContract

sets the contract address for LP staking

function setContract(CONTRACTS _contract, address _address) external onlyManager;

Parameters

NameTypeDescription
_contractCONTRACTSaddress
_addressaddress

setWarmup

set warmup period for new stakers

function setWarmup(uint256 _warmupPeriod) external onlyManager;

Parameters

NameTypeDescription
_warmupPerioduint256uint

Structs

Epoch

struct Epoch {
    uint256 length;
    uint256 number;
    uint256 endBlock;
    uint256 distribute;
}

Claim

struct Claim {
    uint256 deposit;
    uint256 gons;
    uint256 expiry;
    bool lock;
}

Enums

CONTRACTS

enum CONTRACTS {
    DISTRIBUTOR,
    WARMUP,
    LOCKER
}

IERC20

Git Source

Functions

decimals

function decimals() external view returns (uint8);

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

IStaking

Git Source

Functions

stake

function stake(uint256 _amount, address _recipient) external returns (bool);

claim

function claim(address _recipient) external;

StakingHelper

Git Source

State Variables

staking

address public immutable staking;

KLIMA

address public immutable KLIMA;

Functions

constructor

constructor(address _staking, address _KLIMA);

stake

function stake(uint256 _amount) external;

IERC20

Git Source

Submitted for verification at Etherscan.io on 2021-06-12

Functions

decimals

function decimals() external view returns (uint8);

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

StakingWarmup

Git Source

State Variables

staking

address public immutable staking;

sKLIMA

address public immutable sKLIMA;

Functions

constructor

constructor(address _staking, address _sKLIMA);

retrieve

function retrieve(address _staker, uint256 _amount) external;

Contents

SafeMath

Git Source

Submitted for verification at Etherscan.io on 2021-04-14

Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. SafeMath restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

percentageAmount

function percentageAmount(uint256 total_, uint8 percentage_) internal pure returns (uint256 percentAmount_);

substractPercentage

function substractPercentage(uint256 total_, uint8 percentageToSub_) internal pure returns (uint256 result_);

percentageOfTotal

function percentageOfTotal(uint256 part_, uint256 total_) internal pure returns (uint256 percent_);

average

Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol

Returns the average of two numbers. The result is rounded towards zero.

function average(uint256 a, uint256 b) internal pure returns (uint256);

quadraticPricing

function quadraticPricing(uint256 payment_, uint256 multiplier_) internal pure returns (uint256);

bondingCurve

function bondingCurve(uint256 supply_, uint256 multiplier_) internal pure returns (uint256);

IERC20

Git Source

Interface of the ERC20 standard as defined in the EIP.

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

KlimaCirculatingSupplyContract

Git Source

State Variables

isInitialized

bool public isInitialized;

KLIMA

address public KLIMA;

owner

address public owner;

nonCirculatingKLIMAAddresses

address[] public nonCirculatingKLIMAAddresses;

Functions

constructor

constructor(address _owner);

initialize

function initialize(address _klima) external returns (bool);

KLIMACirculatingSupply

function KLIMACirculatingSupply() external view returns (uint256);

getNonCirculatingKLIMA

function getNonCirculatingKLIMA() public view returns (uint256);

setNonCirculatingKLIMAAddresses

function setNonCirculatingKLIMAAddresses(address[] calldata _nonCirculatingAddresses) external returns (bool);

transferOwnership

function transferOwnership(address _owner) external returns (bool);

IBondCalculator

Git Source

Functions

valuation

function valuation(address pair_, uint256 amount_) external view returns (uint256 _value);

markdown

function markdown(address _pair) external view returns (uint256);

IERC20Mintable

Git Source

Functions

mint

function mint(uint256 amount_) external;

mint

function mint(address account_, uint256 ammount_) external;

IKLIMAERC20

Git Source

Functions

burnFrom

function burnFrom(address account_, uint256 amount_) external;

SafeERC20

Git Source

Functions

safeTransfer

function safeTransfer(IERC20 token, address to, uint256 value) internal;

safeTransferFrom

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal;

safeApprove

function safeApprove(IERC20 token, address spender, uint256 value) internal;

safeIncreaseAllowance

function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal;

safeDecreaseAllowance

function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal;

_callOptionalReturn

function _callOptionalReturn(IERC20 token, bytes memory data) private;

IERC20

Git Source

Functions

decimals

function decimals() external view returns (uint8);

totalSupply

function totalSupply() external view returns (uint256);

balanceOf

function balanceOf(address account) external view returns (uint256);

transfer

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

function allowance(address owner, address spender) external view returns (uint256);

approve

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

event Approval(address indexed owner, address indexed spender, uint256 value);

IOwnable

Git Source

Functions

manager

function manager() external view returns (address);

renounceManagement

function renounceManagement() external;

pushManagement

function pushManagement(address newOwner_) external;

pullManagement

function pullManagement() external;

Ownable

Git Source

Inherits: IOwnable

State Variables

_owner

address internal _owner;

_newOwner

address internal _newOwner;

Functions

constructor

constructor();

manager

function manager() public view override returns (address);

onlyManager

modifier onlyManager();

renounceManagement

function renounceManagement() public virtual override onlyManager;

pushManagement

function pushManagement(address newOwner_) public virtual override onlyManager;

pullManagement

function pullManagement() public virtual override;

Events

OwnershipPushed

event OwnershipPushed(address indexed previousOwner, address indexed newOwner);

OwnershipPulled

event OwnershipPulled(address indexed previousOwner, address indexed newOwner);

Address

Git Source

Functions

isContract

function isContract(address account) internal view returns (bool);

sendValue

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

functionStaticCall

function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);

functionStaticCall

function functionStaticCall(address target, bytes memory data, string memory errorMessage)
    internal
    view
    returns (bytes memory);

functionDelegateCall

function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);

functionDelegateCall

function functionDelegateCall(address target, bytes memory data, string memory errorMessage)
    internal
    returns (bytes memory);

_verifyCallResult

function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage)
    private
    pure
    returns (bytes memory);

addressToString

function addressToString(address _address) internal pure returns (string memory);

SafeMath

Git Source

Functions

add

function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

function div(uint256 a, uint256 b) internal pure returns (uint256);

div

function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

KlimaTreasury

Git Source

Inherits: Ownable

State Variables

KLIMA

address public KLIMA;

blocksNeededForQueue

uint256 public blocksNeededForQueue;

reserveTokens

address[] public reserveTokens;

isReserveToken

mapping(address => bool) public isReserveToken;

reserveTokenQueue

mapping(address => uint256) public reserveTokenQueue;

reserveDepositors

address[] public reserveDepositors;

isReserveDepositor

mapping(address => bool) public isReserveDepositor;

reserveDepositorQueue

mapping(address => uint256) public reserveDepositorQueue;

reserveSpenders

address[] public reserveSpenders;

isReserveSpender

mapping(address => bool) public isReserveSpender;

reserveSpenderQueue

mapping(address => uint256) public reserveSpenderQueue;

liquidityTokens

address[] public liquidityTokens;

isLiquidityToken

mapping(address => bool) public isLiquidityToken;

LiquidityTokenQueue

mapping(address => uint256) public LiquidityTokenQueue;

liquidityDepositors

address[] public liquidityDepositors;

isLiquidityDepositor

mapping(address => bool) public isLiquidityDepositor;

LiquidityDepositorQueue

mapping(address => uint256) public LiquidityDepositorQueue;

bondCalculator

mapping(address => address) public bondCalculator;

reserveManagers

address[] public reserveManagers;

isReserveManager

mapping(address => bool) public isReserveManager;

ReserveManagerQueue

mapping(address => uint256) public ReserveManagerQueue;

liquidityManagers

address[] public liquidityManagers;

isLiquidityManager

mapping(address => bool) public isLiquidityManager;

LiquidityManagerQueue

mapping(address => uint256) public LiquidityManagerQueue;

debtors

address[] public debtors;

isDebtor

mapping(address => bool) public isDebtor;

debtorQueue

mapping(address => uint256) public debtorQueue;

debtorBalance

mapping(address => uint256) public debtorBalance;

rewardManagers

address[] public rewardManagers;

isRewardManager

mapping(address => bool) public isRewardManager;

rewardManagerQueue

mapping(address => uint256) public rewardManagerQueue;

sKLIMA

address public sKLIMA;

sKLIMAQueue

uint256 public sKLIMAQueue;

totalReserves

uint256 public totalReserves;

totalDebt

uint256 public totalDebt;

Functions

constructor

constructor(address _KLIMA, address _BCT, uint256 _blocksNeededForQueue);

deposit

allow approved address to deposit an asset for KLIMA

function deposit(uint256 _amount, address _token, uint256 _profit) external returns (uint256 send_);

Parameters

NameTypeDescription
_amountuint256uint
_tokenaddressaddress
_profituint256uint

Returns

NameTypeDescription
send_uint256uint

withdraw

allow approved address to burn KLIMA for reserves

function withdraw(uint256 _amount, address _token) external;

Parameters

NameTypeDescription
_amountuint256uint
_tokenaddressaddress

incurDebt

allow approved address to borrow reserves

function incurDebt(uint256 _amount, address _token) external;

Parameters

NameTypeDescription
_amountuint256uint
_tokenaddressaddress

repayDebtWithReserve

allow approved address to repay borrowed reserves with reserves

function repayDebtWithReserve(uint256 _amount, address _token) external;

Parameters

NameTypeDescription
_amountuint256uint
_tokenaddressaddress

repayDebtWithKLIMA

allow approved address to repay borrowed reserves with KLIMA

function repayDebtWithKLIMA(uint256 _amount) external;

Parameters

NameTypeDescription
_amountuint256uint

manage

allow approved address to withdraw assets

function manage(address _token, uint256 _amount) external;

Parameters

NameTypeDescription
_tokenaddressaddress
_amountuint256uint

mintRewards

send epoch reward to staking contract

function mintRewards(address _recipient, uint256 _amount) external;

excessReserves

returns excess reserves not backing tokens

function excessReserves() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint

auditReserves

takes inventory of all tracked assets

always consolidate to recognized reserves before audit

function auditReserves() external onlyManager;

valueOf

returns KLIMA valuation of asset

function valueOf(address _token, uint256 _amount) public view returns (uint256 value_);

Parameters

NameTypeDescription
_tokenaddressaddress
_amountuint256uint

Returns

NameTypeDescription
value_uint256uint

queue

queue address to change boolean in mapping

function queue(MANAGING _managing, address _address) external onlyManager returns (bool);

Parameters

NameTypeDescription
_managingMANAGINGMANAGING
_addressaddressaddress

Returns

NameTypeDescription
<none>boolbool

toggle

verify queue then set boolean in mapping

function toggle(MANAGING _managing, address _address, address _calculator) external onlyManager returns (bool);

Parameters

NameTypeDescription
_managingMANAGINGMANAGING
_addressaddressaddress
_calculatoraddressaddress

Returns

NameTypeDescription
<none>boolbool

requirements

checks requirements and returns altered structs

function requirements(
    mapping(address => uint256) storage queue_,
    mapping(address => bool) storage status_,
    address _address
) internal view returns (bool);

Parameters

NameTypeDescription
queue_mapping(address => uint256)mapping( address => uint )
status_mapping(address => bool)mapping( address => bool )
_addressaddressaddress

Returns

NameTypeDescription
<none>boolbool

listContains

checks array to ensure against duplicate

function listContains(address[] storage _list, address _token) internal view returns (bool);

Parameters

NameTypeDescription
_listaddress[]address[]
_tokenaddressaddress

Returns

NameTypeDescription
<none>boolbool

Events

Deposit

event Deposit(address indexed token, uint256 amount, uint256 value);

Withdrawal

event Withdrawal(address indexed token, uint256 amount, uint256 value);

CreateDebt

event CreateDebt(address indexed debtor, address indexed token, uint256 amount, uint256 value);

RepayDebt

event RepayDebt(address indexed debtor, address indexed token, uint256 amount, uint256 value);

ReservesManaged

event ReservesManaged(address indexed token, uint256 amount);

ReservesUpdated

event ReservesUpdated(uint256 indexed totalReserves);

ReservesAudited

event ReservesAudited(uint256 indexed totalReserves);

RewardsMinted

event RewardsMinted(address indexed caller, address indexed recipient, uint256 amount);

ChangeQueued

event ChangeQueued(MANAGING indexed managing, address queued);

ChangeActivated

event ChangeActivated(MANAGING indexed managing, address activated, bool result);

Enums

MANAGING

enum MANAGING {
    RESERVEDEPOSITOR,
    RESERVESPENDER,
    RESERVETOKEN,
    RESERVEMANAGER,
    LIQUIDITYDEPOSITOR,
    LIQUIDITYTOKEN,
    LIQUIDITYMANAGER,
    DEBTOR,
    REWARDMANAGER,
    SKLIMA
}

Contents

Contents

ITWAPOracle

Git Source

Intended to update the TWAP for a token based on accepting an update call from that token. expectation is to have this happen in the _beforeTokenTransfer function of ERC20. Provides a method for a token to register its price sourve adaptor. Provides a function for a token to register its TWAP updater. Defaults to token itself. Provides a function a tokent to set its TWAP epoch. Implements automatic closeing and opening up a TWAP epoch when epoch ends. Provides a function to report the TWAP from the last epoch when passed a token address.

Functions

uniV2CompPairAddressForLastEpochUpdateBlockTimstamp

function uniV2CompPairAddressForLastEpochUpdateBlockTimstamp(address) external returns (uint32);

priceTokenAddressForPricingTokenAddressForLastEpochUpdateBlockTimstamp

function priceTokenAddressForPricingTokenAddressForLastEpochUpdateBlockTimstamp(
    address tokenToPrice_,
    address tokenForPriceComparison_,
    uint256 epochPeriod_
) external returns (uint32);

pricedTokenForPricingTokenForEpochPeriodForPrice

function pricedTokenForPricingTokenForEpochPeriodForPrice(address, address, uint256) external returns (uint256);

pricedTokenForPricingTokenForEpochPeriodForLastEpochPrice

function pricedTokenForPricingTokenForEpochPeriodForLastEpochPrice(address, address, uint256)
    external
    returns (uint256);

updateTWAP

function updateTWAP(address uniV2CompatPairAddressToUpdate_, uint256 eopchPeriodToUpdate_) external returns (bool);

EnumerableSet

Git Source

Functions

_add

Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.

function _add(Set storage set, bytes32 value) private returns (bool);

_remove

Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.

function _remove(Set storage set, bytes32 value) private returns (bool);

_contains

Returns true if the value is in the set. O(1).

function _contains(Set storage set, bytes32 value) private view returns (bool);

_length

Returns the number of values on the set. O(1).

function _length(Set storage set) private view returns (uint256);

_at

*Returns the value stored at position index in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements:

  • index must be strictly less than length.*
function _at(Set storage set, uint256 index) private view returns (bytes32);

_getValues

function _getValues(Set storage set_) private view returns (bytes32[] storage);

_insert

Inserts new value by moving existing value at provided index to end of array and setting provided value at provided index

function _insert(Set storage set_, uint256 index_, bytes32 valueToInsert_) private returns (bool);

add

Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.

function add(Bytes4Set storage set, bytes4 value) internal returns (bool);

remove

Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.

function remove(Bytes4Set storage set, bytes4 value) internal returns (bool);

contains

Returns true if the value is in the set. O(1).

function contains(Bytes4Set storage set, bytes4 value) internal view returns (bool);

length

Returns the number of values on the set. O(1).

function length(Bytes4Set storage set) internal view returns (uint256);

at

*Returns the value stored at position index in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements:

  • index must be strictly less than length.*
function at(Bytes4Set storage set, uint256 index) internal view returns (bytes4);

getValues

function getValues(Bytes4Set storage set_) internal view returns (bytes4[] memory);

insert

function insert(Bytes4Set storage set_, uint256 index_, bytes4 valueToInsert_) internal returns (bool);

add

Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.

function add(Bytes32Set storage set, bytes32 value) internal returns (bool);

remove

Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.

function remove(Bytes32Set storage set, bytes32 value) internal returns (bool);

contains

Returns true if the value is in the set. O(1).

function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool);

length

Returns the number of values on the set. O(1).

function length(Bytes32Set storage set) internal view returns (uint256);

at

*Returns the value stored at position index in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements:

  • index must be strictly less than length.*
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32);

getValues

function getValues(Bytes32Set storage set_) internal view returns (bytes4[] memory);

insert

function insert(Bytes32Set storage set_, uint256 index_, bytes32 valueToInsert_) internal returns (bool);

add

Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.

function add(AddressSet storage set, address value) internal returns (bool);

remove

Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.

function remove(AddressSet storage set, address value) internal returns (bool);

contains

Returns true if the value is in the set. O(1).

function contains(AddressSet storage set, address value) internal view returns (bool);

length

Returns the number of values in the set. O(1).

function length(AddressSet storage set) internal view returns (uint256);

at

*Returns the value stored at position index in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements:

  • index must be strictly less than length.*
function at(AddressSet storage set, uint256 index) internal view returns (address);

getValues

TODO Might require explicit conversion of bytes32[] to address[]. Might require iteration.

function getValues(AddressSet storage set_) internal view returns (address[] memory);

insert

function insert(AddressSet storage set_, uint256 index_, address valueToInsert_) internal returns (bool);

add

Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.

function add(UintSet storage set, uint256 value) internal returns (bool);

remove

Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.

function remove(UintSet storage set, uint256 value) internal returns (bool);

contains

Returns true if the value is in the set. O(1).

function contains(UintSet storage set, uint256 value) internal view returns (bool);

length

Returns the number of values on the set. O(1).

function length(UintSet storage set) internal view returns (uint256);

at

*Returns the value stored at position index in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements:

  • index must be strictly less than length.*
function at(UintSet storage set, uint256 index) internal view returns (uint256);

add

Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.

function add(UInt256Set storage set, uint256 value) internal returns (bool);

remove

Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.

function remove(UInt256Set storage set, uint256 value) internal returns (bool);

contains

Returns true if the value is in the set. O(1).

function contains(UInt256Set storage set, uint256 value) internal view returns (bool);

length

Returns the number of values on the set. O(1).

function length(UInt256Set storage set) internal view returns (uint256);

at

*Returns the value stored at position index in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements:

  • index must be strictly less than length.*
function at(UInt256Set storage set, uint256 index) internal view returns (uint256);

Structs

Set

struct Set {
    bytes32[] _values;
    mapping(bytes32 => uint256) _indexes;
}

Bytes4Set

struct Bytes4Set {
    Set _inner;
}

Bytes32Set

struct Bytes32Set {
    Set _inner;
}

AddressSet

struct AddressSet {
    Set _inner;
}

UintSet

struct UintSet {
    Set _inner;
}

UInt256Set

struct UInt256Set {
    Set _inner;
}

IERC20

Git Source

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

SafeMath

Git Source

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

percentageAmount

function percentageAmount(uint256 total_, uint8 percentage_) internal pure returns (uint256 percentAmount_);

substractPercentage

function substractPercentage(uint256 total_, uint8 percentageToSub_) internal pure returns (uint256 result_);

percentageOfTotal

function percentageOfTotal(uint256 part_, uint256 total_) internal pure returns (uint256 percent_);

average

Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol

Returns the average of two numbers. The result is rounded towards zero.

function average(uint256 a, uint256 b) internal pure returns (uint256);

quadraticPricing

function quadraticPricing(uint256 payment_, uint256 multiplier_) internal pure returns (uint256);

bondingCurve

function bondingCurve(uint256 supply_, uint256 multiplier_) internal pure returns (uint256);

ERC20

Git Source

Inherits: IERC20

State Variables

ERC20TOKEN_ERC1820_INTERFACE_ID

bytes32 private constant ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256("ERC20Token");

_balances

mapping(address => uint256) internal _balances;

_allowances

mapping(address => mapping(address => uint256)) internal _allowances;

_totalSupply

uint256 internal _totalSupply;

_name

string internal _name;

_symbol

string internal _symbol;

_decimals

uint8 internal _decimals;

Functions

constructor

Sets the values for name and {symbol}, initializes {decimals} with a default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once during construction.

constructor(string memory name_, string memory symbol_, uint8 decimals_);

name

Returns the name of the token.

function name() public view returns (string memory);

symbol

Returns the symbol of the token, usually a shorter version of the name.

function symbol() public view returns (string memory);

decimals

Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value ERC20 uses, unless {_setupDecimals} is called. NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.

function decimals() public view returns (uint8);

totalSupply

See IERC20-totalSupply.

function totalSupply() public view override returns (uint256);

balanceOf

See IERC20-balanceOf.

function balanceOf(address account) public view virtual override returns (uint256);

transfer

*See IERC20-transfer. Requirements:

  • recipient cannot be the zero address.
  • the caller must have a balance of at least amount.*
function transfer(address recipient, uint256 amount) public virtual override returns (bool);

allowance

See IERC20-allowance.

function allowance(address owner, address spender) public view virtual override returns (uint256);

approve

*See IERC20-approve. Requirements:

  • spender cannot be the zero address.*
function approve(address spender, uint256 amount) public virtual override returns (bool);

transferFrom

*See IERC20-transferFrom. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements:

  • sender and recipient cannot be the zero address.
  • sender must have a balance of at least amount.
  • the caller must have allowance for sender's tokens of at least amount.*
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool);

increaseAllowance

*Atomically increases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.*
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool);

decreaseAllowance

*Atomically decreases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.
  • spender must have allowance for the caller of at least subtractedValue.*
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool);

_transfer

*Moves tokens amount from sender to recipient. This is internal function is equivalent to transfer, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements:

  • sender cannot be the zero address.
  • recipient cannot be the zero address.
  • sender must have a balance of at least amount.*
function _transfer(address sender, address recipient, uint256 amount) internal virtual;

_mint

*Creates amount tokens and assigns them to account, increasing the total supply. Emits a {Transfer} event with from set to the zero address. Requirements:

  • to cannot be the zero address.*
function _mint(address account_, uint256 amount_) internal virtual;

_burn

*Destroys amount tokens from account, reducing the total supply. Emits a {Transfer} event with to set to the zero address. Requirements:

  • account cannot be the zero address.
  • account must have at least amount tokens.*
function _burn(address account, uint256 amount) internal virtual;

_approve

*Sets amount as the allowance of spender over the owner s tokens. This internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain subsystems, etc. Emits an {Approval} event. Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.*
function _approve(address owner, address spender, uint256 amount) internal virtual;

_beforeTokenTransfer

Sets decimals to a value other than the default one of 18. WARNING: This function should only be called from the constructor. Most applications that interact with token contracts will not expect {decimals} to ever change, and may work incorrectly if it does.

*Hook that is called before any transfer of tokens. This includes minting and burning. Calling conditions:

  • when from and to are both non-zero, amount of from's tokens will be to transferred to to.
  • when from is zero, amount tokens will be minted for to.
  • when to is zero, amount of from's tokens will be burned.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _beforeTokenTransfer(address from_, address to_, uint256 amount_) internal virtual;

Counters

Git Source

Functions

current

function current(Counter storage counter) internal view returns (uint256);

increment

function increment(Counter storage counter) internal;

decrement

function decrement(Counter storage counter) internal;

Structs

Counter

struct Counter {
    uint256 _value;
}

IERC2612Permit

Git Source

Functions

permit

*Sets amount as the allowance of spender over owner's tokens, given owner's signed approval. IMPORTANT: The same issues IERC20-approve has related to transaction ordering also apply here. Emits an {Approval} event. Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.
  • deadline must be a timestamp in the future.
  • v, r and s must be a valid secp256k1 signature from owner over the EIP712-formatted function arguments.
  • the signature must use owner's current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section].*
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external;

nonces

Returns the current ERC2612 nonce for owner. This value must be included whenever a signature is generated for permit. Every successful call to {permit} increases owner's nonce by one. This prevents a signature from being used multiple times.

function nonces(address owner) external view returns (uint256);

ERC20Permit

Git Source

Inherits: ERC20, IERC2612Permit

State Variables

_nonces

mapping(address => Counters.Counter) private _nonces;

PERMIT_TYPEHASH

bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

DOMAIN_SEPARATOR

bytes32 public DOMAIN_SEPARATOR;

Functions

constructor

constructor();

permit

See IERC2612Permit-permit.

function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    public
    virtual
    override;

nonces

See IERC2612Permit-nonces.

function nonces(address owner) public view override returns (uint256);

IOwnable

Git Source

Functions

owner

function owner() external view returns (address);

renounceOwnership

function renounceOwnership() external;

transferOwnership

function transferOwnership(address newOwner_) external;

Ownable

Git Source

Inherits: IOwnable

State Variables

_owner

address internal _owner;

Functions

constructor

Initializes the contract setting the deployer as the initial owner.

constructor();

owner

Returns the address of the current owner.

function owner() public view override returns (address);

onlyOwner

Throws if called by any account other than the owner.

modifier onlyOwner();

renounceOwnership

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

function renounceOwnership() public virtual override onlyOwner;

transferOwnership

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

function transferOwnership(address newOwner_) public virtual override onlyOwner;

Events

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

VaultOwned

Git Source

Inherits: Ownable

State Variables

_vault

address internal _vault;

Functions

setVault

function setVault(address vault_) external onlyOwner returns (bool);

vault

Returns the address of the current vault.

function vault() public view returns (address);

onlyVault

Throws if called by any account other than the vault.

modifier onlyVault();

TWAPOracleUpdater

Git Source

Inherits: ERC20Permit, VaultOwned

State Variables

_dexPoolsTWAPSources

EnumerableSet.AddressSet private _dexPoolsTWAPSources;

twapOracle

ITWAPOracle public twapOracle;

twapEpochPeriod

uint256 public twapEpochPeriod;

Functions

constructor

constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_, decimals_);

changeTWAPOracle

function changeTWAPOracle(address newTWAPOracle_) external onlyOwner;

changeTWAPEpochPeriod

function changeTWAPEpochPeriod(uint256 newTWAPEpochPeriod_) external onlyOwner;

addTWAPSource

function addTWAPSource(address newTWAPSourceDexPool_) external onlyOwner;

removeTWAPSource

function removeTWAPSource(address twapSourceToRemove_) external onlyOwner;

_uodateTWAPOracle

function _uodateTWAPOracle(address dexPoolToUpdateFrom_, uint256 twapEpochPeriodToUpdate_) internal;

_beforeTokenTransfer

function _beforeTokenTransfer(address from_, address to_, uint256 amount_) internal virtual override;

Events

TWAPOracleChanged

event TWAPOracleChanged(address indexed previousTWAPOracle, address indexed newTWAPOracle);

TWAPEpochChanged

event TWAPEpochChanged(uint256 previousTWAPEpochPeriod, uint256 newTWAPEpochPeriod);

TWAPSourceAdded

event TWAPSourceAdded(address indexed newTWAPSource);

TWAPSourceRemoved

event TWAPSourceRemoved(address indexed removedTWAPSource);

Divine

Git Source

Inherits: TWAPOracleUpdater

Functions

constructor

constructor(string memory name_, string memory symbol_, uint8 decimals_) TWAPOracleUpdater(name_, symbol_, decimals_);

KlimaToken

Git Source

Inherits: Divine

Functions

constructor

constructor() Divine("Klima DAO", "KLIMA", 9);

mint

function mint(address account_, uint256 amount_) external onlyVault;

burn

Destroys amount tokens from the caller. See ERC20-_burn.

function burn(uint256 amount) public virtual;

burnFrom

function burnFrom(address account_, uint256 amount_) public virtual;

_burnFrom

function _burnFrom(address account_, uint256 amount_) public virtual;

SafeMath

Git Source

Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. SafeMath restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

percentageAmount

function percentageAmount(uint256 total_, uint8 percentage_) internal pure returns (uint256 percentAmount_);

substractPercentage

function substractPercentage(uint256 total_, uint8 percentageToSub_) internal pure returns (uint256 result_);

percentageOfTotal

function percentageOfTotal(uint256 part_, uint256 total_) internal pure returns (uint256 percent_);

average

Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol

Returns the average of two numbers. The result is rounded towards zero.

function average(uint256 a, uint256 b) internal pure returns (uint256);

quadraticPricing

function quadraticPricing(uint256 payment_, uint256 multiplier_) internal pure returns (uint256);

bondingCurve

function bondingCurve(uint256 supply_, uint256 multiplier_) internal pure returns (uint256);

Address

Git Source

Functions

isContract

*Returns true if account is a contract. [IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract. Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====*
function isContract(address account) internal view returns (bool);

sendValue

Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors. https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. sendValue removes this limitation. https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

*Performs a Solidity function call using a low level call. A plaincall is an unsafe replacement for a function call: use this function instead. If target reverts with a revert reason, it is bubbled up by this function (like regular_old Solidity function calls). Returns the raw returned data. To convert to the expected return value, use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[abi.decode]. Requirements:

  • target must be a contract.
  • calling target with data must not revert. Available since v3.1.*
function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

Same as functionCall, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

*Same as functionCall, but also transferring value wei to target. Requirements:

  • the calling contract must have an ETH balance of at least value.
  • the called Solidity function must be payable. Available since v3.1.*
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

Same as functionCallWithValue, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data, string memory errorMessage)
    internal
    view
    returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data, string memory errorMessage)
    internal
    returns (bytes memory);

_verifyCallResult

function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage)
    private
    pure
    returns (bytes memory);

addressToString

function addressToString(address _address) internal pure returns (string memory);

IOwnable

Git Source

Functions

owner

function owner() external view returns (address);

renounceOwnership

function renounceOwnership() external;

transferOwnership

function transferOwnership(address newOwner_) external;

Ownable

Git Source

Inherits: IOwnable

State Variables

_owner

address internal _owner;

Functions

constructor

Initializes the contract setting the deployer as the initial owner.

constructor();

owner

Returns the address of the current owner.

function owner() public view override returns (address);

onlyOwner

Throws if called by any account other than the owner.

modifier onlyOwner();

renounceOwnership

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

function renounceOwnership() public virtual override onlyOwner;

transferOwnership

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

function transferOwnership(address newOwner_) public virtual override onlyOwner;

Events

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

IERC20

Git Source

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

ERC20

Git Source

Inherits: IERC20

State Variables

ERC20TOKEN_ERC1820_INTERFACE_ID

bytes32 private constant ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256("ERC20Token");

_balances

mapping(address => uint256) internal _balances;

_allowances

mapping(address => mapping(address => uint256)) internal _allowances;

_totalSupply

uint256 internal _totalSupply;

_name

string internal _name;

_symbol

string internal _symbol;

_decimals

uint8 internal _decimals;

Functions

constructor

Sets the values for name and {symbol}, initializes {decimals} with a default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once during construction.

constructor(string memory name_, string memory symbol_, uint8 decimals_);

name

Returns the name of the token.

function name() public view returns (string memory);

symbol

Returns the symbol of the token, usually a shorter version of the name.

function symbol() public view returns (string memory);

decimals

Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value ERC20 uses, unless {_setupDecimals} is called. NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.

function decimals() public view returns (uint8);

totalSupply

See IERC20-totalSupply.

function totalSupply() public view override returns (uint256);

balanceOf

See IERC20-balanceOf.

function balanceOf(address account) public view virtual override returns (uint256);

transfer

*See IERC20-transfer. Requirements:

  • recipient cannot be the zero address.
  • the caller must have a balance of at least amount.*
function transfer(address recipient, uint256 amount) public virtual override returns (bool);

allowance

See IERC20-allowance.

function allowance(address owner, address spender) public view virtual override returns (uint256);

approve

*See IERC20-approve. Requirements:

  • spender cannot be the zero address.*
function approve(address spender, uint256 amount) public virtual override returns (bool);

transferFrom

*See IERC20-transferFrom. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements:

  • sender and recipient cannot be the zero address.
  • sender must have a balance of at least amount.
  • the caller must have allowance for sender's tokens of at least amount.*
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool);

increaseAllowance

*Atomically increases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.*
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool);

decreaseAllowance

*Atomically decreases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.
  • spender must have allowance for the caller of at least subtractedValue.*
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool);

_transfer

*Moves tokens amount from sender to recipient. This is internal function is equivalent to transfer, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements:

  • sender cannot be the zero address.
  • recipient cannot be the zero address.
  • sender must have a balance of at least amount.*
function _transfer(address sender, address recipient, uint256 amount) internal virtual;

_mint

*Creates amount tokens and assigns them to account, increasing the total supply. Emits a {Transfer} event with from set to the zero address. Requirements:

  • to cannot be the zero address.*
function _mint(address account_, uint256 ammount_) internal virtual;

_burn

*Destroys amount tokens from account, reducing the total supply. Emits a {Transfer} event with to set to the zero address. Requirements:

  • account cannot be the zero address.
  • account must have at least amount tokens.*
function _burn(address account, uint256 amount) internal virtual;

_approve

*Sets amount as the allowance of spender over the owner s tokens. This internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain subsystems, etc. Emits an {Approval} event. Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.*
function _approve(address owner, address spender, uint256 amount) internal virtual;

_beforeTokenTransfer

Sets decimals to a value other than the default one of 18. WARNING: This function should only be called from the constructor. Most applications that interact with token contracts will not expect {decimals} to ever change, and may work incorrectly if it does.

*Hook that is called before any transfer of tokens. This includes minting and burning. Calling conditions:

  • when from and to are both non-zero, amount of from's tokens will be to transferred to to.
  • when from is zero, amount tokens will be minted for to.
  • when to is zero, amount of from's tokens will be burned.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _beforeTokenTransfer(address from_, address to_, uint256 amount_) internal virtual;

Counters

Git Source

Functions

current

function current(Counter storage counter) internal view returns (uint256);

increment

function increment(Counter storage counter) internal;

decrement

function decrement(Counter storage counter) internal;

Structs

Counter

struct Counter {
    uint256 _value;
}

IERC2612Permit

Git Source

Functions

permit

*Sets amount as the allowance of spender over owner's tokens, given owner's signed approval. IMPORTANT: The same issues IERC20-approve has related to transaction ordering also apply here. Emits an {Approval} event. Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.
  • deadline must be a timestamp in the future.
  • v, r and s must be a valid secp256k1 signature from owner over the EIP712-formatted function arguments.
  • the signature must use owner's current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section].*
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external;

nonces

Returns the current ERC2612 nonce for owner. This value must be included whenever a signature is generated for permit. Every successful call to {permit} increases owner's nonce by one. This prevents a signature from being used multiple times.

function nonces(address owner) external view returns (uint256);

ERC20Permit

Git Source

Inherits: ERC20, IERC2612Permit

State Variables

_nonces

mapping(address => Counters.Counter) private _nonces;

PERMIT_TYPEHASH

bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

DOMAIN_SEPARATOR

bytes32 public DOMAIN_SEPARATOR;

Functions

constructor

constructor();

permit

See IERC2612Permit-permit.

function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    public
    virtual
    override;

nonces

See IERC2612Permit-nonces.

function nonces(address owner) public view override returns (uint256);

sKlima

Git Source

Inherits: ERC20Permit, Ownable

State Variables

monetaryPolicy

address public monetaryPolicy;

stakingContract

address public stakingContract;

MAX_UINT256

uint256 private constant MAX_UINT256 = ~uint256(0);

INITIAL_FRAGMENTS_SUPPLY

uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 500_000 * 10 ** 9;

TOTAL_GONS

uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);

MAX_SUPPLY

uint256 private constant MAX_SUPPLY = ~uint128(0);

_gonsPerFragment

uint256 private _gonsPerFragment;

_gonBalances

mapping(address => uint256) private _gonBalances;

_allowedFragments

mapping(address => mapping(address => uint256)) private _allowedFragments;

Functions

onlyMonetaryPolicy

modifier onlyMonetaryPolicy();

validRecipient

modifier validRecipient(address to);

constructor

constructor() ERC20("Staked Klima", "sKLIMA", 9);

setStakingContract

function setStakingContract(address newStakingContract_) external onlyOwner;

setMonetaryPolicy

function setMonetaryPolicy(address monetaryPolicy_) external onlyOwner;

rebase

function rebase(uint256 olyProfit) public onlyMonetaryPolicy returns (uint256);

balanceOf

function balanceOf(address who) public view override returns (uint256);

circulatingSupply

function circulatingSupply() public view returns (uint256);

transfer

function transfer(address to, uint256 value) public override validRecipient(to) returns (bool);

allowance

function allowance(address owner_, address spender) public view override returns (uint256);

transferFrom

function transferFrom(address from, address to, uint256 value) public override validRecipient(to) returns (bool);

approve

function approve(address spender, uint256 value) public override returns (bool);

_approve

function _approve(address owner, address spender, uint256 value) internal virtual override;

increaseAllowance

function increaseAllowance(address spender, uint256 addedValue) public override returns (bool);

decreaseAllowance

function decreaseAllowance(address spender, uint256 subtractedValue) public override returns (bool);

Events

LogRebase

event LogRebase(uint256 indexed epoch, uint256 totalSupply);

LogMonetaryPolicyUpdated

event LogMonetaryPolicyUpdated(address monetaryPolicy);

SafeMath

Git Source

Submitted for verification at Etherscan.io on 2021-06-12

Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. SafeMath restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

sqrrt

function sqrrt(uint256 a) internal pure returns (uint256 c);

percentageAmount

function percentageAmount(uint256 total_, uint8 percentage_) internal pure returns (uint256 percentAmount_);

substractPercentage

function substractPercentage(uint256 total_, uint8 percentageToSub_) internal pure returns (uint256 result_);

percentageOfTotal

function percentageOfTotal(uint256 part_, uint256 total_) internal pure returns (uint256 percent_);

average

Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol

Returns the average of two numbers. The result is rounded towards zero.

function average(uint256 a, uint256 b) internal pure returns (uint256);

quadraticPricing

function quadraticPricing(uint256 payment_, uint256 multiplier_) internal pure returns (uint256);

bondingCurve

function bondingCurve(uint256 supply_, uint256 multiplier_) internal pure returns (uint256);

Address

Git Source

Functions

isContract

*Returns true if account is a contract. [IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract. Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====*
function isContract(address account) internal view returns (bool);

sendValue

Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors. https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. sendValue removes this limitation. https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

*Performs a Solidity function call using a low level call. A plaincall is an unsafe replacement for a function call: use this function instead. If target reverts with a revert reason, it is bubbled up by this function (like regular Solidity function calls). Returns the raw returned data. To convert to the expected return value, use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[abi.decode]. Requirements:

  • target must be a contract.
  • calling target with data must not revert. Available since v3.1.*
function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

Same as functionCall, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

*Same as functionCall, but also transferring value wei to target. Requirements:

  • the calling contract must have an ETH balance of at least value.
  • the called Solidity function must be payable. Available since v3.1.*
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

Same as functionCallWithValue, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);

functionStaticCall

Same as functionCall, but performing a static call. Available since v3.3.

function functionStaticCall(address target, bytes memory data, string memory errorMessage)
    internal
    view
    returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);

functionDelegateCall

Same as functionCall, but performing a delegate call. Available since v3.3.

function functionDelegateCall(address target, bytes memory data, string memory errorMessage)
    internal
    returns (bytes memory);

_verifyCallResult

function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage)
    private
    pure
    returns (bytes memory);

addressToString

function addressToString(address _address) internal pure returns (string memory);

IERC20

Git Source

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

ERC20

Git Source

Inherits: IERC20

State Variables

ERC20TOKEN_ERC1820_INTERFACE_ID

bytes32 private constant ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256("ERC20Token");

_balances

mapping(address => uint256) internal _balances;

_allowances

mapping(address => mapping(address => uint256)) internal _allowances;

_totalSupply

uint256 internal _totalSupply;

_name

string internal _name;

_symbol

string internal _symbol;

_decimals

uint8 internal _decimals;

Functions

constructor

Sets the values for name and {symbol}, initializes {decimals} with a default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once during construction.

constructor(string memory name_, string memory symbol_, uint8 decimals_);

name

Returns the name of the token.

function name() public view returns (string memory);

symbol

Returns the symbol of the token, usually a shorter version of the name.

function symbol() public view returns (string memory);

decimals

Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value ERC20 uses, unless {_setupDecimals} is called. NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.

function decimals() public view returns (uint8);

totalSupply

See IERC20-totalSupply.

function totalSupply() public view override returns (uint256);

balanceOf

See IERC20-balanceOf.

function balanceOf(address account) public view virtual override returns (uint256);

transfer

*See IERC20-transfer. Requirements:

  • recipient cannot be the zero address.
  • the caller must have a balance of at least amount.*
function transfer(address recipient, uint256 amount) public virtual override returns (bool);

allowance

See IERC20-allowance.

function allowance(address owner, address spender) public view virtual override returns (uint256);

approve

*See IERC20-approve. Requirements:

  • spender cannot be the zero address.*
function approve(address spender, uint256 amount) public virtual override returns (bool);

transferFrom

*See IERC20-transferFrom. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements:

  • sender and recipient cannot be the zero address.
  • sender must have a balance of at least amount.
  • the caller must have allowance for sender's tokens of at least amount.*
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool);

increaseAllowance

*Atomically increases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.*
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool);

decreaseAllowance

*Atomically decreases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.
  • spender must have allowance for the caller of at least subtractedValue.*
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool);

_transfer

*Moves tokens amount from sender to recipient. This is internal function is equivalent to transfer, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements:

  • sender cannot be the zero address.
  • recipient cannot be the zero address.
  • sender must have a balance of at least amount.*
function _transfer(address sender, address recipient, uint256 amount) internal virtual;

_mint

*Creates amount tokens and assigns them to account, increasing the total supply. Emits a {Transfer} event with from set to the zero address. Requirements:

  • to cannot be the zero address.*
function _mint(address account_, uint256 ammount_) internal virtual;

_burn

*Destroys amount tokens from account, reducing the total supply. Emits a {Transfer} event with to set to the zero address. Requirements:

  • account cannot be the zero address.
  • account must have at least amount tokens.*
function _burn(address account, uint256 amount) internal virtual;

_approve

*Sets amount as the allowance of spender over the owner s tokens. This internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain subsystems, etc. Emits an {Approval} event. Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.*
function _approve(address owner, address spender, uint256 amount) internal virtual;

_beforeTokenTransfer

Sets decimals to a value other than the default one of 18. WARNING: This function should only be called from the constructor. Most applications that interact with token contracts will not expect {decimals} to ever change, and may work incorrectly if it does.

*Hook that is called before any transfer of tokens. This includes minting and burning. Calling conditions:

  • when from and to are both non-zero, amount of from's tokens will be to transferred to to.
  • when from is zero, amount tokens will be minted for to.
  • when to is zero, amount of from's tokens will be burned.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _beforeTokenTransfer(address from_, address to_, uint256 amount_) internal virtual;

Counters

Git Source

Functions

current

function current(Counter storage counter) internal view returns (uint256);

increment

function increment(Counter storage counter) internal;

decrement

function decrement(Counter storage counter) internal;

Structs

Counter

struct Counter {
    uint256 _value;
}

IERC2612Permit

Git Source

Functions

permit

*Sets amount as the allowance of spender over owner's tokens, given owner's signed approval. IMPORTANT: The same issues IERC20-approve has related to transaction ordering also apply here. Emits an {Approval} event. Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.
  • deadline must be a timestamp in the future.
  • v, r and s must be a valid secp256k1 signature from owner over the EIP712-formatted function arguments.
  • the signature must use owner's current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section].*
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external;

nonces

Returns the current ERC2612 nonce for owner. This value must be included whenever a signature is generated for permit. Every successful call to {permit} increases owner's nonce by one. This prevents a signature from being used multiple times.

function nonces(address owner) external view returns (uint256);

ERC20Permit

Git Source

Inherits: ERC20, IERC2612Permit

State Variables

_nonces

mapping(address => Counters.Counter) private _nonces;

PERMIT_TYPEHASH

bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

DOMAIN_SEPARATOR

bytes32 public DOMAIN_SEPARATOR;

Functions

constructor

constructor();

permit

See IERC2612Permit-permit.

function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    public
    virtual
    override;

nonces

See IERC2612Permit-nonces.

function nonces(address owner) public view override returns (uint256);

IOwnable

Git Source

Functions

manager

function manager() external view returns (address);

renounceManagement

function renounceManagement() external;

pushManagement

function pushManagement(address newOwner_) external;

pullManagement

function pullManagement() external;

Ownable

Git Source

Inherits: IOwnable

State Variables

_owner

address internal _owner;

_newOwner

address internal _newOwner;

Functions

constructor

constructor();

manager

function manager() public view override returns (address);

onlyManager

modifier onlyManager();

renounceManagement

function renounceManagement() public virtual override onlyManager;

pushManagement

function pushManagement(address newOwner_) public virtual override onlyManager;

pullManagement

function pullManagement() public virtual override;

Events

OwnershipPushed

event OwnershipPushed(address indexed previousOwner, address indexed newOwner);

OwnershipPulled

event OwnershipPulled(address indexed previousOwner, address indexed newOwner);

sKLIMAv2

Git Source

Inherits: ERC20Permit, Ownable

State Variables

stakingContract

address public stakingContract;

initializer

address public initializer;

rebases

Rebase[] public rebases;

INDEX

uint256 public INDEX;

MAX_UINT256

uint256 private constant MAX_UINT256 = ~uint256(0);

INITIAL_FRAGMENTS_SUPPLY

uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 5_000_000 * 10 ** 9;

TOTAL_GONS

uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);

MAX_SUPPLY

uint256 private constant MAX_SUPPLY = ~uint128(0);

_gonsPerFragment

uint256 private _gonsPerFragment;

_gonBalances

mapping(address => uint256) private _gonBalances;

_allowedValue

mapping(address => mapping(address => uint256)) private _allowedValue;

Functions

onlyStakingContract

modifier onlyStakingContract();

constructor

constructor() ERC20("Staked Klima", "sKLIMA", 9) ERC20Permit();

initialize

function initialize(address stakingContract_) external returns (bool);

setIndex

function setIndex(uint256 _INDEX) external onlyManager returns (bool);

rebase

increases sKLIMA supply to increase staking balances relative to profit_

function rebase(uint256 profit_, uint256 epoch_) public onlyStakingContract returns (uint256);

Parameters

NameTypeDescription
profit_uint256uint256
epoch_uint256

Returns

NameTypeDescription
<none>uint256uint256

_storeRebase

emits event with data about rebase

function _storeRebase(uint256 previousCirculating_, uint256 profit_, uint256 epoch_) internal returns (bool);

Parameters

NameTypeDescription
previousCirculating_uint256uint
profit_uint256uint
epoch_uint256uint

Returns

NameTypeDescription
<none>boolbool

balanceOf

function balanceOf(address who) public view override returns (uint256);

gonsForBalance

function gonsForBalance(uint256 amount) public view returns (uint256);

balanceForGons

function balanceForGons(uint256 gons) public view returns (uint256);

circulatingSupply

function circulatingSupply() public view returns (uint256);

index

function index() public view returns (uint256);

transfer

function transfer(address to, uint256 value) public override returns (bool);

allowance

function allowance(address owner_, address spender) public view override returns (uint256);

transferFrom

function transferFrom(address from, address to, uint256 value) public override returns (bool);

approve

function approve(address spender, uint256 value) public override returns (bool);

_approve

function _approve(address owner, address spender, uint256 value) internal virtual override;

increaseAllowance

function increaseAllowance(address spender, uint256 addedValue) public override returns (bool);

decreaseAllowance

function decreaseAllowance(address spender, uint256 subtractedValue) public override returns (bool);

Events

LogSupply

event LogSupply(uint256 indexed epoch, uint256 timestamp, uint256 totalSupply);

LogRebase

event LogRebase(uint256 indexed epoch, uint256 rebase, uint256 index);

LogStakingContractUpdated

event LogStakingContractUpdated(address stakingContract);

Structs

Rebase

struct Rebase {
    uint256 epoch;
    uint256 rebase;
    uint256 totalStakedBefore;
    uint256 totalStakedAfter;
    uint256 amountRebased;
    uint256 index;
    uint256 blockNumberOccured;
}

IERC20

Git Source

Submitted for verification at Etherscan.io on 2021-06-12

Interface of the ERC20 standard as defined in the EIP.

Functions

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account) external view returns (uint256);

transfer

Moves amount tokens from the caller's account to recipient. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transfer(address recipient, uint256 amount) external returns (bool);

allowance

Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through transferFrom. This is zero by default. This value changes when {approve} or {transferFrom} are called.

function allowance(address owner, address spender) external view returns (uint256);

approve

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

function approve(address spender, uint256 amount) external returns (bool);

transferFrom

Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a Transfer event.

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

Events

Transfer

Emitted when value tokens are moved from one account (from) to another (to). Note that value may be zero.

event Transfer(address indexed from, address indexed to, uint256 value);

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

event Approval(address indexed owner, address indexed spender, uint256 value);

SafeMath

Git Source

Wrappers over Solidity's arithmetic operations with added overflow checks. Arithmetic operations in Solidity wrap on overflow. This can easily result in bugs, because programmers usually assume that an overflow raises an error, which is the standard behavior in high level programming languages. SafeMath restores this intuition by reverting the transaction when an operation overflows. Using this library instead of the unchecked operations eliminates an entire class of bugs, so it's recommended to use it always.

Functions

add

*Returns the addition of two unsigned integers, reverting on overflow. Counterpart to Solidity's + operator. Requirements:

  • Addition cannot overflow.*
function add(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b) internal pure returns (uint256);

sub

*Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). Counterpart to Solidity's - operator. Requirements:

  • Subtraction cannot overflow.*
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mul

*Returns the multiplication of two unsigned integers, reverting on overflow. Counterpart to Solidity's * operator. Requirements:

  • Multiplication cannot overflow.*
function mul(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b) internal pure returns (uint256);

div

*Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero. Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b) internal pure returns (uint256);

mod

*Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero. Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas). Requirements:

  • The divisor cannot be zero.*
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256);

Address

Git Source

Collection of functions related to the address type

Functions

isContract

*Returns true if account is a contract. [IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract. Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====*
function isContract(address account) internal view returns (bool);

sendValue

Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors. https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. sendValue removes this limitation. https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].

function sendValue(address payable recipient, uint256 amount) internal;

functionCall

*Performs a Solidity function call using a low level call. A plaincall is an unsafe replacement for a function call: use this function instead. If target reverts with a revert reason, it is bubbled up by this function (like regular Solidity function calls). Returns the raw returned data. To convert to the expected return value, use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[abi.decode]. Requirements:

  • target must be a contract.
  • calling target with data must not revert. Available since v3.1.*
function functionCall(address target, bytes memory data) internal returns (bytes memory);

functionCall

Same as functionCall, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory);

functionCallWithValue

*Same as functionCall, but also transferring value wei to target. Requirements:

  • the calling contract must have an ETH balance of at least value.
  • the called Solidity function must be payable. Available since v3.1.*
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);

functionCallWithValue

Same as functionCallWithValue, but with errorMessage as a fallback revert reason when target reverts. Available since v3.1.

function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage)
    internal
    returns (bytes memory);

_functionCallWithValue

function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage)
    private
    returns (bytes memory);

ERC20

Git Source

Inherits: IERC20

Implementation of the {IERC20} interface. This implementation is agnostic to the way tokens are created. This means that a supply mechanism has to be added in a derived contract using {_mint}. For a generic mechanism see {ERC20PresetMinterPauser}. TIP: For a detailed writeup see our guide https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How to implement supply mechanisms]. We have followed general OpenZeppelin guidelines: functions revert instead of returning false on failure. This behavior is nonetheless conventional and does not conflict with the expectations of ERC20 applications. Additionally, an {Approval} event is emitted on calls to {transferFrom}. This allows applications to reconstruct the allowance for all accounts just by listening to said events. Other implementations of the EIP may not emit these events, as it isn't required by the specification. Finally, the non-standard {decreaseAllowance} and {increaseAllowance} functions have been added to mitigate the well-known issues around setting allowances. See {IERC20-approve}.

State Variables

_balances

mapping(address => uint256) private _balances;

_allowances

mapping(address => mapping(address => uint256)) private _allowances;

_totalSupply

uint256 private _totalSupply;

_name

string private _name;

_symbol

string private _symbol;

_decimals

uint8 private _decimals;

Functions

constructor

Sets the values for name and {symbol}, initializes {decimals} with a default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once during construction.

constructor(string memory name, string memory symbol);

name

Returns the name of the token.

function name() public view returns (string memory);

symbol

Returns the symbol of the token, usually a shorter version of the name.

function symbol() public view returns (string memory);

decimals

Returns the number of decimals used to get its user representation. For example, if decimals equals 2, a balance of 505 tokens should be displayed to a user as 5,05 (505 / 10 ** 2). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value ERC20 uses, unless {_setupDecimals} is called. NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.

function decimals() public view returns (uint8);

totalSupply

See IERC20-totalSupply.

function totalSupply() public view override returns (uint256);

balanceOf

See IERC20-balanceOf.

function balanceOf(address account) public view override returns (uint256);

transfer

*See IERC20-transfer. Requirements:

  • recipient cannot be the zero address.
  • the caller must have a balance of at least amount.*
function transfer(address recipient, uint256 amount) public virtual override returns (bool);

allowance

See IERC20-allowance.

function allowance(address owner, address spender) public view virtual override returns (uint256);

approve

*See IERC20-approve. Requirements:

  • spender cannot be the zero address.*
function approve(address spender, uint256 amount) public virtual override returns (bool);

transferFrom

*See IERC20-transferFrom. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}; Requirements:

  • sender and recipient cannot be the zero address.
  • sender must have a balance of at least amount.
  • the caller must have allowance for sender's tokens of at least amount.*
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool);

increaseAllowance

*Atomically increases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.*
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool);

decreaseAllowance

*Atomically decreases the allowance granted to spender by the caller. This is an alternative to approve that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements:

  • spender cannot be the zero address.
  • spender must have allowance for the caller of at least subtractedValue.*
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool);

_transfer

*Moves tokens amount from sender to recipient. This is internal function is equivalent to transfer, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements:

  • sender cannot be the zero address.
  • recipient cannot be the zero address.
  • sender must have a balance of at least amount.*
function _transfer(address sender, address recipient, uint256 amount) internal virtual;

_mint

*Creates amount tokens and assigns them to account, increasing the total supply. Emits a {Transfer} event with from set to the zero address. Requirements

  • to cannot be the zero address.*
function _mint(address account, uint256 amount) internal virtual;

_burn

*Destroys amount tokens from account, reducing the total supply. Emits a {Transfer} event with to set to the zero address. Requirements

  • account cannot be the zero address.
  • account must have at least amount tokens.*
function _burn(address account, uint256 amount) internal virtual;

_approve

*Sets amount as the allowance of spender over the owner s tokens. This internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain subsystems, etc. Emits an {Approval} event. Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.*
function _approve(address owner, address spender, uint256 amount) internal virtual;

_setupDecimals

Sets decimals to a value other than the default one of 18. WARNING: This function should only be called from the constructor. Most applications that interact with token contracts will not expect {decimals} to ever change, and may work incorrectly if it does.

function _setupDecimals(uint8 decimals_) internal;

_beforeTokenTransfer

*Hook that is called before any transfer of tokens. This includes minting and burning. Calling conditions:

  • when from and to are both non-zero, amount of from's tokens will be to transferred to to.
  • when from is zero, amount tokens will be minted for to.
  • when to is zero, amount of from's tokens will be burned.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual;

SafeERC20

Git Source

Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a using SafeERC20 for IERC20; statement to your contract, which allows you to call the safe operations as token.safeTransfer(...), etc.

Functions

safeTransfer

function safeTransfer(IERC20 token, address to, uint256 value) internal;

safeTransferFrom

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal;

safeApprove

Deprecated. This function has issues similar to the ones found in IERC20-approve, and its usage is discouraged. Whenever possible, use {safeIncreaseAllowance} and {safeDecreaseAllowance} instead.

function safeApprove(IERC20 token, address spender, uint256 value) internal;

safeIncreaseAllowance

function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal;

safeDecreaseAllowance

function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal;

_callOptionalReturn

Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement on the return value: the return value is optional (but if data is returned, it must not be false).

function _callOptionalReturn(IERC20 token, bytes memory data) private;

Parameters

NameTypeDescription
tokenIERC20The token targeted by the call.
databytesThe call data (encoded using abi.encode or one of its variants).

IsKLIMA

Git Source

Functions

index

function index() external view returns (uint256);

wsKLIMA

Git Source

Inherits: ERC20

State Variables

sKLIMA

address public immutable sKLIMA;

Functions

constructor

constructor(address _sKLIMA) ERC20("Wrapped sKLIMA", "wsKLIMA");

wrap

wrap sKLIMA

function wrap(uint256 _amount) external returns (uint256);

Parameters

NameTypeDescription
_amountuint256uint

Returns

NameTypeDescription
<none>uint256uint

unwrap

unwrap sKLIMA

function unwrap(uint256 _amount) external returns (uint256);

Parameters

NameTypeDescription
_amountuint256uint

Returns

NameTypeDescription
<none>uint256uint

wKLIMATosKLIMA

converts wKLIMA amount to sKLIMA

function wKLIMATosKLIMA(uint256 _amount) public view returns (uint256);

Parameters

NameTypeDescription
_amountuint256uint

Returns

NameTypeDescription
<none>uint256uint

sKLIMATowKLIMA

converts sKLIMA amount to wKLIMA

function sKLIMATowKLIMA(uint256 _amount) public view returns (uint256);

Parameters

NameTypeDescription
_amountuint256uint

Returns

NameTypeDescription
<none>uint256uint

Contents

AlchemistKlimaUpgradeable

Git Source

Inherits: ERC20PresetMinterPauserUpgradeable

State Variables

allowMinting

bool public allowMinting;

Functions

constructor

constructor();

initialize

function initialize() public initializer;

__AlchemistKlimaUpgradeable_init

function __AlchemistKlimaUpgradeable_init() internal;

mint

function mint(address recipient_, uint256 amount_) public virtual override;

disableMinting

function disableMinting() external returns (bool);

AlphaKlimaUpgradeable

Git Source

Inherits: ERC20PresetFixedSupplyUpgradeable, OwnableUpgradeable

Functions

constructor

constructor();

initialize

function initialize() public initializer;

__AlphaKlimaUpgradeable_init

function __AlphaKlimaUpgradeable_init(address _Klimadmin) internal;

KlimaIDONFT

Git Source

Inherits: Initializable, ContextUpgradeable, AccessControlEnumerableUpgradeable, ERC721EnumerableUpgradeable, ERC721BurnableUpgradeable, ERC721PausableUpgradeable

State Variables

MINTER_ROLE

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

PAUSER_ROLE

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

_tokenIdTracker

CountersUpgradeable.Counter private _tokenIdTracker;

_baseTokenURI

string private _baseTokenURI;

__gap

uint256[48] private __gap;

Functions

onlyMinter

modifier onlyMinter();

onlyPauser

modifier onlyPauser();

constructor

constructor();

__KlimaIDONFT_init

function __KlimaIDONFT_init(string memory name, string memory symbol, string memory _TokenURI) public initializer;

setTokenURI

function setTokenURI(string memory _TokenURI) public onlyMinter;

_setTokenURI

function _setTokenURI(string memory _TokenURI) internal;

tokenURI

function tokenURI() public view returns (string memory);

totalSupply

function totalSupply() public view override returns (uint256);

burn

function burn(uint256 tokenId) public override;

_burn

function _burn(uint256 tokenId) internal virtual override(ERC721Upgradeable);

mint

function mint(address to) public onlyMinter whenPaused;

batchMint

function batchMint(address[] memory _list) public onlyMinter whenPaused;

pause

function pause() public virtual onlyPauser;

unpause

function unpause() public virtual onlyPauser;

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 tokenId)
    internal
    virtual
    override(ERC721Upgradeable, ERC721EnumerableUpgradeable, ERC721PausableUpgradeable);

supportsInterface

See IERC165-supportsInterface.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(AccessControlEnumerableUpgradeable, ERC721Upgradeable, ERC721EnumerableUpgradeable)
    returns (bool);

PreKlimaTokenUpgradeable

Git Source

Inherits: ERC20PresetFixedSupplyUpgradeable, OwnableUpgradeable

State Variables

requireSellerApproval

bool public requireSellerApproval;

allowMinting

bool public allowMinting;

isApprovedSeller

mapping(address => bool) public isApprovedSeller;

Functions

constructor

constructor();

initialize

function initialize(address _Klimadmin) public initializer;

__PreKlimaTokenUpgradeable_init

function __PreKlimaTokenUpgradeable_init(address _Klimadmin) internal;

allowOpenTrading

function allowOpenTrading() external onlyOwner returns (bool);

disableMinting

function disableMinting() external onlyOwner returns (bool);

_addApprovedSeller

function _addApprovedSeller(address approvedSeller_) internal;

addApprovedSeller

function addApprovedSeller(address approvedSeller_) external onlyOwner returns (bool);

addApprovedSellers

function addApprovedSellers(address[] calldata approvedSellers_) external onlyOwner returns (bool);

_removeApprovedSeller

function _removeApprovedSeller(address disapprovedSeller_) internal;

removeApprovedSeller

function removeApprovedSeller(address disapprovedSeller_) external onlyOwner returns (bool);

removeApprovedSellers

function removeApprovedSellers(address[] calldata disapprovedSellers_) external onlyOwner returns (bool);

_beforeTokenTransfer

function _beforeTokenTransfer(address from_, address to_, uint256 amount_) internal override;

mint

function mint(address recipient_, uint256 amount_) public virtual onlyOwner;

PreKlimaTokenUpgradeableChild

Git Source

Inherits: ERC20PresetFixedSupplyUpgradeable, OwnableUpgradeable

State Variables

requireSellerApproval

bool public requireSellerApproval;

allowMinting

bool public allowMinting;

childChainManagerProxy

address public childChainManagerProxy;

isApprovedSeller

mapping(address => bool) public isApprovedSeller;

Functions

constructor

constructor();

initializeChild

function initializeChild(address _Klimadmin, address _childChainManagerProxy) public initializer;

__PreKlimaTokenUpgradeableChild_init

function __PreKlimaTokenUpgradeableChild_init(address _Klimadmin, address _childChainManagerProxy)
    internal
    initializer;

allowOpenTrading

function allowOpenTrading() external onlyOwner returns (bool);

disableMinting

function disableMinting() external onlyOwner returns (bool);

_addApprovedSeller

function _addApprovedSeller(address approvedSeller_) internal;

addApprovedSeller

function addApprovedSeller(address approvedSeller_) external onlyOwner returns (bool);

addApprovedSellers

function addApprovedSellers(address[] calldata approvedSellers_) external onlyOwner returns (bool);

_removeApprovedSeller

function _removeApprovedSeller(address disapprovedSeller_) internal;

removeApprovedSeller

function removeApprovedSeller(address disapprovedSeller_) external onlyOwner returns (bool);

removeApprovedSellers

function removeApprovedSellers(address[] calldata disapprovedSellers_) external onlyOwner returns (bool);

_beforeTokenTransfer

function _beforeTokenTransfer(address from_, address to_, uint256 amount_) internal override;

mint

function mint(address recipient_, uint256 amount_) public virtual onlyOwner;

deposit

called when token is deposited on root chain

Should be callable only by ChildChainManager Should handle deposit by minting the required amount for user Make sure minting is done only by this function

function deposit(address user, bytes calldata depositData) external;

Parameters

NameTypeDescription
useraddressuser address for whom deposit is being done
depositDatabytesabi encoded amount

withdraw

called when user wants to withdraw tokens back to root chain

Should burn user's tokens. This transaction will be verified when exiting on root chain

function withdraw(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256amount of tokens to withdraw

Contents

Contents

IBentoBoxMinimal

Git Source

Functions

setMasterContractApproval

Approves users' BentoBox assets to a "master" contract.

function setMasterContractApproval(address user, address masterContract, bool approved, uint8 v, bytes32 r, bytes32 s)
    external;

IC3Pool

Git Source

Functions

freeRedeem

function freeRedeem(uint256 amount) external;

taxedRedeem

function taxedRedeem(address[] memory erc20Addresses, uint256[] memory amount) external;

getFreeRedeemAddresses

function getFreeRedeemAddresses() external view returns (address[] memory);

feeRedeem

function feeRedeem() external view returns (uint256);

IC3ProjectToken

Git Source

Functions

offsetFor

function offsetFor(uint256 amount, address beneficiary, string memory transferee, string memory reason) external;

ICarbonChain

Git Source

Functions

offsetCarbon

function offsetCarbon(uint256 _carbonTon, string calldata _transactionInfo, string calldata _onBehalfOf) external;

IKlimaCarbonRetirements

Git Source

Functions

carbonRetired

function carbonRetired(
    address _retiree,
    address _pool,
    uint256 _amount,
    string calldata _beneficiaryString,
    string calldata _retirementMessage
) external;

getUnclaimedTotal

function getUnclaimedTotal(address _minter) external view returns (uint256);

offsetClaimed

function offsetClaimed(address _minter, uint256 _amount) external returns (bool);

getRetirementIndexInfo

function getRetirementIndexInfo(address _retiree, uint256 _index)
    external
    view
    returns (address, uint256, string memory, string memory);

getRetirementPoolInfo

function getRetirementPoolInfo(address _retiree, address _pool) external view returns (uint256);

getRetirementTotals

function getRetirementTotals(address _retiree) external view returns (uint256, uint256, uint256);

IKlimaInfinity

Git Source

Functions

retireExactCarbonDefault

function retireExactCarbonDefault(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

retireExactCarbonSpecific

function retireExactCarbonSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 maxAmountIn,
    uint256 retireAmount,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

retireExactSourceDefault

function retireExactSourceDefault(
    address sourceToken,
    address poolToken,
    uint256 maxAmountIn,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

retireExactSourceSpecific

function retireExactSourceSpecific(
    address sourceToken,
    address poolToken,
    address projectToken,
    uint256 maxAmountIn,
    string memory retiringEntityString,
    address beneficiaryAddress,
    string memory beneficiaryString,
    string memory retirementMessage,
    uint8 fromMode
) external payable returns (uint256 retirementIndex);

getSourceAmountDefaultRetirement

function getSourceAmountDefaultRetirement(address sourceToken, address carbonToken, uint256 retireAmount)
    external
    view
    returns (uint256 amountIn);

getSourceAmountSpecificRetirement

function getSourceAmountSpecificRetirement(address sourceToken, address carbonToken, uint256 retireAmount)
    external
    view
    returns (uint256 amountIn);

getRetireAmountSourceDefault

function getRetireAmountSourceDefault(address sourceToken, address carbonToken, uint256 amount)
    external
    view
    returns (uint256 amountOut);

getRetireAmountSourceSpecific

function getRetireAmountSourceSpecific(address sourceToken, address carbonToken, uint256 amount)
    external
    view
    returns (uint256 amountOut);

IKlimaRetirementAggregator

Git Source

Functions

KLIMA

function KLIMA() external pure returns (address);

sKLIMA

function sKLIMA() external pure returns (address);

wsKLIMA

function wsKLIMA() external pure returns (address);

USDC

function USDC() external pure returns (address);

staking

function staking() external pure returns (address);

stakingHelper

function stakingHelper() external pure returns (address);

klimaRetirementStorage

function klimaRetirementStorage() external pure returns (address);

treasury

function treasury() external pure returns (address);

IRetireBridgeCommon

Git Source

Functions

getNeededBuyAmount

function getNeededBuyAmount(address _sourceToken, address _poolToken, uint256 _poolAmount, bool _retireSpecific)
    external
    view
    returns (uint256, uint256);

getSwapPath

function getSwapPath(address _sourceToken, address _poolToken) external view returns (address[] memory);

poolRouter

function poolRouter(address _poolToken) external view returns (address);

IRetireC3Carbon

Git Source

Functions

retireC3

function retireC3(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) external;

retireC3Specific

function retireC3Specific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree,
    address[] memory _carbonList
) external;

getNeededBuyAmount

function getNeededBuyAmount(address _sourceToken, address _poolToken, uint256 _poolAmount, bool _retireSpecific)
    external
    view
    returns (uint256, uint256);

IRetireMossCarbon

Git Source

Functions

retireMoss

function retireMoss(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) external;

getNeededBuyAmount

function getNeededBuyAmount(address _sourceToken, address _poolToken, uint256 _poolAmount, bool _retireSpecific)
    external
    view
    returns (uint256, uint256);

IRetireToucanCarbon

Git Source

Functions

retireToucan

function retireToucan(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) external;

retireToucanSpecific

function retireToucanSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree,
    address[] memory _carbonList
) external;

getNeededBuyAmount

function getNeededBuyAmount(address _sourceToken, address _poolToken, uint256 _poolAmount, bool _retireSpecific)
    external
    view
    returns (uint256, uint256);

IStaking

Git Source

Functions

unstake

function unstake(uint256 _amount, bool _trigger) external;

IStakingHelper

Git Source

Functions

stake

function stake(uint256 _amount) external;

IToucanCarbonOffsets

Git Source

Functions

retire

function retire(uint256 amount) external;

retireAndMintCertificate

function retireAndMintCertificate(
    string calldata retiringEntityString,
    address beneficiary,
    string calldata beneficiaryString,
    string calldata retirementMessage,
    uint256 amount
) external;

mintCertificateLegacy

function mintCertificateLegacy(
    string calldata retiringEntityString,
    address beneficiary,
    string calldata beneficiaryString,
    string calldata retirementMessage,
    uint256 amount
) external;

IToucanContractRegistry

Git Source

Functions

carbonOffsetBatchesAddress

function carbonOffsetBatchesAddress() external view returns (address);

carbonProjectsAddress

function carbonProjectsAddress() external view returns (address);

carbonProjectVintagesAddress

function carbonProjectVintagesAddress() external view returns (address);

toucanCarbonOffsetsFactoryAddress

function toucanCarbonOffsetsFactoryAddress() external view returns (address);

carbonOffsetBadgesAddress

function carbonOffsetBadgesAddress() external view returns (address);

checkERC20

function checkERC20(address _address) external view returns (bool);

addERC20

function addERC20(address _address) external;

IToucanPool

Git Source

Functions

redeemAuto2

function redeemAuto2(uint256 amount) external returns (address[] memory tco2s, uint256[] memory amounts);

redeemMany

function redeemMany(address[] calldata erc20s, uint256[] calldata amounts) external;

feeRedeemPercentageInBase

function feeRedeemPercentageInBase() external pure returns (uint256);

feeRedeemDivider

function feeRedeemDivider() external pure returns (uint256);

redeemFeeExemptedAddresses

function redeemFeeExemptedAddresses(address) external view returns (bool);

ITridentPool

Git Source

Trident pool interface.

Functions

getAmountOut

Simulates a trade and returns the expected output.

The pool does not need to include a trade simulator directly in itself - it can use a library.

function getAmountOut(bytes calldata data) external view returns (uint256 finalAmountOut);

Parameters

NameTypeDescription
databytesABI-encoded params that the pool requires.

Returns

NameTypeDescription
finalAmountOutuint256The amount of output tokens that will be sent to the user if the trade is executed.

getAmountIn

Simulates a trade and returns the expected output.

The pool does not need to include a trade simulator directly in itself - it can use a library.

function getAmountIn(bytes calldata data) external view returns (uint256 finalAmountIn);

Parameters

NameTypeDescription
databytesABI-encoded params that the pool requires.

Returns

NameTypeDescription
finalAmountInuint256The amount of input tokens that are required from the user if the trade is executed.

ITridentRouter

Git Source

Trident pool router interface.

Functions

exactInputSingleWithNativeToken

function exactInputSingleWithNativeToken(ExactInputSingleParams calldata params)
    external
    payable
    returns (uint256 amountOut);

Structs

ExactInputSingleParams

struct ExactInputSingleParams {
    uint256 amountIn;
    uint256 amountOutMinimum;
    address pool;
    address tokenIn;
    bytes data;
}

IUniswapV2Pair

Git Source

Functions

name

function name() external pure returns (string memory);

symbol

function symbol() external pure returns (string memory);

decimals

function decimals() external pure returns (uint8);

totalSupply

function totalSupply() external view returns (uint256);

balanceOf

function balanceOf(address owner) external view returns (uint256);

allowance

function allowance(address owner, address spender) external view returns (uint256);

approve

function approve(address spender, uint256 value) external returns (bool);

transfer

function transfer(address to, uint256 value) external returns (bool);

transferFrom

function transferFrom(address from, address to, uint256 value) external returns (bool);

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32);

PERMIT_TYPEHASH

function PERMIT_TYPEHASH() external pure returns (bytes32);

nonces

function nonces(address owner) external view returns (uint256);

permit

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external;

MINIMUM_LIQUIDITY

function MINIMUM_LIQUIDITY() external pure returns (uint256);

factory

function factory() external view returns (address);

token0

function token0() external view returns (address);

token1

function token1() external view returns (address);

getReserves

function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);

price0CumulativeLast

function price0CumulativeLast() external view returns (uint256);

price1CumulativeLast

function price1CumulativeLast() external view returns (uint256);

kLast

function kLast() external view returns (uint256);

mint

function mint(address to) external returns (uint256 liquidity);

burn

function burn(address to) external returns (uint256 amount0, uint256 amount1);

swap

function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;

skim

function skim(address to) external;

sync

function sync() external;

initialize

function initialize(address, address) external;

Events

Approval

event Approval(address indexed owner, address indexed spender, uint256 value);

Transfer

event Transfer(address indexed from, address indexed to, uint256 value);

Mint

event Mint(address indexed sender, uint256 amount0, uint256 amount1);

Burn

event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);

Swap

event Swap(
    address indexed sender,
    uint256 amount0In,
    uint256 amount1In,
    uint256 amount0Out,
    uint256 amount1Out,
    address indexed to
);

Sync

event Sync(uint112 reserve0, uint112 reserve1);

IUniswapV2Router01

Git Source

Functions

factory

function factory() external pure returns (address);

WETH

function WETH() external pure returns (address);

addLiquidity

function addLiquidity(
    address tokenA,
    address tokenB,
    uint256 amountADesired,
    uint256 amountBDesired,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);

addLiquidityETH

function addLiquidityETH(
    address token,
    uint256 amountTokenDesired,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);

removeLiquidity

function removeLiquidity(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETH

function removeLiquidityETH(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);

removeLiquidityWithPermit

function removeLiquidityWithPermit(
    address tokenA,
    address tokenB,
    uint256 liquidity,
    uint256 amountAMin,
    uint256 amountBMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountA, uint256 amountB);

removeLiquidityETHWithPermit

function removeLiquidityETHWithPermit(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);

swapExactTokensForTokens

function swapExactTokensForTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapTokensForExactTokens

function swapTokensForExactTokens(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactETHForTokens

function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

swapTokensForExactETH

function swapTokensForExactETH(
    uint256 amountOut,
    uint256 amountInMax,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapExactTokensForETH

function swapExactTokensForETH(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external returns (uint256[] memory amounts);

swapETHForExactTokens

function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline)
    external
    payable
    returns (uint256[] memory amounts);

quote

function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB);

getAmountOut

function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountOut);

getAmountIn

function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
    external
    pure
    returns (uint256 amountIn);

getAmountsOut

function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

getAmountsIn

function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);

IUniswapV2Router02

Git Source

Inherits: IUniswapV2Router01

Functions

removeLiquidityETHSupportingFeeOnTransferTokens

function removeLiquidityETHSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline
) external returns (uint256 amountETH);

removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
    address token,
    uint256 liquidity,
    uint256 amountTokenMin,
    uint256 amountETHMin,
    address to,
    uint256 deadline,
    bool approveMax,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 amountETH);

swapExactTokensForTokensSupportingFeeOnTransferTokens

function swapExactTokensForTokensSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

swapExactETHForTokensSupportingFeeOnTransferTokens

function swapExactETHForTokensSupportingFeeOnTransferTokens(
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external payable;

swapExactTokensForETHSupportingFeeOnTransferTokens

function swapExactTokensForETHSupportingFeeOnTransferTokens(
    uint256 amountIn,
    uint256 amountOutMin,
    address[] calldata path,
    address to,
    uint256 deadline
) external;

IwsKLIMA

Git Source

Functions

wrap

function wrap(uint256 _amount) external returns (uint256);

unwrap

function unwrap(uint256 _amount) external returns (uint256);

wKLIMATosKLIMA

function wKLIMATosKLIMA(uint256 _amount) external view returns (uint256);

sKLIMATowKLIMA

function sKLIMATowKLIMA(uint256 _amount) external view returns (uint256);

KlimaCarbonRetirements

Git Source

Inherits: Ownable

This is used to store any offset retirements made through Klima retirement helper contracts.

State Variables

retirements

mapping(address => Retirement) public retirements;

isHelperContract

mapping(address => bool) public isHelperContract;

isMinterContract

mapping(address => bool) public isMinterContract;

Functions

carbonRetired

Stores the details of an offset transaction for future use

function carbonRetired(
    address _retiree,
    address _pool,
    uint256 _amount,
    string calldata _beneficiaryString,
    string calldata _retirementMessage
) public;

Parameters

NameTypeDescription
_retireeaddressAddress of the retiree. Not the address of a helper contract.
_pooladdressAddress of the carbon pool token.
_amountuint256Number of tons offset. Expected is with 18 decimals.
_beneficiaryStringstringString that can be used to describe the beneficiary
_retirementMessagestringString for specific retirement message if needed.

getUnclaimedTotal

Return any unclaimed NFT totals for an address

function getUnclaimedTotal(address _minter) public view returns (uint256);

Parameters

NameTypeDescription
_minteraddressAddress of user trying to mint.

Returns

NameTypeDescription
<none>uint256The net amount of offsets not used for minting an NFT to date.

offsetClaimed

This function updates the total claimed amount for minting an NFT.

function offsetClaimed(address _minter, uint256 _amount) public returns (bool);

Parameters

NameTypeDescription
_minteraddressAddress of the user trying to mint.
_amountuint256Amount being claimed for the mint. Expected value in 18 decimals.

getRetirementIndexInfo

This returns information on a specific retirement for an address.

function getRetirementIndexInfo(address _retiree, uint256 _index)
    public
    view
    returns (address, uint256, string memory, string memory);

Parameters

NameTypeDescription
_retireeaddressAddress that retired the offsets.
_indexuint256Index of all retirements made. Starts at 0.

Returns

NameTypeDescription
<none>addressReturns a tuple of the address for the pool address, amount offset in 18 decimals, and beneficiary description and message used in the retirement.
<none>uint256
<none>string
<none>string

getRetirementPoolInfo

This returns the total amount offset by an address for a specific pool.

function getRetirementPoolInfo(address _retiree, address _pool) public view returns (uint256);

Parameters

NameTypeDescription
_retireeaddressAddress that performed the retirement.
_pooladdressAddress of the pool token.

Returns

NameTypeDescription
<none>uint256Int with 18 decimals for the total amount offset for this pool token.

getRetirementTotals

This returns totals about retirements and claims on an address

function getRetirementTotals(address _retiree) public view returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
_retireeaddressAddress that performed the retirement.

Returns

NameTypeDescription
<none>uint256Int tuple. Total retirements, total tons retired, total tons claimed for NFTs.
<none>uint256
<none>uint256

addHelperContract

Allow contract owner to whitelist new helper contracts. This is to prevent writing abuse from external interfaces.

function addHelperContract(address _helper) public onlyOwner;

Parameters

NameTypeDescription
_helperaddressAddress of the helper contract.

removeHelperContract

Allow contract owner to remove helper contracts. This is to prevent writing abuse from external interfaces.

function removeHelperContract(address _helper) public onlyOwner;

Parameters

NameTypeDescription
_helperaddressAddress of the helper contract.

addMinterContract

Allow contract owner to whitelist new reward contracts. This is to prevent writing abuse from external interfaces.

function addMinterContract(address _minter) public onlyOwner;

Parameters

NameTypeDescription
_minteraddressAddress of the helper contract.

removeMinterContract

Allow contract owner to remove reward contracts. This is to prevent writing abuse from external interfaces.

function removeMinterContract(address _minter) public onlyOwner;

Parameters

NameTypeDescription
_minteraddressAddress of the helper contract.

Events

HelperAdded

event HelperAdded(address helper);

HelperRemoved

event HelperRemoved(address helper);

MinterAdded

event MinterAdded(address minter);

MinterRemoved

event MinterRemoved(address minter);

Structs

Retirement

struct Retirement {
    uint256 totalRetirements;
    uint256 totalCarbonRetired;
    uint256 totalClaimed;
    mapping(uint256 => address) retiredPool;
    mapping(uint256 => uint256) retiredAmount;
    mapping(uint256 => string) retirementBeneficiary;
    mapping(uint256 => string) retirementMessage;
    mapping(address => uint256) totalPoolRetired;
}

KlimaRetirementAggregator

Git Source

Inherits: Initializable, ContextUpgradeable, OwnableUpgradeable

Author: KlimaDAO

This is the master aggregator contract for the Klima retirement utility. This allows a user to provide a source token and an approved carbon pool token to retire. If the source is different than the pool, it will attempt to swap to that pool then retire.

State Variables

KLIMA

=== State Variables and Mappings ===

address public KLIMA;

sKLIMA

address public sKLIMA;

wsKLIMA

address public wsKLIMA;

USDC

address public USDC;

staking

address public staking;

stakingHelper

address public stakingHelper;

treasury

address public treasury;

klimaRetirementStorage

address public klimaRetirementStorage;

isPoolToken

mapping(address => bool) public isPoolToken;

poolBridge

mapping(address => uint256) public poolBridge;

bridgeHelper

mapping(uint256 => address) public bridgeHelper;

INFINITY

address public constant INFINITY = 0x8cE54d9625371fb2a068986d32C85De8E6e995f8;

Functions

initialize

function initialize() public initializer;

retireCarbon

=== Non Specific Auto Retirements

This function will retire a carbon pool token that is held in the caller's wallet. Depending on the pool provided the appropriate retirement helper will be used as defined in the bridgeHelper mapping. If a token other than the pool is provided then the helper will attempt to swap to the appropriate pool and then retire.

function retireCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage
) public;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.

retireCarbon

function retireCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage
) public;

retireCarbonFrom

This function will retire a carbon pool token that has been transferred to this contract. Useful when an intermediary contract has approval to transfer the source tokens from the initiator. Depending on the pool provided the appropriate retirement helper will be used as defined in the bridgeHelper mapping. If a token other than the pool is provided then the helper will attempt to swap to the appropriate pool and then retire.

function retireCarbonFrom(
    address _initiator,
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage
) public;

Parameters

NameTypeDescription
_initiatoraddressThe original sender of the transaction.
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.

_retireCarbon

Internal function that checks to make sure the needed source tokens have been transferred to this contract, then calls the retirement function on the bridge's specific helper contract.

function _retireCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) internal;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_retireeaddressAddress of the initiator where source tokens originated.

_retireCarbon

function _retireCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) internal;

retireCarbonSpecific

=== Specific offset selection retirements ===

This function will retire a carbon pool token that is held in the caller's wallet. Depending on the pool provided the appropriate retirement helper will be used as defined in the bridgeHelper mapping. If a token other than the pool is provided then the helper will attempt to swap to the appropriate pool and then retire.

function retireCarbonSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address[] memory _carbonList
) public;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_carbonListaddress[]

retireCarbonSpecific

function retireCarbonSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address[] memory _carbonList
) public;

retireCarbonSpecificFrom

function retireCarbonSpecificFrom(
    address _initiator,
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address[] memory _carbonList
) public;

_retireCarbonSpecific

Internal function that checks to make sure the needed source tokens have been transferred to this contract, then calls the retirement function on the bridge's specific helper contract.

function _retireCarbonSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree,
    address[] memory _carbonList
) internal;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_retireeaddressAddress of the initiator where source tokens originated.
_carbonListaddress[]

_retireCarbonSpecific

function _retireCarbonSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree,
    address[] memory _carbonList
) internal;

_prepareRetireSpecific

function _prepareRetireSpecific(address _sourceToken, address _poolToken, uint256 _amount, bool _amountInCarbon)
    internal;

getSourceAmount

=== External views and helpful functions ===

This function calls the appropriate helper for a pool token and returns the total amount in source tokens needed to perform the transaction. Any swap slippage buffers and fees are included in the return value.

function getSourceAmount(address _sourceToken, address _poolToken, uint256 _amount, bool _amountInCarbon)
    public
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.

Returns

NameTypeDescription
<none>uint256Returns both the source amount and carbon amount as a result of swaps.
<none>uint256

getSourceAmountSpecific

Same as getSourceAmount, but factors in the redemption fee for specific retirements.

function getSourceAmountSpecific(address _sourceToken, address _poolToken, uint256 _amount, bool _amountInCarbon)
    public
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.

Returns

NameTypeDescription
<none>uint256Returns both the source amount and carbon amount as a result of swaps.
<none>uint256

setAddress

Allow the contract owner to update Klima protocol addresses resulting from possible migrations.

function setAddress(uint256 _selection, address _newAddress) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_selectionuint256Int to indicate which address is being updated.
_newAddressaddressNew address for contract needing to be updated.

Returns

NameTypeDescription
<none>boolbool

addPool

Add a new carbon pool to retire with helper contract.

function addPool(address _poolToken, uint256 _poolBridge) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being added.
_poolBridgeuint256Int ID of the bridge used for this token.

Returns

NameTypeDescription
<none>boolbool

removePool

Remove a carbon pool to retire.

function removePool(address _poolToken) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being removed.

Returns

NameTypeDescription
<none>boolbool

setBridgeHelper

Set the helper contract to be used with a carbon bridge.

function setBridgeHelper(uint256 _bridgeID, address _helper) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_bridgeIDuint256Int ID of the bridge.
_helperaddressHelper contract to use with this bridge.

Returns

NameTypeDescription
<none>boolbool

feeWithdraw

Allow withdrawal of any tokens sent in error

function feeWithdraw(address _token, address _recipient) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_tokenaddressAddress of token to transfer
_recipientaddress

Events

AddressUpdated

=== Event Setup ===

event AddressUpdated(uint256 addressIndex, address indexed oldAddress, address indexed newAddress);

PoolAdded

event PoolAdded(address poolToken, uint256 bridge);

PoolRemoved

event PoolRemoved(address poolToken);

BridgeHelperUpdated

event BridgeHelperUpdated(uint256 bridgeID, address helper);

RetireC3Carbon

Git Source

Inherits: Initializable, ContextUpgradeable, OwnableUpgradeable

State Variables

feeAmount

=== State Variables and Mappings ===

feeAmount represents the fee to be bonded for KLIMA. 0.1% increments. 10 = 1%

uint256 public feeAmount;

masterAggregator

address public masterAggregator;

tridentRouter

address public tridentRouter;

bento

address public bento;

isPoolToken

mapping(address => bool) public isPoolToken;

poolRouter

mapping(address => address) public poolRouter;

tridentPool

mapping(address => address) public tridentPool;

Functions

initialize

function initialize() public initializer;

retireC3

=== Free Redeem and Offset Functions ===

This function transfers source tokens if needed, swaps to the C3 pool token, utilizes freeRedeem, then retires the redeemed C3T. Needed source token amount is expected to be held by the caller to use.

function retireC3(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) public;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_retireeaddressThe original sender of the transaction.

_retireCarbon

Redeems the pool and retires the C3T tokens on Polygon. Emits a retirement event and updates the KlimaCarbonRetirements contract with retirement details and amounts.

function _retireCarbon(
    uint256 _totalAmount,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _poolToken
) internal;

Parameters

NameTypeDescription
_totalAmountuint256Total pool tokens being retired. Expected uint with 18 decimals.
_beneficiaryAddressaddressAddress of the beneficiary if different than sender. Value is set to _msgSender() if null is sent.
_beneficiaryStringstringString that can be used to describe the beneficiary
_retirementMessagestringString for specific retirement message if needed.
_poolTokenaddressAddress of pool token being used to retire.

retireC3Specific

=== Taxed Redeem and Offset Functions ===

This function transfers source tokens if needed, swaps to the C3 pool token, utilizes taxedRedeem, then retires the redeemed C3T. Needed source token amount is expected to be held by the caller to use.

function retireC3Specific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree,
    address[] memory _carbonList
) public;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_retireeaddressThe original sender of the transaction.
_carbonListaddress[]List of C3Ts to redeem

_prepareRetireSpecific

This function is mainly used to avoid stack too deep. It performs the initial transfer and swap to the pool token for a specific retirement.

function _prepareRetireSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _retiree
) internal returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_retireeaddressThe original sender of the transaction. To return trade dust.

Returns

NameTypeDescription
<none>uint256(uint256, uint256) tuple for the amount to pass to redeem and retire, and the aggregator fee.
<none>uint256

_retireCarbonSpecific

Redeems the pool and retires the C3T tokens on Polygon. Emits a retirement event and updates the KlimaCarbonRetirements contract with retirement details and amounts.

function _retireCarbonSpecific(
    uint256 _totalAmount,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _poolToken,
    address[] memory _carbonList
) internal;

Parameters

NameTypeDescription
_totalAmountuint256Total pool tokens being retired. Expected uint with 18 decimals.
_beneficiaryAddressaddressAddress of the beneficiary if different than sender. Value is set to _msgSender() if null is sent.
_beneficiaryStringstringString that can be used to describe the beneficiary
_retirementMessagestringString for specific retirement message if needed.
_poolTokenaddressAddress of pool token being used to retire.
_carbonListaddress[]List of C3T tokens to redeem

_transferSourceTokens

=== Internal helper functions ===

Transfers the needed source tokens from the caller to perform any needed swaps and then retire the tokens.

function _transferSourceTokens(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    bool _specificRetire
) internal returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_specificRetirebool

_stakedToUnstaked

Unwraps/unstakes any KLIMA needed to regular KLIMA.

function _stakedToUnstaked(address _klimaType, uint256 _amountIn) internal returns (uint256);

Parameters

NameTypeDescription
_klimaTypeaddressAddress of the KLIMA type being used.
_amountInuint256Amount of total KLIMA needed.

Returns

NameTypeDescription
<none>uint256Returns the total number of KLIMA after unwrapping/unstaking.

_swapForExactCarbon

Swaps the source token for an exact number of carbon tokens, and returns any dust to the initiator.

This is only called if the _amountInCarbon bool is set to true.

function _swapForExactCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _carbonAmount,
    uint256 _amountIn,
    address _retiree
) internal;

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_carbonAmountuint256Total carbon needed.
_amountInuint256Maximum amount of source tokens.
_retireeaddressInitiator of the retirement to return any dust.

_swapExactForCarbon

Swaps an exact number of source tokens for carbon tokens.

This is only called if the _amountInCarbon bool is set to false.

function _swapExactForCarbon(address _sourceToken, address _poolToken, uint256 _amountIn)
    internal
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_amountInuint256Total source tokens to swap.

Returns

NameTypeDescription
<none>uint256Returns the resulting carbon amount to retire and the fee from the results of the swap.
<none>uint256

_returnTradeDust

Returns any trade dust to the designated address. If sKLIMA or wsKLIMA was provided as a source token, it is re-staked and/or wrapped before transferring back.

function _returnTradeDust(uint256[] memory _amounts, address _sourceToken, uint256 _amountIn, address _retiree)
    internal;

Parameters

NameTypeDescription
_amountsuint256[]The amounts resulting from the Uniswap tradeTokensForExactTokens.
_sourceTokenaddressAddress of token being used to purchase the pool token.
_amountInuint256Total source tokens initially provided.
_retireeaddressAddress where to send the dust.

_getSpecificCarbonFee

Gets the fee amount for a carbon pool and returns the value.

function _getSpecificCarbonFee(address _poolToken, uint256 _poolAmount, bool _amountInCarbon)
    internal
    view
    returns (uint256);

Parameters

NameTypeDescription
_poolTokenaddressAddress of pool token being used.
_poolAmountuint256Amount of tokens being retired.
_amountInCarbonboolBool indicating if _amount is in carbon or source.

Returns

NameTypeDescription
<none>uint256poolFeeAmount Fee amount for specificly redeeming a ton.

getNeededBuyAmount

=== External views and helpful functions ===

Call the UniswapV2 routers for needed amounts on token being retired. Also calculates and returns any fee needed in the pool token total.

function getNeededBuyAmount(address _sourceToken, address _poolToken, uint256 _poolAmount, bool _specificRetire)
    public
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_poolAmountuint256Amount of tokens being retired.
_specificRetirebool

Returns

NameTypeDescription
<none>uint256Tuple of the total pool amount needed, followed by the fee.
<none>uint256

getSwapPath

This creates the path for UniswapV2 to get to KLIMA. A secondary swap will be performed in Trident to get the pool token.

This function will produce an invalid path if the source token does not have a direct USDC LP route on the pool's AMM. The resulting transaction would revert.

function getSwapPath(address _sourceToken, address _poolToken) public view returns (address[] memory);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.

Returns

NameTypeDescription
<none>address[]Array of addresses to be used as the path for the swap.

setFeeAmount

=== Admin Functions ===

Set the fee for the helper

function setFeeAmount(uint256 _amount) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_amountuint256New fee amount, in .1% increments. 10 = 1%

Returns

NameTypeDescription
<none>boolbool

setPoolRouter

Update the router for an existing pool

function setPoolRouter(address _poolToken, address _router) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being updated
_routeraddressNew router address

Returns

NameTypeDescription
<none>boolbool

addPool

Add a new carbon pool to retire with helper contract

function addPool(address _poolToken, address _router, address _tridentPool) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being added
_routeraddressUniswapV2 router to route trades through for non-pool retirements
_tridentPooladdress

Returns

NameTypeDescription
<none>boolbool

removePool

Remove a carbon pool to retire with helper contract

function removePool(address _poolToken) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being removed

Returns

NameTypeDescription
<none>boolbool

feeWithdraw

Allow withdrawal of any tokens sent in error

function feeWithdraw(address _token, address _recipient) public onlyOwner returns (bool);

Parameters

NameTypeDescription
_tokenaddressAddress of token to transfer
_recipientaddressAddress where to send tokens.

setMasterAggregator

Allow the contract owner to update the master aggregator proxy address used.

function setMasterAggregator(address _newAddress) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_newAddressaddressNew address for contract needing to be updated.

Returns

NameTypeDescription
<none>boolbool

setTrident

Allow the contract owner to update the SushiSwap Trident AMM addresses.

function setTrident(address _tridentRouter, address _bento) external onlyOwner;

Parameters

NameTypeDescription
_tridentRouteraddressNew address for Trident router.
_bentoaddressNew address for Bento Box.

Events

C3Retired

=== Event Setup ===

event C3Retired(
    address indexed retiringAddress,
    address indexed beneficiaryAddress,
    string beneficiaryString,
    string retirementMessage,
    address indexed carbonPool,
    address carbonToken,
    uint256 retiredAmount
);

PoolAdded

event PoolAdded(address indexed carbonPool, address indexed poolRouter, address indexed tridentPool);

PoolRemoved

event PoolRemoved(address indexed carbonPool);

PoolRouterChanged

event PoolRouterChanged(address indexed carbonPool, address indexed oldRouter, address indexed newRouter);

TridentChanged

event TridentChanged(
    address indexed oldBento, address indexed newBento, address indexed oldTrident, address newTrident
);

FeeUpdated

event FeeUpdated(uint256 oldFee, uint256 newFee);

MasterAggregatorUpdated

event MasterAggregatorUpdated(address indexed oldAddress, address indexed newAddress);

RetireMossCarbon

Git Source

Inherits: Initializable, ContextUpgradeable, OwnableUpgradeable

State Variables

feeAmount

=== State Variables and Mappings ===

feeAmount represents the fee to be bonded for KLIMA. 0.1% increments. 10 = 1%

uint256 public feeAmount;

carbonChain

address public carbonChain;

masterAggregator

address public masterAggregator;

isPoolToken

mapping(address => bool) public isPoolToken;

poolRouter

mapping(address => address) public poolRouter;

Functions

initialize

function initialize() public initializer;

retireMoss

This function transfers source tokens if needed, swaps to the Moss pool token, and then retires via their CarbonChain interface. Needed source token amount is expected to be held by the caller to use.

function retireMoss(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) public;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_retireeaddressThe original sender of the transaction.

_retireCarbon

Retires the MCO2 tokens on Polygon where they will be bridged back to L1. Emits a retirement event and updates the KlimaCarbonRetirements contract with retirement details and amounts.

function _retireCarbon(
    uint256 _totalAmount,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _poolToken
) internal;

Parameters

NameTypeDescription
_totalAmountuint256Total pool tokens being retired. Expected uint with 18 decimals.
_beneficiaryAddressaddressAddress of the beneficiary if different than sender. Value is set to _msgSender() if null is sent.
_beneficiaryStringstringString that can be used to describe the beneficiary
_retirementMessagestringString for specific retirement message if needed.
_poolTokenaddressAddress of pool token being used to retire.

_transferSourceTokens

Transfers the needed source tokens from the caller to perform any needed swaps and then retire the tokens.

function _transferSourceTokens(address _sourceToken, address _poolToken, uint256 _amount, bool _amountInCarbon)
    internal
    returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.

_stakedToUnstaked

Unwraps/unstakes any KLIMA needed to regular KLIMA.

function _stakedToUnstaked(address _klimaType, uint256 _amountIn) internal returns (uint256);

Parameters

NameTypeDescription
_klimaTypeaddressAddress of the KLIMA type being used.
_amountInuint256Amount of total KLIMA needed.

Returns

NameTypeDescription
<none>uint256Returns the total number of KLIMA after unwrapping/unstaking.

getNeededBuyAmount

Call the UniswapV2 routers for needed amounts on token being retired. Also calculates and returns any fee needed in the pool token total.

function getNeededBuyAmount(address _sourceToken, address _poolToken, uint256 _poolAmount, bool _specificRetire)
    public
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_poolAmountuint256Amount of tokens being retired.
_specificRetirebool

Returns

NameTypeDescription
<none>uint256Tuple of the total pool amount needed, followed by the fee.
<none>uint256

getSwapPath

Creates an array of addresses to use in performing any needed swaps to receive the pool token from the source token.

This function will produce an invalid path if the source token does not have a direct USDC LP route on the pool's AMM. The resulting transaction would revert.

function getSwapPath(address _sourceToken, address _poolToken) public view returns (address[] memory);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.

Returns

NameTypeDescription
<none>address[]Array of addresses to be used as the path for the swap.

_swapForExactCarbon

Swaps the source token for an exact number of carbon tokens, and returns any dust to the initiator.

This is only called if the _amountInCarbon bool is set to true.

function _swapForExactCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _carbonAmount,
    uint256 _amountIn,
    address _retiree
) internal;

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_carbonAmountuint256Total carbon needed.
_amountInuint256Maximum amount of source tokens.
_retireeaddressInitiator of the retirement to return any dust.

_swapExactForCarbon

Swaps an exact number of source tokens for carbon tokens.

This is only called if the _amountInCarbon bool is set to false.

function _swapExactForCarbon(address _sourceToken, address _poolToken, uint256 _amountIn)
    internal
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_amountInuint256Total source tokens to swap.

Returns

NameTypeDescription
<none>uint256Returns the resulting carbon amount to retire and the fee from the results of the swap.
<none>uint256

_returnTradeDust

Returns any trade dust to the designated address. If sKLIMA or wsKLIMA was provided as a source token, it is re-staked and/or wrapped before transferring back.

function _returnTradeDust(uint256[] memory _amounts, address _sourceToken, uint256 _amountIn, address _retiree)
    internal;

Parameters

NameTypeDescription
_amountsuint256[]The amounts resulting from the Uniswap tradeTokensForExactTokens.
_sourceTokenaddressAddress of token being used to purchase the pool token.
_amountInuint256Total source tokens initially provided.
_retireeaddressAddress where to send the dust.

setFeeAmount

Set the fee for the helper

function setFeeAmount(uint256 _amount) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_amountuint256New fee amount, in .1% increments. 10 = 1%

Returns

NameTypeDescription
<none>boolbool

setPoolRouter

Update the router for an existing pool

function setPoolRouter(address _poolToken, address _router) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being updated
_routeraddressNew router address

Returns

NameTypeDescription
<none>boolbool

addPool

Add a new carbon pool to retire with helper contract

function addPool(address _poolToken, address _router) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being added
_routeraddressUniswapV2 router to route trades through for non-pool retirements

Returns

NameTypeDescription
<none>boolbool

removePool

Remove a carbon pool to retire with helper contract

function removePool(address _poolToken) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being removed

Returns

NameTypeDescription
<none>boolbool

feeWithdraw

Allow withdrawal of any tokens sent in error

function feeWithdraw(address _token, address _recipient) public onlyOwner returns (bool);

Parameters

NameTypeDescription
_tokenaddressAddress of token to transfer
_recipientaddressAddress where to send tokens.

setCarbonChain

Allow the contract owner to update the Moss CarbonChain Proxy address used.

function setCarbonChain(address _newAddress) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_newAddressaddressNew address for contract needing to be updated.

Returns

NameTypeDescription
<none>boolbool

setMasterAggregator

Allow the contract owner to update the master aggregator proxy address used.

function setMasterAggregator(address _newAddress) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_newAddressaddressNew address for contract needing to be updated.

Returns

NameTypeDescription
<none>boolbool

Events

MossRetired

=== Event Setup ===

event MossRetired(
    address indexed retiringAddress,
    address indexed beneficiaryAddress,
    string beneficiaryString,
    string retirementMessage,
    address indexed carbonPool,
    uint256 retiredAmount
);

PoolAdded

event PoolAdded(address indexed carbonPool, address indexed poolRouter);

PoolRemoved

event PoolRemoved(address indexed carbonPool);

PoolRouterChanged

event PoolRouterChanged(address indexed carbonPool, address indexed oldRouter, address indexed newRouter);

FeeUpdated

event FeeUpdated(uint256 oldFee, uint256 newFee);

CarbonChainUpdated

event CarbonChainUpdated(address indexed oldAddress, address indexed newAddress);

MasterAggregatorUpdated

event MasterAggregatorUpdated(address indexed oldAddress, address indexed newAddress);

RetireToucanCarbon

Git Source

Inherits: Initializable, ContextUpgradeable, OwnableUpgradeable, IERC721ReceiverUpgradeable

State Variables

feeAmount

=== State Variables and Mappings ===

feeAmount represents the fee to be bonded for KLIMA. 0.1% increments. 10 = 1%

uint256 public feeAmount;

masterAggregator

address public masterAggregator;

isPoolToken

mapping(address => bool) public isPoolToken;

poolRouter

mapping(address => address) public poolRouter;

toucanRegistry

address public toucanRegistry;

lastTokenId

uint256 public lastTokenId;

Functions

initialize

function initialize() public initializer;

retireToucan

This function transfers source tokens if needed, swaps to the Toucan pool token, utilizes redeemAuto, then retires the redeemed TCO2. Needed source token amount is expected to be held by the caller to use.

function retireToucan(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree
) public;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_retireEntityStringstring
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_retireeaddressThe original sender of the transaction.

_prepareRetire

This function transfers source tokens if needed, swaps to the Toucan pool token and the returns the resulting values to be retired.

function _prepareRetire(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _retiree
) internal returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_retireeaddressThe original sender of the transaction.

retireToucanSpecific

This function transfers source tokens if needed, swaps to the Toucan pool token, utilizes redeemMany, then retires the redeemed TCO2. Needed source token amount is expected to be held by the caller to use.

function retireToucanSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _retiree,
    address[] memory _carbonList
) public;

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_retireEntityStringstring
_beneficiaryAddressaddressAddress of the beneficiary of the retirement.
_beneficiaryStringstringString representing the beneficiary. A name perhaps.
_retirementMessagestringSpecific message relating to this retirement event.
_retireeaddressThe original sender of the transaction.
_carbonListaddress[]List of TCO2s to redeem

_prepareRetireSpecific

This function transfers source tokens if needed, swaps to the Toucan pool token and the returns the resulting values to be retired.

function _prepareRetireSpecific(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    address _retiree
) internal returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_retireeaddressThe original sender of the transaction.

_retireCarbon

Redeems the pool and retires the TCO2 tokens on Polygon. Emits a retirement event and updates the KlimaCarbonRetirements contract with retirement details and amounts.

function _retireCarbon(
    uint256 _totalAmount,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _poolToken
) internal;

Parameters

NameTypeDescription
_totalAmountuint256Total pool tokens being retired. Expected uint with 18 decimals.
_retireEntityStringstring
_beneficiaryAddressaddressAddress of the beneficiary if different than sender. Value is set to _msgSender() if null is sent.
_beneficiaryStringstringString that can be used to describe the beneficiary
_retirementMessagestringString for specific retirement message if needed.
_poolTokenaddressAddress of pool token being used to retire.

_retireCarbonSpecific

Redeems the pool and retires the TCO2 tokens on Polygon. Emits a retirement event and updates the KlimaCarbonRetirements contract with retirement details and amounts.

function _retireCarbonSpecific(
    uint256 _totalAmount,
    string memory _retireEntityString,
    address _beneficiaryAddress,
    string memory _beneficiaryString,
    string memory _retirementMessage,
    address _poolToken,
    address[] memory _carbonList
) internal;

Parameters

NameTypeDescription
_totalAmountuint256Total pool tokens being retired. Expected uint with 18 decimals.
_retireEntityStringstring
_beneficiaryAddressaddressAddress of the beneficiary if different than sender. Value is set to _msgSender() if null is sent.
_beneficiaryStringstringString that can be used to describe the beneficiary
_retirementMessagestringString for specific retirement message if needed.
_poolTokenaddressAddress of pool token being used to retire.
_carbonListaddress[]List of TCO2 tokens to redeem

_transferSourceTokens

Transfers the needed source tokens from the caller to perform any needed swaps and then retire the tokens.

function _transferSourceTokens(
    address _sourceToken,
    address _poolToken,
    uint256 _amount,
    bool _amountInCarbon,
    bool _specificRetire
) internal returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressThe contract address of the token being supplied.
_poolTokenaddressThe contract address of the pool token being retired.
_amountuint256The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon.
_amountInCarbonboolBool indicating if _amount is in carbon or source.
_specificRetirebool

_stakedToUnstaked

Unwraps/unstakes any KLIMA needed to regular KLIMA.

function _stakedToUnstaked(address _klimaType, uint256 _amountIn) internal returns (uint256);

Parameters

NameTypeDescription
_klimaTypeaddressAddress of the KLIMA type being used.
_amountInuint256Amount of total KLIMA needed.

Returns

NameTypeDescription
<none>uint256Returns the total number of KLIMA after unwrapping/unstaking.

getNeededBuyAmount

Call the UniswapV2 routers for needed amounts on token being retired. Also calculates and returns any fee needed in the pool token total.

function getNeededBuyAmount(address _sourceToken, address _poolToken, uint256 _poolAmount, bool _specificRetire)
    public
    view
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_poolAmountuint256Amount of tokens being retired.
_specificRetirebool

Returns

NameTypeDescription
<none>uint256Tuple of the total pool amount needed, followed by the fee.
<none>uint256

_getSpecificCarbonFee

function _getSpecificCarbonFee(address _poolToken, uint256 _poolAmount) internal view returns (uint256);

getSwapPath

Creates an array of addresses to use in performing any needed swaps to receive the pool token from the source token.

This function will produce an invalid path if the source token does not have a direct USDC LP route on the pool's AMM. The resulting transaction would revert.

function getSwapPath(address _sourceToken, address _poolToken) public view returns (address[] memory);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.

Returns

NameTypeDescription
<none>address[]Array of addresses to be used as the path for the swap.

_swapForExactCarbon

Swaps the source token for an exact number of carbon tokens, and returns any dust to the initiator.

This is only called if the _amountInCarbon bool is set to true.

function _swapForExactCarbon(
    address _sourceToken,
    address _poolToken,
    uint256 _carbonAmount,
    uint256 _amountIn,
    address _retiree
) internal;

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_carbonAmountuint256Total carbon needed.
_amountInuint256Maximum amount of source tokens.
_retireeaddressInitiator of the retirement to return any dust.

_swapExactForCarbon

Swaps an exact number of source tokens for carbon tokens.

This is only called if the _amountInCarbon bool is set to false.

function _swapExactForCarbon(address _sourceToken, address _poolToken, uint256 _amountIn)
    internal
    returns (uint256, uint256);

Parameters

NameTypeDescription
_sourceTokenaddressAddress of token being used to purchase the pool token.
_poolTokenaddressAddress of pool token being used.
_amountInuint256Total source tokens to swap.

Returns

NameTypeDescription
<none>uint256Returns the resulting carbon amount to retire and the fee from the results of the swap.
<none>uint256

_returnTradeDust

Returns any trade dust to the designated address. If sKLIMA or wsKLIMA was provided as a source token, it is re-staked and/or wrapped before transferring back.

function _returnTradeDust(uint256[] memory _amounts, address _sourceToken, uint256 _amountIn, address _retiree)
    internal;

Parameters

NameTypeDescription
_amountsuint256[]The amounts resulting from the Uniswap tradeTokensForExactTokens.
_sourceTokenaddressAddress of token being used to purchase the pool token.
_amountInuint256Total source tokens initially provided.
_retireeaddressAddress where to send the dust.

onERC721Received

=== Toucan Certificate Functions ===

function onERC721Received(address, address, uint256 tokenId, bytes memory) external virtual override returns (bytes4);

_sendRetireCert

function _sendRetireCert(address _beneficiary) internal;

setFeeAmount

=== Admin Functions ===

Set the fee for the helper

function setFeeAmount(uint256 _amount) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_amountuint256New fee amount, in .1% increments. 10 = 1%

Returns

NameTypeDescription
<none>boolbool

setPoolRouter

Update the router for an existing pool

function setPoolRouter(address _poolToken, address _router) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being updated
_routeraddressNew router address

Returns

NameTypeDescription
<none>boolbool

setToucanRegistry

Update the Toucan Contract Registry

function setToucanRegistry(address _registry) external onlyOwner;

Parameters

NameTypeDescription
_registryaddressNew Registry Address

addPool

Add a new carbon pool to retire with helper contract

function addPool(address _poolToken, address _router) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being added
_routeraddressUniswapV2 router to route trades through for non-pool retirements

Returns

NameTypeDescription
<none>boolbool

removePool

Remove a carbon pool to retire with helper contract

function removePool(address _poolToken) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressPool being removed

Returns

NameTypeDescription
<none>boolbool

feeWithdraw

Allow withdrawal of any tokens sent in error

function feeWithdraw(address _token, address _recipient) public onlyOwner returns (bool);

Parameters

NameTypeDescription
_tokenaddressAddress of token to transfer
_recipientaddressAddress where to send tokens.

setMasterAggregator

Allow the contract owner to update the master aggregator proxy address used.

function setMasterAggregator(address _newAddress) external onlyOwner returns (bool);

Parameters

NameTypeDescription
_newAddressaddressNew address for contract needing to be updated.

Returns

NameTypeDescription
<none>boolbool

mintToucanCertificate

function mintToucanCertificate(address _beneficiary, uint256 _index, address _carbonToken) external onlyOwner;

Events

ToucanRetired

=== Event Setup ===

event ToucanRetired(
    address indexed retiringAddress,
    address indexed beneficiaryAddress,
    string beneficiaryString,
    string retirementMessage,
    address indexed carbonPool,
    address carbonToken,
    uint256 retiredAmount
);

PoolAdded

event PoolAdded(address indexed carbonPool, address indexed poolRouter);

PoolRemoved

event PoolRemoved(address indexed carbonPool);

PoolRouterChanged

event PoolRouterChanged(address indexed carbonPool, address indexed oldRouter, address indexed newRouter);

FeeUpdated

event FeeUpdated(uint256 oldFee, uint256 newFee);

MasterAggregatorUpdated

event MasterAggregatorUpdated(address indexed oldAddress, address indexed newAddress);

RegistryUpdated

event RegistryUpdated(address indexed oldAddress, address indexed newAddress);