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.
Documentation
This repo is configured with Foundry to generate documentation for the solidity source files with the forge doc command.
Foundry forge doc generates and builds an mdbook from the natspec comments contained within the Solidity source files.The book.toml
file located in the root folder contains the config settings and the preprocess_summary.py
script allows you to customize the book after it is generated.
The preprocess_summary.py
script is necessary to customize the book after Foundry has generated the book from the natspec comments. This script can also be used to insert additional pages into the book automatically. If you were to modify the book without this script, each time someone ran the build command it will overwrite these changes.
If you have not installed Foundry, follow the guide above before proceeding.
Please follow these rules:
- Annonate your code with proper NatSpec comments
- Before committing code, run the
forge doc --build
in order to build the doc/book - A new mdbook should be manually deployed to the public documentation from the
main
branch each time contracts are verified to block explorers like Polygonscan.
You can run a local version of the documentation by running forge doc --serve
Vercel is configured to deploy previews of the mdbook from docs/book
.
Additional information
Automating the building and deployment of the solidity documentation mdbook can also be achieved in a number of ways, each with their own trade offs.
- Configure github actions to checkout foundry toolchain, build the book, and deploy to github pages. This requires a higher tier github org for multiple pages.
- Configure github actions to checkout foundry toolchain, build the book, and deploy it to Vercel via Vercel CLI. This requires Vercel secrets stored in the repo.
- Configure github actions to checkout foundry toolchain, build the book, and then commit it to the repo and configure Vercel to deploy. This requires Github actions to add commits after each commit.
Note: Vercel lacks a system level dependency required to install foundry to build the book before deploying
Ultimately, it was simpler to document the build process and deploy the public documentation manually as new smart contracts are not deployed frequently enough to warrant automated deployment. These notes were documented in case automatic deployment were to be revisited in the future.
Contents
Contents
- Bridges
- Retire
- DiamondCutFacet
- DiamondLoupeFacet
- DustFacet
- ERC1155ReceiverFacet
- ERC721ReceiverFacet
- MetaTransactionsFacet
- OwnershipFacet
- RetirementQuoter
- TokenFacet
Contents
Contents
RedeemC3PoolFacet
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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token to use in the redemption |
poolToken | address | Pool token to redeem |
amount | uint256 | Amount to redeem |
maxAmountIn | uint256 | Max amount of source token to spend |
fromMode | LibTransfer.From | From Mode for transfering tokens |
toMode | LibTransfer.To | To Mode for where undlerying tokens are sent |
Returns
Name | Type | Description |
---|---|---|
projectTokens | address[] | List of underlying tokens received |
amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token to use in the redemption |
poolToken | address | Pool token to redeem |
maxAmountIn | uint256 | Max amount of source token to spend |
projectTokens | address[] | Underlying tokens to redeem |
amounts | uint256[] | Amounts of underlying tokens to redeem |
fromMode | LibTransfer.From | From Mode for transfering tokens |
toMode | LibTransfer.To | To Mode for where undlerying tokens are sent |
Returns
Name | Type | Description |
---|---|---|
redeemedAmounts | uint256[] | Amounts of underlying tokens redeemed |
RetireC3C3TFacet
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
Name | Type | Description |
---|---|---|
carbonToken | address | Pool token to redeem |
amount | uint256 | Amounts of underlying tokens to redeem |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
carbonToken | address | Pool token to redeem |
amount | uint256 | Amounts of underlying tokens to redeem |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
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
Name | Type | Description |
---|---|---|
projectToken | address | Project token address |
tokenId | uint256 | Token ID for project to retire |
amount | uint256 | Amounts of underlying tokens to redeem |
retiringEntityString | string | String description for the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token to use in the redemption |
poolToken | address | Pool token to redeem |
amount | uint256 | Amount to redeem |
maxAmountIn | uint256 | Max amount of source token to spend |
fromMode | LibTransfer.From | From Mode for transfering tokens |
toMode | LibTransfer.To | To Mode for where undlerying tokens are sent |
Returns
Name | Type | Description |
---|---|---|
projectTokens | address[] | List of underlying tokens received |
amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token to use in the redemption |
poolToken | address | Pool token to redeem |
maxAmountIn | uint256 | Maximum amount of source token to spend |
projectTokens | address[] | Underlying tokens to redeem |
amounts | uint256[] | Amounts of underlying tokens to redeem |
fromMode | LibTransfer.From | From Mode for transfering tokens |
toMode | LibTransfer.To | To Mode for where undlerying tokens are sent |
Returns
Name | Type | Description |
---|---|---|
redeemedAmounts | uint256[] | Amounts of underlying tokens redeemed |
RetireToucanTCO2Facet
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
Name | Type | Description |
---|---|---|
carbonToken | address | Pool token to redeem |
amount | uint256 | Amounts of underlying tokens to redeem |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
carbonToken | address | Pool token to redeem |
amount | uint256 | Amounts of underlying tokens to redeem |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The latest retirement index for the beneficiary address |
toucanRetireExactPuroTCO2
Retires Puro TCO2 directly
function toucanRetireExactPuroTCO2(
address projectToken,
uint256 tokenId,
uint256 amount,
LibRetire.RetireDetails memory details,
LibTransfer.From fromMode
) external nonReentrant returns (uint256 retirementIndex);
Parameters
Name | Type | Description |
---|---|---|
projectToken | address | Puro token to retire |
tokenId | uint256 | Token ID being retired |
amount | uint256 | Amounts of underlying tokens to redeem |
details | LibRetire.RetireDetails | Encoded struct of retirement details needed for the request |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
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
Name | Type | Description |
---|---|---|
sourceToken | address | Source ERC-20 token to use for the retirement |
poolToken | address | Pool token to use for this retirement |
maxAmountIn | uint256 | Maximum amount of source tokens to spend in this retirement |
retireAmount | uint256 | The amount of carbon to retire |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source ERC-20 token to use for the retirement |
poolToken | address | Pool token to use for this retirement |
projectToken | address | Project token to redeem and retire |
maxAmountIn | uint256 | Maximum amount of source tokens to spend in this retirement |
retireAmount | uint256 | The amount of carbon to retire |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
Inherits: ReentrancyGuard
Functions
retireCarbonmarkListing
Retires an exact amount of carbon using default redemption
function retireCarbonmarkListing(
ICarbonmark.CreditListing memory listing,
uint256 maxAmountIn,
uint256 retireAmount,
LibRetire.RetireDetails memory details,
LibTransfer.From fromMode
) external payable nonReentrant returns (uint256 retirementIndex);
Parameters
Name | Type | Description |
---|---|---|
listing | ICarbonmark.CreditListing | |
maxAmountIn | uint256 | Maximum amount of USDC tokens to spend for this retirement |
retireAmount | uint256 | The amount of carbon to retire |
details | LibRetire.RetireDetails | Encoded struct of retirement details needed for the retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
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
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
Name | Type | Description |
---|---|---|
sourceToken | address | Source ERC-20 token to use for the retirement |
poolToken | address | Pool token to use for this retirement |
maxAmountIn | uint256 | Maximum amount of source tokens to spend in this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source ERC-20 token to use for the retirement |
poolToken | address | Pool token to use for this retirement |
projectToken | address | Project token to redeem and retire |
maxAmountIn | uint256 | Maximum amount of source tokens to spend in this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
fromMode | LibTransfer.From | From Mode for transfering tokens |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
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
Name | Type | Description |
---|---|---|
_diamondCut | FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A function call, including function selector and arguments _calldata is executed with delegatecall on _init |
DiamondLoupeFacet
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
_facet | address | The facet address. |
Returns
Name | Type | Description |
---|---|---|
facetFunctionSelectors_ | bytes4[] | facetFunctionSelectors_ |
facetAddresses
Get all the facet addresses used by a diamond.
function facetAddresses() external view override returns (address[] memory facetAddresses_);
Returns
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
_functionSelector | bytes4 | The function selector. |
Returns
Name | Type | Description |
---|---|---|
facetAddress_ | address | The facet address. |
supportsInterface
function supportsInterface(bytes4 _interfaceId) external view override returns (bool);
DustFacet
Inherits: ReentrancyGuard
Author: Cujo
Functions
sendDust
function sendDust() external payable;
ERC1155ReceiverFacet
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
Inherits: ReentrancyGuard, IERC721Receiver
Functions
onERC721Received
function onERC721Received(address, address, uint256 tokenId, bytes memory) external virtual override returns (bytes4);
MetaTransactionsFacet
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
Name | Type | Description |
---|---|---|
user | address | Address to query |
Returns
Name | Type | Description |
---|---|---|
nonce_ | uint256 | The 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
Inherits: IERC173
Functions
transferOwnership
function transferOwnership(address _newOwner) external override;
owner
function owner() external view override returns (address owner_);
RetirementQuoter
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
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
C3SushiInit
State Variables
s
AppStorage internal s;
Functions
init
function init() external;
DiamondInit
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;
DiamondInitCoorest
State Variables
s
AppStorage internal s;
Functions
init
function init() external;
InitProjectTotals
State Variables
s
AppStorage internal s;
Functions
init
function init() external;
_EmptyInit
Functions
init
function init() external;
Contents
- IC3Pool
- IC3ProjectToken
- IC3ProjectFactory
- ICarbonChain
- ICarbonmark
- ICCO2
- ICoorest
- IDiamond
- IDiamondCut
- IDiamondLoupe
- IERC1155Receiver
- IERC165
- IERC173
- IERC721Receiver
- ICarbonContractRegistry
- IProject
- IStaking
- IStakingHelper
- IwsKLIMA
- IKlimaRetirementBond
- IKlimaCarbonRetirements
- IKlimaInfinity
- IToucanPool
- IToucanCarbonOffsets
- IToucanContractRegistry
- IToucanPuroCarbonOffsets
- IBentoBoxMinimal
- ITridentRouter
- ITridentPool
- IUniswapV2Pair
- IUniswapV2Router01
- IUniswapV2Router02
- IWMATIC
IC3Pool
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
Functions
offsetFor
function offsetFor(uint256 amount, address beneficiary, string memory transferee, string memory reason) external;
IC3ProjectFactory
Functions
isTokenExists
function isTokenExists(address _address) external returns (bool);
ICarbonChain
Functions
offsetCarbon
function offsetCarbon(uint256 _carbonTon, string calldata _transactionInfo, string calldata _onBehalfOf) external;
ICarbonmark
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
Name | Type | Description |
---|---|---|
token | address | The token being listed |
amount | uint256 | The amount to be listed |
unitPrice | uint256 | The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000 |
minFillAmount | uint256 | The minimum number of tons needed to be purchased to fill this listing |
deadline | uint256 | The block timestamp at which this listing will expire |
Returns
Name | Type | Description |
---|---|---|
id | bytes32 | The 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
Name | Type | Description |
---|---|---|
id | bytes32 | The listing ID to update |
listingAccount | address | The account that created the listing you are filling |
listingToken | address | The token you are swapping for |
listingUnitPrice | uint256 | The unit price per token to fill the listing |
amount | uint256 | Amount of the listing to fill |
maxCost | uint256 | Maximum 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
Name | Type | Description |
---|---|---|
id | bytes32 | |
account | address | Ethereum address of the account who owns the listing |
token | address | Ethereum address of the token being listing |
tokenId | uint256 | |
remainingAmount | uint256 | Remaining amount that can be filled on this listing |
unitPrice | uint256 | The unit price in USDC of the listing |
ICCO2
Functions
burningPercentage
function burningPercentage() external view returns (uint256);
decimalRatio
function decimalRatio() external view returns (uint256);
ICoorest
Functions
mintPOCC
function mintPOCC(uint256 _amountCO2, string memory _reason, string memory _owner) external payable returns (uint256);
IDiamond
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
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
Name | Type | Description |
---|---|---|
_diamondCut | FacetCut[] | Contains the facet addresses and function selectors |
_init | address | The address of the contract or facet to execute _calldata |
_calldata | bytes | A 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
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
_facet | address | The facet address. |
Returns
Name | Type | Description |
---|---|---|
facetFunctionSelectors_ | bytes4[] | facetFunctionSelectors_ |
facetAddresses
Get all the facet addresses used by a diamond.
function facetAddresses() external view returns (address[] memory facetAddresses_);
Returns
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
_functionSelector | bytes4 | The function selector. |
Returns
Name | Type | Description |
---|---|---|
facetAddress_ | address | The facet address. |
Structs
Facet
These functions are expected to be called frequently by tools.
struct Facet {
address facetAddress;
bytes4[] functionSelectors;
}
IERC1155Receiver
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
Name | Type | Description |
---|---|---|
operator | address | The address which initiated the transfer (i.e. msg.sender) |
from | address | The address which previously owned the token |
id | uint256 | The ID of the token being transferred |
value | uint256 | The amount of tokens being transferred |
data | bytes | Additional data with no specified format |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes4 | bytes4(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
Name | Type | Description |
---|---|---|
operator | address | The address which initiated the batch transfer (i.e. msg.sender) |
from | address | The address which previously owned the token |
ids | uint256[] | An array containing ids of each token being transferred (order and length must match values array) |
values | uint256[] | An array containing amounts of each token being transferred (order and length must match ids array) |
data | bytes | Additional data with no specified format |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes4 | bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) if transfer is allowed |
IERC165
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
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | The interface identifier, as specified in ERC-165 |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IERC173
Functions
owner
Get the address of the owner
function owner() external view returns (address owner_);
Returns
Name | Type | Description |
---|---|---|
owner_ | address | The 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
Name | Type | Description |
---|---|---|
_newOwner | address | The 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
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
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
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
Functions
unstake
function unstake(uint256 _amount, bool _trigger) external;
IStakingHelper
Functions
stake
function stake(uint256 _amount) external;
IwsKLIMA
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
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
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
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
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
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;
standardRegistry
function standardRegistry() external returns (string memory registry);
IToucanContractRegistry
Functions
isValidERC20
function isValidERC20(address erc20) external returns (bool);
IToucanPuroCarbonOffsets
Functions
requestRetirement
function requestRetirement(CreateRetirementRequestParams calldata params) external returns (uint256 requestId);
Structs
CreateRetirementRequestParams
struct CreateRetirementRequestParams {
uint256[] tokenIds;
uint256 amount;
string retiringEntityString;
address beneficiary;
string beneficiaryString;
string retirementMessage;
string beneficiaryLocation;
string consumptionCountryCode;
uint256 consumptionPeriodStart;
uint256 consumptionPeriodEnd;
}
IBentoBoxMinimal
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
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
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
Name | Type | Description |
---|---|---|
data | bytes | ABI-encoded params that the pool requires. |
Returns
Name | Type | Description |
---|---|---|
finalAmountOut | uint256 | The 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
Name | Type | Description |
---|---|---|
data | bytes | ABI-encoded params that the pool requires. |
Returns
Name | Type | Description |
---|---|---|
finalAmountIn | uint256 | The amount of input tokens that are required from the user if the trade is executed. |
IUniswapV2Pair
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
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
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
Inherits: IERC20
Author: Cujo
Functions
deposit
function deposit() external payable;
withdraw
function withdraw(uint256) external;
Contents
Contents
LibC3Carbon
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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
amount | uint256 | Amount of tokens to redeem and retire |
retiringAddress | address | Address initiating this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
projectToken | address | Project token being redeemed |
amount | uint256 | Amount of tokens to redeem and retire |
retiringAddress | address | Address initiating this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
projectToken | address | Project token being redeemed |
amount | uint256 | Amount of tokens to redeem and retire |
retiringAddress | address | Address initiating this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
amount | uint256 | Amount of tokens to redeem and retire |
Returns
Name | Type | Description |
---|---|---|
poolFeeAmount | uint256 | Additional 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
amount | uint256 | Amount of tokens to redeem and retire |
Returns
Name | Type | Description |
---|---|---|
retireAmount | uint256 | Amount 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
amount | uint256 | Amount of tokens to redeem and retire |
toMode | LibTransfer.To | Where to send redeemed tokens to |
Returns
Name | Type | Description |
---|---|---|
allProjectTokens | address[] | Default redeem C3T list from the pool |
amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
projectTokens | address[] | Project tokens to redeem |
amounts | uint256[] | Amounts of the project tokens to redeem |
toMode | LibTransfer.To | Where to send redeemed tokens to |
Returns
Name | Type | Description |
---|---|---|
<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
);
LibCoorestCarbon
Author: must-be-carbon
Handles interaction with the Coorest Pool and child tokens ( CCO2, POCC )
Functions
retireCarbonToken
Retires CCO2
Use this function to retire CCO2.
This function assumes that checks to carbonToken are make higher up in call stack.
It's important to know that Coorest transfers fee portion to it's account & rest amount is burned
function retireCarbonToken(
address carbonToken,
uint256 retireAmount,
uint256 retireAmountWithFee,
LibRetire.RetireDetails memory details
) internal returns (uint256 poccId);
Parameters
Name | Type | Description |
---|---|---|
carbonToken | address | CCO2 token address. |
retireAmount | uint256 | The amount of underlying tokens to retire. |
retireAmountWithFee | uint256 | |
details | LibRetire.RetireDetails |
Returns
Name | Type | Description |
---|---|---|
poccId | uint256 | POCC Certificate Id. |
getSpecificRetirementFee
Calculates the Coorest fee that needs to be added to desired retire amount
Use this function to compute the Coorest fee.
This function assumes that checks to carbonToken are make higher up in call stack
function getSpecificRetirementFee(address carbonToken, uint256 amount) internal view returns (uint256 feeAmount);
Parameters
Name | Type | Description |
---|---|---|
carbonToken | address | CCO2 token address |
amount | uint256 | The amount of underlying tokens to retire. |
Returns
Name | Type | Description |
---|---|---|
feeAmount | uint256 | Fee charged by Coorest. |
getFeePercent
This function fetches fee percent & divider from CCO2 token contract.
function getFeePercent(address carbonToken) private view returns (FeeParams memory feeParams);
Parameters
Name | Type | Description |
---|---|---|
carbonToken | address | CCO2 token address. |
Returns
Name | Type | Description |
---|---|---|
feeParams | FeeParams | Fee percentage & the fee divider. |
Events
CarbonRetired
event CarbonRetired(
LibRetire.CarbonBridge carbonBridge,
address indexed retiringAddress,
string retiringEntityString,
address indexed beneficiaryAddress,
string beneficiaryString,
string retirementMessage,
address indexed carbonPool,
address carbonToken,
uint256 retiredAmount
);
Errors
FeePercentageGreaterThanDivider
error FeePercentageGreaterThanDivider();
FeeRetireDividerIsZero
error FeeRetireDividerIsZero();
RetireAmountIsZero
error RetireAmountIsZero();
Structs
FeeParams
struct FeeParams {
uint256 feeRetireBp;
uint256 feeRetireDivider;
}
LibICRCarbon
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
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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
amount | uint256 | Amounts of the project tokens to retire |
retiringAddress | address | Address initiating this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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
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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
amount | uint256 | Amount of the project token to retire |
retiringAddress | address | Address initiating this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
projectToken | address | Project token to use for this retirement |
amount | uint256 | Amount of the project token to retire |
retiringAddress | address | Address initiating this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
Returns
Name | Type | Description |
---|---|---|
retiredAmount | uint256 | The 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to use for this retirement |
projectToken | address | Project token to use for this retirement |
amount | uint256 | Amount of the project token to retire |
retiringAddress | address | Address initiating this retirement |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
retirePuroTCO2
Creates a Retirement Request for Toucan Puro TCO2s
function retirePuroTCO2(uint256 tokenId, address projectToken, uint256 amount, LibRetire.RetireDetails memory details)
internal;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | Credit token ID to be retired |
projectToken | address | Project token to use for this retirement |
amount | uint256 | Amount of the project token to retire |
details | LibRetire.RetireDetails |
sendRetireCert
Send the ERC-721 retirement certificate received to a beneficiary
function sendRetireCert(address _beneficiary) internal;
Parameters
Name | Type | Description |
---|---|---|
_beneficiary | address | Beneficiary 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to redeem |
amount | uint256 | Amount of TCO2 needed |
Returns
Name | Type | Description |
---|---|---|
poolFeeAmount | uint256 | Number 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to redeem |
amount | uint256 | Amount of pool tokens redeemed |
Returns
Name | Type | Description |
---|---|---|
retireAmount | uint256 | Number 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to redeem |
amount | uint256 | Amount of tokens being redeemed |
toMode | LibTransfer.To | Where to send TCO2 tokens |
Returns
Name | Type | Description |
---|---|---|
projectTokens | address[] | TCO2 token addresses redeemed |
amounts | uint256[] | 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token to redeem |
projectTokens | address[] | Project tokens to redeem |
amounts | uint256[] | Token amounts to redeem |
toMode | LibTransfer.To | Where to send TCO2 tokens |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256[] | redeemedAmounts TCO2 token amounts redeemed |
isValid
function isValid(address token) internal returns (bool);
isPuro
function isPuro(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
);
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
LibApprove
Author: publius
Functions
approveToken
function approveToken(IERC20 token, address spender, uint256 amount) internal;
LibBalance
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
Author: Cujo
Functions
refundMatic
function refundMatic() internal;
LibTransfer
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
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
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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
carbonToken | address | Pool token needed |
sourceAmount | uint256 | Max amount of the source token |
carbonAmount | uint256 | Needed amount of tokens out |
Returns
Name | Type | Description |
---|---|---|
carbonReceived | uint256 | Pool 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
carbonToken | address | Pool token needed |
amount | uint256 | Amount of the source token to swap |
Returns
Name | Type | Description |
---|---|---|
carbonReceived | uint256 | Pool tokens actually received |
returnTradeDust
Return any dust/slippaged amounts still held by the contract
function returnTradeDust(address sourceToken, address poolToken) internal;
Parameters
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
poolToken | address | Pool token used |
swapToKlimaFromUsdc
Swaps a given amount of USDC for KLIMA using Sushiswap
function swapToKlimaFromUsdc(uint256 sourceAmount, uint256 klimaAmount) internal returns (uint256 klimaReceived);
Parameters
Name | Type | Description |
---|---|---|
sourceAmount | uint256 | Amount of USDC to swap |
klimaAmount | uint256 | Amount of KLIMA to swap for |
Returns
Name | Type | Description |
---|---|---|
klimaReceived | uint256 | Amount 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
sourceAmount | uint256 | Amount of source token to swap |
klimaAmount | uint256 | Amount of KLIMA to swap for |
Returns
Name | Type | Description |
---|---|---|
klimaReceived | uint256 | Amount 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
carbonToken | address | Carbon token to receive |
sourceAmount | uint256 | Amount of source token to swap |
carbonAmount | uint256 | Amount of carbon token needed |
Returns
Name | Type | Description |
---|---|---|
carbonRecieved | uint256 | Amount 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
carbonToken | address | Pool token used |
amount | uint256 | Amount of carbon tokens needed |
Returns
Name | Type | Description |
---|---|---|
sourceNeeded | uint256 | Total 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
carbonToken | address | Pool token used |
amount | uint256 | Amount of carbon tokens needed |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
carbonToken | address | Pool token used |
amount | uint256 | Amount of carbon tokens needed |
Returns
Name | Type | Description |
---|---|---|
sourceNeeded | uint256 | Total 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
Name | Type | Description |
---|---|---|
sourceToken | address | Source token provided to swap |
carbonToken | address | Pool token used |
amount | uint256 | Amount of carbon tokens needed |
Returns
Name | Type | Description |
---|---|---|
amountOut | uint256 | Amount 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
Name | Type | Description |
---|---|---|
dex | uint8 | Identifier for which DEX to use |
router | address | Router for the swap |
path | address[] | Trade path to use |
maxAmountIn | uint256 | Max amount of source tokens to swap |
amount | uint256 | Total pool tokens needed |
Returns
Name | Type | Description |
---|---|---|
amountOut | uint256 | Total 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
Name | Type | Description |
---|---|---|
dex | uint8 | Identifier for which DEX to use |
router | address | Router for the swap |
path | address[] | Trade path to use |
amount | uint256 | Amount of tokens to swap |
Returns
Name | Type | Description |
---|---|---|
amountOut | uint256 | Total 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
Name | Type | Description |
---|---|---|
dex | uint8 | Identifier for which DEX to use |
router | address | Router for the swap |
path | address[] | Trade path to use |
amount | uint256 | Total pool tokens needed |
Returns
Name | Type | Description |
---|---|---|
amountIn | uint256 | Total 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
Name | Type | Description |
---|---|---|
dex | uint8 | Identifier for which DEX to use |
router | address | Router for the swap |
path | address[] | Trade path to use |
amount | uint256 | Total source tokens spent |
Returns
Name | Type | Description |
---|---|---|
amountOut | uint256 | Total pool tokens swapped |
LibTreasurySwap
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
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
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
Author: Publius
Functions
diamondStorage
function diamondStorage() internal pure returns (AppStorage storage ds);
LibDiamond
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
Author: Cujo
Functions
toWrappedAmount
Returns wsKLIMA amount for provided sKLIMA amount
function toWrappedAmount(uint256 amount) internal view returns (uint256 wrappedAmount);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | sKLIMA provided |
Returns
Name | Type | Description |
---|---|---|
wrappedAmount | uint256 | wsKLIMA amount |
toUnwrappedAmount
Returns sKLIMA amount for provided wsKLIMA amount
function toUnwrappedAmount(uint256 amount) internal view returns (uint256 unwrappedAmount);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | wsKLIMA provided |
Returns
Name | Type | Description |
---|---|---|
unwrappedAmount | uint256 | sKLIMA amount |
unwrapKlima
Unwraps and unstakes provided wsKLIMA amount
function unwrapKlima(uint256 amount) internal returns (uint256 unwrappedAmount);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | wsKLIMA provided |
Returns
Name | Type | Description |
---|---|---|
unwrappedAmount | uint256 | Final KLIMA amount |
unstakeKlima
Unstakes provided sKLIMA amount
function unstakeKlima(uint256 amount) internal;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | sKLIMA provided |
wrapKlima
Stakes and wraps provided KLIMA amount
function wrapKlima(uint256 amount) internal returns (uint256 wrappedAmount);
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | KLIMA provided |
Returns
Name | Type | Description |
---|---|---|
wrappedAmount | uint256 | Final wsKLIMA amount |
stakeKlima
Stakes provided KLIMA amount
function stakeKlima(uint256 amount) internal;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | KLIMA provided |
LibMeta
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_);
addressToString
Converts an address to a string representation.
function addressToString(address _address) internal pure returns (string memory);
Parameters
Name | Type | Description |
---|---|---|
_address | address | The address to convert. |
Returns
Name | Type | Description |
---|---|---|
<none> | string | The string representation of the address. |
LibRetire
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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token used to retire |
amount | uint256 | The amount of carbon to retire |
retiringAddress | address | |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token used to retire |
projectToken | address | Project token being retired |
amount | uint256 | The amount of carbon to retire |
retiringAddress | address | |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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
Name | Type | Description |
---|---|---|
creditToken | address | Pool token used to retire |
tokenId | uint256 | |
amount | uint256 | The amount of carbon to retire |
retiringAddress | address | |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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, RetireDetails memory details)
internal;
Parameters
Name | Type | Description |
---|---|---|
creditToken | address | Credit token used to retire |
tokenId | uint256 | Token Id for the credit (if applicable) |
amount | uint256 | The amount of carbon to retire |
details | RetireDetails | Encoded struct of retirement details needed for the 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token used to retire |
projectToken | address | Project token being retired |
amount | uint256 | The amount of carbon to retire |
retiringAddress | address | |
retiringEntityString | string | String description of the retiring entity |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String message for this specific retirement |
Returns
Name | Type | Description |
---|---|---|
redeemedAmount | uint256 | Number of pool tokens redeemed |
getTotalCarbon
Returns the total carbon needed fee included
function getTotalCarbon(uint256 retireAmount) internal view returns (uint256 totalCarbon);
Parameters
Name | Type | Description |
---|---|---|
retireAmount | uint256 | Pool token used to retire |
Returns
Name | Type | Description |
---|---|---|
totalCarbon | uint256 | Total pool token needed |
getTotalCarbonSpecific
Returns the total carbon needed fee included
function getTotalCarbonSpecific(address poolToken, uint256 retireAmount) internal view returns (uint256 totalCarbon);
Parameters
Name | Type | Description |
---|---|---|
poolToken | address | Pool token used to retire |
retireAmount | uint256 | Amount of carbon wanting to retire |
Returns
Name | Type | Description |
---|---|---|
totalCarbon | uint256 | Total 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
Name | Type | Description |
---|---|---|
carbonAmount | uint256 | Amount being retired |
Returns
Name | Type | Description |
---|---|---|
fee | uint256 | Total 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
Name | Type | Description |
---|---|---|
poolToken | address | Pool token used to retire |
projectToken | address | Pool token used to retire |
amount | uint256 | Amount of carbon wanting to retire |
beneficiaryAddress | address | 0x address for the beneficiary |
beneficiaryString | string | String description of the beneficiary |
retirementMessage | string | String 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;
string beneficiaryLocation;
string consumptionCountryCode;
uint256 consumptionPeriodStart;
uint256 consumptionPeriodEnd;
}
Enums
CarbonBridge
enum CarbonBridge {
TOUCAN,
MOSS,
C3,
ICR,
COOREST
}
Contents
ConstantsGetter
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_bridged
function usdc_bridged() 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);
coorestPool
function coorestPool() external pure returns (address);
coorestPoCCToken
function coorestPoCCToken() external pure returns (address);
coorestCCO2Token
function coorestCCO2Token() external pure returns (address);
CoorestLibraryMock
Functions
getSpecificRetirementFee
function getSpecificRetirementFee(address carbonToken, uint256 amount) public returns (uint256);
Account
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
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
Name | Type | Description |
---|---|---|
tokenId | uint256 | The last tokenId received from transferSingle |
value | uint256 | The last value received from transferSingle |
ids | uint256[] | The last tokenIds received from transferBatch |
values | uint256[] | The last values received from transferBatch |
AppStorage
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
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_BRIDGED
address private constant USDC_BRIDGED = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174;
USDC
address private constant USDC = 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359;
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;
COOREST_POOL
address constant COOREST_POOL = 0x363ae9B7Dbf55c0956A74C3be4ed0996d277A8BE;
COOREST_POCC_TOKEN
address constant COOREST_POCC_TOKEN = 0x51cF819352FC536aD8A84214922615C160BB497D;
COOREST_CCO2_TOKEN
address constant COOREST_CCO2_TOKEN = 0x82B37070e43C1BA0EA9e2283285b674eF7f1D4E2;
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_bridged
function usdc_bridged() 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);
coorestPool
function coorestPool() internal pure returns (address);
coorestPoCCToken
function coorestPoCCToken() internal pure returns (address);
coorestCCO2Token
function coorestCCO2Token() internal pure returns (address);
Diamond
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
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
- interfaces
- keepers
- IOwnable
- Ownable
- IUniswapV2Pair
- SafeMathUniswap
- UniswapV2Library
- TransferHelper
- IUniswapV2Router01
- IUniswapV2Router02
- IUniswapV2Factory
- IERC20Uniswap
- IWETH
- UniswapV2Router02
- SushiswapGreenSwapWrapper
- IKlimaRetirementAggregator
- IWrappedAsset
- SwapRetirementHolder
- testETHSender
Contents
IUniswapV2Router01
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
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
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
Inherits: KeeperBase, KeeperCompatibleInterface
KeeperCompatibleInterface
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
Name | Type | Description |
---|---|---|
checkData | bytes | specified 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
Name | Type | Description |
---|---|---|
upkeepNeeded | bool | boolean to indicate whether the keeper should call performUpkeep or not. |
performData | bytes | bytes 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
Name | Type | Description |
---|---|---|
performData | bytes | is 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
Functions
manager
function manager() external view returns (address);
renounceManagement
function renounceManagement() external;
pushManagement
function pushManagement(address newOwner_) external;
pullManagement
function pullManagement() external;
Ownable
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
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
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
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
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
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
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
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
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
Functions
deposit
function deposit() external payable;
transfer
function transfer(address to, uint256 value) external returns (bool);
withdraw
function withdraw(uint256) external;
UniswapV2Router02
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
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
Functions
retireCarbon
function retireCarbon(
address _sourceToken,
address _poolToken,
uint256 _amount,
bool _amountInCarbon,
address _beneficiaryAddress,
string memory _beneficiaryString,
string memory _retirementMessage
) external;
IWrappedAsset
Functions
deposit
function deposit() external payable;
balanceOf
function balanceOf(address user) external;
approve
function approve(address guy, uint256 wad) external returns (bool);
SwapRetirementHolder
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
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
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
Name | Type | Description |
---|---|---|
token | address | The address of the token to fund the retirement bonds with. |
amount | uint256 | The 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
Name | Type | Description |
---|---|---|
token | address | The 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
Name | Type | Description |
---|---|---|
_bondContract | address | The address of the new retirement bond contract. |
updateMaxReservePercent
Updates the maximum reserve percentage allowed.
function updateMaxReservePercent(uint256 _maxReservePercent) external onlyDAO;
Parameters
Name | Type | Description |
---|---|---|
_maxReservePercent | uint256 | The new maximum reserve percentage allowed. 500 = 5%. |
Events
MaxPercentUpdated
event MaxPercentUpdated(uint256 oldMax, uint256 newMax);
Contents
CarbonRetirementBondDepository
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
Name | Type | Description |
---|---|---|
poolToken | address | The pool token address. |
poolAmount | uint256 | The 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
Name | Type | Description |
---|---|---|
poolToken | address | The pool token address. |
retireAmount | uint256 | The amount of carbon to retire. |
retiringEntityString | string | The string representing the retiring entity. |
beneficiaryAddress | address | The address of the beneficiary. |
beneficiaryString | string | The string representing the beneficiary. |
retirementMessage | string | The message for the retirement. |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
poolToken | address | The pool token address. |
projectToken | address | The project token to retire. |
retireAmount | uint256 | The amount of carbon to retire. |
retiringEntityString | string | The string representing the retiring entity. |
beneficiaryAddress | address | The address of the beneficiary. |
beneficiaryString | string | The string representing the beneficiary. |
retirementMessage | string | The message for the retirement. |
Returns
Name | Type | Description |
---|---|---|
retirementIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
poolToken | address | The 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
Name | Type | Description |
---|---|---|
poolToken | address | The 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
Name | Type | Description |
---|---|---|
poolToken | address | The address of the pool token to update the maximum slippage percentage for. |
_maxSlippage | uint256 | The new maximum slippage percentage. |
updateDaoFee
Updates the DAO fee for a specified pool token.
function updateDaoFee(address poolToken, uint256 _daoFee) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
poolToken | address | The address of the pool token to update the DAO fee for. |
_daoFee | uint256 | The 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
Name | Type | Description |
---|---|---|
poolToken | address | The pool token for which to set the reference token. |
referenceToken | address | The 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
Name | Type | Description |
---|---|---|
allocator | address | The 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
Name | Type | Description |
---|---|---|
poolAmount | uint256 | The amount of pool tokens to retire. |
poolToken | address | The address of the pool token to retire. |
Returns
Name | Type | Description |
---|---|---|
klimaNeeded | uint256 | The 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
Name | Type | Description |
---|---|---|
totalKlima | uint256 | The total amount of KLIMA tokens to transfer and burn. |
poolToken | address | The 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
Name | Type | Description |
---|---|---|
poolToken | address | The address of the pool token to get the market quote for. |
amountOut | uint256 | The amount of pool tokens to get the market quote for. |
Returns
Name | Type | Description |
---|---|---|
currentPrice | uint256 | The 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
- IKlimaTreasury
- IKlimaRetirementBond
- IRetirementBondAllocator
- IKlimaInfinity
- IUniswapV2Pair
- IwsKLIMA
IKlima
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
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
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
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
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
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
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
- SafeMath
- Address
- IERC20
- ITreasury
- IPOLY
- ICirculatingOHM
- AltExercisepOLY
- SafeERC20
- SafeMath
- Address
- IERC20
- ITreasury
- IPKLIMA
- IOldClaimContract
- ICirculatingKLIMA
- ExercisepKLIMA
SafeERC20
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
Name | Type | Description |
---|---|---|
token | IERC20 | The token targeted by the call. |
data | bytes | The call data (encoded using abi.encode or one of its variants). |
SafeMath
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
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
withdata
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
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
Functions
deposit
function deposit(uint256 _amount, address _token, uint256 _profit) external returns (uint256);
IPOLY
Functions
isApprovedSeller
function isApprovedSeller(address _address) external view returns (bool);
ICirculatingOHM
Functions
OHMCirculatingSupply
function OHMCirculatingSupply() external view returns (uint256);
AltExercisepOLY
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
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
Name | Type | Description |
---|---|---|
token | IERC20 | The token targeted by the call. |
data | bytes | The call data (encoded using abi.encode or one of its variants). |
SafeMath
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
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
withdata
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
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
Functions
deposit
function deposit(uint256 _amount, address _token, uint256 _profit) external returns (uint256);
IPKLIMA
Functions
burnFrom
function burnFrom(address account_, uint256 amount_) external;
IOldClaimContract
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
Functions
KLIMACirculatingSupply
function KLIMACirculatingSupply() external view returns (uint256);
ExercisepKLIMA
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
- SafeMath
- IERC20
- Address
- IPolicy
- Policy
- ITreasury
- Distributor
- SafeMath
- IERC20
- Address
- SafeERC20
- IOwnable
- Ownable
- IsKLIMA
- IWarmup
- IDistributor
- KlimaStaking
- IERC20
- IStaking
- StakingHelper
- IERC20
- StakingWarmup
SafeERC20
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
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
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
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
Functions
policy
function policy() external view returns (address);
renouncePolicy
function renouncePolicy() external;
pushPolicy
function pushPolicy(address newPolicy_) external;
pullPolicy
function pullPolicy() external;
Policy
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
Functions
mintRewards
function mintRewards(address _recipient, uint256 _amount) external;
Distributor
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
Name | Type | Description |
---|---|---|
_rate | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
nextRewardFor
view function for next reward for specified address
function nextRewardFor(address _recipient) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
addRecipient
adds recipient for distributions
function addRecipient(address _recipient, uint256 _rewardRate) external onlyPolicy;
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | address |
_rewardRate | uint256 | uint |
removeRecipient
removes recipient for distributions
function removeRecipient(uint256 _index, address _recipient) external onlyPolicy;
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | uint |
_recipient | address | address |
setAdjustment
set adjustment info for a collector's reward rate
function setAdjustment(uint256 _index, bool _add, uint256 _rate, uint256 _target) external onlyPolicy;
Parameters
Name | Type | Description |
---|---|---|
_index | uint256 | uint |
_add | bool | bool |
_rate | uint256 | uint |
_target | uint256 | uint |
Structs
Info
struct Info {
uint256 rate;
address recipient;
}
Adjust
struct Adjust {
bool add;
uint256 rate;
uint256 target;
}
SafeMath
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
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
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
withdata
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
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
Name | Type | Description |
---|---|---|
token | IERC20 | The token targeted by the call. |
data | bytes | The call data (encoded using abi.encode or one of its variants). |
IOwnable
Functions
manager
function manager() external view returns (address);
renounceManagement
function renounceManagement() external;
pushManagement
function pushManagement(address newOwner_) external;
pullManagement
function pullManagement() external;
Ownable
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
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
Functions
retrieve
function retrieve(address staker_, uint256 amount_) external;
IDistributor
Functions
distribute
function distribute() external returns (bool);
KlimaStaking
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
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_recipient | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
claim
retrieve sKLIMA from warmup
function claim(address _recipient) public;
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | address |
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
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_trigger | bool | bool |
index
returns the sKLIMA index, which tracks rebase growth
function index() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
rebase
trigger rebase if epoch over
function rebase() public;
contractBalance
returns contract KLIMA holdings, including bonuses provided
function contractBalance() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
giveLockBonus
provide bonus to locked staking contract
function giveLockBonus(uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
returnLockBonus
reclaim bonus from locked staking contract
function returnLockBonus(uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
setContract
sets the contract address for LP staking
function setContract(CONTRACTS _contract, address _address) external onlyManager;
Parameters
Name | Type | Description |
---|---|---|
_contract | CONTRACTS | address |
_address | address |
setWarmup
set warmup period for new stakers
function setWarmup(uint256 _warmupPeriod) external onlyManager;
Parameters
Name | Type | Description |
---|---|---|
_warmupPeriod | uint256 | uint |
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
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
Functions
stake
function stake(uint256 _amount, address _recipient) external returns (bool);
claim
function claim(address _recipient) external;
StakingHelper
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
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
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
- IERC20
- KlimaCirculatingSupplyContract
- IBondCalculator
- IERC20Mintable
- IKLIMAERC20
- SafeERC20
- IERC20
- IOwnable
- Ownable
- Address
- SafeMath
- KlimaTreasury
SafeMath
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
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
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
Functions
valuation
function valuation(address pair_, uint256 amount_) external view returns (uint256 _value);
markdown
function markdown(address _pair) external view returns (uint256);
IERC20Mintable
Functions
mint
function mint(uint256 amount_) external;
mint
function mint(address account_, uint256 ammount_) external;
IKLIMAERC20
Functions
burnFrom
function burnFrom(address account_, uint256 amount_) external;
SafeERC20
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
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
Functions
manager
function manager() external view returns (address);
renounceManagement
function renounceManagement() external;
pushManagement
function pushManagement(address newOwner_) external;
pullManagement
function pullManagement() external;
Ownable
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
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
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
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
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
_profit | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
send_ | uint256 | uint |
withdraw
allow approved address to burn KLIMA for reserves
function withdraw(uint256 _amount, address _token) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
incurDebt
allow approved address to borrow reserves
function incurDebt(uint256 _amount, address _token) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
repayDebtWithReserve
allow approved address to repay borrowed reserves with reserves
function repayDebtWithReserve(uint256 _amount, address _token) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
_token | address | address |
repayDebtWithKLIMA
allow approved address to repay borrowed reserves with KLIMA
function repayDebtWithKLIMA(uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
manage
allow approved address to withdraw assets
function manage(address _token, uint256 _amount) external;
Parameters
Name | Type | Description |
---|---|---|
_token | address | address |
_amount | uint256 | uint |
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
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
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
Name | Type | Description |
---|---|---|
_token | address | address |
_amount | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
value_ | uint256 | uint |
queue
queue address to change boolean in mapping
function queue(MANAGING _managing, address _address) external onlyManager returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_managing | MANAGING | MANAGING |
_address | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
toggle
verify queue then set boolean in mapping
function toggle(MANAGING _managing, address _address, address _calculator) external onlyManager returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_managing | MANAGING | MANAGING |
_address | address | address |
_calculator | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
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
Name | Type | Description |
---|---|---|
queue_ | mapping(address => uint256) | mapping( address => uint ) |
status_ | mapping(address => bool) | mapping( address => bool ) |
_address | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
listContains
checks array to ensure against duplicate
function listContains(address[] storage _list, address _token) internal view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_list | address[] | address[] |
_token | address | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
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
- EnumerableSet
- IERC20
- SafeMath
- ERC20
- Counters
- IERC2612Permit
- ERC20Permit
- IOwnable
- Ownable
- VaultOwned
- TWAPOracleUpdater
- Divine
- KlimaToken
- SafeMath
- Address
- IOwnable
- Ownable
- IERC20
- ERC20
- Counters
- IERC2612Permit
- ERC20Permit
- sKlima
- SafeMath
- Address
- IERC20
- ERC20
- Counters
- IERC2612Permit
- ERC20Permit
- IOwnable
- Ownable
- sKLIMAv2
- IERC20
- SafeMath
- Address
- ERC20
- SafeERC20
- IsKLIMA
- wsKLIMA
ITWAPOracle
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
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
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
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
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
andrecipient
cannot be the zero address.sender
must have a balance of at leastamount
.- the caller must have allowance for
sender
's tokens of at leastamount
.*
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 leastsubtractedValue
.*
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 leastamount
.*
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 leastamount
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
andto
are both non-zero,amount
offrom
's tokens will be to transferred toto
. - when
from
is zero,amount
tokens will be minted forto
. - when
to
is zero,amount
offrom
's tokens will be burned. from
andto
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
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
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
ands
must be a validsecp256k1
signature fromowner
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
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
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
public
virtual
override;
nonces
function nonces(address owner) public view override returns (uint256);
IOwnable
Functions
owner
function owner() external view returns (address);
renounceOwnership
function renounceOwnership() external;
transferOwnership
function transferOwnership(address newOwner_) external;
Ownable
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
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
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
Inherits: TWAPOracleUpdater
Functions
constructor
constructor(string memory name_, string memory symbol_, uint8 decimals_) TWAPOracleUpdater(name_, symbol_, decimals_);
KlimaToken
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
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
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
withdata
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
Functions
owner
function owner() external view returns (address);
renounceOwnership
function renounceOwnership() external;
transferOwnership
function transferOwnership(address newOwner_) external;
Ownable
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
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
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
andrecipient
cannot be the zero address.sender
must have a balance of at leastamount
.- the caller must have allowance for
sender
's tokens of at leastamount
.*
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 leastsubtractedValue
.*
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 leastamount
.*
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 leastamount
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
andto
are both non-zero,amount
offrom
's tokens will be to transferred toto
. - when
from
is zero,amount
tokens will be minted forto
. - when
to
is zero,amount
offrom
's tokens will be burned. from
andto
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
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
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
ands
must be a validsecp256k1
signature fromowner
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
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
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
public
virtual
override;
nonces
function nonces(address owner) public view override returns (uint256);
sKlima
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
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
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
withdata
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
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
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
andrecipient
cannot be the zero address.sender
must have a balance of at leastamount
.- the caller must have allowance for
sender
's tokens of at leastamount
.*
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 leastsubtractedValue
.*
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 leastamount
.*
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 leastamount
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
andto
are both non-zero,amount
offrom
's tokens will be to transferred toto
. - when
from
is zero,amount
tokens will be minted forto
. - when
to
is zero,amount
offrom
's tokens will be burned. from
andto
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
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
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
ands
must be a validsecp256k1
signature fromowner
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
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
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
public
virtual
override;
nonces
function nonces(address owner) public view override returns (uint256);
IOwnable
Functions
manager
function manager() external view returns (address);
renounceManagement
function renounceManagement() external;
pushManagement
function pushManagement(address newOwner_) external;
pullManagement
function pullManagement() external;
Ownable
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
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
Name | Type | Description |
---|---|---|
profit_ | uint256 | uint256 |
epoch_ | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 |
_storeRebase
emits event with data about rebase
function _storeRebase(uint256 previousCirculating_, uint256 profit_, uint256 epoch_) internal returns (bool);
Parameters
Name | Type | Description |
---|---|---|
previousCirculating_ | uint256 | uint |
profit_ | uint256 | uint |
epoch_ | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
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
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
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
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
withdata
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
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
andrecipient
cannot be the zero address.sender
must have a balance of at leastamount
.- the caller must have allowance for
sender
's tokens of at leastamount
.*
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 leastsubtractedValue
.*
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 leastamount
.*
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 leastamount
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
andto
are both non-zero,amount
offrom
's tokens will be to transferred toto
. - when
from
is zero,amount
tokens will be minted forto
. - when
to
is zero,amount
offrom
's tokens will be burned. from
andto
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
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
Name | Type | Description |
---|---|---|
token | IERC20 | The token targeted by the call. |
data | bytes | The call data (encoded using abi.encode or one of its variants). |
IsKLIMA
Functions
index
function index() external view returns (uint256);
wsKLIMA
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
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
unwrap
unwrap sKLIMA
function unwrap(uint256 _amount) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
wKLIMATosKLIMA
converts wKLIMA amount to sKLIMA
function wKLIMATosKLIMA(uint256 _amount) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
sKLIMATowKLIMA
converts sKLIMA amount to wKLIMA
function sKLIMATowKLIMA(uint256 _amount) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | uint |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint |
Contents
- AlchemistKlimaUpgradeable
- AlphaKlimaUpgradeable
- KlimaIDONFT
- PreKlimaTokenUpgradeable
- PreKlimaTokenUpgradeableChild
AlchemistKlimaUpgradeable
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
Inherits: ERC20PresetFixedSupplyUpgradeable, OwnableUpgradeable
Functions
constructor
constructor();
initialize
function initialize() public initializer;
__AlphaKlimaUpgradeable_init
function __AlphaKlimaUpgradeable_init(address _Klimadmin) internal;
KlimaIDONFT
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
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
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
Name | Type | Description |
---|---|---|
user | address | user address for whom deposit is being done |
depositData | bytes | abi 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
Name | Type | Description |
---|---|---|
amount | uint256 | amount of tokens to withdraw |
Contents
- interfaces
- KlimaCarbonRetirements
- KlimaRetirementAggregator
- RetireC3Carbon
- RetireMossCarbon
- RetireToucanCarbon
Contents
- IBentoBoxMinimal
- IC3Pool
- IC3ProjectToken
- ICarbonChain
- IKlimaCarbonRetirements
- IKlimaInfinity
- IKlimaRetirementAggregator
- IRetireBridgeCommon
- IRetireC3Carbon
- IRetireMossCarbon
- IRetireToucanCarbon
- IStaking
- IStakingHelper
- IToucanCarbonOffsets
- IToucanContractRegistry
- IToucanPool
- ITridentPool
- ITridentRouter
- IUniswapV2Pair
- IUniswapV2Router01
- IUniswapV2Router02
- IwsKLIMA
IBentoBoxMinimal
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
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
Functions
offsetFor
function offsetFor(uint256 amount, address beneficiary, string memory transferee, string memory reason) external;
ICarbonChain
Functions
offsetCarbon
function offsetCarbon(uint256 _carbonTon, string calldata _transactionInfo, string calldata _onBehalfOf) external;
IKlimaCarbonRetirements
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
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
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
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
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
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
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
Functions
unstake
function unstake(uint256 _amount, bool _trigger) external;
IStakingHelper
Functions
stake
function stake(uint256 _amount) external;
IToucanCarbonOffsets
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
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
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
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
Name | Type | Description |
---|---|---|
data | bytes | ABI-encoded params that the pool requires. |
Returns
Name | Type | Description |
---|---|---|
finalAmountOut | uint256 | The 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
Name | Type | Description |
---|---|---|
data | bytes | ABI-encoded params that the pool requires. |
Returns
Name | Type | Description |
---|---|---|
finalAmountIn | uint256 | The amount of input tokens that are required from the user if the trade is executed. |
ITridentRouter
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
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
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
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
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
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
Name | Type | Description |
---|---|---|
_retiree | address | Address of the retiree. Not the address of a helper contract. |
_pool | address | Address of the carbon pool token. |
_amount | uint256 | Number of tons offset. Expected is with 18 decimals. |
_beneficiaryString | string | String that can be used to describe the beneficiary |
_retirementMessage | string | String for specific retirement message if needed. |
getUnclaimedTotal
Return any unclaimed NFT totals for an address
function getUnclaimedTotal(address _minter) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_minter | address | Address of user trying to mint. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
_minter | address | Address of the user trying to mint. |
_amount | uint256 | Amount 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
Name | Type | Description |
---|---|---|
_retiree | address | Address that retired the offsets. |
_index | uint256 | Index of all retirements made. Starts at 0. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | Returns 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
Name | Type | Description |
---|---|---|
_retiree | address | Address that performed the retirement. |
_pool | address | Address of the pool token. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Int 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
Name | Type | Description |
---|---|---|
_retiree | address | Address that performed the retirement. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Int 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
Name | Type | Description |
---|---|---|
_helper | address | Address 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
Name | Type | Description |
---|---|---|
_helper | address | Address 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
Name | Type | Description |
---|---|---|
_minter | address | Address 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
Name | Type | Description |
---|---|---|
_minter | address | Address 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
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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific 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
Name | Type | Description |
---|---|---|
_initiator | address | The original sender of the transaction. |
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_retiree | address | Address 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_carbonList | address[] |
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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_retiree | address | Address of the initiator where source tokens originated. |
_carbonList | address[] |
_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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_selection | uint256 | Int to indicate which address is being updated. |
_newAddress | address | New address for contract needing to be updated. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
addPool
Add a new carbon pool to retire with helper contract.
function addPool(address _poolToken, uint256 _poolBridge) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being added. |
_poolBridge | uint256 | Int ID of the bridge used for this token. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
removePool
Remove a carbon pool to retire.
function removePool(address _poolToken) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being removed. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
setBridgeHelper
Set the helper contract to be used with a carbon bridge.
function setBridgeHelper(uint256 _bridgeID, address _helper) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_bridgeID | uint256 | Int ID of the bridge. |
_helper | address | Helper contract to use with this bridge. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
feeWithdraw
Allow withdrawal of any tokens sent in error
function feeWithdraw(address _token, address _recipient) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of token to transfer |
_recipient | address |
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
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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_retiree | address | The 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
Name | Type | Description |
---|---|---|
_totalAmount | uint256 | Total pool tokens being retired. Expected uint with 18 decimals. |
_beneficiaryAddress | address | Address of the beneficiary if different than sender. Value is set to _msgSender() if null is sent. |
_beneficiaryString | string | String that can be used to describe the beneficiary |
_retirementMessage | string | String for specific retirement message if needed. |
_poolToken | address | Address 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_retiree | address | The original sender of the transaction. |
_carbonList | address[] | 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_retiree | address | The original sender of the transaction. To return trade dust. |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
_totalAmount | uint256 | Total pool tokens being retired. Expected uint with 18 decimals. |
_beneficiaryAddress | address | Address of the beneficiary if different than sender. Value is set to _msgSender() if null is sent. |
_beneficiaryString | string | String that can be used to describe the beneficiary |
_retirementMessage | string | String for specific retirement message if needed. |
_poolToken | address | Address of pool token being used to retire. |
_carbonList | address[] | 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_specificRetire | bool |
_stakedToUnstaked
Unwraps/unstakes any KLIMA needed to regular KLIMA.
function _stakedToUnstaked(address _klimaType, uint256 _amountIn) internal returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_klimaType | address | Address of the KLIMA type being used. |
_amountIn | uint256 | Amount of total KLIMA needed. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_carbonAmount | uint256 | Total carbon needed. |
_amountIn | uint256 | Maximum amount of source tokens. |
_retiree | address | Initiator 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_amountIn | uint256 | Total source tokens to swap. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_amounts | uint256[] | The amounts resulting from the Uniswap tradeTokensForExactTokens. |
_sourceToken | address | Address of token being used to purchase the pool token. |
_amountIn | uint256 | Total source tokens initially provided. |
_retiree | address | Address 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
Name | Type | Description |
---|---|---|
_poolToken | address | Address of pool token being used. |
_poolAmount | uint256 | Amount of tokens being retired. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | poolFeeAmount 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_poolAmount | uint256 | Amount of tokens being retired. |
_specificRetire | bool |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Tuple 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
_amount | uint256 | New fee amount, in .1% increments. 10 = 1% |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
setPoolRouter
Update the router for an existing pool
function setPoolRouter(address _poolToken, address _router) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being updated |
_router | address | New router address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
addPool
Add a new carbon pool to retire with helper contract
function addPool(address _poolToken, address _router, address _tridentPool) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being added |
_router | address | UniswapV2 router to route trades through for non-pool retirements |
_tridentPool | address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
removePool
Remove a carbon pool to retire with helper contract
function removePool(address _poolToken) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being removed |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
feeWithdraw
Allow withdrawal of any tokens sent in error
function feeWithdraw(address _token, address _recipient) public onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of token to transfer |
_recipient | address | Address 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
Name | Type | Description |
---|---|---|
_newAddress | address | New address for contract needing to be updated. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
setTrident
Allow the contract owner to update the SushiSwap Trident AMM addresses.
function setTrident(address _tridentRouter, address _bento) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_tridentRouter | address | New address for Trident router. |
_bento | address | New 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
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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_retiree | address | The 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
Name | Type | Description |
---|---|---|
_totalAmount | uint256 | Total pool tokens being retired. Expected uint with 18 decimals. |
_beneficiaryAddress | address | Address of the beneficiary if different than sender. Value is set to _msgSender() if null is sent. |
_beneficiaryString | string | String that can be used to describe the beneficiary |
_retirementMessage | string | String for specific retirement message if needed. |
_poolToken | address | Address 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool 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
Name | Type | Description |
---|---|---|
_klimaType | address | Address of the KLIMA type being used. |
_amountIn | uint256 | Amount of total KLIMA needed. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_poolAmount | uint256 | Amount of tokens being retired. |
_specificRetire | bool |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Tuple 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_carbonAmount | uint256 | Total carbon needed. |
_amountIn | uint256 | Maximum amount of source tokens. |
_retiree | address | Initiator 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_amountIn | uint256 | Total source tokens to swap. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_amounts | uint256[] | The amounts resulting from the Uniswap tradeTokensForExactTokens. |
_sourceToken | address | Address of token being used to purchase the pool token. |
_amountIn | uint256 | Total source tokens initially provided. |
_retiree | address | Address where to send the dust. |
setFeeAmount
Set the fee for the helper
function setFeeAmount(uint256 _amount) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | New fee amount, in .1% increments. 10 = 1% |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
setPoolRouter
Update the router for an existing pool
function setPoolRouter(address _poolToken, address _router) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being updated |
_router | address | New router address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
addPool
Add a new carbon pool to retire with helper contract
function addPool(address _poolToken, address _router) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being added |
_router | address | UniswapV2 router to route trades through for non-pool retirements |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
removePool
Remove a carbon pool to retire with helper contract
function removePool(address _poolToken) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being removed |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
feeWithdraw
Allow withdrawal of any tokens sent in error
function feeWithdraw(address _token, address _recipient) public onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of token to transfer |
_recipient | address | Address 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
Name | Type | Description |
---|---|---|
_newAddress | address | New address for contract needing to be updated. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
setMasterAggregator
Allow the contract owner to update the master aggregator proxy address used.
function setMasterAggregator(address _newAddress) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_newAddress | address | New address for contract needing to be updated. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
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
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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_retireEntityString | string | |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_retiree | address | The 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_retiree | address | The 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_retireEntityString | string | |
_beneficiaryAddress | address | Address of the beneficiary of the retirement. |
_beneficiaryString | string | String representing the beneficiary. A name perhaps. |
_retirementMessage | string | Specific message relating to this retirement event. |
_retiree | address | The original sender of the transaction. |
_carbonList | address[] | 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_retiree | address | The 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
Name | Type | Description |
---|---|---|
_totalAmount | uint256 | Total pool tokens being retired. Expected uint with 18 decimals. |
_retireEntityString | string | |
_beneficiaryAddress | address | Address of the beneficiary if different than sender. Value is set to _msgSender() if null is sent. |
_beneficiaryString | string | String that can be used to describe the beneficiary |
_retirementMessage | string | String for specific retirement message if needed. |
_poolToken | address | Address 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
Name | Type | Description |
---|---|---|
_totalAmount | uint256 | Total pool tokens being retired. Expected uint with 18 decimals. |
_retireEntityString | string | |
_beneficiaryAddress | address | Address of the beneficiary if different than sender. Value is set to _msgSender() if null is sent. |
_beneficiaryString | string | String that can be used to describe the beneficiary |
_retirementMessage | string | String for specific retirement message if needed. |
_poolToken | address | Address of pool token being used to retire. |
_carbonList | address[] | 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
Name | Type | Description |
---|---|---|
_sourceToken | address | The contract address of the token being supplied. |
_poolToken | address | The contract address of the pool token being retired. |
_amount | uint256 | The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. |
_amountInCarbon | bool | Bool indicating if _amount is in carbon or source. |
_specificRetire | bool |
_stakedToUnstaked
Unwraps/unstakes any KLIMA needed to regular KLIMA.
function _stakedToUnstaked(address _klimaType, uint256 _amountIn) internal returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_klimaType | address | Address of the KLIMA type being used. |
_amountIn | uint256 | Amount of total KLIMA needed. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_poolAmount | uint256 | Amount of tokens being retired. |
_specificRetire | bool |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Tuple 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_carbonAmount | uint256 | Total carbon needed. |
_amountIn | uint256 | Maximum amount of source tokens. |
_retiree | address | Initiator 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
Name | Type | Description |
---|---|---|
_sourceToken | address | Address of token being used to purchase the pool token. |
_poolToken | address | Address of pool token being used. |
_amountIn | uint256 | Total source tokens to swap. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Returns 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
Name | Type | Description |
---|---|---|
_amounts | uint256[] | The amounts resulting from the Uniswap tradeTokensForExactTokens. |
_sourceToken | address | Address of token being used to purchase the pool token. |
_amountIn | uint256 | Total source tokens initially provided. |
_retiree | address | Address 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
Name | Type | Description |
---|---|---|
_amount | uint256 | New fee amount, in .1% increments. 10 = 1% |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
setPoolRouter
Update the router for an existing pool
function setPoolRouter(address _poolToken, address _router) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being updated |
_router | address | New router address |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
setToucanRegistry
Update the Toucan Contract Registry
function setToucanRegistry(address _registry) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_registry | address | New Registry Address |
addPool
Add a new carbon pool to retire with helper contract
function addPool(address _poolToken, address _router) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being added |
_router | address | UniswapV2 router to route trades through for non-pool retirements |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
removePool
Remove a carbon pool to retire with helper contract
function removePool(address _poolToken) external onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_poolToken | address | Pool being removed |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
feeWithdraw
Allow withdrawal of any tokens sent in error
function feeWithdraw(address _token, address _recipient) public onlyOwner returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | address | Address of token to transfer |
_recipient | address | Address 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
Name | Type | Description |
---|---|---|
_newAddress | address | New address for contract needing to be updated. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool |
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);